From efcd50f4ac7627b6fb37ddec3ea41e8d001c0e28 Mon Sep 17 00:00:00 2001 From: zaCade Date: Fri, 8 Mar 2019 17:03:57 +0100 Subject: [PATCH] BossHP: Rework halt to boss specific instead of global. Global would actually halt the entire plugin on first error. So this is more preferable. --- _CleanupRequired/BossHP/scripting/BossHP.sp | 113 ++++++++++---------- _CleanupRequired/BossHP/scripting/CBoss.inc | 13 +++ 2 files changed, 70 insertions(+), 56 deletions(-) diff --git a/_CleanupRequired/BossHP/scripting/BossHP.sp b/_CleanupRequired/BossHP/scripting/BossHP.sp index 3819563e..c564e2b2 100644 --- a/_CleanupRequired/BossHP/scripting/BossHP.sp +++ b/_CleanupRequired/BossHP/scripting/BossHP.sp @@ -902,48 +902,48 @@ public void OnGameFrame() if(!g_aBoss) return; - static bool s_bRunningBossFrame = false; static bool s_bLastHudPrinted = false; g_sHUDText[0] = 0; - if (!s_bRunningBossFrame) + for(int i = 0; i < g_aBoss.Length; i++) { - s_bRunningBossFrame = true; + CBoss Boss = g_aBoss.Get(i); - for(int i = 0; i < g_aBoss.Length; 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--; + + continue; + } + + if(!Boss.bActive) { - 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--; - - continue; - } - - if(!Boss.bActive) + if(Boss.fWaitUntil) { - if(Boss.fWaitUntil) - { - if(Boss.fWaitUntil > GetGameTime()) - continue; - Boss.fWaitUntil = 0.0; - } - - if(!BossInit(Boss)) + if(Boss.fWaitUntil > GetGameTime()) continue; + Boss.fWaitUntil = 0.0; } + if(!BossInit(Boss)) + continue; + } + + if(!Boss.bProcessing) + { + // Mark boss as processing, this will stay true on errors, preventing spam due to OnGameFrame otherwise constantly trying again. + Boss.bProcessing = true; + if(!BossProcess(Boss)) { // Delete Boss LogDebugMessage("Deleting boss %d (dead)", i); @@ -958,37 +958,38 @@ public void OnGameFrame() g_aBoss.Erase(i); i--; } - } - if(!IsVoteInProgress()) + // Unmark Boss as processing. + Boss.bProcessing = false; + } + } + + if(!IsVoteInProgress()) + { + if(g_sHUDText[0]) { - if(g_sHUDText[0]) + for(int client = 1; client <= MaxClients; client++) { - for(int client = 1; client <= MaxClients; client++) + if(IsClientInGame(client)) { - if(IsClientInGame(client)) - { - PrintHintText(client, g_sHUDText); - StopSound(client, SNDCHAN_STATIC, "UI/hint.wav"); - } + 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_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; } } diff --git a/_CleanupRequired/BossHP/scripting/CBoss.inc b/_CleanupRequired/BossHP/scripting/CBoss.inc index feecce01..577539b7 100644 --- a/_CleanupRequired/BossHP/scripting/CBoss.inc +++ b/_CleanupRequired/BossHP/scripting/CBoss.inc @@ -10,6 +10,7 @@ methodmap CBoss < Basic Basic myclass = new Basic(); myclass.SetHandle("dConfig", INVALID_HANDLE); + myclass.SetBool("bProcessing", false); myclass.SetBool("bActive", false); myclass.SetBool("bShow", true); myclass.SetInt("iTemplateNum", -1); @@ -34,6 +35,18 @@ methodmap CBoss < Basic } } + property bool bProcessing + { + public get() + { + return this.GetBool("bProcessing"); + } + public set(bool value) + { + this.SetBool("bProcessing", value); + } + } + property bool bActive { public get()