mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Maps: All RespawnInfo* handed to outside code are now RespawnInfo const*, to signify that outside code has zero business changing these.
(cherry picked from commit 803dc789e4)
This commit is contained in:
@@ -3218,9 +3218,11 @@ bool Map::CheckRespawn(RespawnInfo* info)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Map::Respawn(RespawnInfo* info, CharacterDatabaseTransaction dbTrans)
|
||||
void Map::Respawn(RespawnInfo const* info, CharacterDatabaseTransaction dbTrans)
|
||||
{
|
||||
info->respawnTime = GameTime::GetGameTime();
|
||||
if (info->respawnTime <= GameTime::GetGameTime())
|
||||
return;
|
||||
const_cast<RespawnInfo*>(info)->respawnTime = GameTime::GetGameTime();
|
||||
_respawnTimes.increase(info->handle);
|
||||
SaveRespawnInfoDB(*info, dbTrans);
|
||||
}
|
||||
@@ -3283,14 +3285,14 @@ bool Map::AddRespawnInfo(RespawnInfo const& info)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void PushRespawnInfoFrom(std::vector<RespawnInfo*>& data, RespawnInfoMap const& map)
|
||||
static void PushRespawnInfoFrom(std::vector<RespawnInfo const*>& data, RespawnInfoMap const& map)
|
||||
{
|
||||
data.reserve(data.size() + map.size());
|
||||
for (auto const& pair : map)
|
||||
data.push_back(pair.second);
|
||||
}
|
||||
|
||||
void Map::GetRespawnInfo(std::vector<RespawnInfo*>& respawnData, SpawnObjectTypeMask types) const
|
||||
void Map::GetRespawnInfo(std::vector<RespawnInfo const*>& respawnData, SpawnObjectTypeMask types) const
|
||||
{
|
||||
if (types & SPAWN_TYPEMASK_CREATURE)
|
||||
PushRespawnInfoFrom(respawnData, _creatureRespawnTimesBySpawnId);
|
||||
@@ -3298,7 +3300,7 @@ void Map::GetRespawnInfo(std::vector<RespawnInfo*>& respawnData, SpawnObjectType
|
||||
PushRespawnInfoFrom(respawnData, _gameObjectRespawnTimesBySpawnId);
|
||||
}
|
||||
|
||||
RespawnInfo* Map::GetRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawnId) const
|
||||
RespawnInfo const* Map::GetRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawnId) const
|
||||
{
|
||||
RespawnInfoMap const* map = GetRespawnMapForType(type);
|
||||
if (!map)
|
||||
|
||||
@@ -767,18 +767,18 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
|
||||
void DeleteRespawnInfoFromDB(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans = nullptr);
|
||||
|
||||
public:
|
||||
void GetRespawnInfo(std::vector<RespawnInfo*>& respawnData, SpawnObjectTypeMask types) const;
|
||||
RespawnInfo* GetRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawnId) const;
|
||||
void GetRespawnInfo(std::vector<RespawnInfo const*>& respawnData, SpawnObjectTypeMask types) const;
|
||||
RespawnInfo const* GetRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawnId) const;
|
||||
void Respawn(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans = nullptr)
|
||||
{
|
||||
if (RespawnInfo* info = GetRespawnInfo(type, spawnId))
|
||||
if (RespawnInfo const* info = GetRespawnInfo(type, spawnId))
|
||||
Respawn(info, dbTrans);
|
||||
}
|
||||
void Respawn(RespawnInfo* info, CharacterDatabaseTransaction dbTrans = nullptr);
|
||||
void Respawn(RespawnInfo const* info, 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);
|
||||
if (RespawnInfo const* info = GetRespawnInfo(type, spawnId))
|
||||
DeleteRespawnInfo(const_cast<RespawnInfo*>(info), dbTrans);
|
||||
// Some callers might need to make sure the database doesn't contain any respawn time
|
||||
else if (alwaysDeleteFromDB)
|
||||
DeleteRespawnInfoFromDB(type, spawnId, dbTrans);
|
||||
|
||||
@@ -637,7 +637,7 @@ public:
|
||||
handler->PSendSysMessage(LANG_LIST_RESPAWNS_ZONE, EnumUtils::ToTitle(type), zoneName, zoneId);
|
||||
|
||||
handler->PSendSysMessage(LANG_LIST_RESPAWNS_LISTHEADER);
|
||||
std::vector<RespawnInfo*> respawns;
|
||||
std::vector<RespawnInfo const*> respawns;
|
||||
map->GetRespawnInfo(respawns, SpawnObjectTypeMask(1 << type));
|
||||
for (RespawnInfo const* ri : respawns)
|
||||
{
|
||||
|
||||
@@ -1890,12 +1890,12 @@ public:
|
||||
Cell::VisitGridObjects(player, worker, player->GetGridActivationRange());
|
||||
|
||||
// Now handle any that had despawned, but had respawn time logged.
|
||||
std::vector<RespawnInfo*> data;
|
||||
std::vector<RespawnInfo const*> data;
|
||||
player->GetMap()->GetRespawnInfo(data, SPAWN_TYPEMASK_ALL);
|
||||
if (!data.empty())
|
||||
{
|
||||
uint32 const gridId = Trinity::ComputeGridCoord(player->GetPositionX(), player->GetPositionY()).GetId();
|
||||
for (RespawnInfo* info : data)
|
||||
for (RespawnInfo const* info : data)
|
||||
if (info->gridId == gridId)
|
||||
player->GetMap()->Respawn(info->type, info->spawnId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user