2015-02-21 20:53:07 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Add an entry to the specified log
|
2015-02-21 20:47:10 +00:00
|
|
|
*
|
2015-02-21 20:53:07 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: The patient <OBJECT>
|
|
|
|
* 1: The log type <STRING>
|
|
|
|
* 2: The message <STRING>
|
|
|
|
* 3: The arguments for localization <ARRAY>
|
|
|
|
*
|
|
|
|
* Return Value:
|
2015-08-22 14:25:10 +00:00
|
|
|
* None
|
2015-02-21 20:53:07 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
2015-02-21 20:47:10 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-22 14:25:10 +00:00
|
|
|
private ["_moment", "_logVarName", "_log","_newLog", "_logs"];
|
2015-08-22 16:33:06 +00:00
|
|
|
params ["_unit", "_type", "_message", "_arguments"];
|
2015-02-21 20:47:10 +00:00
|
|
|
|
|
|
|
if (!local _unit) exitwith {
|
2015-08-22 16:33:06 +00:00
|
|
|
[_this, QFUNC(addToLog), _unit] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */
|
2015-02-21 20:47:10 +00:00
|
|
|
};
|
|
|
|
|
2015-08-22 16:33:06 +00:00
|
|
|
date params ["", "", "", "_minute", "_hour"];
|
2015-08-22 14:25:10 +00:00
|
|
|
|
2015-08-29 14:52:28 +00:00
|
|
|
_moment = format [ (["%1:%2", "%1:0%2"] select (_minute < 10)), _hour, _minute];
|
2015-08-29 13:29:02 +00:00
|
|
|
|
2015-02-21 20:47:10 +00:00
|
|
|
_logVarName = format[QGVAR(logFile_%1), _type];
|
|
|
|
|
|
|
|
_log = _unit getvariable [_logVarName, []];
|
|
|
|
if (count _log >= 8) then {
|
|
|
|
_newLog = [];
|
|
|
|
{
|
|
|
|
// ensure the first element will not be added
|
|
|
|
if (_foreachIndex > 0) then {
|
|
|
|
_newLog pushback _x;
|
|
|
|
};
|
2015-08-22 14:25:10 +00:00
|
|
|
} foreach _log;
|
2015-02-21 20:47:10 +00:00
|
|
|
_log = _newLog;
|
|
|
|
};
|
2015-08-22 14:25:10 +00:00
|
|
|
_log pushback [_message, _moment, _type, _arguments];
|
2015-02-21 20:47:10 +00:00
|
|
|
|
|
|
|
_unit setvariable [_logVarName, _log, true];
|
2015-06-09 22:30:02 +00:00
|
|
|
["medical_onLogEntryAdded", [_unit, _type, _message, _arguments]] call EFUNC(common,localEvent);
|
2015-02-28 10:47:35 +00:00
|
|
|
|
|
|
|
_logs = _unit getvariable [QGVAR(allLogs), []];
|
|
|
|
if !(_logVarName in _logs) then {
|
|
|
|
_logs pushback _logVarName;
|
|
|
|
_unit setvariable [QGVAR(allLogs), _logs, true];
|
|
|
|
};
|