mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
gm command for reload of eventindex
also i merged both loading functions together (union-select gameobject and creature) those loading functions were pretty similar
This commit is contained in:
parent
2adf6245c2
commit
0ce6395857
7 changed files with 56 additions and 71 deletions
|
|
@ -1468,7 +1468,7 @@ void BattleGround::DoorOpen(uint64 const& guid)
|
|||
|
||||
void BattleGround::OnObjectDBLoad(Creature* creature)
|
||||
{
|
||||
BattleGroundEventIdx eventId = sBattleGroundMgr.GetCreatureEventIndex(creature->GetDBTableGUIDLow());
|
||||
const BattleGroundEventIdx eventId = sBattleGroundMgr.GetCreatureEventIndex(creature->GetDBTableGUIDLow());
|
||||
if (eventId.event1 == BG_EVENT_NONE)
|
||||
return;
|
||||
m_EventObjects[MAKE_PAIR32(eventId.event1, eventId.event2)].creatures.push_back(creature->GetGUID());
|
||||
|
|
@ -1479,7 +1479,7 @@ void BattleGround::OnObjectDBLoad(Creature* creature)
|
|||
|
||||
void BattleGround::OnObjectDBLoad(GameObject* obj)
|
||||
{
|
||||
BattleGroundEventIdx eventId = sBattleGroundMgr.GetGameObjectEventIndex(obj->GetDBTableGUIDLow());
|
||||
const BattleGroundEventIdx eventId = sBattleGroundMgr.GetGameObjectEventIndex(obj->GetDBTableGUIDLow());
|
||||
if (eventId.event1 == BG_EVENT_NONE)
|
||||
return;
|
||||
m_EventObjects[MAKE_PAIR32(eventId.event1, eventId.event2)].gameobjects.push_back(obj->GetGUID());
|
||||
|
|
|
|||
|
|
@ -2099,66 +2099,49 @@ bool BattleGroundMgr::IsBGWeekend(BattleGroundTypeId bgTypeId)
|
|||
}
|
||||
}
|
||||
|
||||
void BattleGroundMgr::LoadCreatureBattleEventIndexes()
|
||||
void BattleGroundMgr::LoadBattleEventIndexes()
|
||||
{
|
||||
mCreatureBattleEventIndexMap.clear(); // need for reload case
|
||||
QueryResult *result = WorldDatabase.Query( "SELECT guid, event1, event2 FROM creature_battleground" );
|
||||
|
||||
BattleGroundEventIdx events;
|
||||
events.event1 = BG_EVENT_NONE;
|
||||
events.event2 = BG_EVENT_NONE;
|
||||
m_GameObjectBattleEventIndexMap.clear(); // need for reload case
|
||||
m_GameObjectBattleEventIndexMap[-1] = events;
|
||||
m_CreatureBattleEventIndexMap.clear(); // need for reload case
|
||||
m_CreatureBattleEventIndexMap[-1] = events;
|
||||
|
||||
QueryResult *result = WorldDatabase.PQuery( "SELECT 1, guid, event1, event2 FROM gameobject_battleground "
|
||||
"UNION "
|
||||
"SELECT 2, guid, event1, event2 FROM creature_battleground");
|
||||
uint32 count = 0;
|
||||
if( !result )
|
||||
{
|
||||
barGoLink bar( 1 );
|
||||
bar.step();
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded 0 battleground eventindexes for creatures - table is empty!" );
|
||||
return;
|
||||
}
|
||||
barGoLink bar( result->GetRowCount() );
|
||||
do
|
||||
{
|
||||
++count;
|
||||
bar.step();
|
||||
Field *fields = result->Fetch();
|
||||
uint32 dbTableGuidLow = fields[0].GetUInt32();
|
||||
BattleGroundEventIdx events;
|
||||
events.event1 = fields[1].GetUInt8();
|
||||
events.event2 = fields[2].GetUInt8();
|
||||
mCreatureBattleEventIndexMap[dbTableGuidLow] = events;
|
||||
if (fields[2].GetUInt8() == BG_EVENT_NONE || fields[3].GetUInt8() == BG_EVENT_NONE)
|
||||
continue; // we don't need to add those to the map
|
||||
|
||||
bool gameobject = (fields[0].GetUInt8() == 1);
|
||||
uint32 dbTableGuidLow = fields[1].GetUInt32();
|
||||
events.event1 = fields[2].GetUInt8();
|
||||
events.event2 = fields[3].GetUInt8();
|
||||
|
||||
if (gameobject)
|
||||
m_GameObjectBattleEventIndexMap[dbTableGuidLow] = events;
|
||||
else
|
||||
m_CreatureBattleEventIndexMap[dbTableGuidLow] = events;
|
||||
|
||||
++count;
|
||||
} while( result->NextRow() );
|
||||
delete result;
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded %u battleground eventindexes for creatures", count );
|
||||
}
|
||||
|
||||
void BattleGroundMgr::LoadGameObjectBattleEventIndexes()
|
||||
{
|
||||
mGameObjectBattleEventIndexMap.clear(); // need for reload case
|
||||
QueryResult *result = WorldDatabase.Query( "SELECT guid, event1, event2 FROM gameobject_battleground" );
|
||||
uint32 count = 0;
|
||||
if( !result )
|
||||
{
|
||||
barGoLink bar( 1 );
|
||||
bar.step();
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded 0 battleground eventindexes for gameobjects - table is empty!" );
|
||||
sLog.outString( ">> Loaded %u battleground eventindexes", count);
|
||||
if (count == 0)
|
||||
return;
|
||||
}
|
||||
barGoLink bar( result->GetRowCount() );
|
||||
do
|
||||
{
|
||||
++count;
|
||||
bar.step();
|
||||
Field *fields = result->Fetch();
|
||||
uint32 dbTableGuidLow = fields[0].GetUInt32();
|
||||
BattleGroundEventIdx events;
|
||||
events.event1 = fields[1].GetUInt8();
|
||||
events.event2 = fields[2].GetUInt8();
|
||||
mGameObjectBattleEventIndexMap[dbTableGuidLow] = events;
|
||||
|
||||
} while( result->NextRow() );
|
||||
delete result;
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded %u battleground eventindexes for gameobjects", count );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,27 +238,20 @@ class BattleGroundMgr
|
|||
return BATTLEGROUND_WS;
|
||||
}
|
||||
|
||||
void LoadCreatureBattleEventIndexes();
|
||||
BattleGroundEventIdx GetCreatureEventIndex(uint32 dbTableGuidLow) const
|
||||
void LoadBattleEventIndexes();
|
||||
const BattleGroundEventIdx GetCreatureEventIndex(uint32 dbTableGuidLow) const
|
||||
{
|
||||
CreatureBattleEventIndexesMap::const_iterator itr = mCreatureBattleEventIndexMap.find(dbTableGuidLow);
|
||||
if(itr != mCreatureBattleEventIndexMap.end())
|
||||
CreatureBattleEventIndexesMap::const_iterator itr = m_CreatureBattleEventIndexMap.find(dbTableGuidLow);
|
||||
if(itr != m_CreatureBattleEventIndexMap.end())
|
||||
return itr->second;
|
||||
BattleGroundEventIdx none;
|
||||
none.event1 = BG_EVENT_NONE;
|
||||
none.event2 = BG_EVENT_NONE;
|
||||
return none; // needed to check for error
|
||||
return m_CreatureBattleEventIndexMap.find(-1)->second;
|
||||
}
|
||||
void LoadGameObjectBattleEventIndexes();
|
||||
BattleGroundEventIdx GetGameObjectEventIndex(uint32 dbTableGuidLow) const
|
||||
const BattleGroundEventIdx GetGameObjectEventIndex(uint32 dbTableGuidLow) const
|
||||
{
|
||||
GameObjectBattleEventIndexesMap::const_iterator itr = mGameObjectBattleEventIndexMap.find(dbTableGuidLow);
|
||||
if(itr != mGameObjectBattleEventIndexMap.end())
|
||||
GameObjectBattleEventIndexesMap::const_iterator itr = m_GameObjectBattleEventIndexMap.find(dbTableGuidLow);
|
||||
if(itr != m_GameObjectBattleEventIndexMap.end())
|
||||
return itr->second;
|
||||
BattleGroundEventIdx none;
|
||||
none.event1 = BG_EVENT_NONE;
|
||||
none.event2 = BG_EVENT_NONE;
|
||||
return none; // needed to check for error
|
||||
return m_GameObjectBattleEventIndexMap.find(-1)->second;
|
||||
}
|
||||
|
||||
bool isArenaTesting() const { return m_ArenaTesting; }
|
||||
|
|
@ -273,8 +266,8 @@ class BattleGroundMgr
|
|||
static bool IsBGWeekend(BattleGroundTypeId bgTypeId);
|
||||
private:
|
||||
BattleMastersMap mBattleMastersMap;
|
||||
CreatureBattleEventIndexesMap mCreatureBattleEventIndexMap;
|
||||
GameObjectBattleEventIndexesMap mGameObjectBattleEventIndexMap;
|
||||
CreatureBattleEventIndexesMap m_CreatureBattleEventIndexMap;
|
||||
GameObjectBattleEventIndexesMap m_GameObjectBattleEventIndexMap;
|
||||
|
||||
/* Battlegrounds */
|
||||
BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID];
|
||||
|
|
|
|||
|
|
@ -404,6 +404,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
|||
{ "creature_ai_scripts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadEventAIScriptsCommand, "", NULL },
|
||||
{ "creature_ai_summons", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadEventAISummonsCommand, "", NULL },
|
||||
{ "creature_ai_texts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadEventAITextsCommand, "", NULL },
|
||||
{ "creature_battleground", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadBattleEventCommand, "", NULL },
|
||||
{ "creature_involvedrelation", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCreatureQuestInvRelationsCommand,"",NULL },
|
||||
{ "creature_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesCreatureCommand, "", NULL },
|
||||
{ "creature_questrelation", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCreatureQuestRelationsCommand, "", NULL },
|
||||
|
|
@ -417,6 +418,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
|||
{ "gameobject_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesGameobjectCommand, "", NULL },
|
||||
{ "gameobject_questrelation", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadGOQuestRelationsCommand, "", NULL },
|
||||
{ "gameobject_scripts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadGameObjectScriptsCommand, "", NULL },
|
||||
{ "gameobject_battleground", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadBattleEventCommand, "", NULL },
|
||||
{ "item_enchantment_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadItemEnchantementsCommand, "", NULL },
|
||||
{ "item_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesItemCommand, "", NULL },
|
||||
{ "item_required_target", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadItemRequiredTragetCommand, "", NULL },
|
||||
|
|
|
|||
|
|
@ -326,6 +326,7 @@ class ChatHandler
|
|||
bool HandleReloadEventAISummonsCommand(const char* args);
|
||||
bool HandleReloadEventAIScriptsCommand(const char* args);
|
||||
bool HandleReloadCommandCommand(const char* args);
|
||||
bool HandleReloadBattleEventCommand(const char* args);
|
||||
bool HandleReloadCreatureQuestRelationsCommand(const char* args);
|
||||
bool HandleReloadCreatureQuestInvRelationsCommand(const char* args);
|
||||
bool HandleReloadDbScriptStringCommand(const char* args);
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ bool ChatHandler::HandleReloadAllCommand(const char*)
|
|||
HandleReloadReservedNameCommand("");
|
||||
HandleReloadMangosStringCommand("");
|
||||
HandleReloadGameTeleCommand("");
|
||||
HandleReloadBattleEventCommand("");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -594,6 +595,14 @@ bool ChatHandler::HandleReloadItemRequiredTragetCommand(const char*)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleReloadBattleEventCommand(const char*)
|
||||
{
|
||||
sLog.outString( "Re-Loading BattleGround Eventindexes..." );
|
||||
sBattleGroundMgr.LoadBattleEventIndexes();
|
||||
SendGlobalSysMessage("DB table `gameobject_battleground` and `creature_battleground` reloaded.");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleReloadGameObjectScriptsCommand(const char* arg)
|
||||
{
|
||||
if(sWorld.IsScriptScheduled())
|
||||
|
|
|
|||
|
|
@ -1371,11 +1371,8 @@ void World::SetInitialWorldSettings()
|
|||
sLog.outString( "Loading BattleMasters..." );
|
||||
sBattleGroundMgr.LoadBattleMastersEntry();
|
||||
|
||||
sLog.outString( "Loading Creature BattleGround event indexes..." );
|
||||
sBattleGroundMgr.LoadCreatureBattleEventIndexes();
|
||||
|
||||
sLog.outString( "Loading GameObject BattleGround event indexes..." );
|
||||
sBattleGroundMgr.LoadGameObjectBattleEventIndexes();
|
||||
sLog.outString( "Loading BattleGround event indexes..." );
|
||||
sBattleGroundMgr.LoadBattleEventIndexes();
|
||||
|
||||
sLog.outString( "Loading GameTeleports..." );
|
||||
objmgr.LoadGameTele();
|
||||
|
|
@ -2178,4 +2175,4 @@ void World::LoadDBVersion()
|
|||
|
||||
if(m_CreatureEventAIVersion.empty())
|
||||
m_CreatureEventAIVersion = "Unknown creature EventAI.";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue