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

AssignGear - Stop assuming 'r' exists as a default loadout #11

Draft
wants to merge 6 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions addons/assigngear/functions/fnc_AIGearEH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ if !(
isClass (missionConfigFile >> "CfgLoadouts" >> _loadout >> _role) ||
isClass (configFile >> "CfgLoadouts" >> _loadout >> _role)
) then {
ERROR_2("AIGear: ""%1"" not present in ""%2"", reverting to default ""r""",_role,_loadout);
_role = "r";
ERROR_2("AIGear: ""%1"" not present in ""%2"", attempting to revert to ""baseMan"" loadout.",_role,_loadout);
_role = "baseMan";
};

[_unit,_loadout,_role] call FUNC(assignGear);
Expand Down
8 changes: 5 additions & 3 deletions addons/assigngear/functions/fnc_assignGear.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ if !(local _unit) exitWith {};
_this params [
"",
["_faction", _unit getVariable [QGVAR(faction), toLower faction _unit]],
["_role", _unit getVariable [QGVAR(role), "r"]]
["_role", _unit getVariable [QGVAR(role), ""]]
];

if (_role == "") exitWith {TRACE_2("No role assigned",_unit,_faction)};

// Sometimes in editor this function is run before preInit, this should make sure that the namespace exists
private _namespace = missionNamespace getVariable QGVAR(namespace);
ISNILS(_namespace,[FUNC(initNamespace)] call CBA_fnc_directCall);
Expand Down Expand Up @@ -148,8 +150,8 @@ _unit setUnitLoadout (configFile >> 'EmptyLoadout');
};
} forEach _loadoutArray;

_unit setVariable [QGVAR(faction), _faction,true];
_unit setVariable [QGVAR(role), _role,true];
_unit setVariable [QGVAR(faction), _faction, true];
_unit setVariable [QGVAR(role), _role, true];

LOG_3("Assigned loadout to unit",_unit,_faction,_loadout);

Expand Down
2 changes: 1 addition & 1 deletion addons/assigngear/functions/fnc_gui_gearSelector_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
disableSerialization;
params ["_display"];

private _playerRole = CURUNIT getVariable [QGVAR(role), "r"];
private _playerRole = CURUNIT getVariable [QGVAR(role), "baseman"];
private _playerFaction = CURUNIT getVariable [QGVAR(faction), faction CURUNIT];

if !(isClass (missionConfigFile >> "CfgLoadouts" >> _playerFaction) || isClass (configFile >> "CfgLoadouts" >> _playerFaction)) then {
Expand Down
3 changes: 2 additions & 1 deletion addons/assigngear/functions/fnc_loadAssignGear.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Description:
* Loads assigngear from config
*/

#define CFGROLE (_cfg >> "CfgLoadouts" >> _faction >> _role)
#define CFGPARSE (configFile >> "CfgLoadoutsParser")

Expand All @@ -39,7 +40,7 @@ private _loadoutArray = [];

// Create an array where each index is tied to a specific type of item
#define CASE(_type,_index) case _type: {_loadoutArray set [_index, _x call BIS_fnc_getCfgData]}
; // Travis doesn't like defines without ;

{
switch (toLower configName _x) do {
// Equipment/appearance
Expand Down
4 changes: 2 additions & 2 deletions addons/assigngear/functions/fnc_testGear.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private _fnc_checkExists_insignia = {
};

private _fncTestUnit = {
params ["_faction",["_role","r"]];
params ["_faction",["_role","baseman"]];

private _cfg = missionConfigFile >> "cfgLoadouts" >> _faction >> _role;
if (!isClass (_cfg)) then {
Expand Down Expand Up @@ -237,7 +237,7 @@ private _loadoutFreespace = [];
(_unit get3DENAttribute 'TMF_assignGear_enabled') params [["_enabled",false]];

if (_enabled) then {
(_unit get3DENAttribute 'TMF_assignGear_role') params [["_role","r"]];
(_unit get3DENAttribute 'TMF_assignGear_role') params [["_role","baseman"]];
(_unit get3DENAttribute 'TMF_assignGear_faction') params [["_faction",toLower(faction _unit)]];

private _index = _loadoutsTested pushBackUnique [_faction, _role];
Expand Down