Skip to content

Commit

Permalink
Minor code optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
DerZade committed Apr 6, 2018
1 parent a03bf6e commit c3a5007
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
1 change: 1 addition & 0 deletions addons/GRAD_slingHelmet/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class CfgFunctions
class EHHandleDisconnect {};
class EHKilled {};
class weaponHolder {};
class whitelist {};
};
};
};
4 changes: 2 additions & 2 deletions addons/GRAD_slingHelmet/allowedHeadgear.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_allowedHeadgear = [
private _allowedHeadgear = [
// Vanilla + Apex + Laws Of War
"H_HelmetSpecO_blk",
"H_HelmetSpecO_ocamo",
Expand Down Expand Up @@ -390,7 +390,7 @@ _allowedHeadgear = [
"rhsusf_protech_helmet_ess",
"rhsusf_protech_helmet_rhino",
"rhsusf_protech_helmet_rhino_ess",

//3CB
"UK3CB_BAF_H_CrewHelmet_DDPM_A",
"UK3CB_BAF_H_CrewHelmet_DDPM_ESS_A",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ if (! isServer) exitWith {
};

//init variable if isn't yet
if (isNil "GRAD_slingHelmet_whitelist") then {
GRAD_slingHelmet_whitelist = [];
};
[] call GRAD_slingHelmet_fnc_whitelist;

//add classnames
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* Public: No
*/

#include "..\..\allowedHeadgear.hpp"

params ["_unit"];

//unit has to have headgear
Expand All @@ -24,9 +22,10 @@ if (headgear _unit isEqualTo '') exitWith {false;};
//unit must not have a slung helmet already
if !([_unit] call GRAD_slingHelmet_fnc_getSlungHelmet isEqualTo '') exitWith {false;};

//check ii uni's helmet is allowed by mod creator
if !(isNull (configFile >> "CfgWeapons" >> (headgear _unit) >> "grad_slingHelmet_allow")) exitWith {true;};

//check wether unit's helemt is in list of allowed helmets
_allowedHeadgear append (missionNamespace getVariable ["GRAD_slingHelmet_whitelist",[]]);
if (!((headgear _unit) in _allowedHeadgear) && (isNull (configFile >> "CfgWeapons" >> (headgear _unit) >> "grad_slingHelmet_allow"))) exitWith {false;};
if !((headgear _unit) in ([] call GRAD_slingHelmet_fnc_whitelist)) exitWith {false;};

true;
25 changes: 25 additions & 0 deletions addons/GRAD_slingHelmet/functions/misc/fn_whitelist.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Author: DerZade
* Returns all whitelisted helmets.
*
* Arguments:
* None
*
* Return Value:
* Whitelisted Headgear <ARRAY>
*
* Example:
* [] call GRAD_slingHelmet_fnc_whitelist;
*
* Public: No
*/

#include "..\..\allowedHeadgear.hpp"

if (isNil "GRAD_slingHelmet_whitelist") then {
//var has to be initialized
GRAD_slingHelmet_whitelist = _allowedHeadgear;
publicVariable "GRAD_slingHelmet_whitelist";
};

GRAD_slingHelmet_whitelist;

0 comments on commit c3a5007

Please sign in to comment.