Added validation and various fixes

This commit is contained in:
Michael Braun 2015-08-10 19:04:49 +02:00
parent 5287455c0b
commit 3e82391a36
4 changed files with 41 additions and 8 deletions

View File

@ -7,6 +7,7 @@ PREP(drawMapGestures);
PREP(endTransmit);
PREP(getProximityPlayers);
PREP(initTransmit);
PREP(isValidColorArray);
PREP(moduleGroupSettings);
PREP(moduleSettings);
PREP(receiverInit);

View File

@ -0,0 +1,28 @@
/*
* Author: MikeMatrix
* Validate if an array is in the propper color format.
*
* Arguments:
* 0: Color Array <ARRAY>
*
* Return Value:
* Is valid Color Array <BOOL>
*
* 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

View File

@ -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);

View File

@ -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);