diff options
Diffstat (limited to 'src/game/InstanceData.cpp')
-rw-r--r-- | src/game/InstanceData.cpp | 42 |
1 files changed, 1 insertions, 41 deletions
diff --git a/src/game/InstanceData.cpp b/src/game/InstanceData.cpp index 1398038d724..00738a72a94 100644 --- a/src/game/InstanceData.cpp +++ b/src/game/InstanceData.cpp @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - #include "InstanceData.h" #include "Database/DatabaseEnv.h" #include "Map.h" @@ -25,7 +24,6 @@ #include "GameObject.h" #include "Creature.h" #include "CreatureAI.h" - void InstanceData::SaveToDB() { std::string data = GetSaveData(); @@ -34,7 +32,6 @@ void InstanceData::SaveToDB() CharacterDatabase.escape_string(data); CharacterDatabase.PExecute("UPDATE instance SET data = '%s' WHERE id = '%d'", data.c_str(), instance->GetInstanceId()); } - void InstanceData::HandleGameObject(uint64 GUID, bool open, GameObject *go) { if(!go) @@ -44,40 +41,33 @@ void InstanceData::HandleGameObject(uint64 GUID, bool open, GameObject *go) else debug_log("TSCR: InstanceData: HandleGameObject failed"); } - bool InstanceData::IsEncounterInProgress() const { for(std::vector<BossInfo>::const_iterator itr = bosses.begin(); itr != bosses.end(); ++itr) if(itr->state == IN_PROGRESS) return true; - return false; } - void InstanceData::LoadMinionData(const MinionData *data) { while(data->entry) { if(data->bossId < bosses.size()) minions.insert(std::make_pair(data->entry, MinionInfo(&bosses[data->bossId]))); - ++data; } sLog.outDebug("InstanceData::LoadMinionData: %u minions loaded.", doors.size()); } - void InstanceData::LoadDoorData(const DoorData *data) { while(data->entry) { if(data->bossId < bosses.size()) doors.insert(std::make_pair(data->entry, DoorInfo(&bosses[data->bossId], data->type, BoundaryType(data->boundary)))); - ++data; } sLog.outDebug("InstanceData::LoadDoorData: %u doors loaded.", doors.size()); } - void InstanceData::UpdateMinionState(Creature *minion, EncounterState state) { switch(state) @@ -96,14 +86,12 @@ void InstanceData::UpdateMinionState(Creature *minion, EncounterState state) break; } } - void InstanceData::UpdateDoorState(GameObject *door) { DoorInfoMap::iterator lower = doors.lower_bound(door->GetEntry()); DoorInfoMap::iterator upper = doors.upper_bound(door->GetEntry()); if(lower == upper) return; - bool open = true; for(DoorInfoMap::iterator itr = lower; itr != upper; ++itr) { @@ -124,18 +112,15 @@ void InstanceData::UpdateDoorState(GameObject *door) } } } - door->SetGoState(open ? GO_STATE_ACTIVE : GO_STATE_READY); //sLog.outError("Door %u is %s.", door->GetEntry(), open ? "opened" : "closed"); } - 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) return; - for(DoorInfoMap::iterator itr = lower; itr != upper; ++itr) { if(add) @@ -167,23 +152,19 @@ void InstanceData::AddDoor(GameObject *door, bool add) else itr->second.bossInfo->door[itr->second.type].erase(door); } - if(add) UpdateDoorState(door); } - void InstanceData::AddMinion(Creature *minion, bool add) { MinionInfoMap::iterator itr = minions.find(minion->GetEntry()); if(itr == minions.end()) return; - if(add) itr->second.bossInfo->minion.insert(minion); else itr->second.bossInfo->minion.erase(minion); } - bool InstanceData::SetBossState(uint32 id, EncounterState state) { if(id < bosses.size()) @@ -199,28 +180,22 @@ bool InstanceData::SetBossState(uint32 id, EncounterState state) { if(bossInfo->state == state) return false; - if(state == DONE) for(MinionSet::iterator i = bossInfo->minion.begin(); i != bossInfo->minion.end(); ++i) if((*i)->isWorldBoss() && (*i)->isAlive()) return false; - bossInfo->state = state; SaveToDB(); } - for(uint32 type = 0; type < MAX_DOOR_TYPES; ++type) for(DoorSet::iterator i = bossInfo->door[type].begin(); i != bossInfo->door[type].end(); ++i) UpdateDoorState(*i); - for(MinionSet::iterator i = bossInfo->minion.begin(); i != bossInfo->minion.end(); ++i) UpdateMinionState(*i, state); - return true; } return false; } - std::string InstanceData::LoadBossState(const char * data) { if(!data) return NULL; @@ -235,22 +210,18 @@ std::string InstanceData::LoadBossState(const char * data) } return loadStream.str(); } - std::string InstanceData::GetBossSaveData() { std::ostringstream saveStream; for(std::vector<BossInfo>::iterator i = bosses.begin(); i != bosses.end(); ++i) saveStream << (uint32)i->state << " "; return saveStream.str(); -} - +} void InstanceData::DoUseDoorOrButton(uint64 uiGuid, uint32 uiWithRestoreTime, bool bUseAlternativeState) { if (!uiGuid) return; - GameObject* pGo = instance->GetGameObject(uiGuid); - if (pGo) { if (pGo->GetGoType() == GAMEOBJECT_TYPE_DOOR || pGo->GetGoType() == GAMEOBJECT_TYPE_BUTTON) @@ -264,7 +235,6 @@ void InstanceData::DoUseDoorOrButton(uint64 uiGuid, uint32 uiWithRestoreTime, bo error_log("SD2: Script call DoUseDoorOrButton, but gameobject entry %u is type %u.",pGo->GetEntry(),pGo->GetGoType()); } } - void InstanceData::DoRespawnGameObject(uint64 uiGuid, uint32 uiTimeToDespawn) { if (GameObject* pGo = instance->GetGameObject(uiGuid)) @@ -273,18 +243,14 @@ void InstanceData::DoRespawnGameObject(uint64 uiGuid, uint32 uiTimeToDespawn) 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()) return; - pGo->SetRespawnTime(uiTimeToDespawn); } } - void InstanceData::DoUpdateWorldState(uint32 uiStateId, uint32 uiStateData) { Map::PlayerList const& lPlayers = instance->GetPlayers(); - if (!lPlayers.isEmpty()) { for(Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr) @@ -296,38 +262,32 @@ void InstanceData::DoUpdateWorldState(uint32 uiStateId, uint32 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, ...) { InstanceMap::PlayerList const &PlayerList = instance->GetPlayers(); InstanceMap::PlayerList::const_iterator i; - if (!PlayerList.isEmpty()) for (i = PlayerList.begin(); i != PlayerList.end(); ++i) if ((*i).getSource() && (*i).getSource()->GetSession()) (*i).getSource()->GetSession()->SendNotification(format); } - // Complete Achievement for all players in instance void InstanceData::DoCompleteAchievement(uint32 achievement) { AchievementEntry const* AE = GetAchievementStore()->LookupEntry(achievement); Map::PlayerList const &PlayerList = instance->GetPlayers(); - if (!PlayerList.isEmpty()) for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) if (i->getSource()) i->getSource()->CompletedAchievement(AE); } */ - // Remove Auras due to Spell on all players in instance void InstanceData::DoRemoveAurasDueToSpellOnPlayers(uint32 spell) { Map::PlayerList const &PlayerList = instance->GetPlayers(); - if (!PlayerList.isEmpty()) for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) if (i->getSource() && i->getSource()->HasAura(spell)) i->getSource()->RemoveAurasDueToSpell(spell); |