From 4dd2568fe0011aac3bf91856c207a0995ed2d4f6 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sat, 11 Nov 2023 01:13:53 +0100 Subject: [PATCH] Cargo - Remove cargo objects from zeus editable objects (#9400) Remove cargo from zeus editable objects --- addons/cargo/functions/fnc_loadItem.sqf | 11 +++++++++++ addons/cargo/functions/fnc_unloadItem.sqf | 9 +++++++++ addons/zeus/XEH_postInit.sqf | 20 ++++++++++++++++---- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/addons/cargo/functions/fnc_loadItem.sqf b/addons/cargo/functions/fnc_loadItem.sqf index ae2d845d38..587543f776 100644 --- a/addons/cargo/functions/fnc_loadItem.sqf +++ b/addons/cargo/functions/fnc_loadItem.sqf @@ -38,6 +38,17 @@ if (_item isEqualType objNull) then { _item attachTo [_vehicle,[0,0,-100]]; [QEGVAR(common,hideObjectGlobal), [_item, true]] call CBA_fnc_serverEvent; + if (["ace_zeus"] call EFUNC(common,isModLoaded)) then { + private _objectCurators = objectCurators _item; + + // Save which curators had this object as editable + _item setVariable [QGVAR(objectCurators), _objectCurators, true]; + + if (_objectCurators isEqualTo []) exitWith {}; + + [QEGVAR(zeus,removeObjects), [[_item], _objectCurators]] call CBA_fnc_serverEvent; + }; + // Some objects below water will take damage over time and eventualy become "water logged" and unfixable (because of negative z attach) [_item, "blockDamage", "ACE_cargo", true] call EFUNC(common,statusEffect_set); }; diff --git a/addons/cargo/functions/fnc_unloadItem.sqf b/addons/cargo/functions/fnc_unloadItem.sqf index 83b0b2ff0e..93fdfaa099 100644 --- a/addons/cargo/functions/fnc_unloadItem.sqf +++ b/addons/cargo/functions/fnc_unloadItem.sqf @@ -53,6 +53,15 @@ if (_object isEqualType objNull) then { // hideObjectGlobal must be executed before setPos to ensure light objects are rendered correctly // do both on server to ensure they are executed in the correct order [QGVAR(serverUnload), [_object, _emptyPosAGL]] call CBA_fnc_serverEvent; + + if (["ace_zeus"] call EFUNC(common,isModLoaded)) then { + // Get which curators had this object as editable + private _objectCurators = _object getVariable [QGVAR(objectCurators), []]; + + if (_objectCurators isEqualTo []) exitWith {}; + + [QEGVAR(zeus,addObjects), [[_object], _objectCurators]] call CBA_fnc_serverEvent; + }; } else { _object = createVehicle [_item, _emptyPosAGL, [], 0, "NONE"]; _object setPosASL (AGLtoASL _emptyPosAGL); diff --git a/addons/zeus/XEH_postInit.sqf b/addons/zeus/XEH_postInit.sqf index c1dba7e0e4..b4d1302ab5 100644 --- a/addons/zeus/XEH_postInit.sqf +++ b/addons/zeus/XEH_postInit.sqf @@ -19,20 +19,32 @@ if (isServer) then { [QGVAR(addObjects), { params ["_objects", ["_curator", objNull]]; - if (!isNull _curator) exitWith {_curator addCuratorEditableObjects [_objects, true]}; + // If valid object + if (_curator isEqualType objNull && {!isNull _curator}) exitWith {_curator addCuratorEditableObjects [_objects, true]}; + + // If invalid object (= objNull) or other + if !(_curator isEqualType []) then { + _curator = allCurators; + }; { _x addCuratorEditableObjects [_objects, true]; - } forEach allCurators; + } forEach _curator; }] call CBA_fnc_addEventHandler; [QGVAR(removeObjects), { params ["_objects", ["_curator", objNull]]; - if (!isNull _curator) exitWith {_curator removeCuratorEditableObjects [_objects, true]}; + // If valid object + if (_curator isEqualType objNull && {!isNull _curator}) exitWith {_curator removeCuratorEditableObjects [_objects, true]}; + + // If invalid object (= objNull) or other + if !(_curator isEqualType []) then { + _curator = allCurators; + }; { _x removeCuratorEditableObjects [_objects, true]; - } forEach allCurators; + } forEach _curator; }] call CBA_fnc_addEventHandler; [QGVAR(createZeus), {