diff options
author | Krudor <erikstrandberg93@hotmail.com> | 2016-07-16 14:58:33 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2016-07-16 14:58:33 +0200 |
commit | 649e3a9ac59a1d24eeec3419138d0d5f11dee566 (patch) | |
tree | 94834378e61389199ec5e734f34a02097e80d911 /src/server/game/Instances/InstanceSaveMgr.cpp | |
parent | e2d6c362f2c80346c464f053ad20b773f9e31863 (diff) |
Core/Instances: Add functionality for modifying instance entrance locations
Instances have since MoP (Possibly even Cataclysm) been able to set new locations for players when they zone into the instance.
A theoretic example of this could be after a certain boss has been defeated, a new entrance location is set to bring players entering the instance closer to the relevant content.
A real example would be Siege of Orgrimmar changing entrance locations many times as the raid progresses.
Added SetEntranceLocation for setting entrance locations that will be saved to DB the next time the instance is saved, and SetTemporaryEntranceLocation for when you don't want the value to be saved to the database.
Closes #17167
Diffstat (limited to 'src/server/game/Instances/InstanceSaveMgr.cpp')
-rw-r--r-- | src/server/game/Instances/InstanceSaveMgr.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index 4d979ecb9b3..9258977f7a8 100644 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -71,7 +71,7 @@ void InstanceSaveManager::Unload() - adding instance into manager - called from InstanceMap::Add, _LoadBoundInstances, LoadGroups */ -InstanceSave* InstanceSaveManager::AddInstanceSave(uint32 mapId, uint32 instanceId, Difficulty difficulty, time_t resetTime, bool canReset, bool load) +InstanceSave* InstanceSaveManager::AddInstanceSave(uint32 mapId, uint32 instanceId, Difficulty difficulty, time_t resetTime, uint32 entranceId, bool canReset, bool load) { if (InstanceSave* old_save = GetInstanceSave(instanceId)) return old_save; @@ -96,6 +96,12 @@ InstanceSave* InstanceSaveManager::AddInstanceSave(uint32 mapId, uint32 instance return NULL; } + if (entranceId && !sWorldSafeLocsStore.LookupEntry(entranceId)) + { + TC_LOG_WARN("misc", "InstanceSaveManager::AddInstanceSave: invalid entranceId = %d defined for instance save with mapid = %d, instanceid = %d!", entranceId, mapId, instanceId); + entranceId = 0; + } + if (!resetTime) { // initialize reset time @@ -112,7 +118,7 @@ InstanceSave* InstanceSaveManager::AddInstanceSave(uint32 mapId, uint32 instance TC_LOG_DEBUG("maps", "InstanceSaveManager::AddInstanceSave: mapid = %d, instanceid = %d", mapId, instanceId); - InstanceSave* save = new InstanceSave(mapId, instanceId, difficulty, resetTime, canReset); + InstanceSave* save = new InstanceSave(mapId, instanceId, difficulty, entranceId, resetTime, canReset); if (!load) save->SaveToDB(); @@ -173,9 +179,9 @@ void InstanceSaveManager::UnloadInstanceSave(uint32 InstanceId) save->UnloadIfEmpty(); } -InstanceSave::InstanceSave(uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, bool canReset) +InstanceSave::InstanceSave(uint16 MapId, uint32 InstanceId, Difficulty difficulty, uint32 entranceId, time_t resetTime, bool canReset) : m_resetTime(resetTime), m_instanceid(InstanceId), m_mapid(MapId), - m_difficulty(difficulty), m_canReset(canReset), m_toDelete(false) { } + m_difficulty(difficulty), m_entranceId(entranceId), m_canReset(canReset), m_toDelete(false) { } InstanceSave::~InstanceSave() { @@ -200,6 +206,7 @@ void InstanceSave::SaveToDB() { data = instanceScript->GetSaveData(); completedEncounters = instanceScript->GetCompletedEncounterMask(); + m_entranceId = instanceScript->GetEntranceLocation(); } } @@ -210,6 +217,7 @@ void InstanceSave::SaveToDB() stmt->setUInt8(3, uint8(GetDifficultyID())); stmt->setUInt32(4, completedEncounters); stmt->setString(5, data); + stmt->setUInt32(6, m_entranceId); CharacterDatabase.Execute(stmt); } |