From 085ebd89dbae90a31b9b314f6aed84500a873512 Mon Sep 17 00:00:00 2001 From: mharis001 <34453221+mharis001@users.noreply.github.com> Date: Thu, 26 Dec 2019 20:42:48 -0500 Subject: [PATCH] Pass function by reference to Draw3D EH (#7333) --- addons/ai/CfgEventHandlers.hpp | 2 +- addons/ai/XEH_PREP.hpp | 3 +- .../fnc_drawCuratorGarrisonPathing.sqf | 80 ++++++++++--------- .../ai/functions/fnc_initDisplayCurator.sqf | 18 +++++ 4 files changed, 62 insertions(+), 41 deletions(-) create mode 100644 addons/ai/functions/fnc_initDisplayCurator.sqf diff --git a/addons/ai/CfgEventHandlers.hpp b/addons/ai/CfgEventHandlers.hpp index 9e715077f3..45d472cd21 100644 --- a/addons/ai/CfgEventHandlers.hpp +++ b/addons/ai/CfgEventHandlers.hpp @@ -19,6 +19,6 @@ class Extended_PostInit_EventHandlers { class Extended_DisplayLoad_EventHandlers { class RscDisplayCurator { - ADDON = QUOTE(call FUNC(drawCuratorGarrisonPathing)); + ADDON = QUOTE(call FUNC(initDisplayCurator)); }; }; diff --git a/addons/ai/XEH_PREP.hpp b/addons/ai/XEH_PREP.hpp index 9596af3286..97f2b64e9d 100644 --- a/addons/ai/XEH_PREP.hpp +++ b/addons/ai/XEH_PREP.hpp @@ -1,4 +1,5 @@ PREP(drawCuratorGarrisonPathing); PREP(garrison); -PREP(unGarrison); PREP(garrisonMove); +PREP(initDisplayCurator); +PREP(unGarrison); diff --git a/addons/ai/functions/fnc_drawCuratorGarrisonPathing.sqf b/addons/ai/functions/fnc_drawCuratorGarrisonPathing.sqf index de9a5b4dc7..ca0d8ccfa7 100644 --- a/addons/ai/functions/fnc_drawCuratorGarrisonPathing.sqf +++ b/addons/ai/functions/fnc_drawCuratorGarrisonPathing.sqf @@ -1,54 +1,56 @@ #include "script_component.hpp" /* * Author: alganthe - * Add draw3D eh to the curator interface. + * Draws AI garrison pathing while the Zeus display is open. * * Arguments: * None * - * Return value: + * Return Value: * None * + * Example: + * [] call ace_ai_fnc_drawCuratorGarrisonPathing + * * Public: No -*/ + */ -addMissionEventHandler ["Draw3D", { - if (findDisplay 312 isEqualTo displayNull) exitWith { - removeMissionEventHandler ["Draw3D", _thisEventHandler]; - }; +if (isNull findDisplay 312) exitWith { + removeMissionEventHandler ["Draw3D", _thisEventHandler]; +}; - private _unitMoveList = missionNameSpace getVariable [QGVAR(garrison_unitMoveList), []]; - { - _x params ["_unit", "_pos"]; +private _unitMoveList = missionNameSpace getVariable [QGVAR(garrison_unitMoveList), []]; - switch (true) do { - case (surfaceIsWater (getPos _unit) && {surfaceIsWater _pos}) : { - for "_i" from 0 to 3 do { - drawLine3D [_unit modelToWorldVisualWorld [0,0,1], (AGLtoASL _pos), [1,0,0,1]]; - }; - drawIcon3D ["\a3\ui_f\data\map\groupicons\waypoint.paa", [1,0,0,1], (AGLtoASL _pos), 0.75, 0.75, 0.75]; - }; - - case (!surfaceIsWater (getPos _unit) && {!surfaceIsWater _pos}) : { - for "_i" from 0 to 3 do { - drawLine3D [_unit modelToWorldVisual [0,0,1], _pos, [1,0,0,1]]; - }; - drawIcon3D ["\a3\ui_f\data\map\groupicons\waypoint.paa", [1,0,0,1], _pos, 0.75, 0.75, 0.75]; - }; - - case (!surfaceIsWater (getPos _unit) && {surfaceIsWater _pos}) : { - for "_i" from 0 to 3 do { - drawLine3D [_unit modelToWorldVisual [0,0,1], (AGLToASL _pos), [1,0,0,1]]; - }; - drawIcon3D ["\a3\ui_f\data\map\groupicons\waypoint.paa", [1,0,0,1], (AGLtoASL _pos), 0.75, 0.75, 0.75]; - }; - - case (surfaceIsWater (getPos _unit) && {!surfaceIsWater _pos}) : { - for "_i" from 0 to 3 do { - drawLine3D [_unit modelToWorldVisualWorld [0,0,1], _pos, [1,0,0,1]]; - }; - drawIcon3D ["\a3\ui_f\data\map\groupicons\waypoint.paa", [1,0,0,1], _pos, 0.75, 0.75, 0.75]; +{ + _x params ["_unit", "_pos"]; + + switch (true) do { + case (surfaceIsWater (getPos _unit) && {surfaceIsWater _pos}) : { + for "_i" from 0 to 3 do { + drawLine3D [_unit modelToWorldVisualWorld [0,0,1], (AGLtoASL _pos), [1,0,0,1]]; }; + drawIcon3D ["\a3\ui_f\data\map\groupicons\waypoint.paa", [1,0,0,1], (AGLtoASL _pos), 0.75, 0.75, 0.75]; }; - } forEach _unitMoveList; -}]; + + case (!surfaceIsWater (getPos _unit) && {!surfaceIsWater _pos}) : { + for "_i" from 0 to 3 do { + drawLine3D [_unit modelToWorldVisual [0,0,1], _pos, [1,0,0,1]]; + }; + drawIcon3D ["\a3\ui_f\data\map\groupicons\waypoint.paa", [1,0,0,1], _pos, 0.75, 0.75, 0.75]; + }; + + case (!surfaceIsWater (getPos _unit) && {surfaceIsWater _pos}) : { + for "_i" from 0 to 3 do { + drawLine3D [_unit modelToWorldVisual [0,0,1], (AGLToASL _pos), [1,0,0,1]]; + }; + drawIcon3D ["\a3\ui_f\data\map\groupicons\waypoint.paa", [1,0,0,1], (AGLtoASL _pos), 0.75, 0.75, 0.75]; + }; + + case (surfaceIsWater (getPos _unit) && {!surfaceIsWater _pos}) : { + for "_i" from 0 to 3 do { + drawLine3D [_unit modelToWorldVisualWorld [0,0,1], _pos, [1,0,0,1]]; + }; + drawIcon3D ["\a3\ui_f\data\map\groupicons\waypoint.paa", [1,0,0,1], _pos, 0.75, 0.75, 0.75]; + }; + }; +} forEach _unitMoveList; diff --git a/addons/ai/functions/fnc_initDisplayCurator.sqf b/addons/ai/functions/fnc_initDisplayCurator.sqf new file mode 100644 index 0000000000..1ab54086b4 --- /dev/null +++ b/addons/ai/functions/fnc_initDisplayCurator.sqf @@ -0,0 +1,18 @@ +#include "script_component.hpp" +/* + * Author: mharis001 + * Initializes the Zeus display. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_ai_fnc_initDisplayCurator + * + * Public: No + */ + +addMissionEventHandler ["Draw3D", {call FUNC(drawCuratorGarrisonPathing)}];