Skip to content

fix: sector tracking bugs, contested events, and typed event args#97

Merged
fank merged 5 commits intomainfrom
fix/sector-tracking-contested
Mar 7, 2026
Merged

fix: sector tracking bugs, contested events, and typed event args#97
fank merged 5 commits intomainfrom
fix/sector-tracking-contested

Conversation

@fank
Copy link
Member

@fank fank commented Mar 6, 2026

Summary

Sector Tracking Bug Fixes

  • Fix case-sensitive event name: "OwnerChanged""ownerChanged" — BIS fires lowercase, and BIS_fnc_addScriptedEventHandler stores handlers case-sensitively, so the handler never fired
  • Fix swapped parameters: _oldOwner, _newOwner_newOwner, _oldOwner — BIS passes [sector, newOwner, oldOwner]
  • Fix unreachable init mode: _this isEqualType [] always matched because bare call inherits _this=[] from CBA XEH scope — added && {count _this > 0} guard

Contested Sector Events

  • When a sector loses its owner (sideUnknown), emit a "contested" event instead of silently dropping the transition
  • Removed redundant INFO RPT log (extension logging already captures these)

Typed Event Args

  • fnc_handleCustomEvent.sqf: Routes by event type — captured/contested/capturedFlag send typed positional args [frame, type, objectType, unitName, posX, posY, posZ], endMission sends [frame, type, side, message], other events keep the legacy format
  • fnc_trackSectors.sqf: Passes ["sector", _name, _pos] arrays instead of format ["%1,sector", _name] comma-delimited strings — fixes parsing when sector names contain commas
  • fnc_exportData.sqf: Sends typed [frame, "endMission", side, message] instead of empty message + extraData JSON — fixes data loss in v1 export

Companion PR

Test plan

  • Deploy to server with sector-based mission (MP_COOP_m05)
  • Verify sector capture events appear in OCAP recording with typed JSON arrays
  • Verify contested events appear when sector becomes neutral
  • Verify Zeus-placed sectors are tracked
  • Addon builds clean (hemtt build)
  • Verify endMission data appears correctly after extension PR is deployed

fank added 2 commits March 6, 2026 23:43
1. Init mode unreachable: bare `call FUNC(trackSectors)` inherits
   `_this` as an array from the CBA XEH calling scope, so
   `_this isEqualType []` was always true — entering single-sector
   mode with no sector argument instead of init mode. Fixed by
   requiring a non-empty array for single-sector dispatch.

2. Case mismatch: BIS_fnc_moduleSector fires the scripted event as
   "ownerChanged" (lowercase), but we registered for "OwnerChanged"
   (uppercase). The BIS scripted EH system uses case-sensitive
   getVariable for lookup, so our handler was never called.

3. Swapped parameters: BIS passes [sector, newOwner, oldOwner] but
   params had _oldOwner and _newOwner reversed, causing the
   sideUnknown guard to check the wrong side.
When a sector's owner changes to sideUnknown (neutral), emit a
"contested" event instead of silently dropping the transition.
Previously only captured events were emitted, and ownership loss
was filtered out entirely.

Also removes redundant INFO RPT log since the extension log
already captures these events.
@gemini-code-assist
Copy link

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 addresses several issues related to sector tracking and event handling within the recorder addon. It refines how sector ownership changes are detected and reported, ensuring more accurate and comprehensive event logging. The changes improve the reliability of event triggers, correct parameter handling, and introduce a new event type for contested sectors, ultimately enhancing the fidelity of recorded gameplay data.

Highlights

  • Event Name Case Sensitivity: Corrected the 'OwnerChanged' event name to 'ownerChanged' to match BIS's lowercase firing convention, ensuring event handlers are properly triggered.
  • Parameter Order Correction: Rectified the order of parameters for the 'ownerChanged' event, swapping '_oldOwner' and '_newOwner' to align with BIS's expected parameter passing.
  • Initialization Mode Guard: Added a guard condition && {count _this > 0} to the single-sector initialization block to prevent unintended execution when _this is an empty array, which could occur due to CBA XEH scope inheritance.
  • Contested Event Introduction: Implemented a new 'contested' event that is emitted when a sector's owner becomes 'sideUnknown', providing better tracking for neutral sectors.
  • Logging Optimization: Removed a redundant 'INFO' log entry, as extension logging already captures these events, reducing log verbosity.
Changelog
  • addons/recorder/fnc_trackSectors.sqf
    • Fixed case sensitivity for the 'ownerChanged' event handler name.
    • Corrected the order of '_newOwner' and '_oldOwner' parameters in the event handler.
    • Added a condition to prevent the single-sector initialization block from executing with an empty '_this' array.
    • Introduced logic to emit a 'contested' event when a sector becomes neutral ('sideUnknown').
    • Removed an unnecessary INFO log statement.
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

@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 several important bug fixes for sector tracking, including correcting a case-sensitive event name, fixing swapped event handler parameters, and preventing an issue with _this initialization. It also adds a new 'contested' event type for when a sector becomes neutral. The changes are well-documented and address real issues. I have one suggestion to improve code conciseness by refactoring the new event dispatching logic.

@fank fank changed the title fix: sector tracking bugs and add contested event type fix: sector tracking bugs, contested events, and typed event args Mar 7, 2026
@fank fank merged commit 308f16b into main Mar 7, 2026
1 check passed
@fank fank deleted the fix/sector-tracking-contested branch March 7, 2026 00:09
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