BossHP: Add wrapper into OnGameFrame.

Simply to prevent error spam, since errors halt function. Meaning boolean wouldn't reset.
This commit is contained in:
zaCade 2019-03-07 21:33:31 +01:00
parent 7428d9c68b
commit 1d7a6973a1

View File

@ -902,85 +902,93 @@ public void OnGameFrame()
if(!g_aBoss)
return;
static bool s_bRunningBossFrame = false;
static bool s_bLastHudPrinted = false;
g_sHUDText[0] = 0;
for(int i = 0; i < g_aBoss.Length; i++)
if (!s_bRunningBossFrame)
{
CBoss Boss = g_aBoss.Get(i);
s_bRunningBossFrame = true;
if(Boss.fKillAt && Boss.fKillAt < GetGameTime())
{ // Delete Boss
LogDebugMessage("Deleting boss %d (KillAt)", i);
Call_StartForward(g_hFwd_OnBossKilled);
Call_PushCell(Boss);
Call_PushCell(Boss.dConfig);
Call_PushCell(1);
Call_Finish();
delete Boss;
g_aBoss.Erase(i);
i--;
continue;
}
if(!Boss.bActive)
for(int i = 0; i < g_aBoss.Length; i++)
{
if(Boss.fWaitUntil)
{
if(Boss.fWaitUntil > GetGameTime())
continue;
Boss.fWaitUntil = 0.0;
}
CBoss Boss = g_aBoss.Get(i);
if(Boss.fKillAt && Boss.fKillAt < GetGameTime())
{ // Delete Boss
LogDebugMessage("Deleting boss %d (KillAt)", i);
Call_StartForward(g_hFwd_OnBossKilled);
Call_PushCell(Boss);
Call_PushCell(Boss.dConfig);
Call_PushCell(1);
Call_Finish();
delete Boss;
g_aBoss.Erase(i);
i--;
if(!BossInit(Boss))
continue;
}
if(!BossProcess(Boss))
{ // Delete Boss
LogDebugMessage("Deleting boss %d (dead)", i);
Call_StartForward(g_hFwd_OnBossKilled);
Call_PushCell(Boss);
Call_PushCell(Boss.dConfig);
Call_PushCell(2);
Call_Finish();
delete Boss;
g_aBoss.Erase(i);
i--;
}
}
if(!IsVoteInProgress())
{
if(g_sHUDText[0])
{
for(int client = 1; client <= MaxClients; client++)
{
if(IsClientInGame(client))
{
PrintHintText(client, g_sHUDText);
StopSound(client, SNDCHAN_STATIC, "UI/hint.wav");
}
}
s_bLastHudPrinted = true;
}
else if(s_bLastHudPrinted)
{
for(int client = 1; client <= MaxClients; client++)
if(!Boss.bActive)
{
if(IsClientInGame(client))
if(Boss.fWaitUntil)
{
PrintHintText(client, "");
StopSound(client, SNDCHAN_STATIC, "UI/hint.wav");
if(Boss.fWaitUntil > GetGameTime())
continue;
Boss.fWaitUntil = 0.0;
}
if(!BossInit(Boss))
continue;
}
if(!BossProcess(Boss))
{ // Delete Boss
LogDebugMessage("Deleting boss %d (dead)", i);
Call_StartForward(g_hFwd_OnBossKilled);
Call_PushCell(Boss);
Call_PushCell(Boss.dConfig);
Call_PushCell(2);
Call_Finish();
delete Boss;
g_aBoss.Erase(i);
i--;
}
s_bLastHudPrinted = false;
}
if(!IsVoteInProgress())
{
if(g_sHUDText[0])
{
for(int client = 1; client <= MaxClients; client++)
{
if(IsClientInGame(client))
{
PrintHintText(client, g_sHUDText);
StopSound(client, SNDCHAN_STATIC, "UI/hint.wav");
}
}
s_bLastHudPrinted = true;
}
else if(s_bLastHudPrinted)
{
for(int client = 1; client <= MaxClients; client++)
{
if(IsClientInGame(client))
{
PrintHintText(client, "");
StopSound(client, SNDCHAN_STATIC, "UI/hint.wav");
}
}
s_bLastHudPrinted = false;
}
}
s_bRunningBossFrame = false;
}
}