diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index da61bf06ca..49edd8810b 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -10,34 +10,4 @@ GVAR(SELECTIONS) = ["head", "body", "hand_l", "hand_r", "leg_l", "leg_r"]; call FUNC(parseConfigForInjuries); GVAR(STATE_MACHINE) = (configFile >> "ACE_Medical_StateMachine") call FUNC(createStateMachine); -//Hack for #3168 (units in static weapons do not take any damage): -//doing a manual pre-load with a small distance seems to fix the LOD problems with handle damage not returning full results -GVAR(fixedStatics) = []; -private _fixStatic = { - params ["_vehicle"]; - private _vehType = typeOf _vehicle; - TRACE_2("",_vehicle,_vehType); - if (!(_vehType in GVAR(fixedStatics))) then { - GVAR(fixedStatics) pushBack _vehType; - TRACE_1("starting preload",_vehType); - [{ - 1 preloadObject (_this select 0); - }, { - TRACE_1("preload done",_this); - }, [_vehType]] call CBA_fnc_waitUntilAndExecute; - }; -}; -["StaticWeapon", "init", _fixStatic] call CBA_fnc_addClassEventHandler; -["Car", "init", _fixStatic] call CBA_fnc_addClassEventHandler; -addMissionEventHandler ["Loaded",{ - { - TRACE_1("starting preload (save load)",_x); - [{ - 1 preloadObject (_this select 0); - }, { - TRACE_1("preload done",_this); - }, [_x]] call CBA_fnc_waitUntilAndExecute; - } forEach GVAR(fixedStatics); -}]; - ADDON = true; diff --git a/addons/medical_engine/XEH_postInit.sqf b/addons/medical_engine/XEH_postInit.sqf index e0b963df2a..223f81d6a3 100644 --- a/addons/medical_engine/XEH_postInit.sqf +++ b/addons/medical_engine/XEH_postInit.sqf @@ -41,47 +41,3 @@ ]; }] call CBA_fnc_waitUntilAndExecute; #endif - -// Hack for #3168 (units in static weapons do not take any damage): -// Doing a manual pre-load with a small distance seems to fix the LOD problems -// with handle damage not returning full results. -GVAR(fixedStatics) = []; - -private _fnc_fixStatic = { - params ["_vehicle"]; - - private _type = typeOf _vehicle; - TRACE_2("",_vehicle,_type); - - if !(_type in GVAR(fixedStatics)) then { - GVAR(fixedStatics) pushBack _type; - - ACE_LOGINFO_1("Starting preload for ""%1""",_type); - [{ - 1 preloadObject _this; - }, { - ACE_LOGINFO_1("Preload done for ""%1""",_this); - }, _type] call CBA_fnc_waitUntilAndExecute; - }; -}; - -["StaticWeapon", "init", _fnc_fixStatic, nil, nil, true] call CBA_fnc_addClassEventHandler; -["Car", "init", _fnc_fixStatic, nil, nil, true] call CBA_fnc_addClassEventHandler; - -addMissionEventHandler ["Loaded", { - { - ACE_LOGINFO_1("Starting preload for ""%1""",_x); - [{ - 1 preloadObject _this; - }, { - ACE_LOGINFO_1("Preload done for ""%1""",_this); - }, _x] call CBA_fnc_waitUntilAndExecute; - } forEach GVAR(fixedStatics); -}]; - -#define BLAH __FILE__ -diag_log BLAH; - -diag_log 127; - -diag_log __FILE__; diff --git a/addons/medical_engine/XEH_preInit.sqf b/addons/medical_engine/XEH_preInit.sqf index 09fc6ebc64..347c4c6021 100644 --- a/addons/medical_engine/XEH_preInit.sqf +++ b/addons/medical_engine/XEH_preInit.sqf @@ -4,6 +4,30 @@ ADDON = false; #include "XEH_PREP.hpp" +// Hack for #3168 (units in static weapons do not take any damage): +// Doing a manual pre-load with a small distance seems to fix the LOD problems +// with handle damage not returning full results. +GVAR(fixedStatics) = []; + +private _fnc_fixStatic = { + params ["_vehicle"]; + private _type = typeOf _vehicle; + + if !(_type in GVAR(fixedStatics)) then { + GVAR(fixedStatics) pushBack _type; + PRELOAD_CLASS(_type); + }; +}; + +["StaticWeapon", "init", _fnc_fixStatic] call CBA_fnc_addClassEventHandler; +["Car", "init", _fnc_fixStatic] call CBA_fnc_addClassEventHandler; + +addMissionEventHandler ["Loaded", { + { + PRELOAD_CLASS(_x); + } forEach GVAR(fixedStatics); +}]; + // HitScream GVAR(HitScreamNamespace) = [] call CBA_fnc_createNamespace; GVAR(HitScreamNamespace) setVariable ["#default", "Male08ENG"]; diff --git a/addons/medical_engine/script_component.hpp b/addons/medical_engine/script_component.hpp index 5d726ffe13..0cf3b9a67a 100644 --- a/addons/medical_engine/script_component.hpp +++ b/addons/medical_engine/script_component.hpp @@ -27,3 +27,11 @@ #define EMPTY_SOUND {"A3\Sounds_F\dummysound.wss",1,1} #define NAMESPACE_NULL locationNull + +#define PRELOAD_CLASS(class) \ + LOG_1("Starting preload for ""%1""",class);\ + [{\ + 1 preloadObject _this;\ + }, {\ + LOG_1("Preload done for ""%1""",_this);\ + }, class] call CBA_fnc_waitUntilAndExecute