diff --git a/addons/map_gestures/XEH_preInit.sqf b/addons/map_gestures/XEH_preInit.sqf index 08159aa972..ad4da44998 100644 --- a/addons/map_gestures/XEH_preInit.sqf +++ b/addons/map_gestures/XEH_preInit.sqf @@ -7,6 +7,7 @@ PREP(drawMapGestures); PREP(endTransmit); PREP(getProximityPlayers); PREP(initTransmit); +PREP(isValidColorArray); PREP(moduleGroupSettings); PREP(moduleSettings); PREP(receiverInit); diff --git a/addons/map_gestures/functions/fnc_isValidColorArray.sqf b/addons/map_gestures/functions/fnc_isValidColorArray.sqf new file mode 100644 index 0000000000..a64cf249eb --- /dev/null +++ b/addons/map_gestures/functions/fnc_isValidColorArray.sqf @@ -0,0 +1,28 @@ +/* + * Author: MikeMatrix + * Validate if an array is in the propper color format. + * + * Arguments: + * 0: Color Array + * + * Return Value: + * Is valid Color Array + * + * Example: + * [[1, 0.2, 1, 0.5]] call ace_map_gestures_fnc_isValidColorArray + * + * Public: No + */ +#include "script_component.hpp" + +params ["_colorArray"]; + +if (isNil "_colorArray") exitWith {false}; +if ((typeName _colorArray) != "ARRAY") exitWith {false}; +if (count _colorArray != 4) exitWith {false}; + +{ + if ((typeName _x) != "SCALAR" || _x < 0 || _x > 1) exitWith {false}; +} count _colorArray; + +true diff --git a/addons/map_gestures/functions/fnc_moduleGroupSettings.sqf b/addons/map_gestures/functions/fnc_moduleGroupSettings.sqf index c0158d90c7..32f7e73143 100644 --- a/addons/map_gestures/functions/fnc_moduleGroupSettings.sqf +++ b/addons/map_gestures/functions/fnc_moduleGroupSettings.sqf @@ -19,19 +19,22 @@ params ["_logic", "_units", "_activated"]; +diag_log "Running"; + if (!_activated) exitWith {}; if (!isServer) exitWith {}; _leadColor = call compile ("[" + (_logic getVariable ["leadColor", ""]) + "]"); -if (isNil "_leadColor" || !((typeName _leadColor) isEqualTo "ARRAY") || {count _leadColor != 4}) exitWith {}; +if (!([_leadColor] call FUNC(isValidColorArray))) exitWith {ERROR("leadColor is not a valid color array.")}; _color = call compile ("[" + (_logic getVariable ["color", ""]) + "]"); -if (isNil "_color" || !((typeName _color) isEqualTo "ARRAY") || {count _color != 4}) exitWith {}; +if (!([_color] call FUNC(isValidColorArray))) exitWith {ERROR("color is not a valid color array.")}; -_configurationGroups = if (isNil QGVAR(GroupColorConfigurationsGroups) then { [] } else { +GVAR(GroupColorConfigurationsGroups) }; +_configurations = if (isNil QGVAR(GroupColorConfigurations)) then { [] } else { +GVAR(GroupColorConfigurations) }; +_configurationGroups = if (isNil QGVAR(GroupColorConfigurationsGroups)) then { [] } else { +GVAR(GroupColorConfigurationsGroups) }; +_configurationGroupsIndex = if (isNil QGVAR(GroupColorConfigurationsGroupIndex)) then { [] } else { +GVAR(GroupColorConfigurationsGroupIndex) }; -if (isNil "_configurationGroups") then {_configurationGroups = [];}; -if (isNil "_configurationGroupsIndex") then {_configurationGroupsIndex = [];}; _completedGroups = []; +_configurationIndex = _configurations pushBack [_leadColor, _color]; { private "_group"; _group = groupID (group _x); diff --git a/addons/map_gestures/functions/fnc_moduleSettings.sqf b/addons/map_gestures/functions/fnc_moduleSettings.sqf index 00cfc7288c..6b21db8588 100644 --- a/addons/map_gestures/functions/fnc_moduleSettings.sqf +++ b/addons/map_gestures/functions/fnc_moduleSettings.sqf @@ -27,9 +27,10 @@ if (!isServer) exitWith {}; [_logic, QGVAR(interval), "interval"] call EFUNC(common,readSettingFromModule); _defaultLeadColor = call compile ("[" + (_logic getVariable ["defaultLeadColor", ""]) + "]"); -if (isNil "_leadColor" || !((typeName _leadColor) isEqualTo "ARRAY") || {count _leadColor != 4}) exitWith {}; -[QGVAR(defaultLeadColor), _defaultLeadColor, true, true] call EFUNC(common,setSetting); +if (!([_defaultLeadColor] call FUNC(isValidColorArray))) exitWith {ERROR("defaultLeadColor is not a valid color array.")}; _defaultColor = call compile ("[" + (_logic getVariable ["defaultColor", ""]) + "]"); -if (isNil "_color" || !((typeName _color) isEqualTo "ARRAY") || {count _color != 4}) exitWith {}; +if (!([_defaultColor] call FUNC(isValidColorArray))) exitWith {ERROR("defaultColor is not a valid color array.")}; + +[QGVAR(defaultLeadColor), _defaultLeadColor, true, true] call EFUNC(common,setSetting); [QGVAR(defaultColor), _defaultColor, true, true] call EFUNC(common,setSetting);