diff options
Diffstat (limited to 'src/server/game/Maps/Map.cpp')
-rw-r--r-- | src/server/game/Maps/Map.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 856b5a4185c..8c1d6aae417 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -3062,10 +3062,24 @@ void Map::SendObjectUpdates() } } +// CheckRespawn MUST do one of the following: +// -) return true +// -) set info->respawnTime to zero, which indicates the respawn time should be deleted (and will never be processed again without outside intervention) +// -) set info->respawnTime to a new respawn time, which must be strictly GREATER than the current time (GameTime::GetGameTime()) bool Map::CheckRespawn(RespawnInfo* info) { + SpawnData const* data = sObjectMgr->GetSpawnData(info->type, info->spawnId); + ASSERT(data, "Invalid respawn info with type %u, spawnID " UI64FMTD " in respawn queue.", info->type, info->spawnId); + + // First, check if this creature's spawn group is inactive + if (!IsSpawnGroupActive(data->spawnGroupData->groupId)) + { + info->respawnTime = 0; + return false; + } + uint32 poolId = info->spawnId ? sPoolMgr->IsPartOfAPool(info->type, info->spawnId) : 0; - // First, check if there's already an instance of this object that would block the respawn + // Next, check if there's already an instance of this object that would block the respawn // Only do this for unpooled spawns if (!poolId) { @@ -3075,11 +3089,7 @@ bool Map::CheckRespawn(RespawnInfo* info) case SPAWN_TYPE_CREATURE: { // escort check for creatures only (if the world config boolean is set) - bool isEscort = false; - if (sWorld->getBoolConfig(CONFIG_RESPAWN_DYNAMIC_ESCORTNPC) && info->type == SPAWN_TYPE_CREATURE) - if (CreatureData const* cdata = sObjectMgr->GetCreatureData(info->spawnId)) - if (cdata->spawnGroupData->flags & SPAWNGROUP_FLAG_ESCORTQUESTNPC) - isEscort = true; + bool const isEscort = (sWorld->getBoolConfig(CONFIG_RESPAWN_DYNAMIC_ESCORTNPC) && data->spawnGroupData->flags & SPAWNGROUP_FLAG_ESCORTQUESTNPC); auto range = _creatureBySpawnIdStore.equal_range(info->spawnId); for (auto it = range.first; it != range.second; ++it) @@ -3143,15 +3153,7 @@ bool Map::CheckRespawn(RespawnInfo* info) return false; } - // if we're a creature, see if the script objects to us spawning - if (info->type == SPAWN_TYPE_CREATURE) - { - if (!sScriptMgr->CanSpawn(info->spawnId, info->entry, sObjectMgr->GetCreatureData(info->spawnId), this)) - { // if a script blocks our respawn, schedule next check in a little bit - info->respawnTime = GameTime::GetGameTime() + urand(4, 7); - return false; - } - } + // everything ok, let's spawn return true; } |