-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathfnc_exportData.sqf
More file actions
168 lines (134 loc) · 6.39 KB
/
fnc_exportData.sqf
File metadata and controls
168 lines (134 loc) · 6.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/* ----------------------------------------------------------------------------
FILE: fnc_exportData.sqf
FUNCTION: OCAP_recorder_fnc_exportData
Description:
This function facilitates the actual endMission and save events in the extension, prompting it to pack the mission and upload it to the web component.
Called directly, it is subject to the <OCAP_settings_minMissionTime> setting, and will not export if the mission is not long enough. It can also be called using <OCAP_listener_exportData> to bypass this check.
When <OCAP_settings_saveMissionEnded> is true, this function will be called automatically when the mission ends.
When <OCAP_settings_saveOnEmpty> is true, this function will execute when the last player leaves the mission (to lobby or when disconnecting).
<OCAP_settings_saveTag> is used to tag the mission with a custom string, which can be used to identify the mission in the web component.
Parameters:
_side - The winning side [optional, Side]
_message - A custom description of how the victory was achieved [optional, String]
_tag - A custom tag to override that which is defined in userconfig.hpp that will make it filterable in web [optional, String]
Returns:
Nothing
Examples:
(start code)
// "Mission ended"
[] call FUNC(exportData);
// "BLUFOR Win."
[west] call FUNC(exportData);
// "OPFOR Win. OPFOR controlled all sectors!
[east, "OPFOR controlled all sectors!"] call FUNC(exportData);
// "Independent Win. INDFOR stole the intel!"
// Mission is saved under filterable "SnatchAndGrab" tag on web
[independent, "INDFOR stole the intel!", "SnatchAndGrab"] call FUNC(exportData);
["OCAP_exportData", west] call CBA_fnc_serverEvent;
(end code)
Public:
No
Author:
Dell, Zealot, IndigoFox, TyroneMF
---------------------------------------------------------------------------- */
#include "script_component.hpp"
params ["_side", "_message", "_tag", ["_overrideLimits", false, [false]]];
// overrideLimits will bypass any restriction checks, in case someone wants to save a mission even if doesn't meet their usual criteria
if (isNil QGVAR(startTime)) exitWith {
// if recording hasn't started, there's nothing to save
LOG(["Export data call received, but recording of this session hasn't yet started."]);
{
[{!isNull player}, {
player createDiaryRecord [
"OCAPInfo",
[
"Status",
"<font color='#33FF33'>OCAP was asked to save, but recording hasn't started yet.</font>"
], taskNull, "", false
];
player setDiarySubjectPicture [
"OCAPInfo",
"\A3\ui_f\data\igui\cfg\simpleTasks\types\use_ca.paa"
];
}] call CBA_fnc_waitUntilAndExecute;
} remoteExecCall ["call", 0, true];
};
_elapsedTime = time - GVAR(startTime);
_frameTimeDuration = (GVAR(frameCaptureDelay) * GVAR(captureFrameNo)) / 60;
TRACE_5("Save attempted. Elapsed Time =",_elapsedTime," Frame Count * Delay Duration =",_frameTimeDuration," delta =",_elapsedTime - _frameTimeDuration);
if (_frameTimeDuration < GVAR(minMissionTime) && !_overrideLimits) exitWith {
// if the total duration in minutes is not met based on how many frames have been recorded & the frame capture delay,
// then we won't save, but will continue recording in case admins want to save once that threshold is met.
// allow this restriction to be overriden
LOG("Save attempted, but the minimum recording duration hasn't been met. Not saving, continuing to record.");
["OCAP attempted to save, but the minimum recording duration hasn't been met. Recording will continue.", 1, [1, 1, 1, 1]] remoteExecCall ["CBA_fnc_notify", [0, -2] select isDedicated];
{
player createDiaryRecord [
"OCAPInfo",
[
"Status",
(
"<font color='#FFFF33'>OCAP capture of " + briefingName + " has not yet reached the minimum duration to save it. Recording will continue.</font>"
)
]
];
player setDiarySubjectPicture [
"OCAPInfo",
"\A3\ui_f\data\igui\cfg\simpleTasks\types\danger_ca.paa"
];
} remoteExec ["call", 0, false];
};
call FUNC(stopRecording);
private _endFrameNumber = GVAR(captureFrameNo);
if (!isNil QGVAR(PFHObject)) then {
[GVAR(PFHObject)] call CBA_fnc_deletePerFrameHandlerObject;
GVAR(PFHObject) = nil;
};
private _winSide = if (isNil "_side") then {""} else {if (_side isEqualTo sideUnknown) then {""} else {str _side}};
private _endMessage = if (isNil "_message") then {if (_winSide == "") then {"Mission ended"} else {""}} else {_message};
[":EVENT:ENDMISSION:", [
_endFrameNumber,
_winSide,
_endMessage
]] call EFUNC(extension,sendData);
private _saveTag = if (!isNil "_tag") then {_tag} else {EGVAR(settings,saveTag)};
INFO_3("Saving recording — mission: %1 | frames: %2 | tag: %3",GVAR(missionName),_endFrameNumber,_saveTag);
// Save is now asynchronous — the extension returns immediately and will fire
// a :MISSION:SAVED: ExtensionCallback when the write + upload finishes.
// The final success/failure notification is driven from that callback in
// fnc_initSession.sqf.
INFO_2("Mission save queued — mission: %1 | frames: %2",GVAR(missionName),_endFrameNumber);
[":MISSION:SAVE:", []] call EFUNC(extension,sendData);
OCAPEXTLOG(ARR4("Queued recording of mission",GVAR(missionName),"with tag",_saveTag));
// Interim "saving..." toast; the final result comes from :MISSION:SAVED:
[format["OCAP saving %1 (%2 frames) — upload will follow", briefingName, _endFrameNumber], 1, [1, 1, 1, 1]] remoteExec ["CBA_fnc_notify", [0, -2] select isDedicated];
[[GVAR(missionName), GVAR(captureFrameNo)], {
params ["_missionName", "_endFrame"];
player setDiarySubjectPicture [
"OCAPInfo",
"\A3\ui_f\data\igui\cfg\simpleTasks\types\upload_ca.paa"
];
player createDiaryRecord [
"OCAPInfo",
[
"Status",
format[
"<font color='#33FF33'>OCAP capture of %1 has been exported with %2 frames saved.</font><br/><br/>Upload results have been logged.",
_missionName,
_endFrame
]
]
];
}] remoteExec ["call", [0, -2] select isDedicated, true];
// reset vars in case a new recording is started
GVAR(captureFrameNo) = 0;
publicVariable QGVAR(captureFrameNo);
GVAR(startTime) = nil;
{
_x setVariable [QGVARMAIN(isInitialized), nil];
_x setVariable [QGVARMAIN(exclude), nil];
_x setVariable [QGVARMAIN(id), nil];
_x setVariable [QGVARMAIN(unitType), nil];
} count (allUnits + allDeadMen + vehicles);
GVAR(nextId) = 0;
EGVAR(extension,sessionReady) = false;