Made more modules use assignObjectsInList common function

This commit is contained in:
jonpas 2015-08-24 21:55:48 +02:00
parent ef2924623f
commit 5b6429f23e
5 changed files with 30 additions and 111 deletions

View File

@ -1,63 +1,26 @@
/* /*
* Author: Glowbal * Author: Glowbal
* Assign a medical role to a unit * Assign a medical role to a unit.
* *
* Arguments: * Arguments:
* 0: The module logic <LOGIC> * 0: The module logic <OBJECT>
* 1: units <ARRAY> * 1: Synchronized units <ARRAY>
* 2: activated <BOOL> * 2: Activated <BOOL>
* *
* Return Value: * Return Value:
* None <NIL> * None <NIL>
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_logic","_setting","_objects", "_list", "_splittedList", "_nilCheckPassedList", "_parsedList"]; params ["_logic"];
_logic = [_this,0,objNull,[objNull]] call BIS_fnc_param;
if (!isNull _logic) then { if (!isNull _logic) then {
_list = _logic getvariable ["EnableList",""]; private ["_list", "_setting"];
_list = _logic getVariable ["EnableList", ""];
_setting = _logic getVariable ["role", 0];
_splittedList = [_list, ","] call BIS_fnc_splitString; [_list, QGVAR(medicClass), _setting, true] call EFUNC(common,assignObjectsInList);
_nilCheckPassedList = ""; [synchronizedObjects _logic, QGVAR(medicClass), _setting, true] call EFUNC(common,assignObjectsInList);
{
_x = [_x] call EFUNC(common,stringRemoveWhiteSpace);
if !(isnil _x) then {
if (_nilCheckPassedList == "") then {
_nilCheckPassedList = _x;
} else {
_nilCheckPassedList = _nilCheckPassedList + ","+ _x;
}; };
};
}foreach _splittedList;
_list = "[" + _nilCheckPassedList + "]";
_parsedList = [] call compile _list;
_setting = _logic getvariable ["role",0];
_objects = synchronizedObjects _logic;
if (!(_objects isEqualTo []) && _parsedList isEqualTo []) then {
{
if (!isnil "_x") then {
if (typeName _x == typeName objNull) then {
if (local _x) then {
_x setvariable [QGVAR(medicClass), _setting, true];
};
};
};
}foreach _objects;
};
{
if (!isnil "_x") then {
if (typeName _x == typeName objNull) then {
if (local _x) then {
_x setvariable [QGVAR(medicClass), _setting, true];
};
};
};
}foreach _parsedList;
};
true

View File

@ -1,64 +1,26 @@
/* /*
* Author: Glowbal * Author: Glowbal
* Assign vehicle as a medical vehicle * Assign vehicle as a medical vehicle.
* *
* Arguments: * Arguments:
* 0: The module logic <LOGIC> * 0: The module logic <OBJECT>
* 1: units <ARRAY> * 1: Synchronized units <ARRAY>
* 2: activated <BOOL> * 2: Activated <BOOL>
* *
* Return Value: * Return Value:
* None <NIL> * None <NIL>
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_logic","_setting","_objects", "_list", "_splittedList", "_nilCheckPassedList", "_parsedList"]; params ["_logic"];
_logic = [_this,0,objNull,[objNull]] call BIS_fnc_param;
if (!isNull _logic) then { if (!isNull _logic) then {
_list = _logic getvariable ["EnableList",""]; private ["_list", "_setting"];
_list = _logic getVariable ["EnableList", ""];
_setting = _logic getVariable ["enabled", 0];
_splittedList = [_list, ","] call BIS_fnc_splitString; [_list, QGVAR(medicClass), _setting, true] call EFUNC(common,assignObjectsInList);
_nilCheckPassedList = ""; [synchronizedObjects _logic, QGVAR(medicClass), _setting, true] call EFUNC(common,assignObjectsInList);
{
_x = [_x] call EFUNC(common,stringRemoveWhiteSpace);
if !(isnil _x) then {
if (_nilCheckPassedList == "") then {
_nilCheckPassedList = _x;
} else {
_nilCheckPassedList = _nilCheckPassedList + ","+ _x;
}; };
};
}foreach _splittedList;
_list = "[" + _nilCheckPassedList + "]";
_parsedList = [] call compile _list;
_setting = _logic getvariable ["enabled", 0];
_objects = synchronizedObjects _logic;
if (!(_objects isEqualTo []) && _parsedList isEqualTo []) then {
{
if (!isnil "_x") then {
if (typeName _x == typeName objNull) then {
if (local _x) then {
_x setvariable [QGVAR(medicClass), _setting, true];
};
};
};
}foreach _objects;
};
{
if (!isnil "_x") then {
if (typeName _x == typeName objNull) then {
if (local _x) then {
_x setvariable [QGVAR(medicClass), _setting, true];
};
};
};
}foreach _parsedList;
};
true;

View File

@ -27,5 +27,3 @@ if (!isNull _logic) then {
[_list, "ACE_IsEngineer", _setting, true] call EFUNC(common,assignObjectsInList); [_list, "ACE_IsEngineer", _setting, true] call EFUNC(common,assignObjectsInList);
[synchronizedObjects _logic, "ACE_IsEngineer", _setting, true] call EFUNC(common,assignObjectsInList); [synchronizedObjects _logic, "ACE_IsEngineer", _setting, true] call EFUNC(common,assignObjectsInList);
}; };
true

View File

@ -27,5 +27,3 @@ if (!isNull _logic) then {
[_list, "ACE_isRepairFacility", _setting, true] call EFUNC(common,assignObjectsInList); [_list, "ACE_isRepairFacility", _setting, true] call EFUNC(common,assignObjectsInList);
[synchronizedObjects _logic, "ACE_isRepairFacility", _setting, true] call EFUNC(common,assignObjectsInList); [synchronizedObjects _logic, "ACE_isRepairFacility", _setting, true] call EFUNC(common,assignObjectsInList);
}; };
true

View File

@ -27,5 +27,3 @@ if (!isNull _logic) then {
[_list, "ACE_isRepairVehicle", _setting, true] call EFUNC(common,assignObjectsInList); [_list, "ACE_isRepairVehicle", _setting, true] call EFUNC(common,assignObjectsInList);
[synchronizedObjects _logic, "ACE_isRepairVehicle", _setting, true] call EFUNC(common,assignObjectsInList); [synchronizedObjects _logic, "ACE_isRepairVehicle", _setting, true] call EFUNC(common,assignObjectsInList);
}; };
true