Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common - Filter for ACRE radio IDs when serializing objects #640

Merged
merged 15 commits into from
Feb 9, 2022
Merged
1 change: 1 addition & 0 deletions addons/common/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ PREP(getPylonTurret);
PREP(getSelectedUnits);
PREP(getSelectedVehicles);
PREP(getSideIcon);
PREP(getUnitLoadout);
PREP(getVehicleAmmo);
PREP(getVehicleIcon);
PREP(getWeaponReloadTime);
Expand Down
3 changes: 2 additions & 1 deletion addons/common/functions/fnc_exportMissionSQF.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ private _fnc_processInventory = {
_outputObjects pushBack ["['%1', 'onEachFrame', {", _nextFrameHandle];
_outputObjects pushBack " params [""_unit""];";
if !(_object call FUNC(hasDefaultInventory)) then {
_outputObjects pushBack [" _unit setUnitLoadout %1;", getUnitLoadout _object];
private _loadout = [_object] call FUNC(getUnitLoadout);
_outputObjects pushBack [" _unit setUnitLoadout %1;", _loadout];
};
_outputObjects pushBack " _unit call BIN_fnc_CBRNHoseInit;";
_outputObjects pushBack [" ['%1', 'onEachFrame'] call BIS_fnc_removeStackedEventHandler;", _nextFrameHandle];
Expand Down
27 changes: 27 additions & 0 deletions addons/common/functions/fnc_getUnitLoadout.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "script_component.hpp"
/*
* Author: mjc4wilton
* Returns the given unit's loadout. Handles filtering items with unique radio IDs.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* Unit Loadout Array <ARRAY>
*
* Example:
* [_unit] call zen_common_fnc_getUnitLoadout
*
* Public: No
*/

params ["_unit"];

private _loadout = getUnitLoadout _unit;

// ACRE radios
if (isClass (configFile >> "CfgPatches" >> "acre_main")) then {
_loadout = [_loadout] call acre_api_fnc_filterUnitLoadout;
};

_loadout
2 changes: 1 addition & 1 deletion addons/common/functions/fnc_hasDefaultInventory.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ params ["_object"];

// Compare current loadout to config defined loadout if an infantry unit is given
if (_object isKindOf "CAManBase") exitWith {
private _current = getUnitLoadout _object;
private _current = [_object] call FUNC(getUnitLoadout);
private _default = getUnitLoadout typeOf _object;

// Always match facewear because it is influenced by identity, not config inventory
Expand Down
2 changes: 1 addition & 1 deletion addons/common/functions/fnc_serializeObjects.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private _fnc_serializeUnit = {
private _skill = skill _unit;
private _stance = unitPos _unit;

private _loadout = getUnitLoadout _unit;
private _loadout = [_unit] call FUNC(getUnitLoadout);
private _identity = [name _unit, face _unit, speaker _unit, pitch _unit, nameSound _unit, _unit call BIS_fnc_getUnitInsignia];
private _flagTexture = getForcedFlagTexture _unit;

Expand Down
2 changes: 1 addition & 1 deletion addons/context_actions/CfgContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class EGVAR(context_menu,actions) {
};
class Copy {
displayName = "$STR_3DEN_Display3DEN_MenuBar_EntityCopy_text";
statement = QUOTE(GVAR(loadout) = getUnitLoadout _hoveredEntity);
statement = QUOTE(GVAR(loadout) = _hoveredEntity call EFUNC(common,getUnitLoadout));
icon = QPATHTOF(ui\copy_ca.paa);
};
class Paste {
Expand Down