2015-03-22 11:39:26 +00:00
#include "script_component.hpp"
2016-06-03 19:38:16 +00:00
[QEGVAR(common,initSettingsFromModules), {
2015-05-30 04:18:23 +00:00
// TODO This is a basic and limited implementation that mimics some of the functionality from the A3 module framework, but not all of it.
// We have to execute this in the postInit XEH because on object init, the parameters of the modules are not yet available. They are if we execute it at the start of postInit execution.
2016-05-03 00:32:44 +00:00
2015-11-17 20:02:20 +00:00
private _uniqueModulesHandled = [];
2015-05-30 04:18:23 +00:00
{
[_x] call {
2015-10-19 04:34:11 +00:00
params ["_logic"];
2015-11-30 16:19:57 +00:00
private _logicType = typeOf _logic;
2017-01-14 21:47:03 +00:00
_logic hideObject true;
2015-03-22 11:39:26 +00:00
2015-11-30 16:27:09 +00:00
if (_logic getVariable [QGVAR(initalized), false]) exitWith {};
2015-11-17 20:02:20 +00:00
private _config = (configFile >> "CfgVehicles" >> _logicType);
2015-11-30 16:14:05 +00:00
if !(isClass _config) exitWith {};
2015-03-22 11:39:26 +00:00
2015-11-17 20:02:20 +00:00
private _isGlobal = getNumber (_config >> "isGlobal") > 0;
private _isDisposable = getNumber (_config >> "isDisposable") > 0;
2017-01-14 21:47:03 +00:00
private _isPersistent = getNumber (_config >> "isPersistent") > 0 || getNumber (_config >> "isGlobal") > 1;
2015-11-17 20:02:20 +00:00
private _isSingular = getNumber (_config >> "isSingular") > 0;
private _function = getText (_config >> "function");
2015-11-30 16:22:16 +00:00
if (isNil _function) then {
2015-05-30 04:18:23 +00:00
_function = compile _function;
} else {
2015-11-30 16:27:09 +00:00
_function = missionNamespace getVariable _function;
2015-05-30 04:18:23 +00:00
};
2015-10-19 04:34:11 +00:00
if (_isSingular && {_logicType in _uniqueModulesHandled}) then { //ToDo: should this be an exit?
2016-10-02 10:55:31 +00:00
WARNING_1("Module [%1] - More than 1 singular module placed", _logicType);
2016-05-03 00:32:44 +00:00
};
if (_isSingular) then {_uniqueModulesHandled pushBack _logicType;};
2015-03-22 11:39:26 +00:00
2015-07-01 06:53:15 +00:00
if (_isGlobal || isServer) then {
[_logic, (synchronizedObjects _logic), true] call _function;
2015-03-22 11:45:46 +00:00
};
2015-03-22 11:39:26 +00:00
2015-05-30 04:18:23 +00:00
if !(_isPersistent) then {
2015-11-30 16:27:09 +00:00
_logic setVariable [QGVAR(initalized), true];
2015-05-30 04:18:23 +00:00
};
2015-03-22 11:39:26 +00:00
2015-05-30 04:18:23 +00:00
if (_isDisposable) then {
2017-11-11 19:21:55 +00:00
if (_isGlobal) then {WARNING_1("Deleting Global Module??? [%1]",_logicType);};
2015-05-30 04:18:23 +00:00
deleteVehicle _logic;
};
2015-03-22 11:45:46 +00:00
};
2015-10-19 04:34:11 +00:00
} forEach GVAR(moduleInitCollection);
2016-05-03 00:32:44 +00:00
2015-06-09 06:27:59 +00:00
if (isServer) then {
GVAR(serverModulesRead) = true;
publicVariable QGVAR(serverModulesRead);
};
2016-05-22 15:29:05 +00:00
}] call CBA_fnc_addEventHandler;