aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Maps/Map.cpp
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2018-02-22 20:31:42 +0100
committerTreeston <treeston.mmoc@gmail.com>2018-02-22 20:31:42 +0100
commit94b5d9bfa1195ad7c32cf51a665b55514dac0938 (patch)
treea90a7c289199727a604caf7c08703a271f4bec83 /src/server/game/Maps/Map.cpp
parent3753ec56476d597b180968eb673cb20776785f31 (diff)
Core/Spawning: Actually check spawn group state before processing a respawn. It feels like that is something that should've been noticed at some point.
Also remove CreatureScript::CanSpawn since nobody uses it, and spawn groups do the same thing.
Diffstat (limited to 'src/server/game/Maps/Map.cpp')
-rw-r--r--src/server/game/Maps/Map.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 8a55e13da77..84335b3fab4 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -2924,10 +2924,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 %u 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)
{
@@ -2937,11 +2951,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)
@@ -3003,15 +3013,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;
}