Improve zeus auto-add XEH behaviour

The XEH InitPost event only needs to be added if the `GVAR(autoAddObjects)` setting is enabled. This change will save on overhead when the setting is disabled and also removes some complexity from the function that runs in response to the event.
This commit is contained in:
SilentSpike 2016-06-18 15:41:13 +01:00
parent 72092d6464
commit ca01f31b52
3 changed files with 7 additions and 13 deletions

View File

@ -16,11 +16,3 @@ class Extended_PostInit_EventHandlers {
init = QUOTE(call COMPILE_FILE(XEH_postInit)); init = QUOTE(call COMPILE_FILE(XEH_postInit));
}; };
}; };
class Extended_InitPost_EventHandlers {
class AllVehicles {
class ADDON {
serverInit = QUOTE(call FUNC(addObjectToCurator));
};
};
};

View File

@ -1,5 +1,12 @@
#include "script_component.hpp" #include "script_component.hpp"
["ace_settingsInitialized",{
// Only add an InitPost EH if setting is enabled (and apply retroactively)
if (isServer && GVAR(autoAddObjects)) then {
["AllVehicles", "InitPost", FUNC(addObjectToCurator), true, [], true] call CBA_fnc_addClassEventHandler;
};
}] call CBA_fnc_addEventHandler;
// Global skill module PVs values for persistence, just listen for the PV // Global skill module PVs values for persistence, just listen for the PV
QGVAR(GlobalSkillAI) addPublicVariableEventHandler FUNC(moduleGlobalSetSkill); QGVAR(GlobalSkillAI) addPublicVariableEventHandler FUNC(moduleGlobalSetSkill);

View File

@ -15,11 +15,6 @@
params ["_object"]; params ["_object"];
if !(EGVAR(common,settingsInitFinished)) exitWith {
TRACE_1("pushing to runAtSettingsInitialized", _this);
EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(addObjectToCurator), _this];
};
if (!(_object getVariable [QGVAR(addObject), GVAR(autoAddObjects)])) exitWith {}; if (!(_object getVariable [QGVAR(addObject), GVAR(autoAddObjects)])) exitWith {};
[{ [{