Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
marceldev89 committed Oct 21, 2016
1 parent 0a89f04 commit 8bfc653
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions addons/sup_artillery/fnc_artillery.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ switch (_operation) do {
_roundType,
1
];

hint format ["%3: _unit: %1 firing 1 %2", _unit, _roundType, time];
} else {
{
private _roundCount = [_fireMission, "roundCount"] call ALIVE_fnc_hashGet;
Expand Down Expand Up @@ -250,6 +248,25 @@ switch (_operation) do {
"(group this) setVariable ['sup_artillery_inPosition', true]"
];
};
case "returnToBase": {
private _group = _logic getVariable ["group", grpNull];
private _units = (units _group) select {vehicle _x != _x && {gunner (vehicle _x) == _x}};
_units doWatch objNull;

// Cleanup event handlers
{
private _vehicle = vehicle _x;
private _firedEH = _vehicle getVariable ["sup_artillery_firedEH", nil];

if (!isNil "_firedEH") then {
_vehicle removeEventHandler ["Fired", _firedEH];
_vehicle setVariable ["sup_artillery_firedEH", nil];
};
} forEach _units;

_logic setVariable ["fireMission", []];
[_logic, "move", [position _logic]] call MAINCLASS;
};
case "spawn": {
private _position = position _logic;
private _type = _logic getVariable ["artillery_type", ""];
Expand Down Expand Up @@ -317,23 +334,7 @@ switch (_operation) do {
[_logic, "execute"] call MAINCLASS;
};
case "onReturnToBase": {
private _group = _logic getVariable ["group", grpNull];
private _units = (units _group) select {vehicle _x != _x && {gunner (vehicle _x) == _x}};
_units doWatch objNull;

// Cleanup event handlers
{
private _vehicle = vehicle _x;
private _firedEH = _vehicle getVariable ["sup_artillery_firedEH", nil];

if (!isNil "_firedEH") then {
_vehicle removeEventHandler ["Fired", _firedEH];
_vehicle setVariable ["sup_artillery_firedEH", nil];
};
} forEach _units;

_logic setVariable ["fireMission", []];
[_logic, "move", [position _logic]] call MAINCLASS; // TODO: Find (best) RTB position
[_logic, "returnToBase"] call MAINCLASS;
};
};

Expand Down

0 comments on commit 8bfc653

Please sign in to comment.