mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Use single queue for blood cleanup (#4586)
This commit is contained in:
parent
08a378bb2d
commit
20f40f8c55
@ -3,4 +3,5 @@ PREP(handleWoundReceived);
|
||||
PREP(isBleeding);
|
||||
PREP(onBleeding);
|
||||
PREP(createBlood);
|
||||
PREP(serverCleanupBlood);
|
||||
PREP(spurt);
|
||||
|
@ -10,13 +10,17 @@ if (isServer) then {
|
||||
|
||||
[QGVAR(bloodDropCreated), {
|
||||
params ["_bloodDrop"];
|
||||
GVAR(bloodDrops) pushBack _bloodDrop;
|
||||
// Add to created queue with format [expireTime, object]
|
||||
private _index = GVAR(bloodDrops) pushBack [(CBA_missionTime + BLOOD_OBJECT_LIFETIME), _bloodDrop];
|
||||
|
||||
if (count GVAR(bloodDrops) >= MAX_BLOOD_OBJECTS) then {
|
||||
private _deletedBloodDrop = GVAR(bloodDrops) deleteAt 0;
|
||||
(GVAR(bloodDrops) deleteAt 0) params ["", "_deletedBloodDrop"];
|
||||
deleteVehicle _deletedBloodDrop;
|
||||
};
|
||||
|
||||
[{deleteVehicle _this}, _bloodDrop, BLOOD_OBJECT_LIFETIME] call CBA_fnc_waitAndExecute;
|
||||
if (_index == 1) then { // Start the waitAndExecute loop
|
||||
[FUNC(serverCleanupBlood), [], BLOOD_OBJECT_LIFETIME] call CBA_fnc_waitAndExecute;
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
};
|
||||
|
||||
@ -30,7 +34,7 @@ if (isServer) then {
|
||||
} else {
|
||||
{allUnits select {(local _x) && {[_x] call FUNC(isBleeding)}}}; // filter all local bleeding units
|
||||
};
|
||||
|
||||
|
||||
private _stateMachine = [_listcode, true] call CBA_statemachine_fnc_create;
|
||||
[_stateMachine, {call FUNC(onBleeding)}, {}, {}, "Bleeding"] call CBA_statemachine_fnc_addState;
|
||||
|
||||
|
23
addons/medical_blood/functions/fnc_serverCleanupBlood.sqf
Normal file
23
addons/medical_blood/functions/fnc_serverCleanupBlood.sqf
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Loop that cleans up blood
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* ReturnValue:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
(GVAR(bloodDrops) deleteAt 0) params ["", "_deletedBloodDrop"];
|
||||
deleteVehicle _deletedBloodDrop;
|
||||
|
||||
// If we cleaned out the array, exit loop
|
||||
if (GVAR(bloodDrops) isEqualTo []) exitWith {};
|
||||
|
||||
// Wait until the next blood drop in the queue will expire
|
||||
(GVAR(bloodDrops) select 0) params ["_expireTime"];
|
||||
[FUNC(serverCleanupBlood), [], (_expireTime - CBA_missionTime)] call CBA_fnc_waitAndExecute;
|
Loading…
Reference in New Issue
Block a user