From 1d7a6973a1aab239b39161ff3470c90de1c0c35b Mon Sep 17 00:00:00 2001 From: zaCade Date: Thu, 7 Mar 2019 21:33:31 +0100 Subject: [PATCH] BossHP: Add wrapper into OnGameFrame. Simply to prevent error spam, since errors halt function. Meaning boolean wouldn't reset. --- _CleanupRequired/BossHP/scripting/BossHP.sp | 138 +++++++++++--------- 1 file changed, 73 insertions(+), 65 deletions(-) diff --git a/_CleanupRequired/BossHP/scripting/BossHP.sp b/_CleanupRequired/BossHP/scripting/BossHP.sp index 56d4ada0..3819563e 100644 --- a/_CleanupRequired/BossHP/scripting/BossHP.sp +++ b/_CleanupRequired/BossHP/scripting/BossHP.sp @@ -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; } }