Skip to content

Commit b5189f7

Browse files
authored
fix: sector event routing, type guards, and color field (#99)
* fix: pass side field through sector events to extension - 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: * docs: design for separating capturedFlag from :EVENT:SECTOR: * fix: remove capturedFlag from :EVENT:SECTOR: routing 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. * fix: simplify side extraction in sector event routing param [2, ""] already guarantees a string default, so the isEqualType check was redundant. * fix: add type guard for side extraction in sector events 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. * fix: update sector event comment and add type guards to all params 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. * feat: capture color field from sector events 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?]. * fix: restore sector example in comment, not flag capture * fix: add empty color field to sector capture events 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. * chore: remove outdated design doc
1 parent 2bc1b7f commit b5189f7

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

addons/recorder/fnc_handleCustomEvent.sqf

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
66
Description:
77
Routes custom events to the extension with typed positional args based on
8-
event type. Sector events (captured/contested/capturedFlag) use :EVENT:SECTOR:
9-
with structured fields; endMission uses :EVENT:ENDMISSION: with side and
10-
message; all other events use :EVENT:GENERAL: with JSON-encoded extraData.
8+
event type. Sector events (captured/contested) use :EVENT:SECTOR: with
9+
structured fields; endMission uses :EVENT:ENDMISSION: with side and
10+
message; all other events (including capturedFlag) use :EVENT:GENERAL:
11+
with JSON-encoded extraData.
1112
1213
Applied during initialization of OCAP in <OCAP_recorder_fnc_init>.
1314
@@ -22,7 +23,7 @@
2223
Examples:
2324
(start code)
2425
// Sector captured with structured data (sent by fnc_trackSectors)
25-
[QGVARMAIN(customEvent), ["captured", ["sector", "Sector Alpha", [100, 200, 0]]]] call CBA_fnc_localEvent;
26+
[QGVARMAIN(customEvent), ["captured", ["sector", "Sector Alpha", str west, "", getPos _sector]]] call CBA_fnc_localEvent;
2627
2728
// End mission with side and message
2829
[QGVARMAIN(customEvent), ["endMission", [str west, "BLUFOR controlled all sectors!"]]] call CBA_fnc_localEvent;
@@ -49,14 +50,15 @@ params [
4950

5051
switch (_eventName) do {
5152
case "captured";
52-
case "contested";
53-
case "capturedFlag": {
53+
case "contested": {
5454
private _args = [GVAR(captureFrameNo), _eventName];
5555

5656
if (_eventMessage isEqualType []) then {
57-
// Array format: ["objectType", "unitName", ...maybePosition...]
58-
_args pushBack (_eventMessage param [0, ""]);
59-
_args pushBack (_eventMessage param [1, ""]);
57+
// Array format: [objectType, unitName, side, color, [posX, posY, posZ]]
58+
_args pushBack (_eventMessage param [0, "", [""]]);
59+
_args pushBack (_eventMessage param [1, "", [""]]);
60+
_args pushBack (_eventMessage param [2, "", [""]]);
61+
_args pushBack (_eventMessage param [3, "", [""]]);
6062
{
6163
if (_x isEqualType [] && {count _x >= 2} && {(_x # 0) isEqualType 0}) exitWith {
6264
_args append _x;

addons/recorder/fnc_trackSectors.sqf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ if (_this isEqualType [] && {count _this > 0}) exitWith {
4141

4242
private _pos = getPosATL _sector;
4343
if (_newOwner isEqualTo sideUnknown) then {
44-
[QGVARMAIN(customEvent), ["contested", ["sector", _name, _pos]]] call CBA_fnc_localEvent;
44+
[QGVARMAIN(customEvent), ["contested", ["sector", _name, "", "", _pos]]] call CBA_fnc_localEvent;
4545
} else {
46-
[QGVARMAIN(customEvent), ["captured", ["sector", _name, _pos]]] call CBA_fnc_localEvent;
46+
[QGVARMAIN(customEvent), ["captured", ["sector", _name, str _newOwner, "", _pos]]] call CBA_fnc_localEvent;
4747
};
4848
}] call BIS_fnc_addScriptedEventHandler;
4949
};

0 commit comments

Comments
 (0)