Skip to content

feat: add :SOLDIER:DELETE: and :VEHICLE:DELETE: commands#135

Merged
fank merged 3 commits intomainfrom
feat/entity-remove-commands
Mar 1, 2026
Merged

feat: add :SOLDIER:DELETE: and :VEHICLE:DELETE: commands#135
fank merged 3 commits intomainfrom
feat/entity-remove-commands

Conversation

@fank
Copy link
Copy Markdown
Member

@fank fank commented Mar 1, 2026

Summary

  • Add :SOLDIER:DELETE: and :VEHICLE:DELETE: commands so the addon can report entity removal (disconnect, respawn corpse)
  • Extension stores a DeleteFrame on the entity and uses it as the gap-fill boundary in the v1 builder instead of maxFrame
  • Entities that are excluded mid-recording now stop at their delete frame instead of persisting as frozen markers until the end

Changes

  • Core types: DeleteFrame field on Soldier and Vehicle
  • Parser: ParseSoldierDelete / ParseVehicleDelete
  • Storage interface: DeleteSoldier / DeleteVehicle on Backend
  • Memory backend: Sets DeleteFrame on the record
  • Postgres backend: No-op stubs (postgres handles export differently)
  • WebSocket backend: Forwards via sendEnvelope
  • Worker dispatch: Registered handlers with buffer size 500
  • Builder: Uses DeleteFrame as gap-fill boundary for last state (falls back to maxFrame when 0)

Test plan

  • go test ./... passes
  • Test mission: disconnect → unit disappears at disconnect frame
  • Test mission: respawn → corpse disappears at death frame
  • Normal kill (no respawn) → dead body persists (DeleteFrame defaults to 0)
  • Old recordings unaffected (DeleteFrame=0 → maxFrame fallback)

Allow the addon to report entity removal (disconnect, respawn corpse)
so the v1 builder uses per-entity delete frames as gap-fill boundaries
instead of extending every entity to maxFrame.
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the recording system's ability to accurately represent the lifecycle of soldiers and vehicles by introducing explicit deletion events. This ensures that when entities are removed from the game world, their presence in recorded data correctly terminates at the point of removal, leading to more precise and realistic playback of mission events.

Highlights

  • New Delete Commands: Introduced :SOLDIER:DELETE: and :VEHICLE:DELETE: commands to allow the addon to report when entities are removed from the game, such as due to disconnects or respawned corpses.
  • Entity Removal Tracking: The system now stores a DeleteFrame on Soldier and Vehicle entities, indicating the frame at which they were removed.
  • Improved Recording Playback: The v1 builder now utilizes the DeleteFrame as the gap-fill boundary for an entity's last known state, ensuring that excluded entities stop at their deletion frame instead of persisting as frozen markers until the end of the recording.
Changelog
  • README.md
    • Documented the newly added :SOLDIER:DELETE: and :VEHICLE:DELETE: commands, including their buffer sizes and purpose.
  • internal/parser/parse_soldier.go
    • Added ParseSoldierDelete function to parse soldier deletion commands, extracting the entity ID and deletion frame.
  • internal/parser/parse_vehicle.go
    • Added ParseVehicleDelete function to parse vehicle deletion commands, extracting the entity ID and deletion frame.
  • internal/parser/parser.go
    • Updated the Service interface to include ParseSoldierDelete and ParseVehicleDelete methods.
  • internal/storage/memory/export/v1/builder.go
    • Modified the Build function to use the DeleteFrame of a soldier when determining the end frame for its last state, falling back to maxFrame if DeleteFrame is zero.
    • Modified the Build function to use the DeleteFrame of a vehicle when determining the end frame for its last state, falling back to maxFrame if DeleteFrame is zero.
  • internal/storage/memory/memory.go
    • Implemented DeleteSoldier method to set the DeleteFrame for a soldier record.
    • Implemented DeleteVehicle method to set the DeleteFrame for a vehicle record.
  • internal/storage/postgres/postgres.go
    • Added no-op DeleteSoldier and DeleteVehicle methods, as PostgreSQL handles export logic differently.
  • internal/storage/storage.go
    • Extended the Backend interface with DeleteSoldier and DeleteVehicle methods for entity removal.
  • internal/storage/websocket/websocket.go
    • Implemented DeleteSoldier to send a TypeDeleteSoldier streaming message.
    • Implemented DeleteVehicle to send a TypeDeleteVehicle streaming message.
  • internal/storage/websocket/websocket_test.go
    • Added test cases for DeleteSoldier and DeleteVehicle to ensure correct WebSocket message forwarding.
  • internal/worker/dispatch.go
    • Registered handleSoldierDelete and handleVehicleDelete functions with the dispatcher for the new delete commands, using a buffered queue of size 500.
    • Added handleSoldierDelete function to parse and process soldier deletion events.
    • Added handleVehicleDelete function to parse and process vehicle deletion events.
  • internal/worker/dispatch_test.go
    • Added mock implementations for DeleteSoldier and DeleteVehicle in mockBackend.
    • Added mock implementations for ParseSoldierDelete and ParseVehicleDelete in mockParserService.
    • Updated the list of registered commands in TestRegisterHandlers_RegistersAllCommands to include the new delete commands.
  • pkg/core/soldier.go
    • Added a DeleteFrame field to the Soldier struct to track when the entity was excluded.
  • pkg/core/vehicle.go
    • Added a DeleteFrame field to the Vehicle struct to track when the entity was excluded.
  • pkg/streaming/messages.go
    • Defined new streaming message types TypeDeleteSoldier and TypeDeleteVehicle.
    • Included the new delete message types in the AllMessageTypes slice.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@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 introduces :SOLDIER:DELETE: and :VEHICLE:DELETE: commands to handle entity removal during a recording. This is achieved by adding a DeleteFrame to soldier and vehicle records, which is then used by the v1 JSON exporter to determine the entity's final frame, preventing them from persisting as frozen markers. The changes span across parsing, storage backends, and the worker dispatcher to support the new commands. The implementation looks solid and correctly follows the described logic. I've left one comment regarding code duplication in the new parser functions, which could be refactored for better maintainability.

Comment thread internal/parser/parse_soldier.go
fank added 2 commits March 1, 2026 14:20
Cover ParseSoldierDelete, ParseVehicleDelete, DeleteSoldier,
DeleteVehicle, dispatch handlers, and builder DeleteFrame gap-fill
boundary.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 1, 2026

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/OCAP2/extension/v5/internal/parser 100.00% (ø)
github.com/OCAP2/extension/v5/internal/storage 0.00% (ø)
github.com/OCAP2/extension/v5/internal/storage/memory 99.06% (+0.05%) 👍
github.com/OCAP2/extension/v5/internal/storage/memory/export/v1 100.00% (ø)
github.com/OCAP2/extension/v5/internal/storage/postgres 85.27% (+0.13%) 👍
github.com/OCAP2/extension/v5/internal/storage/websocket 92.27% (+0.09%) 👍
github.com/OCAP2/extension/v5/internal/worker 100.00% (ø)
github.com/OCAP2/extension/v5/pkg/core 0.00% (ø)
github.com/OCAP2/extension/v5/pkg/streaming 0.00% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/OCAP2/extension/v5/internal/parser/parse_soldier.go 100.00% (ø) 94 (+11) 94 (+11) 0
github.com/OCAP2/extension/v5/internal/parser/parse_vehicle.go 100.00% (ø) 83 (+11) 83 (+11) 0
github.com/OCAP2/extension/v5/internal/parser/parser.go 100.00% (ø) 17 17 0
github.com/OCAP2/extension/v5/internal/storage/memory/export/v1/builder.go 100.00% (ø) 206 (+4) 206 (+4) 0
github.com/OCAP2/extension/v5/internal/storage/memory/memory.go 100.00% (ø) 177 (+10) 177 (+10) 0
github.com/OCAP2/extension/v5/internal/storage/postgres/postgres.go 85.27% (+0.13%) 224 (+2) 191 (+2) 33 👍
github.com/OCAP2/extension/v5/internal/storage/storage.go 0.00% (ø) 0 0 0
github.com/OCAP2/extension/v5/internal/storage/websocket/websocket.go 96.55% (+0.12%) 58 (+2) 56 (+2) 2 👍
github.com/OCAP2/extension/v5/internal/worker/dispatch.go 100.00% (ø) 196 (+10) 196 (+10) 0
github.com/OCAP2/extension/v5/pkg/core/soldier.go 0.00% (ø) 0 0 0
github.com/OCAP2/extension/v5/pkg/core/vehicle.go 0.00% (ø) 0 0 0
github.com/OCAP2/extension/v5/pkg/streaming/messages.go 0.00% (ø) 0 0 0

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/OCAP2/extension/v5/internal/parser/parse_soldier_test.go
  • github.com/OCAP2/extension/v5/internal/parser/parse_vehicle_test.go
  • github.com/OCAP2/extension/v5/internal/storage/memory/export/v1/builder_test.go
  • github.com/OCAP2/extension/v5/internal/storage/memory/memory_test.go
  • github.com/OCAP2/extension/v5/internal/storage/postgres/postgres_test.go
  • github.com/OCAP2/extension/v5/internal/storage/websocket/websocket_test.go
  • github.com/OCAP2/extension/v5/internal/worker/dispatch_test.go

@fank fank merged commit c3c2f96 into main Mar 1, 2026
3 checks passed
@fank fank deleted the feat/entity-remove-commands branch March 1, 2026 13:49
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