fix: sector event routing, type guards, and color field#99
Conversation
- fnc_trackSectors: include str _newOwner (side) in captured events, empty string for contested events - fnc_handleCustomEvent: extract side string from eventMessage[2] and pass it as a typed positional arg to :EVENT:SECTOR:
Summary of ChangesHello, 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 restores the Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request correctly adds the side field to sector events, ensuring it's passed to the extension as intended. The changes in fnc_trackSectors.sqf properly include the side information, and fnc_handleCustomEvent.sqf is updated to process it. I have one suggestion for fnc_handleCustomEvent.sqf to simplify the new logic for improved clarity.
capturedFlag has player-centric fields (unitName, unitSide, flagSide) incompatible with sector-centric fields (objectType, unitName, side, position). Let it fall through to :EVENT:GENERAL: instead.
param [2, ""] already guarantees a string default, so the isEqualType check was redundant.
param [2, ""] returns the raw value at index 2 even if it's an array (position), not the default. Use param's type-check argument [2, "", [""]] to ensure only strings are accepted as side, falling back to "" for non-string values like position arrays at index 2.
Document the full format [objectType, unitName, side, color, position] and note that color is not captured by the extension. Add type guards to params 0 and 1 for consistency.
Extract color (index 3) from the event message array and send it to the extension as part of the :EVENT:SECTOR: args. Format changes from [frame, type, objectType, unitName, side, posX?, posY?, posZ?] to [frame, type, objectType, unitName, side, color, posX?, posY?, posZ?].
fnc_trackSectors sends [objectType, name, side, position] but the extension now expects color between side and position. Add empty string for color since sectors don't have a meaningful color value.
Summary
sidefield through sector events (captured/contested) to the extension via:EVENT:SECTOR:capturedFlagfrom:EVENT:SECTOR:routing — it has incompatible player-centric field semantics ([unitName, unitSide, flagSide]) vs sector-centric ([objectType, unitName, side, color, position]).capturedFlagnow falls through to:EVENT:GENERAL:.[""]) to allparamextractions so array values at unexpected indices don't leak through as wrong typescolorfield (index 3) from event message arrays to the extensionfnc_trackSectors.sqfto include empty color field in sector capture eventsSector event args sent to extension change from:
[frame, type, objectType, unitName, side, posX?, posY?, posZ?]to:
[frame, type, objectType, unitName, side, color, posX?, posY?, posZ?]Test plan
capturedevents include side string fromfnc_trackSectorscontestedevents pass empty side stringcapturedFlagroutes through:EVENT:GENERAL:with JSON-encoded datafnc_trackSectorsevents include empty color between side and position