diff --git a/addons/explosives/XEH_postInit.sqf b/addons/explosives/XEH_postInit.sqf index 651f704a6a..e8f12ca6e3 100644 --- a/addons/explosives/XEH_postInit.sqf +++ b/addons/explosives/XEH_postInit.sqf @@ -36,16 +36,40 @@ GVAR(Setup) = objNull; GVAR(pfeh_running) = false; GVAR(CurrentSpeedDial) = 0; -// Properly angle preplaced bottom-attack SLAMs -{ - if (local _x) then { - switch (typeOf _x) do { - case ("ACE_SLAMDirectionalMine_Magnetic_Ammo"): { - [_x, getDir _x, 90] call FUNC(setPosition); - }; +// In case we are a JIP client, ask the server for orientation of any previously +// placed mine. +if (isServer) then { + ["clientRequestsOrientations", { + params ["_logic"]; + TRACE_1("clientRequestsOrientations received:",_logic); + // Filter the array before sending it + GVAR(explosivesOrientations) = GVAR(explosivesOrientations) select { + _x params ["_explosive"]; + (!isNull _explosive && {alive _explosive}) }; - }; -} forEach allMines; + TRACE_1("serverSendsOrientations sent:",GVAR(explosivesOrientations)); + ["serverSendsOrientations", _logic, [GVAR(explosivesOrientations)]] call EFUNC(common,targetEvent); + }] call EFUNC(common,addEventHandler); +} else { + ["serverSendsOrientations", { + params ["_explosivesOrientations"]; + TRACE_1("serverSendsOrientations received:",_explosivesOrientations); + { + _x params ["_explosive","_direction","_pitch"]; + TRACE_3("orientation set:",_explosive,_direction,_pitch); + [_explosive, _direction, _pitch] call FUNC(setPosition); + } forEach _explosivesOrientations; + private _group = group GVAR(localLogic); + deleteVehicle GVAR(localLogic); + GVAR(localLogic) = nil; + deleteGroup _group; + }] call EFUNC(common,addEventHandler); + + // Create a logic to get the client ID + GVAR(localLogic) = (createGroup sideLogic) createUnit ["Logic", [0,0,0], [], 0, "NONE"]; + TRACE_1("clientRequestsOrientations sent:",GVAR(localLogic)); + ["clientRequestsOrientations", [GVAR(localLogic)]] call EFUNC(common,serverEvent); +}; ["interactMenuOpened", { //Cancel placement if interact menu opened diff --git a/addons/explosives/XEH_preInit.sqf b/addons/explosives/XEH_preInit.sqf index 8ec4fa3817..16a9a4124b 100644 --- a/addons/explosives/XEH_preInit.sqf +++ b/addons/explosives/XEH_preInit.sqf @@ -19,4 +19,8 @@ ADDON = false; #include "XEH_PREP.hpp" +if (isServer) then { + GVAR(explosivesOrientations) = [] +}; + ADDON = true; diff --git a/addons/explosives/functions/fnc_setPosition.sqf b/addons/explosives/functions/fnc_setPosition.sqf index b19e63ff5a..430f926138 100644 --- a/addons/explosives/functions/fnc_setPosition.sqf +++ b/addons/explosives/functions/fnc_setPosition.sqf @@ -29,3 +29,15 @@ if (isNull (attachedTo _explosive)) then { //Attaching to a vehicle (dirAndUp based on vehicle) _explosive setVectorDirAndUp [[0,0,1],[(sin _direction),(cos _direction),0]]; }; + +if (isServer) then { + // Store the orientation to broadcast it later to JIP players + GVAR(explosivesOrientations) pushBack [_explosive, _direction, _pitch]; + + // This is a good time to filter the array and remove explosives that no longer exist + GVAR(explosivesOrientations) = GVAR(explosivesOrientations) select { + _x params ["_explosive"]; + (!isNull _explosive && {alive _explosive}) + }; + TRACE_1("setPosition",GVAR(explosivesOrientations)); +}; diff --git a/addons/markers/XEH_postInit.sqf b/addons/markers/XEH_postInit.sqf index f7bf35093c..7b5924d680 100644 --- a/addons/markers/XEH_postInit.sqf +++ b/addons/markers/XEH_postInit.sqf @@ -9,9 +9,8 @@ // request marker data for JIP if (isMultiplayer && {!isServer} && {hasInterface}) then { - private _logic = createGroup sideLogic createUnit ["Logic", [0,0,0], [], 0, "NONE"]; - - [QGVAR(sendMarkersJIP), [_logic]] call EFUNC(common,serverEvent); + GVAR(localLogic) = (createGroup sideLogic) createUnit ["Logic", [0,0,0], [], 0, "NONE"]; + [QGVAR(sendMarkersJIP), [GVAR(localLogic)]] call EFUNC(common,serverEvent); }; GVAR(mapDisplaysWithDrawEHs) = []; diff --git a/addons/markers/functions/fnc_sendMarkersJIP.sqf b/addons/markers/functions/fnc_sendMarkersJIP.sqf index 73a00519e3..5b1a779b27 100644 --- a/addons/markers/functions/fnc_sendMarkersJIP.sqf +++ b/addons/markers/functions/fnc_sendMarkersJIP.sqf @@ -21,5 +21,5 @@ TRACE_1("params",_logic); [ QGVAR(setMarkerJIP), [_logic], - [GETGVAR(allMapMarkers,[]), GETGVAR(allMapMarkersProperties,[]), _logic] + [GETGVAR(allMapMarkers,[]), GETGVAR(allMapMarkersProperties,[])] ] call EFUNC(common,targetEvent); diff --git a/addons/markers/functions/fnc_setMarkerJIP.sqf b/addons/markers/functions/fnc_setMarkerJIP.sqf index bd8832fb36..ccac7d2b7b 100644 --- a/addons/markers/functions/fnc_setMarkerJIP.sqf +++ b/addons/markers/functions/fnc_setMarkerJIP.sqf @@ -17,8 +17,8 @@ */ #include "script_component.hpp" -params ["_allMapMarkers", "_allMapMarkersProperties", "_logic"]; -TRACE_3("params",_allMapMarkers,_allMapMarkersProperties,_logic); +params ["_allMapMarkers", "_allMapMarkersProperties"]; +TRACE_3("params",_allMapMarkers,_allMapMarkersProperties); { private _index = _allMapMarkers find _x; @@ -51,4 +51,7 @@ TRACE_3("params",_allMapMarkers,_allMapMarkersProperties,_logic); false } count allMapMarkers; -deleteVehicle _logic; +private _group = group GVAR(localLogic); +deleteVehicle GVAR(localLogic); +GVAR(localLogic) = nil; +deleteGroup _group;