Skip to content

Commit

Permalink
Merge pull request #1291 from CBATeam/doubleKilledEventFix
Browse files Browse the repository at this point in the history
Prevent double execution of Killed event on the same body
  • Loading branch information
commy2 committed Feb 7, 2020
2 parents 2ccde52 + d5d212a commit 8cec1f0
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions addons/xeh/fnc_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,25 @@ GVAR(EventsLowercase) = [];
_header = format ["scriptName 'XEH:%1';", _x];
#endif
// generate event functions
if (_x isEqualTo "Init") then {
FUNC(Init) = compileFinal (_header + "(_this select 0) call CBA_fnc_initEvents; (_this select 0) call CBA_fnc_init");
} else {
if (_x isEqualTo "HitPart") then {
switch _x do {
case "Init": {
FUNC(Init) = compileFinal (_header + "(_this select 0) call CBA_fnc_initEvents; (_this select 0) call CBA_fnc_init");
};
// This prevents double execution of the Killed event on the same unit.
case "Killed": {
FUNC(Killed) = compileFinal (_header + format ['\
params ["_unit"];\
if (_unit getVariable [QGVAR(killedBody), objNull] != _unit) then {\
_unit setVariable [QGVAR(killedBody), _unit];\
private "_unit";\
{call _x} forEach ((_this select 0) getVariable QGVAR(%1));\
};',
_x]);
};
case "HitPart": {
FUNC(HitPart) = compileFinal (_header + format ['{call _x} forEach ((_this select 0 select 0) getVariable QGVAR(%1))', _x]);
} else {
};
default {
missionNamespace setVariable [
format [QFUNC(%1), _x],
compileFinal (_header + format ['{call _x} forEach ((_this select 0) getVariable QGVAR(%1))', _x])
Expand Down

0 comments on commit 8cec1f0

Please sign in to comment.