Core/Spawn: Move spawn group state management from sObjectMgr to the Map object, which makes it actually function as intended with instances. Woops.

This commit is contained in:
Treeston
2017-08-26 13:14:25 +02:00
parent 80a8867332
commit f279207d48
11 changed files with 182 additions and 156 deletions

View File

@@ -259,13 +259,13 @@ void InstanceScript::UpdateSpawnGroups()
{
uint32 const groupId = pair.first;
bool const doSpawn = (pair.second == SPAWN);
if (sObjectMgr->IsSpawnGroupActive(groupId) == doSpawn)
if (instance->IsSpawnGroupActive(groupId) == doSpawn)
continue; // nothing to do here
// if we should spawn group, then spawn it...
if (doSpawn)
sObjectMgr->SpawnGroupSpawn(groupId, instance);
instance->SpawnGroupSpawn(groupId);
else // otherwise, set it as inactive so it no longer respawns (but don't despawn it)
sObjectMgr->SetSpawnGroupActive(groupId, false);
instance->SetSpawnGroupActive(groupId, false);
}
}
@@ -343,7 +343,7 @@ bool InstanceScript::SetBossState(uint32 id, EncounterState state)
if (bossInfo->state == TO_BE_DECIDED) // loading
{
bossInfo->state = state;
TC_LOG_DEBUG("scripts", "InstanceScript: Initialize boss %u state as %u.", id, (uint32)state);
TC_LOG_DEBUG("scripts", "InstanceScript: Initialize boss %u state as %s (map %u, %u).", id, GetBossStateName(state), instance->GetId(), instance->GetInstanceId());
return false;
}
else
@@ -351,6 +351,12 @@ bool InstanceScript::SetBossState(uint32 id, EncounterState state)
if (bossInfo->state == state)
return false;
if (bossInfo->state == DONE)
{
TC_LOG_ERROR("map", "InstanceScript: Tried to set instance state from %s back to %s for map %u, instance id %u. Blocked!", GetBossStateName(bossInfo->state), GetBossStateName(state), instance->GetId(), instance->GetInstanceId());
return false;
}
if (state == DONE)
for (GuidSet::iterator i = bossInfo->minion.begin(); i != bossInfo->minion.end(); ++i)
if (Creature* minion = instance->GetCreature(*i))
@@ -733,7 +739,7 @@ void InstanceScript::UpdateEncounterStateForSpellCast(uint32 spellId, Unit* sour
UpdateEncounterState(ENCOUNTER_CREDIT_CAST_SPELL, spellId, source);
}
std::string InstanceScript::GetBossStateName(uint8 state)
/*static*/ std::string InstanceScript::GetBossStateName(uint8 state)
{
// See enum EncounterState in InstanceScript.h
switch (state)