Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/database/XEH_prep.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PREP(addEventHandlers);
PREP(getStaticObjects);
PREP(handleChatMessage);
PREP(initDB);
PREP(newMission);
PREP(radioEvent);
PREP(metricsLoop);
PREP(eh_fired_server);
Expand Down
13 changes: 8 additions & 5 deletions addons/database/fnc_initDB.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,14 @@ addMissionEventHandler ["ExtensionCallback", {
INFO("Mission saved to DB. Starting data send.");
GVAR(dbValid) = true;

// set initial stuff unique to DB
[] spawn FUNC(getStaticObjects);
call FUNC(addEventHandlers);
call FUNC(eh_fired_server);
call FUNC(metricsLoop);
// Only run one-time setup on first init, not on re-registration after export
if (isNil QGVAR(initialSetupDone)) then {
GVAR(initialSetupDone) = true;
[] spawn FUNC(getStaticObjects);
call FUNC(addEventHandlers);
call FUNC(eh_fired_server);
call FUNC(metricsLoop);
};
};
}];

Expand Down
37 changes: 37 additions & 0 deletions addons/database/fnc_newMission.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* ----------------------------------------------------------------------------
FILE: fnc_newMission.sqf

FUNCTION: OCAP_database_fnc_newMission

Description:
Re-registers a new mission session with the extension after a previous
recording was exported via fnc_exportData. Reuses the cached world and
mission context from the initial initDB call (same mission is still running).

The existing ExtensionCallback handler (added during initDB) will process
the :MISSION:OK: response and set dbValid = true.

Called from fnc_startRecording when starting a fresh recording with
dbValid = false.

Parameters:
None

Returns:
Nothing

Public:
No

Author:
Fank
---------------------------------------------------------------------------- */
#include "script_component.hpp"

if (isNil QGVAR(worldContext) || isNil QGVAR(missionContext)) exitWith {
ERROR("Cannot re-register mission: cached world/mission context is nil. Full initDB required.");
};

INFO("Re-registering new mission with extension");
GVAR(initTimer) = diag_tickTime;
[":NEW:MISSION:", [GVAR(worldContext), GVAR(missionContext)], 'ocap_recorder'] call EFUNC(extension,sendData);
8 changes: 6 additions & 2 deletions addons/extension/fnc_sendData.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ _res params ["_result","_returnCode","_errorCode"];

diag_log text format ["[OCAP] [EXT] << Response: result='%1', returnCode=%2, errorCode=%3", _result, _returnCode, _errorCode];

if (_errorCode != 0 || _returnCode != 0) exitWith {
diag_log text format ["[OCAP] [EXT] ERROR when calling extension: %1", [_result, _returnCode, _errorCode, _command, _args]];
if (_returnCode != 0) exitWith {
diag_log text format ["[OCAP] [EXT] ERROR from extension (returnCode=%1): %2", _returnCode, [_result, _returnCode, _errorCode, _command, _args]];
nil
};

if (_errorCode != 0) then {
diag_log text format ["[OCAP] [EXT] WARNING: Arma errorCode=%1 for command '%2' (result still valid)", _errorCode, _command];
};

// Parse the response - new format: ["ok", <result>] or ["error", "<message>"]
if (_result isEqualTo "") exitWith {
diag_log text "[OCAP] [EXT] WARNING: Empty response from extension";
Expand Down
1 change: 1 addition & 0 deletions addons/recorder/fnc_exportData.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,4 @@ GVAR(startTime) = nil;
_x setVariable [QGVARMAIN(unitType), nil];
} count (allUnits + allDeadMen + vehicles);
GVAR(nextId) = 0;
EGVAR(database,dbValid) = false;
14 changes: 13 additions & 1 deletion addons/recorder/fnc_startRecording.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,19 @@ _missionDateFormat append (date apply {if (_x < 10) then {"0" + str _x} else {st
}] remoteExec ["call", [0, -2] select isDedicated, true];

if (GVAR(captureFrameNo) == 0) then {
call FUNC(captureLoop);
if (!EGVAR(database,dbValid)) then {
// Previous recording was exported — re-register new mission with extension
call EFUNC(database,newMission);
// Wait for extension to confirm new mission before starting capture
[{EGVAR(database,dbValid)}, {
call FUNC(captureLoop);
}, [], 30, {
ERROR("Timeout waiting for new mission confirmation from extension. Recording will not start.");
["OCAP failed to start recording: extension did not respond", 1, [1, 0, 0, 1]] remoteExecCall ["CBA_fnc_notify", [0, -2] select isDedicated];
}] call CBA_fnc_waitUntilAndExecute;
} else {
call FUNC(captureLoop);
};
};

[QGVARMAIN(customEvent), ["generalEvent", "Recording started."]] call CBA_fnc_serverEvent;
Expand Down
Loading