2018-09-17 19:19:29 +00:00
#define DEBUG_MODE_FULL
2023-09-12 18:58:10 +00:00
#include "..\script_component.hpp"
2015-02-03 05:52:07 +00:00
/*
2015-03-24 04:18:00 +00:00
* Author: esteldunedain
2015-02-03 05:52:07 +00:00
* Reads a setting value from a module, set it and force it. Logs if the setting is missing from the module.
2017-11-11 19:21:55 +00:00
* Must be called on all machines!!!!!!!
2015-02-03 05:52:07 +00:00
*
* Arguments:
2015-09-18 23:50:17 +00:00
* 0: Module <OBJECT>
* 1: ACE_Parameter name <STRING>
* 2: Module parameter name <STRING>
2015-02-03 05:52:07 +00:00
*
* Return Value:
* None
2015-09-18 23:50:17 +00:00
*
2017-06-08 13:31:51 +00:00
* Example:
* [MODULE, "Param", "paramname"] call ace_common_fnc_readSettingFromModule
*
2015-09-18 23:50:17 +00:00
* Public: No
2015-02-03 05:52:07 +00:00
*/
2015-09-18 23:50:17 +00:00
params ["_logic", "_settingName", "_moduleVariable"];
2015-02-03 05:52:07 +00:00
2017-11-11 19:21:55 +00:00
// Check if the variable is already defined
if (isNil _settingName) exitWith {
2024-02-05 17:04:24 +00:00
ERROR_1("readSettingFromModule - param [%1] is not an ace_setting",_settingName);
2017-11-11 19:21:55 +00:00
};
2015-02-03 05:52:07 +00:00
// Check if the parameter is defined in the module
if (isNil {_logic getVariable _moduleVariable}) exitWith {
2016-10-02 10:55:31 +00:00
WARNING_2("Warning in %1 module: %2 setting is missing. Probably an obsolete version of the module is used in the mission.",typeOf _logic,_moduleVariable);
2015-02-03 05:52:07 +00:00
};
2016-02-29 20:06:14 +00:00
private _value = _logic getVariable _moduleVariable;
2016-02-29 22:34:51 +00:00
if (_value isEqualTo -1) then {
2016-02-29 20:06:14 +00:00
//3den missions will save modules with value = 0 as -1
//If the setting has a "values" array, we should be able to assume that -1 is not a valid number as it would not be a valid index for the array
if (isArray (configFile >> "ACE_Settings" >> _settingName >> "values")) then {
2016-10-02 10:55:31 +00:00
WARNING_2("Module For Setting [%1] is saved as (-1), switching to (0) - missionVersion [%2]",_settingName,missionVersion);
2016-02-29 20:06:14 +00:00
_value = 0;
};
};
2017-11-11 19:21:55 +00:00
if ([_settingName, "mission"] call CBA_settings_fnc_isForced) then {
WARNING_1("Setting [%1] - Already Forced",_settingName);
};
// Set the setting as a mission setting and force it
TRACE_2("setSettingMission from module",_settingName,_value);
["CBA_settings_setSettingMission", [_settingName, _value, true]] call CBA_fnc_localEvent;