<commit_before>#include "hull_macros.h"

#define GEAR_TEMPLATE_CONTAINER_CLASS       "HullGearTemplates"
#define GEAR_TEMPLATE_BASE_CLASS            "Rifleman"



hull_gear_fnc_assign = {
    FUN_ARGS_3(_unit,_manualClass,_manualTemplate);

    if (!([_unit, _manualClass, _manualTemplate] call hull_gear_fnc_validateTemplate)) then {
        private ["_template", "_class"];
        _template = [faction _unit, _manualTemplate] call hull_gear_fnc_getTemplate;
        _class = [_template, _manualClass] call hull_gear_fnc_getClass;
        [_unit, _class, _template] call hull_gear_fnc_assignInit;
        [_unit, _class, _template] call hull_gear_fnc_assignTemplate;
    };
};

hull_gear_fnc_assignInit = {
    FUN_ARGS_3(_unit,_class,_template);

    _unit setVariable ["hull_gear_class", _class, true];
    _unit setVariable ["hull_gear_template", _template, true];
    removeAllWeapons _unit;
    removeBackpack _unit;
    _unit setVariable ["ace_sys_wounds_no_medical_gear", true, false];
};

hull_gear_fnc_getTemplate = {
    FUN_ARGS_2(_faction,_manualTemplate);

    private "_template";
    _template = _manualTemplate;
    if (isNil {_template} || {!isClass (HULL_CONFIGFILE >> _manualTemplate)}) then {
        _template = [_faction] call hull_gear_fnc_getTemplateByFaction;
    };

    _template;
};

hull_gear_fnc_getClass = {
    FUN_ARGS_2(_template,_manualClass);

    if (!isClass (HULL_CONFIGFILE >> _template >> _manualClass)) then {
        GEAR_TEMPLATE_BASE_CLASS;
    } else {
        _manualClass;
    };
};

hull_gear_fnc_getTemplateByFaction = {
    FUN_ARGS_1(_faction);

    private ["_factions", "_template"];
    _factions = getArray (HULL_CONFIGFILE >> "Hull_FactionMapping" >> "factions");
    {
        if (toLower (_x select 0) == toLower _faction) exitWith {
            _template = _x select 1;
        };
    } foreach _factions;

    _template;
};

hull_gear_fnc_assignTemplate = {
    FUN_ARGS_3(_unit,_class,_template);

    private "_config";
    _config = HULL_CONFIGFILE >> _template >> _class;
    [_unit, getText (_config >> "ruck")] call hull_gear_fnc_assignRuck;
    [_unit, getText (_config >> "goggles")] call hull_gear_fnc_assignGoggles;
    [_unit, getText (_config >> "vest")] call hull_gear_fnc_assignVest;
    [_unit, getText (_config >> "uniform")] call hull_gear_fnc_assignUniform;
    [_unit, getText (_config >> "helmet")] call hull_gear_fnc_assignHelmet;
    [_unit, getArray (_config >> "magazines")] call hull_gear_fnc_assignMagazines;
    [_unit, getArray (_config >> "weapons")] call hull_gear_fnc_assignWeapons;
    [_unit, getArray (_config >> "primaryAttachments")] call hull_gear_fnc_assignPrimaryAttachments;
    [_unit, getArray (_config >> "secondaryAttachments")] call hull_gear_fnc_assignSecondaryAttachments;
    [_unit, getArray (_config >> "ruckWeapons")] call hull_gear_fnc_assignRuckWeapons;
    [_unit, getArray (_config >> "ruckMagazines")] call hull_gear_fnc_assignRuckMagazines;
    [_unit, getArray (_config >> "vestMagazines")] call hull_gear_fnc_assignVestMagazines;
    [_unit, getArray (_config >> "items")] call hull_gear_fnc_assignNonRadioItems;
    [_unit, _class, _template] call compile getText (_config >> "code");
    _unit selectWeapon primaryWeapon _unit;
};

hull_gear_fnc_assignHelmet = {
    FUN_ARGS_2(_unit,_helmet);

    _unit addHeadgear _helmet;
};

hull_gear_fnc_assignUniform = {
    FUN_ARGS_2(_unit,_uniform);

    _unit addUniform  _uniform;
};

hull_gear_fnc_assignVest = {
    FUN_ARGS_2(_unit,_vest);

    _unit addVest _vest;
};

hull_gear_fnc_assignGoggles = {
    FUN_ARGS_2(_unit,_goggles);

    _unit addGoggles _goggles;
};

hull_gear_fnc_assignRuck = {
    FUN_ARGS_2(_unit,_ruck);

    if(_ruck != "") then {
        _unit addBackpack _ruck;
        [_unit, _ruck] call ACE_fnc_PutWeaponOnBack;
    };
};

hull_gear_fnc_assignMagazines = {
    FUN_ARGS_2(_unit,_magazines);

    {
        for "_i" from 1 to (_x select 1) do {
            _unit addMagazine (_x select 0);
        };
    } foreach _magazines;
};

hull_gear_fnc_assignWeapons = {
    FUN_ARGS_2(_unit,_weapons);

    {
        _unit addWeapon _x;
    } foreach _weapons;
};

hull_gear_fnc_assignPrimaryAttachments = {
    FUN_ARGS_2(_unit,_primAttachments);

    {
        _unit addPrimaryWeaponItem _x
    } foreach _primAttachments;
};

hull_gear_fnc_assignSecondaryAttachments = {<commit_msg>removed ace call for backpacks + changes for code style compliance.<commit_after>#include "hull_macros.h"

#define GEAR_TEMPLATE_CONTAINER_CLASS       "HullGearTemplates"
#define GEAR_TEMPLATE_BASE_CLASS            "Rifleman"



hull_gear_fnc_assign = {
    FUN_ARGS_3(_unit,_manualClass,_manualTemplate);

    if (!([_unit, _manualClass, _manualTemplate] call hull_gear_fnc_validateTemplate)) then {
        private ["_template", "_class"];
        _template = [faction _unit, _manualTemplate] call hull_gear_fnc_getTemplate;
        _class = [_template, _manualClass] call hull_gear_fnc_getClass;
        [_unit, _class, _template] call hull_gear_fnc_assignInit;
        [_unit, _class, _template] call hull_gear_fnc_assignTemplate;
    };
};

hull_gear_fnc_assignInit = {
    FUN_ARGS_3(_unit,_class,_template);

    _unit setVariable ["hull_gear_class", _class, true];
    _unit setVariable ["hull_gear_template", _template, true];
    removeAllWeapons _unit;
    removeBackpack _unit;
    _unit setVariable ["ace_sys_wounds_no_medical_gear", true, false];
};

hull_gear_fnc_getTemplate = {
    FUN_ARGS_2(_faction,_manualTemplate);

    private "_template";
    _template = _manualTemplate;
    if (isNil {_template} || {!isClass (HULL_CONFIGFILE >> _manualTemplate)}) then {
        _template = [_faction] call hull_gear_fnc_getTemplateByFaction;
    };

    _template;
};

hull_gear_fnc_getClass = {
    FUN_ARGS_2(_template,_manualClass);

    if (!isClass (HULL_CONFIGFILE >> _template >> _manualClass)) then {
        GEAR_TEMPLATE_BASE_CLASS;
    } else {
        _manualClass;
    };
};

hull_gear_fnc_getTemplateByFaction = {
    FUN_ARGS_1(_faction);

    private ["_factions", "_template"];
    _factions = getArray (HULL_CONFIGFILE >> "Hull_FactionMapping" >> "factions");
    {
        if (toLower (_x select 0) == toLower _faction) exitWith {
            _template = _x select 1;
        };
    } foreach _factions;

    _template;
};

hull_gear_fnc_assignTemplate = {
    FUN_ARGS_3(_unit,_class,_template);

    private "_config";
    _config = HULL_CONFIGFILE >> _template >> _class;
    [_unit, getText (_config >> "ruck")] call hull_gear_fnc_assignRuck;
    [_unit, getText (_config >> "goggles")] call hull_gear_fnc_assignGoggles;
    [_unit, getText (_config >> "vest")] call hull_gear_fnc_assignVest;
    [_unit, getText (_config >> "uniform")] call hull_gear_fnc_assignUniform;
    [_unit, getText (_config >> "helmet")] call hull_gear_fnc_assignHelmet;
    [_unit, getArray (_config >> "magazines")] call hull_gear_fnc_assignMagazines;
    [_unit, getArray (_config >> "weapons")] call hull_gear_fnc_assignWeapons;
    [_unit, getArray (_config >> "primaryAttachments")] call hull_gear_fnc_assignPrimaryAttachments;
    [_unit, getArray (_config >> "secondaryAttachments")] call hull_gear_fnc_assignSecondaryAttachments;
    [_unit, getArray (_config >> "ruckWeapons")] call hull_gear_fnc_assignRuckWeapons;
    [_unit, getArray (_config >> "ruckMagazines")] call hull_gear_fnc_assignRuckMagazines;
    [_unit, getArray (_config >> "vestMagazines")] call hull_gear_fnc_assignVestMagazines;
    [_unit, getArray (_config >> "items")] call hull_gear_fnc_assignNonRadioItems;
    [_unit, _class, _template] call compile getText (_config >> "code");
    _unit selectWeapon primaryWeapon _unit;
};

hull_gear_fnc_assignHelmet = {
    FUN_ARGS_2(_unit,_helmet);

    _unit addHeadgear _helmet;
};

hull_gear_fnc_assignUniform = {
    FUN_ARGS_2(_unit,_uniform);

    _unit addUniform  _uniform;
};

hull_gear_fnc_assignVest = {
    FUN_ARGS_2(_unit,_vest);

    _unit addVest _vest;
};

hull_gear_fnc_assignGoggles = {
    FUN_ARGS_2(_unit,_goggles);

    _unit addGoggles _goggles;
};

hull_gear_fnc_assignRuck = {
    FUN_ARGS_2(_unit,_ruck);

    if (_ruck != "") then {
        _unit addBackpack _ruck;
    };
};

hull_gear_fnc_assignMagazines = {
    FUN_ARGS_2(_unit,_magazines);

    {
        for "_i" from 1 to (_x select 1) do {
            _unit addMagazine (_x select 0);
        };
    } foreach _magazines;
};

hull_gear_fnc_assignWeapons = {
    FUN_ARGS_2(_unit,_weapons);

    {
        _unit addWeapon _x;
    } foreach _weapons;
};

hull_gear_fnc_assignPrimaryAttachments = {
    FUN_ARGS_2(_unit,_primAttachments);

    {
        _unit addPrimaryWeaponItem _x
    } foreach _primAttachments;
};

hull_gear_fnc_assignSecondaryAttachments = {
{'fraction_non_alphanumeric': 0.10431408354257019, 'fraction_numerical': 0.004336909381419767, 'mean_word_length': 4.263063063063063, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4975514', 'n_tokens_mistral': 3291, 'n_tokens_neox': 3090, 'n_words': 562}