diff options
| author | Giacomo Pozzoni <giacomopoz@gmail.com> | 2020-04-11 12:07:57 +0000 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-01-01 14:02:00 +0100 |
| commit | 97c1d01cbbc3ea828a2edfdc3a0b221e31d89f28 (patch) | |
| tree | a1e074d219999a8c4ecdfe6768325f2bc42e923e /src/server/game/Maps | |
| parent | 281e695c5655475ed5c39f6c612afe31f0202f0e (diff) | |
Core/Pooling: Remove respawn times from the database when despawning a pool (#24422)
* Core/Pooling: Remove respawn times from the database when despawning a pool
Remove respawn times from the database when despawning a pool. This is needed when a Game Event ends but there are still some respawn times saved in the database.
* Remove respawn time of active pool objects even if they are not spawned
(cherry picked from commit 4f33fd3932d362466ee017111895bf14fcc79c88)
Diffstat (limited to 'src/server/game/Maps')
| -rw-r--r-- | src/server/game/Maps/Map.cpp | 15 | ||||
| -rw-r--r-- | src/server/game/Maps/Map.h | 6 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index ee428f70244..091c7c4f88e 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -3330,15 +3330,20 @@ void Map::DeleteRespawnInfo(RespawnInfo* info, CharacterDatabaseTransaction dbTr _respawnTimes.erase(info->handle); // database + DeleteRespawnInfoFromDB(info->type, info->spawnId, dbTrans); + + // then cleanup the object + delete info; +} + +void Map::DeleteRespawnInfoFromDB(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans) +{ CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_RESPAWN); - stmt->setUInt16(0, info->type); - stmt->setUInt64(1, info->spawnId); + stmt->setUInt16(0, type); + stmt->setUInt64(1, spawnId); stmt->setUInt16(2, GetId()); stmt->setUInt32(3, GetInstanceId()); CharacterDatabase.ExecuteOrAppend(dbTrans, stmt); - - // then cleanup the object - delete info; } void Map::DoRespawn(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 gridId) diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index e5319376181..a1ab26b7ee8 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -753,6 +753,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType> bool AddRespawnInfo(RespawnInfo const& info); void UnloadAllRespawnInfos(); void DeleteRespawnInfo(RespawnInfo* info, CharacterDatabaseTransaction dbTrans = nullptr); + void DeleteRespawnInfoFromDB(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans = nullptr); public: void GetRespawnInfo(std::vector<RespawnInfo*>& respawnData, SpawnObjectTypeMask types) const; @@ -763,10 +764,13 @@ class TC_GAME_API Map : public GridRefManager<NGridType> Respawn(info, dbTrans); } void Respawn(RespawnInfo* info, CharacterDatabaseTransaction dbTrans = nullptr); - void RemoveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans = nullptr) + void RemoveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans = nullptr, bool alwaysDeleteFromDB = false) { if (RespawnInfo* info = GetRespawnInfo(type, spawnId)) DeleteRespawnInfo(info, dbTrans); + // Some callers might need to make sure the database doesn't contain any respawn time + else if (alwaysDeleteFromDB) + DeleteRespawnInfoFromDB(type, spawnId, dbTrans); } size_t DespawnAll(SpawnObjectType type, ObjectGuid::LowType spawnId); |
