From 0beb91e17e9ad4f6c6033b3d22915a82e50efcfa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 16 Jan 2022 12:01:53 +0100 Subject: [PATCH] - Blood: don't use references to address gBusy. This will fail if the callback in trProcessBusy adds new entries to the array which would invalidate the reference. --- source/games/blood/src/triggers.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index 041415e3e..38de64029 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -2130,27 +2130,27 @@ void trProcessBusy(void) { sect.velCeil = sect.velFloor = 0; } - for (auto& b : backwards(gBusy)) + for (int i = gBusy.Size(); i >= 0; i--) { int nStatus; - int oldBusy = b.busy; - b.busy = ClipRange(oldBusy + b.delta * 4, 0, 65536); + int oldBusy = gBusy[i].busy; + gBusy[i].busy = ClipRange(oldBusy + gBusy[i].delta * 4, 0, 65536); #ifdef NOONE_EXTENSIONS - if (!gModernMap || !b.sect->xs().unused1) nStatus = gBusyProc[b.type](b.sect, b.busy); + if (!gModernMap || !gBusy[i].sect->xs().unused1) nStatus = gBusyProc[gBusy[i].type](gBusy[i].sect, gBusy[i].busy); else nStatus = 3; // allow to pause/continue motion for sectors any time by sending special command #else - nStatus = gBusyProc[b.type](b.at0, b.at8); + nStatus = gBusyProc[gBusy[i].type](gBusy[i].at0, gBusy[i].at8); #endif switch (nStatus) { case 1: - b.busy = oldBusy; + gBusy[i].busy = oldBusy; break; case 2: - b.busy = oldBusy; - b.delta = -b.delta; + gBusy[i].busy = oldBusy; + gBusy[i].delta = -gBusy[i].delta; break; case 3: - b = gBusy.Last(); + gBusy[i] = gBusy.Last(); gBusy.Pop(); break; }