Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions addons/aar/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ class CfgFunctions
class addUnitEventHandlers {};
class addVehicleEventHandlers {};
class init {};
class reportMarkerPositions {};
class reportUnitPositions {};
class reportVehiclePositions {};
class sendEvent {};
class sendJson {};
class serializeJson {};
class serializeMarker {};
class serializeMission {};
class serializePlayer {};
class serializePosition {};
Expand Down
4 changes: 4 additions & 0 deletions addons/aar/functions/fn_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ addMissionEventHandler ["Ended", { (_this) call anrop_aar_fnc_missionEnded }];

// Periodically send unit positions
if (anrop_aar_position_reporting > 0) then {
[] spawn {
anrop_aar_position_reporting call anrop_aar_fnc_reportMarkerPositions;
};

[] spawn {
anrop_aar_position_reporting call anrop_aar_fnc_reportUnitPositions;
};
Expand Down
42 changes: 42 additions & 0 deletions src/addon/functions/fn_reportMarkerPositions.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
private _markerHash = [[], ""] call CBA_fnc_hashCreate;
private _currentMarkers = [];

private _reportMarker = {
params ["_event", "_marker"];

private _serializedMarker = _marker call anrop_aar_fnc_serializeMarker;

private _obj = ["object",
["type", ["string", _event]],
["marker", _serializedMarker]
];

private _cached = [_markerHash, _marker] call CBA_fnc_hashGet;

private _serialized = _obj call anrop_aar_fnc_serializeJson;
if (_serialized != _cached) then {
[_markerHash, _marker, _serialized] call CBA_fnc_hashSet;
_serialized call anrop_aar_fnc_sendJson;
};
};

while { true } do {
private _allMarkers = allMapMarkers;
private _newMarkers = _allMarkers - _currentMarkers;
private _updatedMarkers = _allMarkers - _newMarkers;
private _removedMarkers = _currentMarkers - _allMarkers;

{
["MarkerCreated", _x] call _reportMarker;
} forEach _newMarkers;

{
["MarkerPosition", _x] call _reportMarker;
} forEach _updatedMarkers;

{
["MarkerDeleted", _x] call _reportMarker;
} forEach _removedMarkers;

sleep _this;
};
26 changes: 26 additions & 0 deletions src/addon/functions/fn_serializeMarker.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
params ["_marker"];

private _id = _marker;
private _alpha = markerAlpha _marker;
private _brush = markerBrush _marker;
private _color = markerColor _marker;
private _position = ([markerPos _marker, markerDir _marker] call anrop_aar_fnc_serializePosition);
private _shape = markerShape _marker;
private _size = markerSize _marker;
private _text = markerText _marker;
private _type = markerType _marker;

["object",
["id", ["string", _id]],
["alpha", ["number", _alpha]],
["brush", ["string", _brush]],
["color", ["string", _color]],
["position", _position],
["shape", ["string", _shape]],
["size", ["object",
["width", ["number", _size select 0]],
["height", ["number", _size select 1]]
]],
["text", ["string", _text]],
["type", ["string", _type]]
];