mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
PV GVAR(settings) after modules, add error debug
This commit is contained in:
parent
26c051d397
commit
16180686d2
@ -197,6 +197,11 @@ call FUNC(checkFiles);
|
||||
// Event so that ACE_Modules have their settings loaded:
|
||||
["InitSettingsFromModules", []] call FUNC(localEvent);
|
||||
|
||||
if (isServer) then {
|
||||
// Publish all settings data after all configs and modules are read
|
||||
publicVariable QGVAR(settings);
|
||||
};
|
||||
|
||||
// Load user settings from profile
|
||||
if (hasInterface) then {
|
||||
call FUNC(loadSettingsFromProfile);
|
||||
|
@ -35,12 +35,23 @@ _fnc_parseConfigForDisplayNames = {
|
||||
_values set [_forEachIndex, _text];
|
||||
};
|
||||
} forEach _values;
|
||||
|
||||
if (!(_values isEqualTo [])) then {
|
||||
if (_typeOf != "SCALAR") then {
|
||||
ACE_LOGWARNING_2("Setting [%1] has values[] but is not SCALAR (%2)", _name, _typeOf);
|
||||
} else {
|
||||
local _value = missionNamespace getVariable [_name, -1];
|
||||
if ((_value < 0) || {_value >= (count _values)}) then {
|
||||
ACE_LOGWARNING_3("Setting [%1] out of bounds %2 (values[] count is %3)(", _name, _value, count _values);
|
||||
};
|
||||
};
|
||||
};
|
||||
true
|
||||
};
|
||||
|
||||
// Iterate through settings
|
||||
{
|
||||
_x params ["_name"];
|
||||
_x params ["_name", "_typeOf"];
|
||||
|
||||
if !([configFile >> "ACE_Settings" >> _name] call _fnc_parseConfigForDisplayNames) then {
|
||||
if !([configFile >> "ACE_ServerSettings" >> _name] call _fnc_parseConfigForDisplayNames) then {
|
||||
|
@ -51,8 +51,6 @@ _fnc_parseConfigForSettings = {
|
||||
// mission side settings
|
||||
[missionConfigFile >> "ACE_Settings"] call _fnc_parseConfigForSettings;
|
||||
|
||||
// Publish all settings data
|
||||
publicVariable QGVAR(settings);
|
||||
// Publish all setting values
|
||||
{
|
||||
publicVariable (_x select 0);
|
||||
|
@ -13,27 +13,37 @@
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* ["ace_map_gestures_enabled", true, false, true] call ace_common_fnc_setSetting
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_name", "_value", ["_force", false], ["_broadcastChanges", false]];
|
||||
|
||||
private ["_settingData", "_failed"];
|
||||
|
||||
_settingData = [_name] call FUNC(getSettingData);
|
||||
local _settingData = [_name] call FUNC(getSettingData);
|
||||
|
||||
// Exit if the setting does not exist
|
||||
if (count _settingData == 0) exitWith {};
|
||||
if (_settingData isEqualTo []) exitWith {};
|
||||
|
||||
_settingData params ["", "_typeName", "_isClientSetable", "", "", "", "_isForced"];
|
||||
|
||||
// Exit if the setting is already forced
|
||||
if (_settingData select 6) exitWith {};
|
||||
if (_isForced) exitWith {
|
||||
ACE_LOGINFO_1("SetSetting [%1] Trying to set forced setting", _name);
|
||||
};
|
||||
|
||||
//This does NOT broadcast changes to GVAR(settings), so clients would not get updated force status
|
||||
if ((missionNamespace getVariable [QEGVAR(modules,serverModulesRead), false]) && {!(_isForced isEqualTo _force)}) then {
|
||||
ACE_LOGWARNING_3("SetSetting [%1] attempting to broadcast a change to force (%2 to %3)", _name, _isForced, _force);
|
||||
};
|
||||
|
||||
// If the type is not equal, try to cast it
|
||||
_failed = false;
|
||||
local _failed = false;
|
||||
if (typeName _value != _settingData select 1) then {
|
||||
_failed = true;
|
||||
if (_settingData select 1 == "BOOL" && typeName _value == "SCALAR") then {
|
||||
if ((_typeName == "BOOL") && {typeName _value == "SCALAR"}) then {
|
||||
// If value is not 0 or 1 consider it invalid and don't set anything
|
||||
if (_value isEqualTo 0) then {
|
||||
_value = false;
|
||||
@ -44,12 +54,12 @@ if (typeName _value != _settingData select 1) then {
|
||||
_failed = false;
|
||||
};
|
||||
};
|
||||
if (_settingData select 1 == "COLOR" && typeName _value == "ARRAY") then {
|
||||
if ((_typeName == "COLOR") && {typeName _value == "ARRAY"}) then {
|
||||
_failed = false;
|
||||
};
|
||||
};
|
||||
|
||||
if (_failed) exitWith {};
|
||||
if (_failed) exitWith {ACE_LOGERROR_3("SetSetting [%1] bad data type expected %2 got %3", _name, _typeName, typeName _value);};
|
||||
|
||||
// Force it if it was required
|
||||
_settingData set [6, _force];
|
||||
|
Loading…
Reference in New Issue
Block a user