Cookoff - Fix smoke effects not getting cleaned up (#8933)

* Cookoff: Added handling for cleaning up smoke effects when vehicle is deleted mid-cookoff

* Cookoff - Prevent effects cleanup Deleted EH from getting duplicated

* Cookoff - Added locality safety check to effects cleanup

* Cookoff -  Global effects cleanup is now triggered by the server to handle locality transfer
This commit is contained in:
JonBons 2022-07-15 09:59:49 -05:00 committed by GitHub
parent 1a95070b80
commit 36442d34cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -11,6 +11,22 @@
[QGVAR(smoke), FUNC(smoke)] call CBA_fnc_addEventHandler;
[QGVAR(cookOffBox), FUNC(cookOffBox)] call CBA_fnc_addEventHandler;
// handle cleaning up effects when vehicle is deleted mid-cookoff
[QGVAR(addCleanupHandlers), {
params ["_vehicle"];
// Don't add a new EH if cookoff is run multiple times
if ((_vehicle getVariable [QGVAR(deletedEH), -1]) == -1) then {
private _deletedEH = _vehicle addEventHandler ["Deleted", {
params ["_vehicle"];
[QGVAR(cleanupEffects), [_vehicle]] call CBA_fnc_globalEvent;
}];
_vehicle setVariable [QGVAR(deletedEH), _deletedEH];
};
}] call CBA_fnc_addEventHandler;
[QGVAR(cleanupEffects), {
params ["_vehicle", ["_effects", []]];

View File

@ -30,6 +30,8 @@ TRACE_9("cooking off",_vehicle,_intensity,_instigator,_smokeDelayEnabled,_ammoDe
if (_vehicle getVariable [QGVAR(isCookingOff), false]) exitWith {};
_vehicle setVariable [QGVAR(isCookingOff), true, true];
[QGVAR(addCleanupHandlers), [_vehicle]] call CBA_fnc_serverEvent;
// limit maximum value of intensity to prevent very long cook-off times
_intensity = _intensity min _maxIntensity;