Skip to content

Skip the null holes that remove() and single player leave behind - #79

Open
darmie wants to merge 1 commit into
RandomityGuy:masterfrom
darmie:fix/null-guards-in-broadphase-and-hunt-counter
Open

Skip the null holes that remove() and single player leave behind#79
darmie wants to merge 1 commit into
RandomityGuy:masterfrom
darmie:fix/null-guards-in-broadphase-and-hunt-counter

Conversation

@darmie

@darmie darmie commented Sep 4, 2026

Copy link
Copy Markdown

Two unguarded reads that throw Null access every frame. In both cases the surrounding code already checks the same condition elsewhere.

GridBroadphase.boundingSearchremove() nulls objects[proxy.index] and keeps the index (// Preserve indices pls), so a cell can name a null slot. build() skips those holes when walking the same array; this loop doesn't.

PlayGui.formatGemHuntCounterplayerList is only populated in multiplayer: initPlayerList() is gated on isMultiplayer, addPlayer() needs playerListCtrl != null. Single player leaves it empty, so playerList[0].us derefs null on every restart.

Neither crashes — System.hl.hx catches per frame, so the game stops rendering and keeps throwing.

Measured on a Gem Hunt level: ~198k throws/40s from the broadphase, ~250k/30s from the counter, both to zero with these guards.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant