Skip to content

Commit

Permalink
Fixed insignia selection and save system being broken (#1104)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBrostrom authored Dec 10, 2023
1 parent 74db9a0 commit 3161c89
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 23 deletions.
6 changes: 3 additions & 3 deletions cScripts/functions/gear/fn_gear_applyCosmetics.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ if (!isNil{GETVAR(_unit,EGVAR(Unit,TeamColor),nil)}) then {

// Apply squad insignia
if (EGVAR(Settings,allowInsigniaApplication)) then {
private _insignia = if (call EFUNC(player,loadInsignia) != "") then {
call EFUNC(player,loadInsignia);
private _insignia = if (call EFUNC(profile,loadInsignia) != "") then {
call EFUNC(profile,loadInsignia);
} else {
call EFUNC(unit,getSquadInsignia);
};
[{
params ["_unit", "_insignia"];
[_unit, _insignia] call EFUNC(unit,setInsignia);
[_unit, _insignia, false] call EFUNC(unit,setInsignia);
}, [_unit, _insignia], 2] call CBA_fnc_waitAndExecute;
};
2 changes: 1 addition & 1 deletion cScripts/functions/init/fn_init_aceArsenal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ GVAR(StagingArsenalOpen) = false;

// Save insignia
private _insigniaClass = [player] call BIS_fnc_getUnitInsignia;
[_insigniaClass] call cScripts_fnc_profile_saveInsignia;
[_insigniaClass] call EFUNC(profile,saveInsignia);

// Reset default loadouts
call FUNC(addDefaultArsenalLoadouts);
Expand Down
12 changes: 1 addition & 11 deletions cScripts/functions/players/fn_profile_loadInsignia.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,7 @@
*
* Public: No
*/

if (!GVAR(isPlayer)) exitWith {""};

// TODO: Legacy handler, remove later
if (!isNil{profileNamespace getVariable [QEGVAR(Cav,Insignia), nil];}) then {
private _legacy = profileNamespace getVariable [QEGVAR(Cav,Insignia), nil];
// Save New
profileNamespace setVariable [QEGVAR(Profile,Insignia), _legacy];
// Remove Legacy
profileNamespace setVariable [QEGVAR(Cav,Insignia), nil];
};
if (!isPlayer _unit) exitWith {};

private _insignia = GETPRVAR(EGVAR(Profile,Insignia), "");

Expand Down
7 changes: 1 addition & 6 deletions cScripts/functions/players/fn_profile_saveInsignia.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@

params [["_insignia", "", [""]]];

if (!GVAR(isPlayer)) exitWith {};

// TODO: Legacy handler, remove later
if (!isNil{ GETPRVAR(EGVAR(Cav,Insignia), nil); }) then {
SETPRVAR(EGVAR(Cav,Insignia), nil);
};
if (!isPlayer _unit) exitWith {};

SETPRVAR(EGVAR(Profile,Insignia), _insignia);

Expand Down
10 changes: 8 additions & 2 deletions cScripts/functions/players/fn_unit_setInsignia.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@

params [
["_unit", objNull, [objNull]],
["_insignia", "", [""]]
["_insignia", "", [""]],
["_save", true, [true]]

];

[_unit, _insignia] call BIS_fnc_setUnitInsignia;
if (GVAR(isPlayer)) then {[_insignia] call EFUNC(player,saveInsignia);};

if (!isPlayer _unit) exitWith {};
if (!_save) exitWith {};

[_insignia] call EFUNC(profile,saveInsignia);

0 comments on commit 3161c89

Please sign in to comment.