Skip to content

Commit 1e988e1

Browse files
committed
Cleanup
1 parent c2fc2f6 commit 1e988e1

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

addons/sup_artillery/fnc_artillery.sqf

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ switch (_operation) do {
177177
_roundType,
178178
1
179179
];
180-
181-
hint format ["%3: _unit: %1 firing 1 %2", _unit, _roundType, time];
182180
} else {
183181
{
184182
private _roundCount = [_fireMission, "roundCount"] call ALIVE_fnc_hashGet;
@@ -250,6 +248,25 @@ switch (_operation) do {
250248
"(group this) setVariable ['sup_artillery_inPosition', true]"
251249
];
252250
};
251+
case "returnToBase": {
252+
private _group = _logic getVariable ["group", grpNull];
253+
private _units = (units _group) select {vehicle _x != _x && {gunner (vehicle _x) == _x}};
254+
_units doWatch objNull;
255+
256+
// Cleanup event handlers
257+
{
258+
private _vehicle = vehicle _x;
259+
private _firedEH = _vehicle getVariable ["sup_artillery_firedEH", nil];
260+
261+
if (!isNil "_firedEH") then {
262+
_vehicle removeEventHandler ["Fired", _firedEH];
263+
_vehicle setVariable ["sup_artillery_firedEH", nil];
264+
};
265+
} forEach _units;
266+
267+
_logic setVariable ["fireMission", []];
268+
[_logic, "move", [position _logic]] call MAINCLASS;
269+
};
253270
case "spawn": {
254271
private _position = position _logic;
255272
private _type = _logic getVariable ["artillery_type", ""];
@@ -317,23 +334,7 @@ switch (_operation) do {
317334
[_logic, "execute"] call MAINCLASS;
318335
};
319336
case "onReturnToBase": {
320-
private _group = _logic getVariable ["group", grpNull];
321-
private _units = (units _group) select {vehicle _x != _x && {gunner (vehicle _x) == _x}};
322-
_units doWatch objNull;
323-
324-
// Cleanup event handlers
325-
{
326-
private _vehicle = vehicle _x;
327-
private _firedEH = _vehicle getVariable ["sup_artillery_firedEH", nil];
328-
329-
if (!isNil "_firedEH") then {
330-
_vehicle removeEventHandler ["Fired", _firedEH];
331-
_vehicle setVariable ["sup_artillery_firedEH", nil];
332-
};
333-
} forEach _units;
334-
335-
_logic setVariable ["fireMission", []];
336-
[_logic, "move", [position _logic]] call MAINCLASS; // TODO: Find (best) RTB position
337+
[_logic, "returnToBase"] call MAINCLASS;
337338
};
338339
};
339340

0 commit comments

Comments
 (0)