BossHP: Rework halt to boss specific instead of global.

Global would actually halt the entire plugin on first error. So this is more preferable.
This commit is contained in:
zaCade 2019-03-08 17:03:57 +01:00
parent 6348ff6acf
commit 07547dfd9f
2 changed files with 70 additions and 56 deletions

View File

@ -902,14 +902,9 @@ public void OnGameFrame()
if(!g_aBoss) if(!g_aBoss)
return; return;
static bool s_bRunningBossFrame = false;
static bool s_bLastHudPrinted = false; static bool s_bLastHudPrinted = false;
g_sHUDText[0] = 0; g_sHUDText[0] = 0;
if (!s_bRunningBossFrame)
{
s_bRunningBossFrame = true;
for(int i = 0; i < g_aBoss.Length; i++) for(int i = 0; i < g_aBoss.Length; i++)
{ {
CBoss Boss = g_aBoss.Get(i); CBoss Boss = g_aBoss.Get(i);
@ -944,6 +939,11 @@ public void OnGameFrame()
continue; 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)) if(!BossProcess(Boss))
{ // Delete Boss { // Delete Boss
LogDebugMessage("Deleting boss %d (dead)", i); LogDebugMessage("Deleting boss %d (dead)", i);
@ -958,6 +958,10 @@ public void OnGameFrame()
g_aBoss.Erase(i); g_aBoss.Erase(i);
i--; i--;
} }
// Unmark Boss as processing.
Boss.bProcessing = false;
}
} }
if(!IsVoteInProgress()) if(!IsVoteInProgress())
@ -987,9 +991,6 @@ public void OnGameFrame()
s_bLastHudPrinted = false; s_bLastHudPrinted = false;
} }
} }
s_bRunningBossFrame = false;
}
} }
bool BossInit(CBoss _Boss) bool BossInit(CBoss _Boss)

View File

@ -10,6 +10,7 @@ methodmap CBoss < Basic
Basic myclass = new Basic(); Basic myclass = new Basic();
myclass.SetHandle("dConfig", INVALID_HANDLE); myclass.SetHandle("dConfig", INVALID_HANDLE);
myclass.SetBool("bProcessing", false);
myclass.SetBool("bActive", false); myclass.SetBool("bActive", false);
myclass.SetBool("bShow", true); myclass.SetBool("bShow", true);
myclass.SetInt("iTemplateNum", -1); 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 property bool bActive
{ {
public get() public get()