diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Maps/Map.cpp | 18 | ||||
-rw-r--r-- | src/server/game/Maps/Map.h | 5 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_list.cpp | 29 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_misc.cpp | 2 |
6 files changed, 36 insertions, 22 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 492729909b6..1db79a9ba30 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2564,7 +2564,7 @@ void Creature::SaveRespawnTime(uint32 forceDelay) } time_t thisRespawnTime = forceDelay ? GameTime::GetGameTime() + forceDelay : m_respawnTime; - GetMap()->SaveRespawnTime(SPAWN_TYPE_CREATURE, m_spawnId, GetEntry(), thisRespawnTime, GetMap()->GetZoneId(GetPhaseShift(), GetHomePosition()), Trinity::ComputeGridCoord(GetHomePosition().GetPositionX(), GetHomePosition().GetPositionY()).GetId()); + GetMap()->SaveRespawnTime(SPAWN_TYPE_CREATURE, m_spawnId, GetEntry(), thisRespawnTime, Trinity::ComputeGridCoord(GetHomePosition().GetPositionX(), GetHomePosition().GetPositionY()).GetId()); } // this should not be called by petAI or diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 6540087ce07..97e38b728fc 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -1383,7 +1383,7 @@ void GameObject::SaveRespawnTime(uint32 forceDelay) } uint32 thisRespawnTime = forceDelay ? GameTime::GetGameTime() + forceDelay : m_respawnTime; - GetMap()->SaveRespawnTime(SPAWN_TYPE_GAMEOBJECT, m_spawnId, GetEntry(), thisRespawnTime, GetZoneId(), Trinity::ComputeGridCoord(GetPositionX(), GetPositionY()).GetId()); + GetMap()->SaveRespawnTime(SPAWN_TYPE_GAMEOBJECT, m_spawnId, GetEntry(), thisRespawnTime, Trinity::ComputeGridCoord(GetPositionX(), GetPositionY()).GetId()); } } diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index b3e03e21755..e06861c0272 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -3255,18 +3255,19 @@ bool Map::AddRespawnInfo(RespawnInfo const& info) return true; } -static void PushRespawnInfoFrom(std::vector<RespawnInfo*>& data, RespawnInfoMap const& map, uint32 zoneId) +static void PushRespawnInfoFrom(std::vector<RespawnInfo*>& data, RespawnInfoMap const& map) { + data.reserve(data.size() + map.size()); for (auto const& pair : map) - if (!zoneId || pair.second->zoneId == zoneId) - data.push_back(pair.second); + data.push_back(pair.second); } -void Map::GetRespawnInfo(std::vector<RespawnInfo*>& respawnData, SpawnObjectTypeMask types, uint32 zoneId) const + +void Map::GetRespawnInfo(std::vector<RespawnInfo*>& respawnData, SpawnObjectTypeMask types) const { if (types & SPAWN_TYPEMASK_CREATURE) - PushRespawnInfoFrom(respawnData, _creatureRespawnTimesBySpawnId, zoneId); + PushRespawnInfoFrom(respawnData, _creatureRespawnTimesBySpawnId); if (types & SPAWN_TYPEMASK_GAMEOBJECT) - PushRespawnInfoFrom(respawnData, _gameObjectRespawnTimesBySpawnId, zoneId); + PushRespawnInfoFrom(respawnData, _gameObjectRespawnTimesBySpawnId); } RespawnInfo* Map::GetRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawnId) const @@ -4487,7 +4488,7 @@ void Map::UpdateIteratorBack(Player* player) m_mapRefIter = m_mapRefIter->nocheck_prev(); } -void Map::SaveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 entry, time_t respawnTime, uint32 zoneId, uint32 gridId, CharacterDatabaseTransaction dbTrans, bool startup) +void Map::SaveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 entry, time_t respawnTime, uint32 gridId, CharacterDatabaseTransaction dbTrans, bool startup) { if (!spawnId) return; @@ -4505,7 +4506,6 @@ void Map::SaveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, uin ri.entry = entry; ri.respawnTime = respawnTime; ri.gridId = gridId; - ri.zoneId = zoneId; bool success = AddRespawnInfo(ri); if (startup) @@ -4545,7 +4545,7 @@ void Map::LoadRespawnTimes() if (type < SPAWN_TYPE_MAX) { if (SpawnData const* data = sObjectMgr->GetSpawnData(type, spawnId)) - SaveRespawnTime(type, spawnId, data->id, time_t(respawnTime), GetZoneId(PhasingHandler::GetEmptyPhaseShift(), data->spawnPoint), Trinity::ComputeGridCoord(data->spawnPoint.GetPositionX(), data->spawnPoint.GetPositionY()).GetId(), nullptr, true); + SaveRespawnTime(type, spawnId, data->id, time_t(respawnTime), Trinity::ComputeGridCoord(data->spawnPoint.GetPositionX(), data->spawnPoint.GetPositionY()).GetId(), nullptr, true); else TC_LOG_ERROR("maps", "Loading saved respawn time of %" PRIu64 " for spawnid (%u," UI64FMTD ") - spawn does not exist, ignoring", respawnTime, uint32(type), spawnId); } diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index fe85ecf3724..96bb6c29aeb 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -232,7 +232,6 @@ struct RespawnInfo uint32 entry; time_t respawnTime; uint32 gridId; - uint32 zoneId; RespawnListHandle handle; }; inline bool CompareRespawnInfo::operator()(RespawnInfo const* a, RespawnInfo const* b) const @@ -538,7 +537,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType> void UpdatePlayerZoneStats(uint32 oldZone, uint32 newZone); - void SaveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 entry, time_t respawnTime, uint32 zoneId, uint32 gridId, CharacterDatabaseTransaction dbTrans = nullptr, bool startup = false); + void SaveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 entry, time_t respawnTime, uint32 gridId, CharacterDatabaseTransaction dbTrans = nullptr, bool startup = false); void SaveRespawnInfoDB(RespawnInfo const& info, CharacterDatabaseTransaction dbTrans = nullptr); void LoadRespawnTimes(); void DeleteRespawnTimes() { UnloadAllRespawnInfos(); DeleteRespawnTimesInDB(GetId(), GetInstanceId()); } @@ -739,7 +738,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType> void DeleteRespawnInfo(RespawnInfo* info, CharacterDatabaseTransaction dbTrans = nullptr); public: - void GetRespawnInfo(std::vector<RespawnInfo*>& respawnData, SpawnObjectTypeMask types, uint32 zoneId = 0) const; + void GetRespawnInfo(std::vector<RespawnInfo*>& respawnData, SpawnObjectTypeMask types) const; RespawnInfo* GetRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawnId) const; void Respawn(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans = nullptr) { diff --git a/src/server/scripts/Commands/cs_list.cpp b/src/server/scripts/Commands/cs_list.cpp index a1b263e7ad8..b0fdcd613d2 100644 --- a/src/server/scripts/Commands/cs_list.cpp +++ b/src/server/scripts/Commands/cs_list.cpp @@ -34,6 +34,7 @@ EndScriptData */ #include "MapManager.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" +#include "PhasingHandler.h" #include "Player.h" #include "RBAC.h" #include "SpellAuraEffects.h" @@ -684,10 +685,11 @@ public: AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(zoneId); return zoneEntry ? zoneEntry->AreaName[locale] : "<unknown zone>"; } + static bool HandleListRespawnsCommand(ChatHandler* handler, char const* args) { Player const* player = handler->GetSession()->GetPlayer(); - Map const* map = player->GetMap(); + Map* map = player->GetMap(); uint32 range = 0; if (*args) range = atoi((char*)args); @@ -696,27 +698,40 @@ public: char const* stringOverdue = sObjectMgr->GetTrinityString(LANG_LIST_RESPAWNS_OVERDUE, locale); uint32 zoneId = player->GetZoneId(); + char const* zoneName = GetZoneName(zoneId, locale); for (SpawnObjectType type : EnumUtils::Iterate<SpawnObjectType>()) { if (range) handler->PSendSysMessage(LANG_LIST_RESPAWNS_RANGE, EnumUtils::ToTitle(type), range); else - handler->PSendSysMessage(LANG_LIST_RESPAWNS_ZONE, EnumUtils::ToTitle(type), GetZoneName(zoneId, locale), zoneId); + handler->PSendSysMessage(LANG_LIST_RESPAWNS_ZONE, EnumUtils::ToTitle(type), zoneName, zoneId); + handler->PSendSysMessage(LANG_LIST_RESPAWNS_LISTHEADER); std::vector<RespawnInfo*> respawns; - map->GetRespawnInfo(respawns, SpawnObjectTypeMask(1 << type), range ? 0 : zoneId); - for (RespawnInfo* ri : respawns) + map->GetRespawnInfo(respawns, SpawnObjectTypeMask(1 << type)); + for (RespawnInfo const* ri : respawns) { SpawnData const* data = sObjectMgr->GetSpawnData(ri->type, ri->spawnId); if (!data) continue; - if (range && !player->IsInDist(data->spawnPoint, range)) - continue; + + uint32 respawnZoneId = map->GetZoneId(PhasingHandler::GetEmptyPhaseShift(), data->spawnPoint); + if (range) + { + if (!player->IsInDist(data->spawnPoint, range)) + continue; + } + else + { + if (zoneId != respawnZoneId) + continue; + } + uint32 gridY = ri->gridId / MAX_NUMBER_OF_GRIDS; uint32 gridX = ri->gridId % MAX_NUMBER_OF_GRIDS; std::string respawnTime = ri->respawnTime > GameTime::GetGameTime() ? secsToTimeString(uint64(ri->respawnTime - GameTime::GetGameTime()), true) : stringOverdue; - handler->PSendSysMessage(UI64FMTD " | %u | [%02u,%02u] | %s (%u) | %s%s", ri->spawnId, ri->entry, gridX, gridY, GetZoneName(ri->zoneId, locale), ri->zoneId, respawnTime.c_str(), map->IsSpawnGroupActive(data->spawnGroupData->groupId) ? "" : " (inactive)"); + handler->PSendSysMessage(UI64FMTD " | %u | [%02u,%02u] | %s (%u) | %s%s", ri->spawnId, ri->entry, gridX, gridY, GetZoneName(respawnZoneId, locale), respawnZoneId, respawnTime.c_str(), map->IsSpawnGroupActive(data->spawnGroupData->groupId) ? "" : " (inactive)"); } } return true; diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index bfb45069900..7b74a54774f 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1977,7 +1977,7 @@ public: // Now handle any that had despawned, but had respawn time logged. std::vector<RespawnInfo*> data; - player->GetMap()->GetRespawnInfo(data, SPAWN_TYPEMASK_ALL, 0); + player->GetMap()->GetRespawnInfo(data, SPAWN_TYPEMASK_ALL); if (!data.empty()) { uint32 const gridId = Trinity::ComputeGridCoord(player->GetPositionX(), player->GetPositionY()).GetId(); |