Skip to content
Merged
18 changes: 15 additions & 3 deletions addons/recorder/fnc_eh_fired_clientBullet.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ if (
{(_data select 18) isEqualTo false}
) exitWith {};

// Sent flag (index 20) — prevents duplicate sends between Deleted EH and PFH failsafe
_data set [20, false];

// HitExplosion
// Tracks a detonation of an explosive round, including the recipient and any nearby units who took damage.
_projectile addEventHandler ["HitExplosion", {
Expand Down Expand Up @@ -125,6 +128,9 @@ _projectile addEventHandler ["Explode", {
_projectile addEventHandler ["Deleted", {
params ["_projectile"];
private _data = _projectile getVariable QGVARMAIN(projectileData);
if (isNil "_data") exitWith {};
if (_data select 20) exitWith {}; // already sent by PFH failsafe
_data set [20, true];
(_data select 14) pushBack [
diag_tickTime,
EGVAR(recorder,captureFrameNo),
Expand All @@ -135,20 +141,26 @@ _projectile addEventHandler ["Deleted", {
}];

// Periodic position sampling for non-bullet projectiles (runs on owning client)
// Passes _data by reference in args so it survives projectile deletion.
// Acts as failsafe sender when the Deleted EH doesn't fire (e.g. locality
// transfer on dedicated server, or engine cleanup bypassing Deleted).
if ((_data select 17) isNotEqualTo "shotBullet") then {
[{
params ["_args", "_handle"];
_args params ["_projectile"];
_args params ["_projectile", "_data"];
if (isNull _projectile) exitWith {
if !(_data select 20) then {
_data set [20, true];
[QGVARMAIN(handleFiredManData), [_data]] call CBA_fnc_serverEvent;
};
[_handle] call CBA_fnc_removePerFrameHandler;
};
private _data = _projectile getVariable QGVARMAIN(projectileData);
(_data select 14) pushBack [
diag_tickTime,
EGVAR(recorder,captureFrameNo),
(getPosASL _projectile) joinString ","
];
}, EGVAR(settings,frameCaptureDelay), [_projectile]] call CBA_fnc_addPerFrameHandler;
}, EGVAR(settings,frameCaptureDelay), [_projectile, _data]] call CBA_fnc_addPerFrameHandler;
};

TRACE_1("Finished applying EH",_projectile);
Expand Down
30 changes: 30 additions & 0 deletions addons/recorder/fnc_eh_fired_server.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,36 @@
_projectile setVariable [QGVARMAIN(placedId), _placedId, true];
TRACE_2("Sending placed object data to extension",_placedId,_data);
[":PLACED:CREATE:", _data] call EFUNC(extension,sendData);

// Server-side fallback: when the placer disconnects the mine transfers to
// the server and the client-side Explode/Deleted EHs are lost. Re-add them
// here via the Local EH so detonation is still captured.
_projectile addEventHandler ["Local", {
params ["_entity", "_isLocal"];
if (!_isLocal) exitWith {};
// Mine just became local to this machine (server) — add lifecycle EHs
_entity setVariable [QGVARMAIN(detonated), false];

_entity addEventHandler ["Explode", {
params ["_projectile", "_pos"];
if (_projectile getVariable [QGVARMAIN(detonated), true]) exitWith {};
_projectile setVariable [QGVARMAIN(detonated), true];
private _placedId = _projectile getVariable [QGVARMAIN(placedId), -1];
[QGVARMAIN(handlePlacedEvent), [[
GVAR(captureFrameNo), _placedId, "detonated", _pos joinString ","
]]] call CBA_fnc_localEvent;
}];

_entity addEventHandler ["Deleted", {
params ["_projectile"];
if (_projectile getVariable [QGVARMAIN(detonated), true]) exitWith {};
_projectile setVariable [QGVARMAIN(detonated), true];
private _placedId = _projectile getVariable [QGVARMAIN(placedId), -1];
[QGVARMAIN(handlePlacedEvent), [[
GVAR(captureFrameNo), _placedId, "deleted", (getPosASL _projectile) joinString ","
]]] call CBA_fnc_localEvent;
}];
Comment thread
fank marked this conversation as resolved.
Outdated
}];
}] call CBA_fnc_addEventHandler;

// Handle placed object lifecycle events (detonation, deletion)
Expand Down