diff options
-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 | 16 | ||||
-rw-r--r-- | src/server/game/Maps/Map.h | 3 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_list.cpp | 24 |
5 files changed, 30 insertions, 17 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 49169f90b2b..d8971130611 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2408,7 +2408,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(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 a20b69143de..c21ab893fdc 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -1233,7 +1233,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 6abf49b81b0..bc0f086b856 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -3093,18 +3093,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 { 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 @@ -4274,7 +4275,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, SQLTransaction dbTrans, bool startup) +void Map::SaveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 entry, time_t respawnTime, uint32 gridId, SQLTransaction dbTrans, bool startup) { if (!spawnId) return; @@ -4292,7 +4293,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) @@ -4332,7 +4332,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(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,%u) - 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 64bef6ed2ea..aac75c95026 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -297,7 +297,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 @@ -587,7 +586,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, SQLTransaction dbTrans = nullptr, bool startup = false); + void SaveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 entry, time_t respawnTime, uint32 gridId, SQLTransaction dbTrans = nullptr, bool startup = false); void SaveRespawnInfoDB(RespawnInfo const& info, SQLTransaction dbTrans = nullptr); void LoadRespawnTimes(); void DeleteRespawnTimes() { UnloadAllRespawnInfos(); DeleteRespawnTimesInDB(GetId(), GetInstanceId()); } diff --git a/src/server/scripts/Commands/cs_list.cpp b/src/server/scripts/Commands/cs_list.cpp index ccca7e79493..e6981873cc9 100644 --- a/src/server/scripts/Commands/cs_list.cpp +++ b/src/server/scripts/Commands/cs_list.cpp @@ -683,6 +683,7 @@ public: AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(zoneId); return zoneEntry ? zoneEntry->area_name[locale] : "<unknown zone>"; } + static bool HandleListRespawnsCommand(ChatHandler* handler, char const* args) { Player const* player = handler->GetSession()->GetPlayer(); @@ -695,27 +696,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) + 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(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("%u | %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("%u | %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; |