From c588072b28f04ee3bdf77a8266eb3e91139784a6 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 16 Nov 2022 17:34:22 +1000 Subject: [PATCH] Fix order of bgchr AI execution --- src/game/chraction.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/game/chraction.c b/src/game/chraction.c index 4ca24c707..6ac24a3e8 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -12391,7 +12391,7 @@ void chraTickBg(void) // Run BG scripts if (g_Vars.lvupdate240 > 0) { - for (i = g_NumBgChrs - 1; i >= 0; i--) { + for (i = 0; i < g_NumBgChrs; i++) { struct chrdata *chr = &g_BgChrs[i]; if (!g_Vars.autocutplaying || (chr->hidden2 & CHRH2FLAG_TICKDURINGAUTOCUT)) { @@ -12400,6 +12400,11 @@ void chraTickBg(void) } chraiExecute(chr, PROPTYPE_CHR); + + if (!g_Vars.chrdata) { + // Ailist has terminated and the current bgchr has been removed + i--; + } } } }