mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Cargo - Fix loaded cargo not being deleted when vehicle is destroyed (#7851)
This commit is contained in:
parent
c8bb046d31
commit
4d769e4b8f
@ -16,11 +16,3 @@ class Extended_PostInit_EventHandlers {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_postInit));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_Killed_EventHandlers {
|
||||
class All {
|
||||
class ADDON {
|
||||
serverKilled = QUOTE(call FUNC(handleDestroyed));
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -4,6 +4,7 @@ PREP(canLoadItemIn);
|
||||
PREP(canUnloadItem);
|
||||
PREP(getCargoSpaceLeft);
|
||||
PREP(getSizeItem);
|
||||
PREP(handleDeleted);
|
||||
PREP(handleDestroyed);
|
||||
PREP(initObject);
|
||||
PREP(initVehicle);
|
||||
|
@ -13,4 +13,10 @@ GVAR(initializedVehicleClasses) = [];
|
||||
GVAR(cargoHolderTypes) = ["Car", "Air", "Tank", "Ship", "Cargo_base_F", "Land_PaperBox_closed_F"];
|
||||
GVAR(disableParadropEffectsClasstypes) = ["Car_F"];
|
||||
|
||||
if (isServer) then {
|
||||
["All", "Deleted", LINKFUNC(handleDeleted)] call CBA_fnc_addClassEventHandler;
|
||||
};
|
||||
|
||||
["All", "Killed", LINKFUNC(handleDestroyed)] call CBA_fnc_addClassEventHandler;
|
||||
|
||||
ADDON = true;
|
||||
|
25
addons/cargo/functions/fnc_handleDeleted.sqf
Normal file
25
addons/cargo/functions/fnc_handleDeleted.sqf
Normal file
@ -0,0 +1,25 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: mharis001
|
||||
* Handles an object being deleted by deleting all loaded cargo.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Object <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [_object] call ace_cargo_fnc_handleDeleted
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_object"];
|
||||
|
||||
{
|
||||
if (_x isEqualType objNull) then {
|
||||
detach _x;
|
||||
deleteVehicle _x;
|
||||
};
|
||||
} forEach (_object getVariable [QGVAR(loaded), []]);
|
@ -1,7 +1,7 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Handle object being destroyed. Only runs on server.
|
||||
* Handle object being destroyed.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Object <OBJECT>
|
||||
@ -10,7 +10,7 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [object] call ace_cargo_fnc_handleDestroyed
|
||||
* [_object] call ace_cargo_fnc_handleDestroyed
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
@ -24,9 +24,9 @@ if (_loaded isEqualTo []) exitWith {};
|
||||
{
|
||||
// TODO Do we want to be able to recover destroyed equipment?
|
||||
if (_x isEqualType objNull) then {
|
||||
detach _x;
|
||||
deleteVehicle _x;
|
||||
};
|
||||
nil
|
||||
} count _loaded;
|
||||
} forEach _loaded;
|
||||
|
||||
[_vehicle] call FUNC(validateCargoSpace);
|
||||
|
Loading…
Reference in New Issue
Block a user