mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Misc: Various dynspawn cleanup and refactors split off from pooling rewrite:
- Map::RemoveRespawnTime(SpawnObjectType, LowType, doRespawn) split into Map::Respawn and Map::RemoveRespawnTime, without the extra boolean - Map::RemoveRespawnTime(RespawnInfo*) merged into Map::DeleteRespawnInfo(RespawnInfo*) and is now private - Map::DeleteRespawnInfo(void) renamed to Map::UnloadAllRespawnInfos to properly describe what it does - Map::ProcessRespawns now actually saves the delayed respawn time to DB if the respawn was delayed - Map::AddRespawnInfo now takes const reference, and returns success as a boolean - Map::AddRespawnInfo no longer offers an unused "replace" parameter - Map::DeleteRespawnInfo no longer offers a variety of unused private overloads - Map::SaveRespawnTime no longer offers a tantalizing writeDB parameter. Parameter is now called "startup" to properly describe what it does. - Map::SaveRespawnInfoDB now takes RespawnInfo reference instead of all the various fields. Still public because compatibility mode. QQ. - Map::GetWorldObjectBySpawnId sanitized - Map::GetXRespawnTime methods sanitized to all go through Map::GetRespawnTime
This commit is contained in:
@@ -229,7 +229,7 @@ void EscortAI::UpdateAI(uint32 diff)
|
||||
if (!isEscort)
|
||||
me->DespawnOrUnsummon(0, 1s);
|
||||
else
|
||||
me->GetMap()->RemoveRespawnTime(SPAWN_TYPE_CREATURE, me->GetSpawnId(), true);
|
||||
me->GetMap()->Respawn(SPAWN_TYPE_CREATURE, me->GetSpawnId());
|
||||
}
|
||||
else
|
||||
me->DespawnOrUnsummon();
|
||||
|
||||
@@ -2288,7 +2288,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
map = targets.front()->GetMap();
|
||||
|
||||
if (map)
|
||||
map->RemoveRespawnTime(SpawnObjectType(e.action.respawnData.spawnType), e.action.respawnData.spawnId, true);
|
||||
map->Respawn(SpawnObjectType(e.action.respawnData.spawnType), e.action.respawnData.spawnId);
|
||||
else
|
||||
TC_LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry %d SourceType %u, Event %u - tries to respawn by spawnId but does not provide a map", e.entryOrGuid, e.GetScriptType(), e.event_id);
|
||||
break;
|
||||
|
||||
@@ -1743,7 +1743,7 @@ bool Creature::hasInvolvedQuest(uint32 quest_id) const
|
||||
toUnload.push_back(pair.second);
|
||||
for (Creature* creature : toUnload)
|
||||
map->AddObjectToRemoveList(creature);
|
||||
map->RemoveRespawnTime(SPAWN_TYPE_CREATURE, spawnId, false, trans);
|
||||
map->RemoveRespawnTime(SPAWN_TYPE_CREATURE, spawnId, trans);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -2026,9 +2026,6 @@ void Creature::Respawn(bool force)
|
||||
|
||||
if (getDeathState() == DEAD)
|
||||
{
|
||||
if (m_spawnId)
|
||||
GetMap()->RemoveRespawnTime(SPAWN_TYPE_CREATURE, m_spawnId);
|
||||
|
||||
TC_LOG_DEBUG("entities.unit", "Respawning creature %s (%s)", GetName().c_str(), GetGUID().ToString().c_str());
|
||||
m_respawnTime = 0;
|
||||
ResetPickPocketRefillTimer();
|
||||
@@ -2067,7 +2064,7 @@ void Creature::Respawn(bool force)
|
||||
else
|
||||
{
|
||||
if (m_spawnId)
|
||||
GetMap()->RemoveRespawnTime(SPAWN_TYPE_CREATURE, m_spawnId, true);
|
||||
GetMap()->Respawn(SPAWN_TYPE_CREATURE, m_spawnId);
|
||||
}
|
||||
|
||||
TC_LOG_DEBUG("entities.unit", "Respawning creature %s (%s)",
|
||||
@@ -2398,8 +2395,11 @@ void Creature::SaveRespawnTime(uint32 forceDelay)
|
||||
|
||||
if (m_respawnCompatibilityMode)
|
||||
{
|
||||
GetMap()->SaveRespawnTimeDB(SPAWN_TYPE_CREATURE, m_spawnId, m_respawnTime);
|
||||
return;
|
||||
RespawnInfo ri;
|
||||
ri.type = SPAWN_TYPE_CREATURE;
|
||||
ri.spawnId = m_spawnId;
|
||||
ri.respawnTime = m_respawnTime;
|
||||
GetMap()->SaveRespawnInfoDB(ri);
|
||||
}
|
||||
|
||||
time_t thisRespawnTime = forceDelay ? GameTime::GetGameTime() + forceDelay : m_respawnTime;
|
||||
|
||||
@@ -1121,7 +1121,7 @@ bool GameObject::LoadFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap
|
||||
toUnload.push_back(pair.second);
|
||||
for (GameObject* obj : toUnload)
|
||||
map->AddObjectToRemoveList(obj);
|
||||
map->RemoveRespawnTime(SPAWN_TYPE_GAMEOBJECT, spawnId, false, trans);
|
||||
map->RemoveRespawnTime(SPAWN_TYPE_GAMEOBJECT, spawnId, trans);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1232,7 +1232,11 @@ void GameObject::SaveRespawnTime(uint32 forceDelay)
|
||||
{
|
||||
if (m_respawnCompatibilityMode)
|
||||
{
|
||||
GetMap()->SaveRespawnTimeDB(SPAWN_TYPE_GAMEOBJECT, m_spawnId, m_respawnTime);
|
||||
RespawnInfo ri;
|
||||
ri.type = SPAWN_TYPE_GAMEOBJECT;
|
||||
ri.spawnId = m_spawnId;
|
||||
ri.respawnTime = m_respawnTime;
|
||||
GetMap()->SaveRespawnInfoDB(ri);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1320,7 +1324,7 @@ void GameObject::Respawn()
|
||||
if (m_spawnedByDefault && m_respawnTime > 0)
|
||||
{
|
||||
m_respawnTime = GameTime::GetGameTime();
|
||||
GetMap()->RemoveRespawnTime(SPAWN_TYPE_GAMEOBJECT, m_spawnId, true);
|
||||
GetMap()->Respawn(SPAWN_TYPE_GAMEOBJECT, m_spawnId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ Map::~Map()
|
||||
|
||||
// Delete all waiting spawns, else there will be a memory leak
|
||||
// This doesn't delete from database.
|
||||
DeleteRespawnInfo();
|
||||
UnloadAllRespawnInfos();
|
||||
|
||||
while (!i_worldObjects.empty())
|
||||
{
|
||||
@@ -3052,9 +3052,12 @@ void Map::Respawn(RespawnInfo* info, SQLTransaction dbTrans)
|
||||
if (!CheckRespawn(info))
|
||||
{
|
||||
if (info->respawnTime)
|
||||
SaveRespawnTime(info->type, info->spawnId, info->entry, info->respawnTime, info->zoneId, info->gridId, true, true, dbTrans);
|
||||
{
|
||||
_respawnTimes.decrease(info->handle);
|
||||
SaveRespawnInfoDB(*info, dbTrans);
|
||||
}
|
||||
else
|
||||
RemoveRespawnTime(info);
|
||||
DeleteRespawnInfo(info, dbTrans);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3062,23 +3065,13 @@ void Map::Respawn(RespawnInfo* info, SQLTransaction dbTrans)
|
||||
SpawnObjectType const type = info->type;
|
||||
uint32 const gridId = info->gridId;
|
||||
ObjectGuid::LowType const spawnId = info->spawnId;
|
||||
RemoveRespawnTime(info);
|
||||
DeleteRespawnInfo(info, dbTrans);
|
||||
DoRespawn(type, spawnId, gridId);
|
||||
}
|
||||
|
||||
void Map::Respawn(std::vector<RespawnInfo*>& respawnData, SQLTransaction dbTrans)
|
||||
bool Map::AddRespawnInfo(RespawnInfo const& info)
|
||||
{
|
||||
SQLTransaction trans = dbTrans ? dbTrans : CharacterDatabase.BeginTransaction();
|
||||
for (RespawnInfo* info : respawnData)
|
||||
Respawn(info, trans);
|
||||
if (!dbTrans)
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
void Map::AddRespawnInfo(RespawnInfo& info, bool replace)
|
||||
{
|
||||
if (!info.spawnId)
|
||||
return;
|
||||
ASSERT(info.spawnId, "Attempt to schedule respawn with zero spawnid (type %u)", uint32(info.type));
|
||||
|
||||
RespawnInfoMap& bySpawnIdMap = GetRespawnMapForType(info.type);
|
||||
|
||||
@@ -3086,13 +3079,10 @@ void Map::AddRespawnInfo(RespawnInfo& info, bool replace)
|
||||
if (it != bySpawnIdMap.end()) // spawnid already has a respawn scheduled
|
||||
{
|
||||
RespawnInfo* const existing = it->second;
|
||||
if (replace || info.respawnTime < existing->respawnTime) // delete existing in this case
|
||||
if (info.respawnTime < existing->respawnTime) // delete existing in this case
|
||||
DeleteRespawnInfo(existing);
|
||||
else // don't delete existing, instead replace respawn time so caller saves the correct time
|
||||
{
|
||||
info.respawnTime = existing->respawnTime;
|
||||
return;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// if we get to this point, we should insert the respawninfo (there either was no prior entry, or it was deleted already)
|
||||
@@ -3100,6 +3090,7 @@ void Map::AddRespawnInfo(RespawnInfo& info, bool replace)
|
||||
ri->handle = _respawnTimes.push(ri);
|
||||
bool success = bySpawnIdMap.emplace(ri->spawnId, ri).second;
|
||||
ASSERT(success, "Insertion of respawn info with id (%u,%u) into spawn id map failed - state desync.", uint32(ri->type), ri->spawnId);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void PushRespawnInfoFrom(std::vector<RespawnInfo*>& data, RespawnInfoMap const& map, uint32 zoneId)
|
||||
@@ -3125,7 +3116,7 @@ RespawnInfo* Map::GetRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawn
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void Map::DeleteRespawnInfo() // delete everything
|
||||
void Map::UnloadAllRespawnInfos() // delete everything from memory
|
||||
{
|
||||
for (RespawnInfo* info : _respawnTimes)
|
||||
delete info;
|
||||
@@ -3134,7 +3125,7 @@ void Map::DeleteRespawnInfo() // delete everything
|
||||
_gameObjectRespawnTimesBySpawnId.clear();
|
||||
}
|
||||
|
||||
void Map::DeleteRespawnInfo(RespawnInfo* info)
|
||||
void Map::DeleteRespawnInfo(RespawnInfo* info, SQLTransaction dbTrans)
|
||||
{
|
||||
// Delete from all relevant containers to ensure consistency
|
||||
ASSERT(info);
|
||||
@@ -3143,15 +3134,10 @@ void Map::DeleteRespawnInfo(RespawnInfo* info)
|
||||
size_t const n = GetRespawnMapForType(info->type).erase(info->spawnId);
|
||||
ASSERT(n == 1, "Respawn stores inconsistent for map %u, spawnid %u (type %u)", GetId(), info->spawnId, uint32(info->type));
|
||||
|
||||
//respawn heap
|
||||
// respawn heap
|
||||
_respawnTimes.erase(info->handle);
|
||||
|
||||
// then cleanup the object
|
||||
delete info;
|
||||
}
|
||||
|
||||
void Map::RemoveRespawnTime(RespawnInfo* info, bool doRespawn, SQLTransaction dbTrans)
|
||||
{
|
||||
// database
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_RESPAWN);
|
||||
stmt->setUInt16(0, info->type);
|
||||
stmt->setUInt32(1, info->spawnId);
|
||||
@@ -3159,19 +3145,8 @@ void Map::RemoveRespawnTime(RespawnInfo* info, bool doRespawn, SQLTransaction db
|
||||
stmt->setUInt32(3, GetInstanceId());
|
||||
CharacterDatabase.ExecuteOrAppend(dbTrans, stmt);
|
||||
|
||||
if (doRespawn)
|
||||
Respawn(info);
|
||||
else
|
||||
DeleteRespawnInfo(info);
|
||||
}
|
||||
|
||||
void Map::RemoveRespawnTime(std::vector<RespawnInfo*>& respawnData, bool doRespawn, SQLTransaction dbTrans)
|
||||
{
|
||||
SQLTransaction trans = dbTrans ? dbTrans : CharacterDatabase.BeginTransaction();
|
||||
for (RespawnInfo* info : respawnData)
|
||||
RemoveRespawnTime(info, doRespawn, trans);
|
||||
if (!dbTrans)
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
// then cleanup the object
|
||||
delete info;
|
||||
}
|
||||
|
||||
void Map::ProcessRespawns()
|
||||
@@ -3200,6 +3175,7 @@ void Map::ProcessRespawns()
|
||||
{
|
||||
ASSERT(now < next->respawnTime); // infinite loop guard
|
||||
_respawnTimes.decrease(next->handle);
|
||||
SaveRespawnInfoDB(*next);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3280,7 +3256,7 @@ bool Map::SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn, bool force, std::v
|
||||
continue;
|
||||
|
||||
// we need to remove the respawn time, otherwise we'd end up double spawning
|
||||
RemoveRespawnTime(data->type, data->spawnId, false);
|
||||
RemoveRespawnTime(data->type, data->spawnId);
|
||||
}
|
||||
|
||||
// don't spawn if the grid isn't loaded (will be handled in grid loader)
|
||||
@@ -4298,12 +4274,15 @@ 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, bool writeDB, bool replace, SQLTransaction dbTrans)
|
||||
void Map::SaveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 entry, time_t respawnTime, uint32 zoneId, uint32 gridId, SQLTransaction dbTrans, bool startup)
|
||||
{
|
||||
if (!spawnId)
|
||||
return;
|
||||
|
||||
if (!respawnTime)
|
||||
{
|
||||
// Delete only
|
||||
RemoveRespawnTime(type, spawnId, false, dbTrans);
|
||||
RemoveRespawnTime(type, spawnId, dbTrans);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4314,19 +4293,23 @@ void Map::SaveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, uin
|
||||
ri.respawnTime = respawnTime;
|
||||
ri.gridId = gridId;
|
||||
ri.zoneId = zoneId;
|
||||
AddRespawnInfo(ri, replace);
|
||||
bool success = AddRespawnInfo(ri);
|
||||
|
||||
if (writeDB)
|
||||
SaveRespawnTimeDB(type, spawnId, ri.respawnTime, dbTrans); // might be different from original respawn time if we didn't replace
|
||||
if (startup)
|
||||
{
|
||||
if (!success)
|
||||
TC_LOG_ERROR("maps", "Attempt to load saved respawn %" PRIu64 " for (%u,%u) failed - duplicate respawn? Skipped.", respawnTime, uint32(type), spawnId);
|
||||
}
|
||||
else if (success)
|
||||
SaveRespawnInfoDB(ri, dbTrans);
|
||||
}
|
||||
|
||||
void Map::SaveRespawnTimeDB(SpawnObjectType type, ObjectGuid::LowType spawnId, time_t respawnTime, SQLTransaction dbTrans)
|
||||
void Map::SaveRespawnInfoDB(RespawnInfo const& info, SQLTransaction dbTrans)
|
||||
{
|
||||
// Just here for support of compatibility mode
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_RESPAWN);
|
||||
stmt->setUInt16(0, type);
|
||||
stmt->setUInt32(1, spawnId);
|
||||
stmt->setUInt64(2, uint64(respawnTime));
|
||||
stmt->setUInt16(0, info.type);
|
||||
stmt->setUInt32(1, info.spawnId);
|
||||
stmt->setUInt64(2, uint64(info.respawnTime));
|
||||
stmt->setUInt16(3, GetId());
|
||||
stmt->setUInt32(4, GetInstanceId());
|
||||
CharacterDatabase.ExecuteOrAppend(dbTrans, stmt);
|
||||
@@ -4346,10 +4329,17 @@ void Map::LoadRespawnTimes()
|
||||
ObjectGuid::LowType spawnId = fields[1].GetUInt32();
|
||||
uint64 respawnTime = fields[2].GetUInt64();
|
||||
|
||||
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(), false);
|
||||
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);
|
||||
else
|
||||
TC_LOG_ERROR("maps", "Loading saved respawn time of %" PRIu64 " for spawnid (%u,%u) - spawn does not exist, ignoring", respawnTime, uint32(type), spawnId);
|
||||
}
|
||||
else
|
||||
TC_LOG_ERROR("maps", "Loading saved respawn time of %" PRIu64 " for spawnid (%u,%u) - spawn does not exist, ignoring", respawnTime, uint32(type), spawnId);
|
||||
{
|
||||
TC_LOG_ERROR("maps", "Loading saved respawn time of %" PRIu64 " for spawnid (%u,%u) - invalid spawn type, ignoring", respawnTime, uint32(type), spawnId);
|
||||
}
|
||||
|
||||
} while (result->NextRow());
|
||||
}
|
||||
|
||||
@@ -501,7 +501,18 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
|
||||
GameObject* GetGameObject(ObjectGuid const& guid);
|
||||
Creature* GetCreatureBySpawnId(ObjectGuid::LowType spawnId) const;
|
||||
GameObject* GetGameObjectBySpawnId(ObjectGuid::LowType spawnId) const;
|
||||
WorldObject* GetWorldObjectBySpawnId(SpawnObjectType type, ObjectGuid::LowType spawnId) const { return (type == SPAWN_TYPE_GAMEOBJECT) ? reinterpret_cast<WorldObject*>(GetGameObjectBySpawnId(spawnId)) : reinterpret_cast<WorldObject*>(GetCreatureBySpawnId(spawnId)); }
|
||||
WorldObject* GetWorldObjectBySpawnId(SpawnObjectType type, ObjectGuid::LowType spawnId) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SPAWN_TYPE_CREATURE:
|
||||
return reinterpret_cast<WorldObject*>(GetCreatureBySpawnId(spawnId));
|
||||
case SPAWN_TYPE_GAMEOBJECT:
|
||||
return reinterpret_cast<WorldObject*>(GetGameObjectBySpawnId(spawnId));
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
Transport* GetTransport(ObjectGuid const& guid);
|
||||
DynamicObject* GetDynamicObject(ObjectGuid const& guid);
|
||||
Pet* GetPet(ObjectGuid const& guid);
|
||||
@@ -565,26 +576,21 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
|
||||
RESPAWN TIMES
|
||||
*/
|
||||
time_t GetLinkedRespawnTime(ObjectGuid guid) const;
|
||||
time_t GetCreatureRespawnTime(ObjectGuid::LowType dbGuid) const
|
||||
time_t GetRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId) const
|
||||
{
|
||||
RespawnInfoMap::const_iterator itr = _creatureRespawnTimesBySpawnId.find(dbGuid);
|
||||
return itr != _creatureRespawnTimesBySpawnId.end() ? itr->second->respawnTime : 0;
|
||||
auto const& map = GetRespawnMapForType(type);
|
||||
auto it = map.find(spawnId);
|
||||
return (it == map.end()) ? 0 : it->second->respawnTime;
|
||||
}
|
||||
|
||||
time_t GetGORespawnTime(ObjectGuid::LowType dbGuid) const
|
||||
{
|
||||
RespawnInfoMap::const_iterator itr = _gameObjectRespawnTimesBySpawnId.find(dbGuid);
|
||||
return itr != _gameObjectRespawnTimesBySpawnId.end() ? itr->second->respawnTime : 0;
|
||||
}
|
||||
|
||||
time_t GetRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId) const { return (type == SPAWN_TYPE_GAMEOBJECT) ? GetGORespawnTime(spawnId) : GetCreatureRespawnTime(spawnId); }
|
||||
time_t GetCreatureRespawnTime(ObjectGuid::LowType spawnId) const { return GetRespawnTime(SPAWN_TYPE_CREATURE, spawnId); }
|
||||
time_t GetGORespawnTime(ObjectGuid::LowType spawnId) const { return GetRespawnTime(SPAWN_TYPE_GAMEOBJECT, spawnId); }
|
||||
|
||||
void UpdatePlayerZoneStats(uint32 oldZone, uint32 newZone);
|
||||
|
||||
void SaveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 entry, time_t respawnTime, uint32 zoneId, uint32 gridId = 0, bool writeDB = true, bool replace = false, SQLTransaction dbTrans = nullptr);
|
||||
void SaveRespawnTimeDB(SpawnObjectType type, ObjectGuid::LowType spawnId, time_t respawnTime, SQLTransaction dbTrans = nullptr);
|
||||
void SaveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 entry, time_t respawnTime, uint32 zoneId, uint32 gridId, SQLTransaction dbTrans = nullptr, bool startup = false);
|
||||
void SaveRespawnInfoDB(RespawnInfo const& info, SQLTransaction dbTrans = nullptr);
|
||||
void LoadRespawnTimes();
|
||||
void DeleteRespawnTimes() { DeleteRespawnInfo(); DeleteRespawnTimesInDB(GetId(), GetInstanceId()); }
|
||||
void DeleteRespawnTimes() { UnloadAllRespawnInfos(); DeleteRespawnTimesInDB(GetId(), GetInstanceId()); }
|
||||
|
||||
void LoadCorpseData();
|
||||
void DeleteCorpseData();
|
||||
@@ -635,7 +641,6 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
|
||||
virtual std::string GetDebugInfo() const;
|
||||
|
||||
private:
|
||||
|
||||
void LoadMapAndVMap(int gx, int gy);
|
||||
void LoadVMap(int gx, int gy);
|
||||
void LoadMap(int gx, int gy, bool reload = false);
|
||||
@@ -760,45 +765,22 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
|
||||
bool CheckRespawn(RespawnInfo* info);
|
||||
void DoRespawn(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 gridId);
|
||||
void Respawn(RespawnInfo* info, SQLTransaction dbTrans = nullptr);
|
||||
void Respawn(std::vector<RespawnInfo*>& respawnData, SQLTransaction dbTrans = nullptr);
|
||||
void AddRespawnInfo(RespawnInfo& info, bool replace = false);
|
||||
void DeleteRespawnInfo();
|
||||
void DeleteRespawnInfo(RespawnInfo* info);
|
||||
void DeleteRespawnInfo(std::vector<RespawnInfo*>& toDelete)
|
||||
{
|
||||
for (RespawnInfo* info : toDelete)
|
||||
DeleteRespawnInfo(info);
|
||||
toDelete.clear();
|
||||
}
|
||||
void DeleteRespawnInfo(SpawnObjectTypeMask types, uint32 zoneId = 0)
|
||||
{
|
||||
std::vector<RespawnInfo*> v;
|
||||
GetRespawnInfo(v, types, zoneId);
|
||||
if (!v.empty())
|
||||
DeleteRespawnInfo(v);
|
||||
}
|
||||
void DeleteRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawnId)
|
||||
{
|
||||
if (RespawnInfo* info = GetRespawnInfo(type, spawnId))
|
||||
DeleteRespawnInfo(info);
|
||||
}
|
||||
bool AddRespawnInfo(RespawnInfo const& info);
|
||||
void UnloadAllRespawnInfos();
|
||||
void DeleteRespawnInfo(RespawnInfo* info, SQLTransaction dbTrans = nullptr);
|
||||
|
||||
public:
|
||||
void GetRespawnInfo(std::vector<RespawnInfo*>& respawnData, SpawnObjectTypeMask types, uint32 zoneId = 0) const;
|
||||
RespawnInfo* GetRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawnId) const;
|
||||
void RemoveRespawnTime(RespawnInfo* info, bool doRespawn = false, SQLTransaction dbTrans = nullptr);
|
||||
void RemoveRespawnTime(std::vector<RespawnInfo*>& respawnData, bool doRespawn = false, SQLTransaction dbTrans = nullptr);
|
||||
void RemoveRespawnTime(SpawnObjectTypeMask types = SPAWN_TYPEMASK_ALL, uint32 zoneId = 0, bool doRespawn = false, SQLTransaction dbTrans = nullptr)
|
||||
{
|
||||
std::vector<RespawnInfo*> v;
|
||||
GetRespawnInfo(v, types, zoneId);
|
||||
if (!v.empty())
|
||||
RemoveRespawnTime(v, doRespawn, dbTrans);
|
||||
}
|
||||
void RemoveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, bool doRespawn = false, SQLTransaction dbTrans = nullptr)
|
||||
void Respawn(SpawnObjectType type, ObjectGuid::LowType spawnId, SQLTransaction dbTrans = nullptr)
|
||||
{
|
||||
if (RespawnInfo* info = GetRespawnInfo(type, spawnId))
|
||||
RemoveRespawnTime(info, doRespawn, dbTrans);
|
||||
Respawn(info, dbTrans);
|
||||
}
|
||||
void RemoveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId,SQLTransaction dbTrans = nullptr)
|
||||
{
|
||||
if (RespawnInfo* info = GetRespawnInfo(type, spawnId))
|
||||
DeleteRespawnInfo(info, dbTrans);
|
||||
}
|
||||
|
||||
SpawnGroupTemplateData const* GetSpawnGroupData(uint32 groupId) const;
|
||||
@@ -851,8 +833,30 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
|
||||
RespawnListContainer _respawnTimes;
|
||||
RespawnInfoMap _creatureRespawnTimesBySpawnId;
|
||||
RespawnInfoMap _gameObjectRespawnTimesBySpawnId;
|
||||
RespawnInfoMap& GetRespawnMapForType(SpawnObjectType type) { return (type == SPAWN_TYPE_GAMEOBJECT) ? _gameObjectRespawnTimesBySpawnId : _creatureRespawnTimesBySpawnId; }
|
||||
RespawnInfoMap const& GetRespawnMapForType(SpawnObjectType type) const { return (type == SPAWN_TYPE_GAMEOBJECT) ? _gameObjectRespawnTimesBySpawnId : _creatureRespawnTimesBySpawnId; }
|
||||
RespawnInfoMap& GetRespawnMapForType(SpawnObjectType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
default:
|
||||
ASSERT(false);
|
||||
case SPAWN_TYPE_CREATURE:
|
||||
return _creatureRespawnTimesBySpawnId;
|
||||
case SPAWN_TYPE_GAMEOBJECT:
|
||||
return _gameObjectRespawnTimesBySpawnId;
|
||||
}
|
||||
}
|
||||
RespawnInfoMap const& GetRespawnMapForType(SpawnObjectType type) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
default:
|
||||
ASSERT(false);
|
||||
case SPAWN_TYPE_CREATURE:
|
||||
return _creatureRespawnTimesBySpawnId;
|
||||
case SPAWN_TYPE_GAMEOBJECT:
|
||||
return _gameObjectRespawnTimesBySpawnId;
|
||||
}
|
||||
}
|
||||
|
||||
void SetSpawnGroupActive(uint32 groupId, bool state);
|
||||
std::unordered_set<uint32> _toggledSpawnGroupIds;
|
||||
|
||||
@@ -27,6 +27,7 @@ EndScriptData */
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DBCStores.h"
|
||||
#include "GameEventMgr.h"
|
||||
#include "GameObject.h"
|
||||
#include "GameObjectAI.h"
|
||||
#include "GameTime.h"
|
||||
#include "Language.h"
|
||||
|
||||
@@ -1908,7 +1908,7 @@ public:
|
||||
uint32 const gridId = Trinity::ComputeGridCoord(player->GetPositionX(), player->GetPositionY()).GetId();
|
||||
for (RespawnInfo* info : data)
|
||||
if (info->gridId == gridId)
|
||||
player->GetMap()->RemoveRespawnTime(info, true);
|
||||
player->GetMap()->Respawn(info->type, info->spawnId);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -337,8 +337,8 @@ struct boss_thaddius : public BossAI
|
||||
me->SetReactState(REACT_PASSIVE);
|
||||
|
||||
// @todo these guys should really be moved to a summon group - this is merely a hack to make them work in dynamic_spawning
|
||||
instance->instance->RemoveRespawnTime(SPAWN_TYPE_CREATURE, 130958, true); // Stalagg
|
||||
instance->instance->RemoveRespawnTime(SPAWN_TYPE_CREATURE, 130959, true); // Feugen
|
||||
instance->instance->Respawn(SPAWN_TYPE_CREATURE, 130958); // Stalagg
|
||||
instance->instance->Respawn(SPAWN_TYPE_CREATURE, 130959); // Feugen
|
||||
}
|
||||
|
||||
void UpdateAI(uint32 diff) override
|
||||
|
||||
Reference in New Issue
Block a user