aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Instances/InstanceScript.cpp
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2017-08-26 13:14:25 +0200
committerShauren <shauren.trinity@gmail.com>2020-08-23 17:00:59 +0200
commit27806eeac9d2588d2f7a3b8a0852d45b15a6a241 (patch)
tree21efaf592786e3c07fafdd1d7ff4b7bacf597081 /src/server/game/Instances/InstanceScript.cpp
parent5d61618955ec3e0efe13fe01899b7dcf9fd13e56 (diff)
Core/Spawn: Move spawn group state management from sObjectMgr to the Map object, which makes it actually function as intended with instances. Woops.
(cherry picked from commit f279207d482b886fc8b049e94b46653325ec4d2d)
Diffstat (limited to 'src/server/game/Instances/InstanceScript.cpp')
-rw-r--r--src/server/game/Instances/InstanceScript.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp
index c3cccd75d63..e120f3457a0 100644
--- a/src/server/game/Instances/InstanceScript.cpp
+++ b/src/server/game/Instances/InstanceScript.cpp
@@ -266,13 +266,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);
}
}
@@ -350,7 +350,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
@@ -358,6 +358,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))
@@ -815,7 +821,7 @@ void InstanceScript::UpdatePhasing()
PhasingHandler::SendToPlayer(player);
}
-std::string InstanceScript::GetBossStateName(uint8 state)
+/*static*/ std::string InstanceScript::GetBossStateName(uint8 state)
{
// See enum EncounterState in InstanceScript.h
switch (state)