mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 01:15:35 +01:00
*Cleanup, fix many cases of unoptimized loops, potential crashes, excessively large data types, unnecessary or wrong casts, non-standardized function calls, and so on..
*Proper Maexxna Web Spray locations (old locations sent players flying into the air) --HG-- branch : trunk
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
void InstanceData::SaveToDB()
|
||||
{
|
||||
std::string data = GetSaveData();
|
||||
if(data.empty())
|
||||
if (data.empty())
|
||||
return;
|
||||
CharacterDatabase.escape_string(data);
|
||||
CharacterDatabase.PExecute("UPDATE instance SET data = '%s' WHERE id = '%d'", data.c_str(), instance->GetInstanceId());
|
||||
@@ -37,9 +37,9 @@ void InstanceData::SaveToDB()
|
||||
|
||||
void InstanceData::HandleGameObject(uint64 GUID, bool open, GameObject *go)
|
||||
{
|
||||
if(!go)
|
||||
if (!go)
|
||||
go = instance->GetGameObject(GUID);
|
||||
if(go)
|
||||
if (go)
|
||||
go->SetGoState(open ? GO_STATE_ACTIVE : GO_STATE_READY);
|
||||
else
|
||||
debug_log("TSCR: InstanceData: HandleGameObject failed");
|
||||
@@ -48,7 +48,7 @@ void InstanceData::HandleGameObject(uint64 GUID, bool open, GameObject *go)
|
||||
bool InstanceData::IsEncounterInProgress() const
|
||||
{
|
||||
for (std::vector<BossInfo>::const_iterator itr = bosses.begin(); itr != bosses.end(); ++itr)
|
||||
if(itr->state == IN_PROGRESS)
|
||||
if (itr->state == IN_PROGRESS)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -58,7 +58,7 @@ void InstanceData::LoadMinionData(const MinionData *data)
|
||||
{
|
||||
while(data->entry)
|
||||
{
|
||||
if(data->bossId < bosses.size())
|
||||
if (data->bossId < bosses.size())
|
||||
minions.insert(std::make_pair(data->entry, MinionInfo(&bosses[data->bossId])));
|
||||
|
||||
++data;
|
||||
@@ -70,7 +70,7 @@ void InstanceData::LoadDoorData(const DoorData *data)
|
||||
{
|
||||
while(data->entry)
|
||||
{
|
||||
if(data->bossId < bosses.size())
|
||||
if (data->bossId < bosses.size())
|
||||
doors.insert(std::make_pair(data->entry, DoorInfo(&bosses[data->bossId], data->type, BoundaryType(data->boundary))));
|
||||
|
||||
++data;
|
||||
@@ -80,18 +80,18 @@ void InstanceData::LoadDoorData(const DoorData *data)
|
||||
|
||||
void InstanceData::UpdateMinionState(Creature *minion, EncounterState state)
|
||||
{
|
||||
switch(state)
|
||||
switch (state)
|
||||
{
|
||||
case NOT_STARTED:
|
||||
if(!minion->isAlive())
|
||||
if (!minion->isAlive())
|
||||
minion->Respawn();
|
||||
else if(minion->isInCombat())
|
||||
else if (minion->isInCombat())
|
||||
minion->AI()->EnterEvadeMode();
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
if(!minion->isAlive())
|
||||
if (!minion->isAlive())
|
||||
minion->Respawn();
|
||||
else if(!minion->getVictim())
|
||||
else if (!minion->getVictim())
|
||||
minion->AI()->DoZoneInCombat();
|
||||
break;
|
||||
}
|
||||
@@ -101,23 +101,23 @@ void InstanceData::UpdateDoorState(GameObject *door)
|
||||
{
|
||||
DoorInfoMap::iterator lower = doors.lower_bound(door->GetEntry());
|
||||
DoorInfoMap::iterator upper = doors.upper_bound(door->GetEntry());
|
||||
if(lower == upper)
|
||||
if (lower == upper)
|
||||
return;
|
||||
|
||||
bool open = true;
|
||||
for (DoorInfoMap::iterator itr = lower; itr != upper; ++itr)
|
||||
{
|
||||
if(itr->second.type == DOOR_TYPE_ROOM)
|
||||
if (itr->second.type == DOOR_TYPE_ROOM)
|
||||
{
|
||||
if(itr->second.bossInfo->state == IN_PROGRESS)
|
||||
if (itr->second.bossInfo->state == IN_PROGRESS)
|
||||
{
|
||||
open = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(itr->second.type == DOOR_TYPE_PASSAGE)
|
||||
else if (itr->second.type == DOOR_TYPE_PASSAGE)
|
||||
{
|
||||
if(itr->second.bossInfo->state != DONE)
|
||||
if (itr->second.bossInfo->state != DONE)
|
||||
{
|
||||
open = false;
|
||||
break;
|
||||
@@ -133,15 +133,15 @@ void InstanceData::AddDoor(GameObject *door, bool add)
|
||||
{
|
||||
DoorInfoMap::iterator lower = doors.lower_bound(door->GetEntry());
|
||||
DoorInfoMap::iterator upper = doors.upper_bound(door->GetEntry());
|
||||
if(lower == upper)
|
||||
if (lower == upper)
|
||||
return;
|
||||
|
||||
for (DoorInfoMap::iterator itr = lower; itr != upper; ++itr)
|
||||
{
|
||||
if(add)
|
||||
if (add)
|
||||
{
|
||||
itr->second.bossInfo->door[itr->second.type].insert(door);
|
||||
switch(itr->second.boundary)
|
||||
switch (itr->second.boundary)
|
||||
{
|
||||
default:
|
||||
case BOUNDARY_NONE:
|
||||
@@ -168,17 +168,17 @@ void InstanceData::AddDoor(GameObject *door, bool add)
|
||||
itr->second.bossInfo->door[itr->second.type].erase(door);
|
||||
}
|
||||
|
||||
if(add)
|
||||
if (add)
|
||||
UpdateDoorState(door);
|
||||
}
|
||||
|
||||
void InstanceData::AddMinion(Creature *minion, bool add)
|
||||
{
|
||||
MinionInfoMap::iterator itr = minions.find(minion->GetEntry());
|
||||
if(itr == minions.end())
|
||||
if (itr == minions.end())
|
||||
return;
|
||||
|
||||
if(add)
|
||||
if (add)
|
||||
itr->second.bossInfo->minion.insert(minion);
|
||||
else
|
||||
itr->second.bossInfo->minion.erase(minion);
|
||||
@@ -186,10 +186,10 @@ void InstanceData::AddMinion(Creature *minion, bool add)
|
||||
|
||||
bool InstanceData::SetBossState(uint32 id, EncounterState state)
|
||||
{
|
||||
if(id < bosses.size())
|
||||
if (id < bosses.size())
|
||||
{
|
||||
BossInfo *bossInfo = &bosses[id];
|
||||
if(bossInfo->state == TO_BE_DECIDED) // loading
|
||||
if (bossInfo->state == TO_BE_DECIDED) // loading
|
||||
{
|
||||
bossInfo->state = state;
|
||||
//sLog.outError("Inialize boss %u state as %u.", id, (uint32)state);
|
||||
@@ -197,10 +197,10 @@ bool InstanceData::SetBossState(uint32 id, EncounterState state)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(bossInfo->state == state)
|
||||
if (bossInfo->state == state)
|
||||
return false;
|
||||
|
||||
if(state == DONE)
|
||||
if (state == DONE)
|
||||
for (MinionSet::iterator i = bossInfo->minion.begin(); i != bossInfo->minion.end(); ++i)
|
||||
if((*i)->isWorldBoss() && (*i)->isAlive())
|
||||
return false;
|
||||
@@ -223,14 +223,15 @@ bool InstanceData::SetBossState(uint32 id, EncounterState state)
|
||||
|
||||
std::string InstanceData::LoadBossState(const char * data)
|
||||
{
|
||||
if(!data) return NULL;
|
||||
if(!data)
|
||||
return NULL;
|
||||
std::istringstream loadStream(data);
|
||||
uint32 buff;
|
||||
uint32 bossId = 0;
|
||||
for (std::vector<BossInfo>::iterator i = bosses.begin(); i != bosses.end(); ++i, ++bossId)
|
||||
{
|
||||
loadStream >> buff;
|
||||
if(buff < TO_BE_DECIDED)
|
||||
if (buff < TO_BE_DECIDED)
|
||||
SetBossState(bossId, (EncounterState)buff);
|
||||
}
|
||||
return loadStream.str();
|
||||
@@ -270,8 +271,8 @@ void InstanceData::DoRespawnGameObject(uint64 uiGuid, uint32 uiTimeToDespawn)
|
||||
if (GameObject* pGo = instance->GetGameObject(uiGuid))
|
||||
{
|
||||
//not expect any of these should ever be handled
|
||||
if (pGo->GetGoType()==GAMEOBJECT_TYPE_FISHINGNODE || pGo->GetGoType()==GAMEOBJECT_TYPE_DOOR ||
|
||||
pGo->GetGoType()==GAMEOBJECT_TYPE_BUTTON || pGo->GetGoType()==GAMEOBJECT_TYPE_TRAP)
|
||||
if (pGo->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE || pGo->GetGoType()==GAMEOBJECT_TYPE_DOOR ||
|
||||
pGo->GetGoType() == GAMEOBJECT_TYPE_BUTTON || pGo->GetGoType()==GAMEOBJECT_TYPE_TRAP)
|
||||
return;
|
||||
|
||||
if (pGo->isSpawned())
|
||||
@@ -288,16 +289,13 @@ void InstanceData::DoUpdateWorldState(uint32 uiStateId, uint32 uiStateData)
|
||||
if (!lPlayers.isEmpty())
|
||||
{
|
||||
for (Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr)
|
||||
{
|
||||
if (Player* pPlayer = itr->getSource())
|
||||
if (Player *pPlayer = itr->getSource())
|
||||
pPlayer->SendUpdateWorldState(uiStateId, uiStateData);
|
||||
}
|
||||
}
|
||||
else
|
||||
debug_log("TSCR: DoUpdateWorldState attempt send data but no players in map.");
|
||||
}
|
||||
|
||||
/* Not used anywhere yet, not sure if they're needed:
|
||||
// Send Notify to all players in instance
|
||||
void InstanceData::DoSendNotifyToInstance(const char *format, ...)
|
||||
{
|
||||
@@ -306,10 +304,11 @@ void InstanceData::DoSendNotifyToInstance(const char *format, ...)
|
||||
|
||||
if (!PlayerList.isEmpty())
|
||||
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
||||
if (i->getSource() && i->getSource()->GetSession())
|
||||
i->getSource()->GetSession()->SendNotification(format);
|
||||
if (Player *pPlayer = i->getSource())
|
||||
if (WorldSession *pSession = pPlayer->GetSession())
|
||||
pSession->SendNotification(format);
|
||||
}
|
||||
*/
|
||||
|
||||
// Complete Achievement for all players in instance
|
||||
void InstanceData::DoCompleteAchievement(uint32 achievement)
|
||||
{
|
||||
@@ -318,8 +317,8 @@ void InstanceData::DoCompleteAchievement(uint32 achievement)
|
||||
|
||||
if (!PlayerList.isEmpty())
|
||||
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
||||
if (i->getSource())
|
||||
i->getSource()->CompletedAchievement(AE);
|
||||
if (Player *pPlayer = i->getSource())
|
||||
pPlayer->CompletedAchievement(AE);
|
||||
}
|
||||
|
||||
// Remove Auras due to Spell on all players in instance
|
||||
@@ -329,6 +328,6 @@ void InstanceData::DoRemoveAurasDueToSpellOnPlayers(uint32 spell)
|
||||
|
||||
if (!PlayerList.isEmpty())
|
||||
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
||||
if (i->getSource())
|
||||
i->getSource()->RemoveAurasDueToSpell(spell);
|
||||
if (Player* pPlayer = i->getSource())
|
||||
pPlayer->RemoveAurasDueToSpell(spell);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user