From e979c4eb4b8661c656a57a3ff12fa6400b432cec Mon Sep 17 00:00:00 2001 From: darmie Date: Fri, 4 Sep 2026 16:20:11 +0100 Subject: [PATCH] Skip the null holes that remove() and single player leave behind boundingSearch reads objects[surfIdx].object, but remove() nulls that slot and keeps the index ("Preserve indices pls"), so a cell can name a null one. build() skips those holes when walking the same array; this loop did not. formatGemHuntCounter reads playerList[0].us, but playerList is only populated in multiplayer: initPlayerList() is gated on isMultiplayer and addPlayer() needs playerListCtrl. Single player leaves it empty. Neither crashes -- System.hl.hx catches per frame -- so the game stops rendering and keeps throwing. On a Gem Hunt level: ~198k throws/40s from the broadphase, ~250k/30s from the counter, both to zero with these guards. --- src/collision/GridBroadphase.hx | 6 +++++- src/gui/PlayGui.hx | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/collision/GridBroadphase.hx b/src/collision/GridBroadphase.hx index 4342b9f9a..7c91b64a5 100644 --- a/src/collision/GridBroadphase.hx +++ b/src/collision/GridBroadphase.hx @@ -246,7 +246,11 @@ class GridBroadphase { for (i in xStart...xEnd) { for (j in yStart...yEnd) { for (surfIdx in cells[16 * i + j]) { - var surf = objects[surfIdx].object; + // remove() nulls the slot but keeps the index; build() skips these too. + var proxy = objects[surfIdx]; + if (proxy == null) + continue; + var surf = proxy.object; if (surf.key == searchKey) continue; surf.key = searchKey; diff --git a/src/gui/PlayGui.hx b/src/gui/PlayGui.hx index 17ced1466..b57ffbed8 100644 --- a/src/gui/PlayGui.hx +++ b/src/gui/PlayGui.hx @@ -1077,7 +1077,8 @@ class PlayGui { gemCountNumbers[4].anim.visible = false; gemCountNumbers[5].anim.visible = false; - var off = playerList[0].us ? 10 : 0; + // playerList is multiplayer-only, so it is empty in single player. + var off = (playerList.length > 0 && playerList[0].us) ? 10 : 0; gemCountNumbers[0].anim.currentFrame = off + collectedHundredths; gemCountNumbers[1].anim.currentFrame = off + collectedTenths;