fix(Scripts/ToC): Fix Trial of the Champion and Trial of the Crusader on … (#13772)
fix(scripts): Fix Trial of the Champion and Trial of the Crusader on player enter cleanup
This commit is contained in:
+20
-8
@@ -256,26 +256,36 @@ public:
|
|||||||
|
|
||||||
// EVENT STUFF BELOW:
|
// EVENT STUFF BELOW:
|
||||||
|
|
||||||
void OnPlayerEnter(Player*) override
|
void OnPlayerEnter(Player* plr) override
|
||||||
|
{
|
||||||
|
if (DoNeedCleanup(plr))
|
||||||
{
|
{
|
||||||
if( DoNeedCleanup(true) )
|
|
||||||
InstanceCleanup();
|
InstanceCleanup();
|
||||||
|
}
|
||||||
|
|
||||||
events.RescheduleEvent(EVENT_CHECK_PLAYERS, CLEANUP_CHECK_INTERVAL);
|
events.RescheduleEvent(EVENT_CHECK_PLAYERS, CLEANUP_CHECK_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoNeedCleanup(bool /*enter*/)
|
bool DoNeedCleanup(Player* ignoredPlayer = nullptr)
|
||||||
{
|
{
|
||||||
uint8 aliveCount = 0;
|
uint8 aliveCount = 0;
|
||||||
Map::PlayerList const& pl = instance->GetPlayers();
|
for (const auto &itr: instance->GetPlayers())
|
||||||
for( Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr )
|
{
|
||||||
if( Player* plr = itr->GetSource() )
|
if (Player* plr = itr.GetSource())
|
||||||
if( plr->IsAlive() && !plr->IsGameMaster() )
|
{
|
||||||
|
if (plr != ignoredPlayer && plr->IsAlive() && !plr->IsGameMaster())
|
||||||
|
{
|
||||||
++aliveCount;
|
++aliveCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool need = aliveCount == 0;
|
bool need = aliveCount == 0;
|
||||||
if (!need && CLEANED)
|
if (!need && CLEANED)
|
||||||
|
{
|
||||||
CLEANED = false;
|
CLEANED = false;
|
||||||
|
}
|
||||||
|
|
||||||
return need;
|
return need;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -769,8 +779,10 @@ public:
|
|||||||
break;
|
break;
|
||||||
case EVENT_CHECK_PLAYERS:
|
case EVENT_CHECK_PLAYERS:
|
||||||
{
|
{
|
||||||
if( DoNeedCleanup(false) )
|
if (DoNeedCleanup())
|
||||||
|
{
|
||||||
InstanceCleanup();
|
InstanceCleanup();
|
||||||
|
}
|
||||||
events.RepeatEvent(CLEANUP_CHECK_INTERVAL);
|
events.RepeatEvent(CLEANUP_CHECK_INTERVAL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
+19
-7
@@ -567,8 +567,10 @@ public:
|
|||||||
DoCheckDedicatedInsanity();
|
DoCheckDedicatedInsanity();
|
||||||
bSwitcher = !bSwitcher;
|
bSwitcher = !bSwitcher;
|
||||||
|
|
||||||
if( DoNeedCleanup(false) )
|
if (DoNeedCleanup())
|
||||||
|
{
|
||||||
InstanceCleanup();
|
InstanceCleanup();
|
||||||
|
}
|
||||||
events.RepeatEvent(CLEANUP_CHECK_INTERVAL);
|
events.RepeatEvent(CLEANUP_CHECK_INTERVAL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1401,8 +1403,10 @@ public:
|
|||||||
else
|
else
|
||||||
plr->SendUpdateWorldState(UPDATE_STATE_UI_SHOW, 0);
|
plr->SendUpdateWorldState(UPDATE_STATE_UI_SHOW, 0);
|
||||||
|
|
||||||
if( DoNeedCleanup(true) )
|
if (DoNeedCleanup(plr))
|
||||||
|
{
|
||||||
InstanceCleanup();
|
InstanceCleanup();
|
||||||
|
}
|
||||||
|
|
||||||
// if missing spawn anub'arak
|
// if missing spawn anub'arak
|
||||||
SpawnAnubArak();
|
SpawnAnubArak();
|
||||||
@@ -1410,18 +1414,26 @@ public:
|
|||||||
events.RescheduleEvent(EVENT_CHECK_PLAYERS, CLEANUP_CHECK_INTERVAL);
|
events.RescheduleEvent(EVENT_CHECK_PLAYERS, CLEANUP_CHECK_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoNeedCleanup(bool /*enter*/)
|
bool DoNeedCleanup(Player* ignoredPlayer = nullptr)
|
||||||
{
|
{
|
||||||
uint8 aliveCount = 0;
|
uint8 aliveCount = 0;
|
||||||
Map::PlayerList const& pl = instance->GetPlayers();
|
for (const auto &itr: instance->GetPlayers())
|
||||||
for( Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr )
|
{
|
||||||
if( Player* plr = itr->GetSource() )
|
if (Player* plr = itr.GetSource())
|
||||||
if( plr->IsAlive() && !plr->IsGameMaster() )
|
{
|
||||||
|
if (plr != ignoredPlayer && plr->IsAlive() && !plr->IsGameMaster())
|
||||||
|
{
|
||||||
++aliveCount;
|
++aliveCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool need = aliveCount == 0;
|
bool need = aliveCount == 0;
|
||||||
if (!need && CLEANED)
|
if (!need && CLEANED)
|
||||||
|
{
|
||||||
CLEANED = false;
|
CLEANED = false;
|
||||||
|
}
|
||||||
|
|
||||||
return need;
|
return need;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user