Skip to content

fix: make deleted units count as dead#422

Merged
fank merged 2 commits intoOCAP2:mainfrom
smitt14ua:fix/deleted-units-alive
May 3, 2026
Merged

fix: make deleted units count as dead#422
fank merged 2 commits intoOCAP2:mainfrom
smitt14ua:fix/deleted-units-alive

Conversation

@smitt14ua
Copy link
Copy Markdown
Contributor

@smitt14ua smitt14ua commented May 2, 2026

Summary

Make units that do not exist on the current frame be considered dead.
Especially useful for missions where AI units are removed after a while if no player takes control.

How to test

Check recording where units were deleted in-game.
Example of this kind of recording:
https://replays.vtg.in.ua/recording/2485/mVTG_Kontrakt_40_v01_20260502_225739
Blue side, Alpha 1-3.
The whole group was deleted at 03:00

Checklist

  • cd ui && npm test passes
  • No breaking changes

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the isAlive function in the UnitsTab component to return false instead of true when an entity snapshot is not found, ensuring that missing entities are not incorrectly identified as alive. I have no feedback to provide as there were no review comments to evaluate.

Copy link
Copy Markdown
Member

@fank fank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one-line fix correctly addresses the root issue. engine.computeSnapshots() only emits snapshots for entities inside [startFrame, endFrame], so a deleted unit (endFrame set at deletion) has no snapshot on later frames. The previous true default rendered deleted units as alive — the new false matches the actual semantics ("not present at this frame" → not alive).

One ask before merging: please add a regression test. ui/src/pages/recording-playback/__tests__/UnitsTab.test.tsx already exercises the alive-count path with live snapshots; extend it with a unit whose lifespan ends before currentFrame (no snapshot returned by entitySnapshots()) and assert it counts as dead and receives the unitRowDead class. Without it, this default is one careless refactor away from silently reverting.

Side note (not blocking): units that haven't spawned yet (currentFrame < startFrame) will now also render as dead. Consistent with the deleted case and fine for a roster view, but worth being aware of.

@smitt14ua smitt14ua requested a review from fank May 3, 2026 11:20
@fank fank merged commit 38ef281 into OCAP2:main May 3, 2026
3 checks passed
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.

2 participants