Skip to content

Commit e0cfa16

Browse files
committed
review(addon): type-validate :MISSION:SAVED: payload and defer final diary
1 parent 07c22ce commit e0cfa16

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

addons/extension/fnc_initSession.sqf

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,26 @@ addMissionEventHandler ["ExtensionCallback", {
160160
// ["ok", path]
161161
// ["partial", path, error]
162162
// ["error", error]
163-
private _status = _data param [0, ""];
164-
private _detail = _data param [1, ""];
165-
private _extra = _data param [2, ""];
163+
// Type-check each field: if the extension ever sends something
164+
// unexpected, fall back to an empty string rather than crashing
165+
// the callback handler with a type error in the switch below.
166+
private _status = _data param [0, "", [""]];
167+
private _detail = _data param [1, "", [""]];
168+
private _extra = _data param [2, "", [""]];
169+
170+
// finalDiary appends a final status entry to the OCAPInfo diary
171+
// subject so the interim "being saved" record from fnc_exportData.sqf
172+
// is followed by the authoritative outcome.
173+
private _finalDiary = {
174+
params ["_diaryHtml"];
175+
[[_diaryHtml], {
176+
params ["_html"];
177+
player createDiaryRecord [
178+
"OCAPInfo",
179+
["Status", _html]
180+
];
181+
}] remoteExec ["call", [0, -2] select isDedicated, true];
182+
};
166183

167184
switch (_status) do {
168185
case "ok": {
@@ -173,6 +190,10 @@ addMissionEventHandler ["ExtensionCallback", {
173190
2,
174191
[0, 0.8, 0, 1]
175192
] remoteExec ["CBA_fnc_notify", [0, -2] select isDedicated];
193+
[format[
194+
"<font color='#33FF33'>OCAP capture of %1 has been exported and uploaded successfully.</font>",
195+
briefingName
196+
]] call _finalDiary;
176197
};
177198
case "partial": {
178199
WARNING_2("Mission save complete but upload failed — path: %1 error: %2",_detail,_extra);
@@ -182,6 +203,10 @@ addMissionEventHandler ["ExtensionCallback", {
182203
2,
183204
[1, 0.8, 0, 1]
184205
] remoteExec ["CBA_fnc_notify", [0, -2] select isDedicated];
206+
[format[
207+
"<font color='#FFCC00'>OCAP capture of %1 was saved locally to %2, but the upload to the web server failed:</font><br/>%3",
208+
briefingName, _detail, _extra
209+
]] call _finalDiary;
185210
};
186211
case "error": {
187212
ERROR_MSG_1("Mission save failed: %1",_detail);
@@ -191,6 +216,10 @@ addMissionEventHandler ["ExtensionCallback", {
191216
2,
192217
[1, 0, 0, 1]
193218
] remoteExec ["CBA_fnc_notify", [0, -2] select isDedicated];
219+
[format[
220+
"<font color='#FF3333'>OCAP save of %1 failed:</font><br/>%2",
221+
briefingName, _detail
222+
]] call _finalDiary;
194223
};
195224
default {
196225
WARNING_1("Unknown :MISSION:SAVED: status: %1",_status);

addons/recorder/fnc_exportData.sqf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ OCAPEXTLOG(ARR4("Queued recording of mission",GVAR(missionName),"with tag",_save
134134

135135
// Interim "saving..." toast; the final result comes from :MISSION:SAVED:
136136
[format["OCAP saving %1 (%2 frames) — upload will follow", briefingName, _endFrameNumber], 1, [1, 1, 1, 1]] remoteExec ["CBA_fnc_notify", [0, -2] select isDedicated];
137+
// Interim diary record. The final "exported successfully" / "upload failed"
138+
// record is appended from the :MISSION:SAVED: ExtensionCallback handler in
139+
// fnc_initSession.sqf once the async save completes.
137140
[[GVAR(missionName), GVAR(captureFrameNo)], {
138141
params ["_missionName", "_endFrame"];
139142

@@ -146,7 +149,7 @@ OCAPEXTLOG(ARR4("Queued recording of mission",GVAR(missionName),"with tag",_save
146149
[
147150
"Status",
148151
format[
149-
"<font color='#33FF33'>OCAP capture of %1 has been exported with %2 frames saved.</font><br/><br/>Upload results have been logged.",
152+
"<font color='#FFFF33'>OCAP capture of %1 with %2 frames is being saved and uploaded.</font><br/><br/>Final status will be reported when the upload completes.",
150153
_missionName,
151154
_endFrame
152155
]

0 commit comments

Comments
 (0)