Skip to content

Commit

Permalink
Optimize xeh (#593)
Browse files Browse the repository at this point in the history
* fix missing seatSwitchedMan event

* optimize xeh eventhandlers

* fix too many quote marks
  • Loading branch information
commy2 authored Feb 17, 2017
1 parent 877a3de commit be717f6
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 54 deletions.
10 changes: 2 additions & 8 deletions addons/xeh/fnc_initEvents.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,8 @@ if !(ISPROCESSED(_unit)) then {
// add events to XEH incompatible units
if (!isClass _eventClass) then {
{
if (_x isEqualTo "hitpart") then {
_unit addEventHandler ["hitpart", "{_this call _x} forEach ((_this select 0 select 0) getVariable ""cba_xeh_hitpart"")"];
} else {
if !(_x isEqualTo "init") then {
_unit addEventHandler [_x, format ["{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_%1"")", _x]];
};
};
} forEach GVAR(EventsLowercase);
_unit addEventHandler [_x, format ['call FUNC(%1)', _x]];
} forEach [XEH_EVENTS];
};

while {isClass _class} do {
Expand Down
14 changes: 14 additions & 0 deletions addons/xeh/fnc_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ CBA_isHeadlessClient = !hasInterface && !isDedicated;
// make case insensitive list of all supported events
GVAR(EventsLowercase) = [];
{
// generate event functions
if (_x isEqualTo "Init") then {
FUNC(Init) = compileFinal "(_this select 0) call CBA_fnc_initEvents; (_this select 0) call CBA_fnc_init";
} else {
if (_x isEqualTo "HitPart") then {
FUNC(HitPart) = compileFinal format ['{call _x; nil} count ((_this select 0 select 0) getVariable QGVAR(%1))', _x];
} else {
missionNamespace setVariable [
format [QFUNC(%1), _x],
compileFinal format ['{call _x; nil} count ((_this select 0) getVariable QGVAR(%1))', _x]
];
};
};

GVAR(EventsLowercase) pushBack toLower _x;
} forEach [XEH_EVENTS];

Expand Down
92 changes: 46 additions & 46 deletions addons/xeh/script_xeh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,52 @@
// Add all XEH event handlers
/////////////////////////////////////////////////////////////////////////////////

#define EXTENDED_EVENTHANDLERS init = "(_this select 0) call CBA_fnc_initEvents; (_this select 0) call CBA_fnc_init"; \
fired = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_fired"")"; \
animChanged = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_animChanged"")"; \
animDone = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_animDone"")"; \
animStateChanged = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_animStateChanged"")"; \
containerClosed = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_containerClosed"")"; \
containerOpened = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_containerOpened"")"; \
controlsShifted = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_controlsShifted"")"; \
dammaged = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_dammaged"")"; \
engine = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_engine"")"; \
epeContact = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_epeContact"")"; \
epeContactEnd = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_epeContactEnd"")"; \
epeContactStart = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_epeContactStart"")"; \
explosion = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_explosion"")"; \
firedNear = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_firedNear"")"; \
fuel = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_cba_xeh_fuel"")"; \
gear = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_gear"")"; \
getIn = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_getIn"")"; \
getInMan = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_getInMan"")"; \
getOut = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_getOut"")"; \
getOutMan = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_getOutMan"")"; \
handleHeal = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_handleHeal"")"; \
hit = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_hit"")"; \
hitPart = "{_this call _x} forEach ((_this select 0 select 0) getVariable ""cba_xeh_hitPart"")"; \
incomingMissile = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_incomingMissile"")"; \
inventoryClosed = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_inventoryClosed"")"; \
inventoryOpened = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_inventoryOpened"")"; \
killed = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_killed"")"; \
landedTouchDown = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_landedTouchDown"")"; \
landedStopped = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_landedStopped"")"; \
local = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_local"")"; \
respawn = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_respawn"")"; \
put = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_put"")"; \
take = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_take"")"; \
seatSwitched = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_seatSwitched"")"; \
seatSwitchedMan = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_seatSwitchedMan"")"; \
soundPlayed = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_soundPlayed"")"; \
weaponAssembled = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_weaponAssembled"")"; \
weaponDisassembled = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_weaponDisassembled"")"; \
weaponDeployed = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_weaponDeployed"")"; \
weaponRested = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_weaponRested"")"; \
reloaded = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_reloaded"")"; \
firedMan = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_firedMan"")"; \
turnIn = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_turnIn"")"; \
turnOut = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_turnOut"")"; \
deleted = "{_this call _x} forEach ((_this select 0) getVariable ""cba_xeh_deleted"")";
#define EXTENDED_EVENTHANDLERS init = "call cba_xeh_fnc_init"; \
fired = "call cba_xeh_fnc_fired"; \
animChanged = "call cba_xeh_fnc_animChanged"; \
animDone = "call cba_xeh_fnc_animDone"; \
animStateChanged = "call cba_xeh_fnc_animStateChanged"; \
containerClosed = "call cba_xeh_fnc_containerClosed"; \
containerOpened = "call cba_xeh_fnc_containerOpened"; \
controlsShifted = "call cba_xeh_fnc_controlsShifted"; \
dammaged = "call cba_xeh_fnc_dammaged"; \
engine = "call cba_xeh_fnc_engine"; \
epeContact = "call cba_xeh_fnc_epeContact"; \
epeContactEnd = "call cba_xeh_fnc_epeContactEnd"; \
epeContactStart = "call cba_xeh_fnc_epeContactStart"; \
explosion = "call cba_xeh_fnc_explosion"; \
firedNear = "call cba_xeh_fnc_firedNear"; \
fuel = "call cba_xeh_fnc_cba_xeh_fuel"; \
gear = "call cba_xeh_fnc_gear"; \
getIn = "call cba_xeh_fnc_getIn"; \
getInMan = "call cba_xeh_fnc_getInMan"; \
getOut = "call cba_xeh_fnc_getOut"; \
getOutMan = "call cba_xeh_fnc_getOutMan"; \
handleHeal = "call cba_xeh_fnc_handleHeal"; \
hit = "call cba_xeh_fnc_hit"; \
hitPart = "call cba_xeh_fnc_hitPart"; \
incomingMissile = "call cba_xeh_fnc_incomingMissile"; \
inventoryClosed = "call cba_xeh_fnc_inventoryClosed"; \
inventoryOpened = "call cba_xeh_fnc_inventoryOpened"; \
killed = "call cba_xeh_fnc_killed"; \
landedTouchDown = "call cba_xeh_fnc_landedTouchDown"; \
landedStopped = "call cba_xeh_fnc_landedStopped"; \
local = "call cba_xeh_fnc_local"; \
respawn = "call cba_xeh_fnc_respawn"; \
put = "call cba_xeh_fnc_put"; \
take = "call cba_xeh_fnc_take"; \
seatSwitched = "call cba_xeh_fnc_seatSwitched"; \
seatSwitchedMan = "call cba_xeh_fnc_seatSwitchedMan"; \
soundPlayed = "call cba_xeh_fnc_soundPlayed"; \
weaponAssembled = "call cba_xeh_fnc_weaponAssembled"; \
weaponDisassembled = "call cba_xeh_fnc_weaponDisassembled"; \
weaponDeployed = "call cba_xeh_fnc_weaponDeployed"; \
weaponRested = "call cba_xeh_fnc_weaponRested"; \
reloaded = "call cba_xeh_fnc_reloaded"; \
firedMan = "call cba_xeh_fnc_firedMan"; \
turnIn = "call cba_xeh_fnc_turnIn"; \
turnOut = "call cba_xeh_fnc_turnOut"; \
deleted = "call cba_xeh_fnc_deleted";


/*
Expand Down

0 comments on commit be717f6

Please sign in to comment.