diff --git a/addons/xeh/CfgFunctions.hpp b/addons/xeh/CfgFunctions.hpp index 29837be6e..b03718f27 100644 --- a/addons/xeh/CfgFunctions.hpp +++ b/addons/xeh/CfgFunctions.hpp @@ -9,7 +9,6 @@ class CfgFunctions { PATHTO_FNC(supportMonitor); PATHTO_FNC(compileEventHandlers); PATHTO_FNC(compileFunction); - PATHTO_FNC(startFallbackLoop); class preStart { preStart = 1; diff --git a/addons/xeh/fnc_addClassEventHandler.sqf b/addons/xeh/fnc_addClassEventHandler.sqf index 726514b6c..949176965 100644 --- a/addons/xeh/fnc_addClassEventHandler.sqf +++ b/addons/xeh/fnc_addClassEventHandler.sqf @@ -31,12 +31,6 @@ params [["_className", "", [""]], ["_eventName", "", [""]], ["_eventFunc", {}, [ private _config = configFile >> "CfgVehicles" >> _className; -// init fallback loop when executing on incompatible class for the first time -if (!GVAR(fallbackRunning) && {ISINCOMP(_className)}) then { - WARNING_1("One or more children of class %1 do not support Extended Event Handlers. Fall back to loop.",configName _config); - call CBA_fnc_startFallbackLoop; -}; - // no such CfgVehicles class if (!isClass _config) exitWith {false}; diff --git a/addons/xeh/fnc_postInit.sqf b/addons/xeh/fnc_postInit.sqf index 09d0417f1..e3c5b1e49 100644 --- a/addons/xeh/fnc_postInit.sqf +++ b/addons/xeh/fnc_postInit.sqf @@ -19,6 +19,32 @@ Author: isNil { XEH_LOG("PostInit started. " + PFORMAT_9("MISSIONINIT",missionName,missionVersion,worldName,isMultiplayer,isServer,isDedicated,CBA_isHeadlessClient,hasInterface,didJIP)); + private _incompatibleClasses = call (uiNamespace getVariable [QGVAR(incompatibleClasses), {[]}]); + if (count _incompatibleClasses > 0) then { + + addMissionEventHandler ["EntityCreated", { + params ["_entity"]; + if ((!ISPROCESSED(_entity)) && (ISINCOMP(typeOf _entity))) then { + _entity call CBA_fnc_initEvents; + + if !(ISINITIALIZED(_entity)) then { + _entity call CBA_fnc_init; + }; + }; + }]; + + // init object incompatile XEH + { + if !(ISPROCESSED(_x)) then { + _x call CBA_fnc_initEvents; + + if !(ISINITIALIZED(_x)) then { + _x call CBA_fnc_init; + }; + }; + } forEach (entities [_incompatibleClasses, [], true, true]); + }; + // fix CBA_missionTime being -1 on (non-JIP) clients at mission start. if (CBA_missionTime == -1) then { CBA_missionTime = 0; diff --git a/addons/xeh/fnc_startFallbackLoop.sqf b/addons/xeh/fnc_startFallbackLoop.sqf deleted file mode 100644 index 9528038ab..000000000 --- a/addons/xeh/fnc_startFallbackLoop.sqf +++ /dev/null @@ -1,53 +0,0 @@ -#include "script_component.hpp" -/* ---------------------------------------------------------------------------- -Internal Function: CBA_fnc_startFallbackLoop - -Description: - Starts a loop to iterate through all objects to initialize event handlers on XEH incompatible objects. - Internal use only. - -Parameters: - None - -Returns: - None - -Examples: - (begin example) - call CBA_fnc_startFallbackLoop; - (end) - -Author: - commy2 ----------------------------------------------------------------------------- */ - -if (GVAR(fallbackRunning)) exitWith {}; - -GVAR(fallbackRunning) = true; - -{ - // don't run init and initPost event handlers on objects that already exist - SETINITIALIZED(_x); -} count (entities [[], [], true, true]); // count is safe here because SETINITIALIZED is a setVariable, which returns nil - -GVAR(entities) = []; - -[{ - SCRIPT(fallbackLoopPFEH); - private _entities = entities [[], [], true, true]; - - if (_entities isNotEqualTo GVAR(entities)) then { - private _newEntities = _entities - GVAR(entities); - GVAR(entities) = _entities; - - { - if !(ISPROCESSED(_x)) then { - _x call CBA_fnc_initEvents; - - if !(ISINITIALIZED(_x)) then { - _x call CBA_fnc_init; - }; - }; - } forEach _newEntities; - }; -}, 0.1, []] call CBA_fnc_addPerFrameHandler;