mirror of
https://github.com/indig0fox/Arma3-AttendanceTracker.git/
synced 2025-12-08 01:41:49 -06:00
add hemtt support, major refactor
- no longer supports server events - can now more easily build using hemtt - extension vastly improved in both structure and functionality - tested on listen server - includes schema change
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -8,3 +8,10 @@ config.json
|
||||
/extension/@AttendanceTracker/
|
||||
|
||||
\@AttendanceTracker.7z
|
||||
*.pbo
|
||||
.hemttout
|
||||
hemtt
|
||||
hemtt.exe
|
||||
*.biprivatekey
|
||||
|
||||
*.bk
|
||||
|
||||
38
.hemtt/project.toml
Normal file
38
.hemtt/project.toml
Normal file
@@ -0,0 +1,38 @@
|
||||
name = "IFX Attendance Tracker"
|
||||
author = "IndigoFox"
|
||||
prefix = "attendancetracker"
|
||||
mainprefix = "x"
|
||||
|
||||
[version]
|
||||
path = "addons/main/script_version.hpp" # Default
|
||||
git_hash = 6 # Default: 8
|
||||
|
||||
[files]
|
||||
include = [
|
||||
"AttendanceTracker.config.json",
|
||||
"LICENSE",
|
||||
"README",
|
||||
"mod.cpp",
|
||||
"*.dll",
|
||||
"*.so",
|
||||
]
|
||||
|
||||
# Launched with `hemtt launch`
|
||||
[hemtt.launch.default]
|
||||
workshop = [
|
||||
"450814997", # CBA_A3's Workshop ID
|
||||
]
|
||||
dlc = []
|
||||
optionals = []
|
||||
parameters = [
|
||||
"-skipIntro", # These parameters are passed to the Arma 3 executable
|
||||
"-noSplash", # They do not need to be added to your list
|
||||
"-showScriptErrors", # You can add additional parameters here
|
||||
"-debug",
|
||||
"-filePatching",
|
||||
]
|
||||
executable = "arma3_x64" # Default: "arma3_x64"
|
||||
|
||||
[hemtt.release]
|
||||
sign = false # Default: true
|
||||
archive = true # Default: true
|
||||
@@ -1,87 +0,0 @@
|
||||
addMissionEventHandler ["ExtensionCallback", {
|
||||
params ["_name", "_function", "_data"];
|
||||
if !(_name == "AttendanceTracker") exitWith {};
|
||||
|
||||
// Validate data param
|
||||
if (isNil "_data") then {_data = ""};
|
||||
|
||||
if (_data isEqualTo "") exitWith {
|
||||
[
|
||||
format ["Callback empty data: %1", _function],
|
||||
"WARN"
|
||||
] call attendanceTracker_fnc_log;
|
||||
false;
|
||||
};
|
||||
|
||||
if (typeName _data != "STRING") exitWith {
|
||||
[
|
||||
format ["Callback invalid data: %1: %2", _function, _data],
|
||||
"WARN"
|
||||
] call attendanceTracker_fnc_log;
|
||||
false;
|
||||
};
|
||||
|
||||
if (missionNamespace getVariable ["AttendanceTracker_" + "debug", true]) then {
|
||||
diag_log format ["Raw callback: %1: %2", _function, _data];
|
||||
};
|
||||
|
||||
// Parse response from string array
|
||||
private "_response";
|
||||
try {
|
||||
// diag_log format ["Raw callback: %1: %2", _function, _data];
|
||||
_response = parseSimpleArray _data;
|
||||
if (_response isEqualTo []) then {
|
||||
throw "Failed to parse response as array";
|
||||
};
|
||||
} catch {
|
||||
[
|
||||
format ["Callback invalid data: %1: %2: %3", _function, _data, _exception],
|
||||
"WARN"
|
||||
] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
if (isNil "_response") exitWith {false};
|
||||
|
||||
switch (_function) do {
|
||||
case "connectDB": {
|
||||
systemChat format ["AttendanceTracker: %1", _response#0];
|
||||
[_response#0, _response#1, _function] call attendanceTracker_fnc_log;
|
||||
if (_response#0 == "SUCCESS") then {
|
||||
// log world info
|
||||
private _response = "AttendanceTracker" callExtension [
|
||||
"logWorld",
|
||||
[
|
||||
[(call attendanceTracker_fnc_getWorldInfo)] call CBA_fnc_encodeJSON
|
||||
]
|
||||
];
|
||||
|
||||
missionNamespace setVariable ["AttendanceTracker_DBConnected", true];
|
||||
};
|
||||
};
|
||||
case "writeWorldInfo": {
|
||||
if (_response#0 == "WORLD_ID") then {
|
||||
AttendanceTracker_worldId = _response#1;
|
||||
|
||||
// world info written. mission info depends on that, so now we'll write it
|
||||
|
||||
// log mission info and get back the row Id to send with future messages
|
||||
private _response = "AttendanceTracker" callExtension [
|
||||
"logMission",
|
||||
[
|
||||
[AttendanceTracker getVariable ["missionContext", createHashMap]] call CBA_fnc_encodeJSON
|
||||
]
|
||||
];
|
||||
};
|
||||
};
|
||||
case "writeMission": {
|
||||
if (_response#0 == "MISSION_ID") then {
|
||||
// mission has written so lets finish out init and set missionId for the returned PK, activating the ability for attendance records to send.
|
||||
AttendanceTracker_missionId = _response#1;
|
||||
};
|
||||
};
|
||||
default {
|
||||
_response call attendanceTracker_fnc_log;
|
||||
};
|
||||
};
|
||||
true;
|
||||
}];
|
||||
@@ -1,3 +0,0 @@
|
||||
private _database = "AttendanceTracker" callExtension "connectDB";
|
||||
// systemChat "AttendanceTracker: Connecting to database...";
|
||||
["Connecting to database...", "INFO"] call attendanceTracker_fnc_log;
|
||||
@@ -1,240 +0,0 @@
|
||||
[
|
||||
["OnUserConnected", {
|
||||
params ["_networkId", "_clientStateNumber", "_clientState"];
|
||||
|
||||
[format ["(EventHandler) OnUserConnected fired: %1", _this], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
|
||||
private _userInfo = (getUserInfo _networkId);
|
||||
if (isNil "_userInfo") exitWith {
|
||||
[format ["(EventHandler) OnUserConnected: No user info found for %1", _networkId], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
_userInfo params ["_playerID", "_ownerId", "_playerUID", "_profileName", "_displayName", "_steamName", "_clientState", "_isHC", "_adminState", "_networkInfo", "_unit"];
|
||||
if (_isHC) exitWith {
|
||||
[format ["(EventHandler) OnUserConnected: %1 is HC, skipping", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
(AttendanceTracker getVariable ["allUsers", createHashMap]) set [_networkId, _userInfo];
|
||||
|
||||
|
||||
[ // write d/c for past events
|
||||
"Server",
|
||||
_playerID,
|
||||
_playerUID,
|
||||
_profileName,
|
||||
_steamName
|
||||
] call attendanceTracker_fnc_writeDisconnect;
|
||||
|
||||
// [
|
||||
// "Server",
|
||||
// _playerID,
|
||||
// _playerUID,
|
||||
// _profileName,
|
||||
// _steamName,
|
||||
// nil,
|
||||
// nil
|
||||
// ] call attendanceTracker_fnc_writeConnect;
|
||||
|
||||
// start CBA PFH
|
||||
[format ["(EventHandler) OnUserConnected: Starting CBA PFH for %1", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
[
|
||||
{
|
||||
params ["_args", "_handle"];
|
||||
// check if player is still connected
|
||||
private _playerID = _args select 1;
|
||||
private _playerUID = _args select 2;
|
||||
if (allUsers find _playerID == -1) exitWith {
|
||||
[format ["(EventHandler) OnUserConnected: %1 (UID %2) is no longer connected, exiting CBA PFH", _playerUID], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
_args call attendanceTracker_fnc_writeConnect;
|
||||
[_handle] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
_args call attendanceTracker_fnc_writeConnect;
|
||||
},
|
||||
missionNamespace getVariable ["AttendanceTracker_" + "dbupdateintervalseconds", 90],
|
||||
[
|
||||
"Server",
|
||||
_playerID,
|
||||
_playerUID,
|
||||
_profileName,
|
||||
_steamName,
|
||||
nil,
|
||||
nil
|
||||
]
|
||||
] call CBA_fnc_addPerFrameHandler;
|
||||
}],
|
||||
["OnUserDisconnected", {
|
||||
params ["_networkId", "_clientStateNumber", "_clientState"];
|
||||
|
||||
[format ["(EventHandler) OnUserDisconnected fired: %1", _this], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
|
||||
if !(call attendanceTracker_fnc_missionLoaded) exitWith {
|
||||
[format ["(EventHandler) OnUserDisconnected: Server is in Mission Asked, likely mission selection state. Skipping.."], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
private _userInfo = (AttendanceTracker getVariable ["allUsers", createHashMap]) get _networkId;
|
||||
if (isNil "_userInfo") exitWith {
|
||||
[format ["(EventHandler) OnUserDisconnected: No user info found for %1", _networkId], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
_userInfo params ["_playerID", "_ownerId", "_playerUID", "_profileName", "_displayName", "_steamName", "_clientState", "_isHC", "_adminState", "_networkInfo", "_unit"];
|
||||
if (_isHC) exitWith {
|
||||
[format ["(EventHandler) OnUserDisconnected: %1 is HC, skipping", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
[
|
||||
"Server",
|
||||
_playerID,
|
||||
_playerUID,
|
||||
_profileName,
|
||||
_steamName
|
||||
] call attendanceTracker_fnc_writeConnect;
|
||||
}],
|
||||
["PlayerConnected", {
|
||||
params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
|
||||
|
||||
[format ["(EventHandler) PlayerConnected fired: %1", _this], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
|
||||
if !(call attendanceTracker_fnc_missionLoaded) exitWith {
|
||||
[format ["(EventHandler) PlayerConnected: Server is in Mission Asked, likely mission selection state. Skipping.."], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
private _userInfo = (getUserInfo _idstr);
|
||||
if (isNil "_userInfo") exitWith {
|
||||
[format ["(EventHandler) PlayerConnected: No user info found for %1", _idstr], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
_userInfo params ["_playerID", "_ownerId", "_playerUID", "_profileName", "_displayName", "_steamName", "_clientState", "_isHC", "_adminState", "_networkInfo", "_unit"];
|
||||
if (_isHC) exitWith {
|
||||
[format ["(EventHandler) PlayerConnected: %1 is HC, skipping", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
(AttendanceTracker getVariable ["allUsers", createHashMap]) set [_playerID, _userInfo];
|
||||
|
||||
|
||||
[ // write d/c for past events
|
||||
"Mission",
|
||||
_playerID,
|
||||
_playerUID,
|
||||
_profileName,
|
||||
_steamName,
|
||||
_jip,
|
||||
nil
|
||||
] call attendanceTracker_fnc_writeDisconnect;
|
||||
|
||||
// [
|
||||
// "Mission",
|
||||
// _playerID,
|
||||
// _playerUID,
|
||||
// _profileName,
|
||||
// _steamName,
|
||||
// _jip,
|
||||
// roleDescription _unit
|
||||
// ] call attendanceTracker_fnc_writeConnect;
|
||||
|
||||
// start CBA PFH
|
||||
[format ["(EventHandler) PlayerConnected: Starting CBA PFH for %1", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
[
|
||||
{
|
||||
params ["_args", "_handle"];
|
||||
// check if player is still connected
|
||||
private _playerID = _args select 1;
|
||||
private _playerUID = _args select 2;
|
||||
private _userInfo = getUserInfo _playerID;
|
||||
private _clientStateNumber = 0;
|
||||
if (!isNil "_userInfo" && {count _userInfo >= 7}) then {
|
||||
_clientStateNumber = _userInfo select 6;
|
||||
};
|
||||
if (_clientStateNumber < 6) exitWith {
|
||||
[format ["(EventHandler) PlayerConnected: %1 (UID) is no longer connected to the mission, exiting CBA PFH", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
_args call attendanceTracker_fnc_writeConnect;
|
||||
[_handle] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
_args call attendanceTracker_fnc_writeConnect;
|
||||
},
|
||||
missionNamespace getVariable ["AttendanceTracker_" + "dbupdateintervalseconds", 300],
|
||||
[
|
||||
"Mission",
|
||||
_playerID,
|
||||
_playerUID,
|
||||
_profileName,
|
||||
_steamName,
|
||||
_jip,
|
||||
roleDescription _unit
|
||||
]
|
||||
] call CBA_fnc_addPerFrameHandler;
|
||||
}],
|
||||
["PlayerDisconnected", {
|
||||
// NOTE: HandleDisconnect returns a DIFFERENT _id than PlayerDisconnected and above handlers, so we can't use it here
|
||||
params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
|
||||
|
||||
[format ["(EventHandler) HandleDisconnect fired: %1", _this], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
|
||||
if !(call attendanceTracker_fnc_missionLoaded) exitWith {
|
||||
[format ["(EventHandler) HandleDisconnect: Server is in Mission Asked, likely mission selection state. Skipping.."], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
private _userInfo = (AttendanceTracker getVariable ["allUsers", createHashMap]) get _idstr;
|
||||
if (isNil "_userInfo") exitWith {
|
||||
[format ["(EventHandler) HandleDisconnect: No user info found for %1", _idstr], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
_userInfo params ["_playerID", "_ownerId", "_playerUID", "_profileName", "_displayName", "_steamName", "_clientState", "_isHC", "_adminState", "_networkInfo", "_unit", "_rowId"];
|
||||
if (_isHC) exitWith {
|
||||
[format ["(EventHandler) HandleDisconnect: %1 is HC, skipping", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
[
|
||||
"Mission",
|
||||
_playerID,
|
||||
_playerUID,
|
||||
_profileName,
|
||||
_steamName,
|
||||
_jip,
|
||||
nil
|
||||
] call attendanceTracker_fnc_writeConnect;
|
||||
|
||||
false;
|
||||
}],
|
||||
["OnUserKicked", {
|
||||
params ["_networkId", "_kickTypeNumber", "_kickType", "_kickReason", "_kickMessageIncReason"];
|
||||
|
||||
[format ["(EventHandler) OnUserKicked fired: %1", _this], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
|
||||
if !(call attendanceTracker_fnc_missionLoaded) exitWith {
|
||||
[format ["(EventHandler) OnUserKicked: Server is in Mission Asked, likely mission selection state. Skipping.."], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
private _userInfo = (AttendanceTracker getVariable ["allUsers", createHashMap]) get _networkId;
|
||||
if (isNil "_userInfo") exitWith {
|
||||
[format ["(EventHandler) OnUserKicked: No user info found for %1", _networkId], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
_userInfo params ["_playerID", "_ownerId", "_playerUID", "_profileName", "_displayName", "_steamName", "_clientState", "_isHC", "_adminState", "_networkInfo", "_unit"];
|
||||
|
||||
if (_isHC) exitWith {
|
||||
[format ["(EventHandler) OnUserKicked: %1 is HC, skipping", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
[
|
||||
"Server",
|
||||
_playerID,
|
||||
_playerUID,
|
||||
_profileName,
|
||||
_steamName,
|
||||
nil,
|
||||
nil
|
||||
] call attendanceTracker_fnc_writeConnect;
|
||||
|
||||
[
|
||||
"Mission",
|
||||
_playerID,
|
||||
_playerUID,
|
||||
_profileName,
|
||||
_steamName,
|
||||
nil,
|
||||
nil
|
||||
] call attendanceTracker_fnc_writeConnect;
|
||||
}]
|
||||
];
|
||||
@@ -1 +0,0 @@
|
||||
(parseSimpleArray ("AttendanceTracker" callExtension "getMissionHash")) select 0;
|
||||
@@ -1 +0,0 @@
|
||||
parseSimpleArray ('AttendanceTracker' callExtension "getSettings");
|
||||
@@ -1,21 +0,0 @@
|
||||
params [
|
||||
["_message", "", [""]],
|
||||
["_level", "INFO", [""]],
|
||||
"_function"
|
||||
];
|
||||
|
||||
if (isNil "_message") exitWith {false};
|
||||
if (
|
||||
missionNamespace getVariable ["AttendanceTracker_debug", false] &&
|
||||
_level != "WARN" && _level != "ERROR"
|
||||
) exitWith {};
|
||||
|
||||
"AttendanceTracker" callExtension ["log", [_level, _message]];
|
||||
|
||||
if (!isNil "_function") then {
|
||||
diag_log formatText["[AttendanceTracker] (%1): <%2> %3", _level, _function, _message];
|
||||
} else {
|
||||
diag_log formatText["[AttendanceTracker] (%1): %2", _level, _message];
|
||||
};
|
||||
|
||||
true;
|
||||
@@ -1,71 +0,0 @@
|
||||
|
||||
AttendanceTracker = false call CBA_fnc_createNamespace;
|
||||
|
||||
AttendanceTracker_missionStartTimestamp = call attendanceTracker_fnc_timestamp;
|
||||
diag_log format ["AttendanceTracker: Mission started at %1", AttendanceTracker_missionStartTimestamp];
|
||||
AttendanceTracker_missionHash = call attendanceTracker_fnc_getMissionHash;
|
||||
diag_log format ["AttendanceTracker: Mission hash is %1", AttendanceTracker_missionHash];
|
||||
|
||||
_settings = call attendanceTracker_fnc_getSettings;
|
||||
if (count _settings > 0) then {
|
||||
for "_i" from 0 to (count _settings) - 1 do {
|
||||
_setting = _settings select _i;
|
||||
_key = _setting select 0;
|
||||
_value = _setting select 1;
|
||||
missionNamespace setVariable ["AttendanceTracker_" + _key, _value];
|
||||
};
|
||||
} else {
|
||||
[format["Failed to parse settings: %1", _settings], "ERROR"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
call attendanceTracker_fnc_connectDB;
|
||||
|
||||
AttendanceTracker setVariable ["missionContext", createHashMapFromArray [
|
||||
["missionHash", AttendanceTracker_missionHash],
|
||||
["missionStart", AttendanceTracker_missionStartTimestamp],
|
||||
["missionName", missionName],
|
||||
["briefingName", briefingName],
|
||||
["missionNameSource", missionNameSource],
|
||||
["onLoadName", getMissionConfigValue ["onLoadName", ""]],
|
||||
["author", getMissionConfigValue ["author", ""]],
|
||||
["serverName", serverName],
|
||||
["serverProfile", profileName],
|
||||
["missionStart", AttendanceTracker_missionStartTimestamp],
|
||||
["missionHash", AttendanceTracker_missionHash],
|
||||
["worldName", toLower worldName]
|
||||
]];
|
||||
|
||||
|
||||
|
||||
// store all user details in a hash when they connect so we can reference it in disconnect events
|
||||
AttendanceTracker setVariable ["allUsers", createHashMap];
|
||||
AttendanceTracker setVariable ["rowIds", createHashMap];
|
||||
|
||||
// update the extension with the current server time to identify restarts
|
||||
[
|
||||
{
|
||||
'AttendanceTracker' callExtension [
|
||||
"updateServerTime",
|
||||
[
|
||||
round(diag_tickTime)
|
||||
]
|
||||
]
|
||||
},
|
||||
30
|
||||
] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
{
|
||||
if (!isServer) exitWith {};
|
||||
_x params ["_ehName", "_code"];
|
||||
|
||||
_handle = (addMissionEventHandler [_ehName, _code]);
|
||||
if (isNil "_handle") then {
|
||||
[format["Failed to add Mission event handler: %1", _x], "ERROR"] call attendanceTracker_fnc_log;
|
||||
false;
|
||||
} else {
|
||||
missionNamespace setVariable [
|
||||
("AttendanceTracker" + "_MEH_" + _ehName),
|
||||
_handle
|
||||
];
|
||||
true;
|
||||
};
|
||||
} forEach (call attendanceTracker_fnc_eventHandlers);
|
||||
@@ -1,31 +0,0 @@
|
||||
params [
|
||||
["_eventType", ""],
|
||||
["_playerId", ""],
|
||||
["_playerUID", ""],
|
||||
["_profileName", ""],
|
||||
["_steamName", ""],
|
||||
["_isJIP", false, [true, false]],
|
||||
["_roleDescription", ""]
|
||||
];
|
||||
|
||||
private _hash = + (AttendanceTracker getVariable ["missionContext", createHashMap]);
|
||||
|
||||
_hash set ["eventType", _eventType];
|
||||
_hash set ["playerId", _playerId];
|
||||
_hash set ["playerUID", _playerUID];
|
||||
_hash set ["profileName", _profileName];
|
||||
_hash set ["steamName", _steamName];
|
||||
_hash set ["isJIP", _isJIP];
|
||||
_hash set ["roleDescription", _roleDescription];
|
||||
|
||||
[
|
||||
{
|
||||
missionNamespace getVariable ["AttendanceTracker_DBConnected", false] &&
|
||||
missionNamespace getVariable ["AttendanceTracker_missionId", -1] > 0
|
||||
},
|
||||
{"AttendanceTracker" callExtension ["writeAttendance", [[_this] call CBA_fnc_encodeJSON]]},
|
||||
_hash, // args
|
||||
30 // timeout in seconds. if DB never connects, we don't want these building up
|
||||
] call CBA_fnc_waitUntilAndExecute;
|
||||
|
||||
true;
|
||||
@@ -1,31 +0,0 @@
|
||||
params [
|
||||
["_eventType", ""],
|
||||
["_playerId", ""],
|
||||
["_playerUID", ""],
|
||||
["_profileName", ""],
|
||||
["_steamName", ""],
|
||||
["_isJIP", false, [true, false]],
|
||||
["_roleDescription", ""]
|
||||
];
|
||||
|
||||
private _hash = + (AttendanceTracker getVariable ["missionContext", createHashMap]);
|
||||
|
||||
_hash set ["eventType", _eventType];
|
||||
_hash set ["playerId", _playerId];
|
||||
_hash set ["playerUID", _playerUID];
|
||||
_hash set ["profileName", _profileName];
|
||||
_hash set ["steamName", _steamName];
|
||||
_hash set ["isJIP", _isJIP];
|
||||
_hash set ["roleDescription", _roleDescription];
|
||||
|
||||
[
|
||||
{
|
||||
missionNamespace getVariable ["AttendanceTracker_DBConnected", false] &&
|
||||
missionNamespace getVariable ["AttendanceTracker_missionId", -1] > 0
|
||||
},
|
||||
{"AttendanceTracker" callExtension ["writeDisconnectEvent", [[_this] call CBA_fnc_encodeJSON]]},
|
||||
_hash, // args
|
||||
30 // timeout in seconds. if DB never connects, we don't want these building up
|
||||
] call CBA_fnc_waitUntilAndExecute;
|
||||
|
||||
true;
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"sqlConfig": {
|
||||
"mysqlHost": "127.0.0.1",
|
||||
"mysqlPort": 3306,
|
||||
"mysqlUser": "root",
|
||||
"mysqlPassword": "root",
|
||||
"mysqlDatabase": "arma3_attendance"
|
||||
},
|
||||
"armaConfig": {
|
||||
"dbUpdateIntervalSeconds": 90,
|
||||
"serverEventFillNullMinutes": 90,
|
||||
"missionEventFillNullMinutes": 15,
|
||||
"debug": false
|
||||
}
|
||||
}
|
||||
14
AttendanceTracker.config.json
Normal file
14
AttendanceTracker.config.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"sqlConfig": {
|
||||
"mysqlHost": "localhost",
|
||||
"mysqlPort": 3306,
|
||||
"mysqlUser": "root",
|
||||
"mysqlPassword": "password",
|
||||
"mysqlDatabase": "a3attendance"
|
||||
},
|
||||
"armaConfig": {
|
||||
"dbUpdateInterval": "90s",
|
||||
"debug": false,
|
||||
"traceLogToFile": false
|
||||
}
|
||||
}
|
||||
119
LICENSE
Normal file
119
LICENSE
Normal file
@@ -0,0 +1,119 @@
|
||||
Copyright (c) 2023 <indigo@indigofox.dev>
|
||||
|
||||
Brief summary of this Licence
|
||||
|
||||
PLEASE, NOTE THAT THIS SUMMARY HAS NO LEGAL EFFECT AND IS ONLY OF AN INFORMATORY NATURE DESIGNED FOR YOU TO GET THE BASIC INFORMATION ABOUT THE CONTENT OF THIS LICENCE. THE ONLY LEGALLY BINDING PROVISIONS ARE THOSE IN THE ORIGINAL AND FULL TEXT OF THIS LICENCE.
|
||||
|
||||
With this licence you are free to adapt (i.e. modify, rework or update) and share (i.e. copy, distribute or transmit) the material under the following conditions:
|
||||
|
||||
Attribution - You must attribute the material in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the material).
|
||||
Noncommercial - You may not use this material for any commercial purposes.
|
||||
Arma Only - You may not convert or adapt this material to be used in other games than Arma.
|
||||
Share Alike - If you adapt, or build upon this material, you may distribute the resulting material only under the same license.
|
||||
|
||||
Full version of licence
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Arma Public License - Share Alike ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
|
||||
Section 1 – Definitions
|
||||
|
||||
Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
|
||||
Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
|
||||
ArmaOnly means primarily intended for or directed towards the use in any of existing and future Arma games, including but not limited to Arma: Cold War Assault, Arma, Arma 2 and Arma 3 and its official sequels and expansion packs.
|
||||
Arma Public Share Alike Compatible License means a license listed at https://www.bohemia.net/community/licenses as essentially the equivalent of this Public License.
|
||||
Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
|
||||
Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
|
||||
Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
|
||||
Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
|
||||
Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
|
||||
Licensor means the individual(s) or entity(ies) granting rights under this Public License.
|
||||
NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
|
||||
Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
|
||||
Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
|
||||
You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
|
||||
|
||||
Section 2 – Scope
|
||||
|
||||
License grant
|
||||
Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
|
||||
reproduce and Share the Licensed Material, in whole or in part, for NonCommercial and ArmaOnly purposes only; and
|
||||
produce, reproduce, and Share Adapted Material for NonCommercial and ArmaOnly purposes only.
|
||||
Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
|
||||
Term. The term of this Public License is specified in Section 6(a).
|
||||
Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
|
||||
Downstream recipients.
|
||||
Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
|
||||
Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply.
|
||||
No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
|
||||
No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(a)(i).
|
||||
Other rights
|
||||
Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
|
||||
Patent and trademark rights are not licensed under this Public License.
|
||||
To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial and ArmaOnly purposes.
|
||||
|
||||
Section 3 – License Conditions
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
||||
|
||||
Attribution
|
||||
|
||||
If You Share the Licensed Material (including in modified form), You must:
|
||||
retain the following if it is supplied by the Licensor with the Licensed Material:
|
||||
identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
|
||||
a copyright notice;
|
||||
a notice that refers to this Public License;
|
||||
a notice that refers to the disclaimer of warranties;
|
||||
a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
|
||||
indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
|
||||
indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
|
||||
You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
|
||||
If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(a) to the extent reasonably practicable.
|
||||
ShareAlike
|
||||
|
||||
In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
|
||||
The Adapter’s License You apply must be this Public License, or an Arma Public Share Alike Compatible License.
|
||||
You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
|
||||
You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
|
||||
|
||||
Section 4 – Sui Generis Database Rights
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
|
||||
|
||||
for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial and ArmaOnly purposes only;
|
||||
if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
|
||||
You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
|
||||
Section 5 – Disclaimer of Warranties and Limitation of Liability
|
||||
|
||||
Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
|
||||
To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
|
||||
The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
|
||||
|
||||
Section 6 – Term and Termination
|
||||
|
||||
This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
|
||||
|
||||
Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
|
||||
automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
|
||||
upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
|
||||
For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
|
||||
Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
|
||||
|
||||
Section 7 – Other Terms and Conditions
|
||||
|
||||
The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
|
||||
Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
|
||||
|
||||
Section 8 – Interpretation
|
||||
|
||||
For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
|
||||
To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
|
||||
No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
|
||||
Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
|
||||
|
||||
Bohemia Interactive Notices
|
||||
|
||||
Bohemia Interactive a.s. is not a party to this License, and makes no warranty whatsoever in connection with the Licensed Material. Bohemia Interactive a.s. will not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding the foregoing two (2) sentences, Bohemia Interactive a.s. may elect to apply the Public License to material it publishes and in those instances it becomes the "Licensor".
|
||||
Except for the limited purpose of indicating to the public that the Licensed Material is shared under this Public License, Bohemia Interactive a.s. does not authorize the use by either party of the trademarks "Arma", "Bohemia Interactive" or any related trademark or logo of Arma or Bohemia Interactive without the prior written consent of Bohemia Interactive a.s.
|
||||
104
LICENSE.md
104
LICENSE.md
@@ -1,104 +0,0 @@
|
||||
# Arma Public License Share Alike (APL-SA)
|
||||
|
||||
## Brief summary of this Licence
|
||||
|
||||
PLEASE, NOTE THAT THIS SUMMARY HAS NO LEGAL EFFECT AND IS ONLY OF AN INFORMATORY NATURE DESIGNED FOR YOU TO GET THE BASIC INFORMATION ABOUT THE CONTENT OF THIS LICENCE. THE ONLY LEGALLY BINDING PROVISIONS ARE THOSE IN THE ORIGINAL AND FULL TEXT OF THIS LICENCE.
|
||||
|
||||
With this licence you are free to adapt (i.e. modify, rework or update) and share (i.e. copy, distribute or transmit) the material under the following conditions:
|
||||
|
||||
Attribution - You must attribute the material in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the material).
|
||||
Noncommercial - You may not use this material for any commercial purposes.
|
||||
Arma Only - You may not convert or adapt this material to be used in other games than Arma.
|
||||
Share Alike - If you adapt, or build upon this material, you may distribute the resulting material only under the same license.
|
||||
|
||||
## Full version of licence
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Arma Public License - Share Alike ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
|
||||
|
||||
Section 1 – Definitions
|
||||
Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
|
||||
Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
|
||||
ArmaOnly means primarily intended for or directed towards the use in any of existing and future Arma games, including but not limited to Arma: Cold War Assault, Arma, Arma 2 and Arma 3 and its official sequels and expansion packs.
|
||||
Arma Public Share Alike Compatible License means a license listed at <https://www.bohemia.net/community/licenses> as essentially the equivalent of this Public License.
|
||||
Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
|
||||
Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
|
||||
Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
|
||||
Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
|
||||
Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
|
||||
Licensor means the individual(s) or entity(ies) granting rights under this Public License.
|
||||
NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
|
||||
Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
|
||||
Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
|
||||
You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
|
||||
Section 2 – Scope
|
||||
License grant
|
||||
Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
|
||||
reproduce and Share the Licensed Material, in whole or in part, for NonCommercial and ArmaOnly purposes only; and
|
||||
produce, reproduce, and Share Adapted Material for NonCommercial and ArmaOnly purposes only.
|
||||
Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
|
||||
Term. The term of this Public License is specified in Section 6(a).
|
||||
Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
|
||||
Downstream recipients.
|
||||
Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
|
||||
Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply.
|
||||
No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
|
||||
No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(a)(i).
|
||||
Other rights
|
||||
Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
|
||||
Patent and trademark rights are not licensed under this Public License.
|
||||
To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial and ArmaOnly purposes.
|
||||
Section 3 – License Conditions
|
||||
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
||||
|
||||
Attribution
|
||||
If You Share the Licensed Material (including in modified form), You must:
|
||||
|
||||
retain the following if it is supplied by the Licensor with the Licensed Material:
|
||||
identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
|
||||
a copyright notice;
|
||||
a notice that refers to this Public License;
|
||||
a notice that refers to the disclaimer of warranties;
|
||||
a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
|
||||
indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
|
||||
indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
|
||||
You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
|
||||
If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(a) to the extent reasonably practicable.
|
||||
ShareAlike
|
||||
In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
|
||||
|
||||
The Adapter’s License You apply must be this Public License, or an Arma Public Share Alike Compatible License.
|
||||
You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
|
||||
You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
|
||||
Section 4 – Sui Generis Database Rights
|
||||
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
|
||||
|
||||
for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial and ArmaOnly purposes only;
|
||||
if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
|
||||
You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
|
||||
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
|
||||
|
||||
Section 5 – Disclaimer of Warranties and Limitation of Liability
|
||||
Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
|
||||
To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
|
||||
The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
|
||||
Section 6 – Term and Termination
|
||||
This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
|
||||
Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
|
||||
|
||||
automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
|
||||
upon express reinstatement by the Licensor.
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
|
||||
|
||||
For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
|
||||
Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
|
||||
Section 7 – Other Terms and Conditions
|
||||
The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
|
||||
Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
|
||||
Section 8 – Interpretation
|
||||
For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
|
||||
To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
|
||||
No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
|
||||
Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
|
||||
Bohemia Interactive Notices
|
||||
Bohemia Interactive a.s. is not a party to this License, and makes no warranty whatsoever in connection with the Licensed Material. Bohemia Interactive a.s. will not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding the foregoing two (2) sentences, Bohemia Interactive a.s. may elect to apply the Public License to material it publishes and in those instances it becomes the "Licensor".
|
||||
Except for the limited purpose of indicating to the public that the Licensed Material is shared under this Public License, Bohemia Interactive a.s. does not authorize the use by either party of the trademarks "Arma", "Bohemia Interactive" or any related trademark or logo of Arma or Bohemia Interactive without the prior written consent of Bohemia Interactive a.s.
|
||||
@@ -191,17 +191,48 @@ Pull requests are welcome. For major changes, please open an issue first to disc
|
||||
- [MinGW-w64](https://sourceforge.net/projects/mingw-w64/) (Windows only)
|
||||
- [GCC](https://gcc.gnu.org/) (Linux only)
|
||||
|
||||
### Building
|
||||
### Building Extension using Docker
|
||||
|
||||
You will need Docker Engine installed and running. This can be done on Windows or on Linux. However, you will need to use Linux containers if you're on Windows (specified in Docker Desktop settings).
|
||||
|
||||
Once it's built, copy the file from ./dist to the project root, then build the addon.
|
||||
|
||||
#### COMPILING FOR WINDOWS
|
||||
|
||||
```bash
|
||||
cd ./extension
|
||||
$ENV:GOARCH = "amd64"
|
||||
$ENV:CGO_ENABLED = 1
|
||||
go1.16.4 build -o ../@AttendanceTracker/AttendanceTracker_x64.dll -buildmode=c-shared .
|
||||
docker pull x1unix/go-mingw:1.20
|
||||
|
||||
# Compile x64 Windows DLL
|
||||
docker run --rm -it -v ${PWD}:/go/work -w /go/work x1unix/go-mingw:1.20 go build -o dist/AttendanceTracker_x64.dll -buildmode=c-shared -ldflags '-w -s' ./cmd
|
||||
|
||||
# Compile x86 Windows DLL
|
||||
docker run --rm -it -v ${PWD}:/go/work -w /go/work -e GOARCH=386 x1unix/go-mingw:1.20 go build -o dist/AttendanceTracker.dll -buildmode=c-shared -ldflags '-w -s' ./cmd
|
||||
|
||||
# Compile x64 Windows EXE
|
||||
docker run --rm -it -v ${PWD}:/go/work -w /go/work x1unix/go-mingw:1.20 go build -o dist/AttendanceTracker_x64.exe -ldflags '-w -s' ./cmd
|
||||
```
|
||||
|
||||
To prepare the addon, you'll need some PBO manager utility to pack this folder:
|
||||
[`@AttendanceTracker/addons/AttendanceTracker`](@AttendanceTracker/addons/AttendanceTracker)
|
||||
#### COMPILING FOR LINUX
|
||||
|
||||
```bash
|
||||
docker build -t indifox926/build-a3go:linux-so -f ./build/Dockerfile.build ./cmd
|
||||
|
||||
# Compile x64 Linux .so
|
||||
docker run --rm -it -v ${PWD}:/app -e GOOS=linux -e GOARCH=amd64 -e CGO_ENABLED=1 -e CC=gcc indifox926/build-a3go:linux-so go build -o dist/AttendanceTracker_x64.so -linkshared -ldflags '-w -s' ./cmd
|
||||
|
||||
# Compile x86 Linux .so
|
||||
docker run --rm -it -v ${PWD}:/app -e GOOS=linux -e GOARCH=386 -e CGO_ENABLED=1 -e CC=gcc indifox926/build-a3go:linux-so go build -o dist/AttendanceTracker.so -linkshared -ldflags '-w -s' ./cmd
|
||||
```
|
||||
|
||||
### Compile Addon
|
||||
|
||||
To prepare the addon, you'll need to download the [HEMTT](https://brettmayson.github.io/HEMTT/commands/build.html) binary, place it in the project root, and run the following command:
|
||||
|
||||
```bash
|
||||
./HEMTT.exe release
|
||||
```
|
||||
|
||||
The PBOs and relevant files will be placed in the ./.hemmttout/build directory.
|
||||
|
||||
---
|
||||
|
||||
1
addons/main/$PBOPREFIX$
Normal file
1
addons/main/$PBOPREFIX$
Normal file
@@ -0,0 +1 @@
|
||||
x\addons\attendancetracker\main
|
||||
@@ -1,30 +1,36 @@
|
||||
#include "script_mod.hpp"
|
||||
|
||||
class CfgPatches {
|
||||
class AttendanceTracker {
|
||||
units[] = {};
|
||||
weapons[] = {};
|
||||
requiredVersion = 2.10;
|
||||
requiredAddons[] = {};
|
||||
requiredAddons[] = {
|
||||
"cba_main",
|
||||
"cba_xeh",
|
||||
"cba_settings"
|
||||
};
|
||||
VERSION_CONFIG;
|
||||
author[] = {"IndigoFox"};
|
||||
authorUrl = "http://example.com";
|
||||
authorUrl = "https://github.com/indig0fox";
|
||||
};
|
||||
};
|
||||
|
||||
class CfgFunctions {
|
||||
class attendanceTracker {
|
||||
class functions {
|
||||
file = "\AttendanceTracker\functions";
|
||||
file = "x\addons\attendancetracker\main\functions";
|
||||
class postInit {postInit = 1;};
|
||||
class connectDB {};
|
||||
class eventHandlers {};
|
||||
class callbackHandler {postInit = 1;};
|
||||
class log {};
|
||||
class writeConnect {};
|
||||
class writeDisconnect {};
|
||||
class timestamp {};
|
||||
class getSettings {};
|
||||
class getMissionHash {};
|
||||
class getMissionInfo {};
|
||||
class getSettings {};
|
||||
class getWorldInfo {};
|
||||
class log {};
|
||||
class missionLoaded {};
|
||||
class onPlayerConnected {};
|
||||
class timestamp {};
|
||||
class writePlayer {};
|
||||
};
|
||||
};
|
||||
};
|
||||
24
addons/main/functions/fn_callbackHandler.sqf
Normal file
24
addons/main/functions/fn_callbackHandler.sqf
Normal file
@@ -0,0 +1,24 @@
|
||||
addMissionEventHandler ["ExtensionCallback", {
|
||||
params ["_name", "_function", "_data"];
|
||||
if !(_name isEqualTo "AttendanceTracker") exitWith {};
|
||||
|
||||
if (ATDebug && _function isNotEqualTo ":LOG:") then {
|
||||
diag_log format ["Raw callback: %1 _ %2", _function, _data];
|
||||
};
|
||||
|
||||
_dataArr = parseSimpleArray _data;
|
||||
if (count _dataArr < 1) exitWith {};
|
||||
|
||||
switch (_function) do {
|
||||
case ":LOG:": {
|
||||
diag_log formatText[
|
||||
"[Attendance Tracker] %1",
|
||||
_dataArr select 0
|
||||
];
|
||||
};
|
||||
default {
|
||||
[format["%1", _dataArr]] call attendanceTracker_fnc_log;
|
||||
};
|
||||
};
|
||||
true;
|
||||
}];
|
||||
19
addons/main/functions/fn_getMissionHash.sqf
Normal file
19
addons/main/functions/fn_getMissionHash.sqf
Normal file
@@ -0,0 +1,19 @@
|
||||
addMissionEventHandler ["ExtensionCallback", {
|
||||
params ["_extension", "_function", "_data"];
|
||||
if !(_extension isEqualTo "AttendanceTracker") exitWith {};
|
||||
if !(_function isEqualTo ":MISSION:HASH:") exitWith {};
|
||||
|
||||
_dataArr = parseSimpleArray _data;
|
||||
if (count _dataArr < 1) exitWith {};
|
||||
|
||||
_dataArr params ["_startTime", "_hash"];
|
||||
ATNamespace setVariable ["missionStartTime", call attendanceTracker_fnc_timestamp];
|
||||
ATNamespace setVariable ["missionHash", _hash];
|
||||
|
||||
removeMissionEventHandler [
|
||||
"ExtensionCallback",
|
||||
_thisEventHandler
|
||||
];
|
||||
}];
|
||||
|
||||
"AttendanceTracker" callExtension ":MISSION:HASH:";
|
||||
12
addons/main/functions/fn_getMissionInfo.sqf
Normal file
12
addons/main/functions/fn_getMissionInfo.sqf
Normal file
@@ -0,0 +1,12 @@
|
||||
createHashMapFromArray [
|
||||
["missionName", missionName],
|
||||
["missionStart", ATNamespace getVariable "missionStartTime"],
|
||||
["missionHash", ATNamespace getVariable "missionHash"],
|
||||
["briefingName", briefingName],
|
||||
["missionNameSource", missionNameSource],
|
||||
["onLoadName", getMissionConfigValue ["onLoadName", ""]],
|
||||
["author", getMissionConfigValue ["author", ""]],
|
||||
["serverName", serverName],
|
||||
["serverProfile", profileName],
|
||||
["worldName", toLower worldName]
|
||||
];
|
||||
27
addons/main/functions/fn_getSettings.sqf
Normal file
27
addons/main/functions/fn_getSettings.sqf
Normal file
@@ -0,0 +1,27 @@
|
||||
addMissionEventHandler ["ExtensionCallback", {
|
||||
params ["_extension", "_function", "_data"];
|
||||
if !(_extension isEqualTo "AttendanceTracker") exitWith {};
|
||||
if !(_function isEqualTo ":GET:SETTINGS:") exitWith {};
|
||||
|
||||
_dataArr = parseSimpleArray _data;
|
||||
diag_log format ["AT: Settings received: %1", _dataArr];
|
||||
if (count _dataArr < 1) exitWith {};
|
||||
|
||||
private _settingsJSON = _dataArr select 0;
|
||||
private _settingsNamespace = [_settingsJSON] call CBA_fnc_parseJSON;
|
||||
{
|
||||
ATNamespace setVariable [_x, _settingsNamespace getVariable _x];
|
||||
} forEach (allVariables _settingsNamespace);
|
||||
ATDebug = ATNamespace getVariable "debug";
|
||||
ATUpdateDelay = ATNamespace getVariable "dbUpdateInterval";
|
||||
// remove last character (unit of time) and parse to number
|
||||
ATUpdateDelay = parseNumber (ATUpdateDelay select [0, count ATUpdateDelay - 1]);
|
||||
|
||||
|
||||
removeMissionEventHandler [
|
||||
"ExtensionCallback",
|
||||
_thisEventHandler
|
||||
];
|
||||
}];
|
||||
|
||||
"AttendanceTracker" callExtension ":GET:SETTINGS:";
|
||||
@@ -21,8 +21,8 @@ _return = createHashMapFromArray [
|
||||
["worldName", toLower worldName],
|
||||
["worldNameOriginal", _name],
|
||||
["worldSize", worldSize],
|
||||
["latitude", getNumber( _world >> "latitude" )],
|
||||
["latitude", -1 * getNumber( _world >> "latitude" )],
|
||||
["longitude", getNumber( _world >> "longitude" )]
|
||||
];
|
||||
diag_log format ["Attendance Tracker: WorldInfo is: %1", _return];
|
||||
[format["WorldInfo is: %1", _return]] call attendanceTracker_fnc_log;
|
||||
_return
|
||||
15
addons/main/functions/fn_log.sqf
Normal file
15
addons/main/functions/fn_log.sqf
Normal file
@@ -0,0 +1,15 @@
|
||||
params [
|
||||
["_message", "", [""]],
|
||||
["_level", "INFO", [""]],
|
||||
"_function"
|
||||
];
|
||||
|
||||
if (isNil "_message") exitWith {false};
|
||||
if (
|
||||
missionNamespace getVariable ["ATDebug", true] &&
|
||||
_level != "WARN" && _level != "ERROR"
|
||||
) exitWith {};
|
||||
|
||||
LOG_SYS(_level, _message);
|
||||
|
||||
true;
|
||||
63
addons/main/functions/fn_onPlayerConnected.sqf
Normal file
63
addons/main/functions/fn_onPlayerConnected.sqf
Normal file
@@ -0,0 +1,63 @@
|
||||
params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
|
||||
|
||||
[format ["(EventHandler) PlayerConnected fired: %1", _this], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
|
||||
if !(call attendanceTracker_fnc_missionLoaded) exitWith {
|
||||
[format ["(EventHandler) PlayerConnected: Server is in Mission Asked, likely mission selection state. Skipping.."], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
private _userInfo = (getUserInfo _idstr);
|
||||
if ((count _userInfo) isEqualTo 0) exitWith {
|
||||
[format ["(EventHandler) PlayerConnected: No user info found for %1", _idstr], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
_userInfo params ["_playerID", "_ownerId", "_playerUID", "_profileName", "_displayName", "_steamName", "_clientState", "_isHC", "_adminState", "_networkInfo", "_unit"];
|
||||
if (_isHC) exitWith {
|
||||
[
|
||||
format [
|
||||
"(EventHandler) PlayerConnected: %1 is HC, skipping",
|
||||
_playerID
|
||||
],
|
||||
"DEBUG"
|
||||
] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
// start CBA PFH
|
||||
[
|
||||
format [
|
||||
"(EventHandler) PlayerConnected: Starting CBA PFH for %1",
|
||||
_playerID
|
||||
],
|
||||
"DEBUG"
|
||||
] call attendanceTracker_fnc_log;
|
||||
|
||||
[
|
||||
{
|
||||
params ["_args", "_handle"];
|
||||
// check if player is still connected
|
||||
_args params ["_playerID", "_playerUID", "_profileName", "_steamName", "_jip", "_roleDescription"];
|
||||
private _userInfo = getUserInfo _playerID;
|
||||
private _clientStateNumber = 0;
|
||||
if (_userInfo isEqualTo []) exitWith {
|
||||
[_handle] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
_clientStateNumber = _userInfo select 6;
|
||||
|
||||
if (_clientStateNumber < 6) exitWith {
|
||||
[format ["(EventHandler) PlayerConnected: %1 (UID) is no longer connected to the mission, exiting CBA PFH", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
[_handle] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
_args call attendanceTracker_fnc_writePlayer;
|
||||
},
|
||||
ATUpdateDelay,
|
||||
[
|
||||
_playerID,
|
||||
_playerUID,
|
||||
_profileName,
|
||||
_steamName,
|
||||
_jip,
|
||||
roleDescription _unit
|
||||
]
|
||||
] call CBA_fnc_addPerFrameHandler;
|
||||
61
addons/main/functions/fn_postInit.sqf
Normal file
61
addons/main/functions/fn_postInit.sqf
Normal file
@@ -0,0 +1,61 @@
|
||||
#include "..\script_mod.hpp"
|
||||
|
||||
if (!isServer) exitWith {};
|
||||
|
||||
ATNamespace = false call CBA_fnc_createNamespace;
|
||||
ATDebug = true;
|
||||
"AttendanceTracker" callExtension ":START:";
|
||||
|
||||
|
||||
// we'll wait for the asynchronous init steps of the extension to finish, to confirm we have a DB connection and our config was loaded. If there are errors with either, the extension won't reply and initiate further during this mission.
|
||||
addMissionEventHandler ["ExtensionCallback", {
|
||||
params ["_name", "_function", "_data"];
|
||||
if !(_name isEqualTo "AttendanceTracker") exitWith {};
|
||||
if !(_function isEqualTo ":READY:") exitWith {};
|
||||
|
||||
call attendanceTracker_fnc_getMissionHash;
|
||||
call attendanceTracker_fnc_getSettings;
|
||||
|
||||
[
|
||||
{// wait until settings have been loaded from extension
|
||||
!isNil {ATNamespace getVariable "missionHash"} &&
|
||||
!isNil {ATDebug}
|
||||
},
|
||||
{
|
||||
|
||||
// get world and mission context
|
||||
ATNamespace setVariable [
|
||||
"worldContext",
|
||||
call attendanceTracker_fnc_getWorldInfo
|
||||
];
|
||||
ATNamespace setVariable [
|
||||
"missionContext",
|
||||
call attendanceTracker_fnc_getMissionInfo
|
||||
];
|
||||
|
||||
// write them to establish DB rows
|
||||
"AttendanceTracker" callExtension [
|
||||
":LOG:MISSION:",
|
||||
[
|
||||
[ATNamespace getVariable "missionContext"] call CBA_fnc_encodeJSON,
|
||||
[ATNamespace getVariable "worldContext"] call CBA_fnc_encodeJSON
|
||||
]
|
||||
];
|
||||
|
||||
// add player connected (to mission) handler
|
||||
addMissionEventHandler ["PlayerConnected", {
|
||||
_this call attendanceTracker_fnc_onPlayerConnected;
|
||||
}];
|
||||
},
|
||||
[],
|
||||
10, // 10 second timeout
|
||||
{ // timeout code
|
||||
["Failed to load settings", "ERROR"] call attendanceTracker_fnc_log;
|
||||
}
|
||||
] call CBA_fnc_waitUntilAndExecute;
|
||||
|
||||
removeMissionEventHandler [
|
||||
"ExtensionCallback",
|
||||
_thisEventHandler
|
||||
];
|
||||
}];
|
||||
@@ -1,6 +1,6 @@
|
||||
// (parseSimpleArray ("AttendanceTracker" callExtension "getTimestamp")) select 0;
|
||||
|
||||
// need date for MySQL in format 2006-01-02 15:04:05
|
||||
// const time.RFC3339 untyped string = "2006-01-02T15:04:05Z07:00"
|
||||
|
||||
systemTimeUTC apply {if (_x < 10) then {"0" + str _x} else {str _x}} params [
|
||||
"_year",
|
||||
@@ -13,7 +13,7 @@ systemTimeUTC apply {if (_x < 10) then {"0" + str _x} else {str _x}} params [
|
||||
];
|
||||
|
||||
format[
|
||||
"%1-%2-%3T%4:%5:%6.000Z",
|
||||
"%1-%2-%3T%4:%5:%6Z",
|
||||
_year,
|
||||
_month,
|
||||
_day,
|
||||
21
addons/main/functions/fn_writePlayer.sqf
Normal file
21
addons/main/functions/fn_writePlayer.sqf
Normal file
@@ -0,0 +1,21 @@
|
||||
params [
|
||||
["_playerId", ""],
|
||||
["_playerUID", ""],
|
||||
["_profileName", ""],
|
||||
["_steamName", ""],
|
||||
["_isJIP", false, [true, false]],
|
||||
["_roleDescription", ""]
|
||||
];
|
||||
|
||||
private _hash = +(ATNamespace getVariable ["missionContext", createHashMap]);
|
||||
|
||||
_hash set ["playerId", _playerId];
|
||||
_hash set ["playerUID", _playerUID];
|
||||
_hash set ["profileName", _profileName];
|
||||
_hash set ["steamName", _steamName];
|
||||
_hash set ["isJIP", _isJIP];
|
||||
_hash set ["roleDescription", _roleDescription];
|
||||
|
||||
"AttendanceTracker" callExtension [":LOG:PRESENCE:", [[_hash] call CBA_fnc_encodeJSON]];
|
||||
|
||||
true;
|
||||
12
addons/main/script_mod.hpp
Normal file
12
addons/main/script_mod.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "script_version.hpp"
|
||||
|
||||
#define COMPONENT main
|
||||
#define COMPONENT_BEAUTIFIED Main
|
||||
|
||||
#define MAINPREFIX x
|
||||
#define SUBPREFIX addons
|
||||
#define PREFIX AttendanceTracker
|
||||
|
||||
|
||||
|
||||
#include "\x\cba\addons\main\script_macros_common.hpp"
|
||||
8
addons/main/script_version.hpp
Normal file
8
addons/main/script_version.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#define MAJOR 0
|
||||
#define MINOR 2
|
||||
#define PATCH 0
|
||||
#define BUILD 20230919
|
||||
|
||||
#define VERSION 0.2
|
||||
#define VERSION_STR MAJOR##.##MINOR##.##PATCH##.##BUILD
|
||||
#define VERSION_AR MAJOR,MINOR,PATCH,BUILD
|
||||
BIN
extension/AttendanceTracker/cmd.exe
Normal file
BIN
extension/AttendanceTracker/cmd.exe
Normal file
Binary file not shown.
383
extension/AttendanceTracker/cmd/main.go
Normal file
383
extension/AttendanceTracker/cmd/main.go
Normal file
@@ -0,0 +1,383 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
*/
|
||||
import "C" // This is required to import the C code
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/indig0fox/Arma3-AttendanceTracker/internal/db"
|
||||
"github.com/indig0fox/Arma3-AttendanceTracker/internal/logger"
|
||||
"github.com/indig0fox/Arma3-AttendanceTracker/internal/util"
|
||||
"github.com/indig0fox/a3go/a3interface"
|
||||
"github.com/indig0fox/a3go/assemblyfinder"
|
||||
)
|
||||
|
||||
const EXTENSION_NAME string = "AttendanceTracker"
|
||||
const ADDON_NAME string = "AttendanceTracker"
|
||||
const EXTENSION_VERSION string = "0.9.0.1"
|
||||
|
||||
// file paths
|
||||
const ATTENDANCE_TABLE string = "attendance"
|
||||
const MISSIONS_TABLE string = "missions"
|
||||
const WORLDS_TABLE string = "worlds"
|
||||
|
||||
var currentMissionID uint = 0
|
||||
|
||||
var RVExtensionChannels = map[string]chan string{
|
||||
":START:": make(chan string),
|
||||
":MISSION:HASH:": make(chan string),
|
||||
":GET:SETTINGS:": make(chan string),
|
||||
}
|
||||
|
||||
var RVExtensionArgsChannels = map[string]chan []string{
|
||||
":LOG:MISSION:": make(chan []string),
|
||||
":LOG:PRESENCE:": make(chan []string),
|
||||
}
|
||||
|
||||
var (
|
||||
modulePath string
|
||||
modulePathDir string
|
||||
|
||||
initSuccess bool // default false
|
||||
)
|
||||
|
||||
// configure log output
|
||||
func init() {
|
||||
|
||||
a3interface.SetVersion(EXTENSION_VERSION)
|
||||
a3interface.RegisterRvExtensionChannels(RVExtensionChannels)
|
||||
a3interface.RegisterRvExtensionArgsChannels(RVExtensionArgsChannels)
|
||||
|
||||
go func() {
|
||||
var err error
|
||||
|
||||
modulePath = assemblyfinder.GetModulePath()
|
||||
// get absolute path of module path
|
||||
modulePathAbs, err := filepath.Abs(modulePath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
modulePathDir = filepath.Dir(modulePathAbs)
|
||||
|
||||
result, configErr := util.LoadConfig(modulePathDir)
|
||||
logger.InitLoggers(&logger.LoggerOptionsType{
|
||||
Path: filepath.Join(
|
||||
modulePathDir,
|
||||
fmt.Sprintf(
|
||||
"%s_v%s.log",
|
||||
EXTENSION_NAME,
|
||||
EXTENSION_VERSION,
|
||||
)),
|
||||
AddonName: ADDON_NAME,
|
||||
ExtensionName: EXTENSION_NAME,
|
||||
Debug: util.ConfigJSON.GetBool("armaConfig.debug"),
|
||||
Trace: util.ConfigJSON.GetBool("armaConfig.traceLogToFile"),
|
||||
})
|
||||
if configErr != nil {
|
||||
logger.Log.Error().Err(configErr).Msgf(`Error loading config`)
|
||||
return
|
||||
} else {
|
||||
logger.Log.Info().Msgf(result)
|
||||
}
|
||||
|
||||
logger.ArmaOnly.Info().Msgf(`%s v%s started`, EXTENSION_NAME, "0.0.0")
|
||||
logger.ArmaOnly.Info().Msgf(`Log path: %s`, logger.ActiveOptions.Path)
|
||||
|
||||
db.SetConfig(db.ConfigStruct{
|
||||
MySQLHost: util.ConfigJSON.GetString("sqlConfig.mysqlHost"),
|
||||
MySQLPort: util.ConfigJSON.GetInt("sqlConfig.mysqlPort"),
|
||||
MySQLUser: util.ConfigJSON.GetString("sqlConfig.mysqlUser"),
|
||||
MySQLPassword: util.ConfigJSON.GetString("sqlConfig.mysqlPassword"),
|
||||
MySQLDatabase: util.ConfigJSON.GetString("sqlConfig.mysqlDatabase"),
|
||||
})
|
||||
err = db.Connect()
|
||||
if err != nil {
|
||||
logger.Log.Error().Err(err).Msgf(`Error connecting to database`)
|
||||
return
|
||||
}
|
||||
err = db.Client().Set("gorm:table_options", "ENGINE=InnoDB").AutoMigrate(
|
||||
&World{},
|
||||
&Mission{},
|
||||
&Session{},
|
||||
)
|
||||
if err != nil {
|
||||
logger.Log.Error().Err(err).Msgf(`Error migrating database schema`)
|
||||
}
|
||||
|
||||
startA3CallHandlers()
|
||||
|
||||
initSuccess = true
|
||||
logger.RotateLogs()
|
||||
a3interface.WriteArmaCallback(
|
||||
EXTENSION_NAME,
|
||||
":READY:",
|
||||
)
|
||||
|
||||
go finalizeUnendedSessions()
|
||||
}()
|
||||
}
|
||||
|
||||
func startA3CallHandlers() error {
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-RVExtensionChannels[":START:"]:
|
||||
logger.Log.Trace().Msgf(`RVExtension :START: requested`)
|
||||
if !initSuccess {
|
||||
logger.Log.Warn().Msgf(`Received another :START: command before init was complete, ignoring.`)
|
||||
continue
|
||||
} else {
|
||||
logger.RotateLogs()
|
||||
a3interface.WriteArmaCallback(
|
||||
EXTENSION_NAME,
|
||||
":READY:",
|
||||
)
|
||||
}
|
||||
case <-RVExtensionChannels[":MISSION:HASH:"]:
|
||||
logger.Log.Trace().Msgf(`RVExtension :MISSION:HASH: requested`)
|
||||
timestamp, hash := getMissionHash()
|
||||
a3interface.WriteArmaCallback(
|
||||
EXTENSION_NAME,
|
||||
":MISSION:HASH:",
|
||||
timestamp,
|
||||
hash,
|
||||
)
|
||||
case <-RVExtensionChannels[":GET:SETTINGS:"]:
|
||||
logger.Log.Trace().Msg(`Settings requested`)
|
||||
armaConfig, err := util.ConfigArmaFormat()
|
||||
if err != nil {
|
||||
logger.Log.Error().Err(err).Msg(`Error when marshaling arma config`)
|
||||
continue
|
||||
}
|
||||
logger.Log.Trace().Str("armaConfig", armaConfig).Send()
|
||||
a3interface.WriteArmaCallback(
|
||||
EXTENSION_NAME,
|
||||
":GET:SETTINGS:",
|
||||
armaConfig,
|
||||
)
|
||||
case v := <-RVExtensionArgsChannels[":LOG:MISSION:"]:
|
||||
go func(data []string) {
|
||||
writeWorldInfo(v[1])
|
||||
writeMission(v[0])
|
||||
}(v)
|
||||
case v := <-RVExtensionArgsChannels[":LOG:PRESENCE:"]:
|
||||
go writeAttendance(v[0])
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// getMissionHash will return the current time in UTC and an md5 hash of that time
|
||||
func getMissionHash() (sqlTime, hashString string) {
|
||||
// get md5 hash of string
|
||||
// https://stackoverflow.com/questions/2377881/how-to-get-a-md5-hash-from-a-string-in-golang
|
||||
|
||||
nowTime := time.Now().UTC()
|
||||
// mysql format
|
||||
sqlTime = nowTime.Format("2006-01-02 15:04:05")
|
||||
hash := md5.Sum([]byte(sqlTime))
|
||||
hashString = fmt.Sprintf(`%x`, hash)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// finalizeUnendedSessions will fill in the disconnect time for any sessions that have not been ended with a time 1 update interval after the join time
|
||||
func finalizeUnendedSessions() {
|
||||
logger.Log.Debug().Msg("Filling missing disconnect events due to server restart.")
|
||||
// get all events with null DisconnectTime & set DisconnectTime
|
||||
var events []*Session
|
||||
db.Client().Model(&Session{}).
|
||||
Where("join_time_utc IS NOT NULL AND disconnect_time_utc IS NULL").
|
||||
Find(&events)
|
||||
for _, event := range events {
|
||||
// if difference between JoinTime and current time is greater than threshold, set to threshold
|
||||
if event.JoinTimeUTC.Time.Before(
|
||||
time.Now().Add(-1 * util.ConfigJSON.GetDuration("armaConfig.dbUpdateInterval")),
|
||||
) {
|
||||
// if more than the update interval has passed, set disconnect time as 1 interval after join
|
||||
event.DisconnectTimeUTC = sql.NullTime{
|
||||
Time: event.JoinTimeUTC.Time.Add(util.ConfigJSON.GetDuration("armaConfig.dbUpdateInterval")),
|
||||
Valid: true,
|
||||
}
|
||||
} else {
|
||||
// otherwise, set disconnect time as now
|
||||
event.DisconnectTimeUTC = sql.NullTime{
|
||||
Time: time.Now(),
|
||||
Valid: true,
|
||||
}
|
||||
}
|
||||
|
||||
db.Client().Save(&event)
|
||||
if db.Client().Error != nil {
|
||||
logger.Log.Error().Err(db.Client().Error).Msgf(`Error when updating disconnect time for event %d`, event.ID)
|
||||
}
|
||||
}
|
||||
|
||||
// log how many
|
||||
logger.Log.Info().Msgf(`Filled disconnect time of %d events.`, len(events))
|
||||
}
|
||||
|
||||
func writeWorldInfo(worldInfo string) {
|
||||
// worldInfo is json, parse it
|
||||
var wi World
|
||||
fixedString := unescapeArmaQuotes(worldInfo)
|
||||
err := json.Unmarshal([]byte(fixedString), &wi)
|
||||
if err != nil {
|
||||
logger.Log.Error().Err(err).Msgf(`Error when unmarshalling world info`)
|
||||
return
|
||||
}
|
||||
|
||||
// write world if not exist
|
||||
var dbWorld World
|
||||
db.Client().Where("world_name = ?", wi.WorldName).First(&dbWorld)
|
||||
if dbWorld.ID == 0 {
|
||||
db.Client().Create(&wi)
|
||||
if db.Client().Error != nil {
|
||||
logger.Log.Error().Err(db.Client().Error).Msgf(`Error when creating world`)
|
||||
return
|
||||
}
|
||||
logger.Log.Info().Msgf(`World %s created.`, wi.WorldName)
|
||||
} else {
|
||||
// don't do anything if exists
|
||||
logger.Log.Debug().Msgf(`World %s exists with ID %d.`, wi.WorldName, dbWorld.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func writeMission(missionJSON string) {
|
||||
var err error
|
||||
// writeLog(functionName, fmt.Sprintf(`["%s", "DEBUG"]`, Mission))
|
||||
// Mission is json, parse it
|
||||
var mi Mission
|
||||
fixedString := fixEscapeQuotes(trimQuotes(missionJSON))
|
||||
err = json.Unmarshal([]byte(fixedString), &mi)
|
||||
if err != nil {
|
||||
logger.Log.Error().Err(err).Msgf(`Error when unmarshalling mission`)
|
||||
return
|
||||
}
|
||||
|
||||
// get world from WorldName
|
||||
var dbWorld World
|
||||
db.Client().Where("world_name = ?", mi.WorldName).First(&dbWorld)
|
||||
if dbWorld.ID == 0 {
|
||||
logger.Log.Error().Msgf(`World %s not found.`, mi.WorldName)
|
||||
return
|
||||
}
|
||||
|
||||
mi.WorldID = dbWorld.ID
|
||||
|
||||
// write mission to database
|
||||
db.Client().Create(&mi)
|
||||
if db.Client().Error != nil {
|
||||
logger.Log.Error().Err(db.Client().Error).Msgf(`Error when creating mission`)
|
||||
return
|
||||
}
|
||||
logger.Log.Info().Msgf(`Mission %s created with ID %d`, mi.MissionName, mi.ID)
|
||||
currentMissionID = mi.ID
|
||||
}
|
||||
|
||||
func writeAttendance(data string) {
|
||||
var err error
|
||||
// data is json, parse it
|
||||
stringjson := unescapeArmaQuotes(data)
|
||||
var event Session
|
||||
err = json.Unmarshal([]byte(stringjson), &event)
|
||||
if err != nil {
|
||||
logger.Log.Error().Err(err).Msgf(`Error when unmarshalling attendance`)
|
||||
return
|
||||
}
|
||||
|
||||
// search existing event
|
||||
var dbEvent Session
|
||||
db.Client().
|
||||
Where(
|
||||
"player_uid = ? AND mission_hash = ?",
|
||||
event.PlayerUID,
|
||||
event.MissionHash,
|
||||
).
|
||||
Order("join_time_utc desc").
|
||||
First(&dbEvent)
|
||||
if dbEvent.ID != 0 {
|
||||
// update disconnect time
|
||||
dbEvent.DisconnectTimeUTC = sql.NullTime{
|
||||
Time: time.Now(),
|
||||
Valid: true,
|
||||
}
|
||||
err = db.Client().Save(&dbEvent).Error
|
||||
if err != nil {
|
||||
logger.Log.Error().Err(err).
|
||||
Msgf(`Error when updating disconnect time for event %d`, dbEvent.ID)
|
||||
return
|
||||
}
|
||||
logger.Log.Debug().Msgf(`Attendance updated for %s (%s)`,
|
||||
dbEvent.ProfileName,
|
||||
dbEvent.PlayerUID,
|
||||
)
|
||||
} else {
|
||||
// insert new row
|
||||
event.JoinTimeUTC = sql.NullTime{
|
||||
Time: time.Now(),
|
||||
Valid: true,
|
||||
}
|
||||
|
||||
if currentMissionID == 0 {
|
||||
logger.Log.Error().Msgf(`Current mission ID not set, cannot create attendance event`)
|
||||
return
|
||||
}
|
||||
event.MissionID = currentMissionID
|
||||
err = db.Client().Create(&event).Error
|
||||
if err != nil {
|
||||
logger.Log.Error().Err(err).Msgf(`Error when creating attendance event`)
|
||||
return
|
||||
}
|
||||
logger.Log.Debug().Msgf(`Attendance created for %s (%s)`,
|
||||
event.ProfileName,
|
||||
event.PlayerUID,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func getTimestamp() string {
|
||||
// get the current unix timestamp in nanoseconds
|
||||
// return time.Now().Local().Unix()
|
||||
return time.Now().Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
func trimQuotes(s string) string {
|
||||
// trim the start and end quotes from a string
|
||||
return strings.Trim(s, `"`)
|
||||
}
|
||||
|
||||
func fixEscapeQuotes(s string) string {
|
||||
// fix the escape quotes in a string
|
||||
return strings.Replace(s, `""`, `"`, -1)
|
||||
}
|
||||
|
||||
func unescapeArmaQuotes(s string) string {
|
||||
return fixEscapeQuotes(trimQuotes(s))
|
||||
}
|
||||
|
||||
func main() {
|
||||
// loadConfig()
|
||||
// fmt.Println("Running DB connect/migrate to build schema...")
|
||||
// err := connectDB()
|
||||
// if err != nil {
|
||||
// fmt.Println(err)
|
||||
// } else {
|
||||
// fmt.Println("DB connect/migrate complete!")
|
||||
// }
|
||||
// fmt.Scanln()
|
||||
}
|
||||
99
extension/AttendanceTracker/cmd/types.go
Normal file
99
extension/AttendanceTracker/cmd/types.go
Normal file
@@ -0,0 +1,99 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type World struct {
|
||||
gorm.Model
|
||||
Author string `json:"author"`
|
||||
WorkshopID string `json:"workshopID"`
|
||||
DisplayName string `json:"displayName"`
|
||||
WorldName string `json:"worldName"`
|
||||
WorldNameOriginal string `json:"worldNameOriginal"`
|
||||
WorldSize float32 `json:"worldSize"`
|
||||
Latitude float32 `json:"latitude"`
|
||||
Longitude float32 `json:"longitude"`
|
||||
Missions []Mission
|
||||
}
|
||||
|
||||
type Mission struct {
|
||||
gorm.Model
|
||||
MissionName string `json:"missionName"`
|
||||
BriefingName string `json:"briefingName"`
|
||||
MissionNameSource string `json:"missionNameSource"`
|
||||
OnLoadName string `json:"onLoadName"`
|
||||
Author string `json:"author"`
|
||||
ServerName string `json:"serverName"`
|
||||
ServerProfile string `json:"serverProfile"`
|
||||
MissionStart time.Time `json:"missionStart" gorm:"index"`
|
||||
MissionHash string `json:"missionHash" gorm:"index"`
|
||||
WorldName string `json:"worldName" gorm:"-"`
|
||||
WorldID uint
|
||||
World World `gorm:"foreignkey:WorldID"`
|
||||
Attendees []Session
|
||||
}
|
||||
|
||||
func (m *Mission) UnmarshalJSON(data []byte) error {
|
||||
type Alias Mission
|
||||
aux := &struct {
|
||||
*Alias
|
||||
MissionStart string `json:"missionStart"`
|
||||
}{Alias: (*Alias)(m)}
|
||||
err := json.Unmarshal(data, &aux)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m.MissionStart, err = time.Parse(time.RFC3339, aux.MissionStart)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
PlayerUID string `json:"playerUID" gorm:"index;primaryKey"`
|
||||
MissionHash string `json:"missionHash"`
|
||||
PlayerId string `json:"playerId"`
|
||||
JoinTimeUTC sql.NullTime `json:"joinTimeUTC" gorm:"index"`
|
||||
DisconnectTimeUTC sql.NullTime `json:"disconnectTimeUTC" gorm:"index"`
|
||||
ProfileName string `json:"profileName"`
|
||||
SteamName string `json:"steamName"`
|
||||
IsJIP bool `json:"isJIP" gorm:"column:is_jip"`
|
||||
RoleDescription string `json:"roleDescription"`
|
||||
MissionID uint
|
||||
Mission Mission `gorm:"foreignkey:MissionID"`
|
||||
}
|
||||
|
||||
func (s *Session) UnmarshalJSON(data []byte) error {
|
||||
type Alias Session
|
||||
aux := &struct {
|
||||
*Alias
|
||||
JoinTimeUTC string `json:"joinTimeUTC"`
|
||||
DisconnectTimeUTC string `json:"disconnectTimeUTC"`
|
||||
}{Alias: (*Alias)(s)}
|
||||
err := json.Unmarshal(data, &aux)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if aux.JoinTimeUTC != "" {
|
||||
s.JoinTimeUTC.Time, err = time.Parse(time.RFC3339, aux.JoinTimeUTC)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.JoinTimeUTC.Valid = true
|
||||
}
|
||||
if aux.DisconnectTimeUTC != "" {
|
||||
s.DisconnectTimeUTC.Time, err = time.Parse(time.RFC3339, aux.DisconnectTimeUTC)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.DisconnectTimeUTC.Valid = true
|
||||
}
|
||||
return nil
|
||||
}
|
||||
35
extension/AttendanceTracker/go.mod
Normal file
35
extension/AttendanceTracker/go.mod
Normal file
@@ -0,0 +1,35 @@
|
||||
module github.com/indig0fox/Arma3-AttendanceTracker
|
||||
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/go-sql-driver/mysql v1.7.1
|
||||
github.com/indig0fox/a3go v0.2.0
|
||||
github.com/rs/zerolog v1.30.0
|
||||
github.com/spf13/viper v1.16.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
gorm.io/driver/mysql v1.5.1
|
||||
gorm.io/gorm v1.25.4
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
|
||||
github.com/peterstace/simplefeatures v0.44.0 // indirect
|
||||
github.com/spf13/afero v1.9.5 // indirect
|
||||
github.com/spf13/cast v1.5.1 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
golang.org/x/sys v0.12.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
1785
extension/AttendanceTracker/go.sum
Normal file
1785
extension/AttendanceTracker/go.sum
Normal file
File diff suppressed because it is too large
Load Diff
62
extension/AttendanceTracker/internal/db/db.go
Normal file
62
extension/AttendanceTracker/internal/db/db.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/indig0fox/a3go/a3interface"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var db *gorm.DB
|
||||
var config ConfigStruct
|
||||
|
||||
type ConfigStruct struct {
|
||||
MySQLHost string `json:"mysqlHost"`
|
||||
MySQLPort int `json:"mysqlPort"`
|
||||
MySQLUser string `json:"mysqlUser"`
|
||||
MySQLPassword string `json:"mysqlPassword"`
|
||||
MySQLDatabase string `json:"mysqlDatabase"`
|
||||
}
|
||||
|
||||
func SetConfig(c ConfigStruct) {
|
||||
config = c
|
||||
}
|
||||
|
||||
func Client() *gorm.DB {
|
||||
return db
|
||||
}
|
||||
|
||||
func Connect() error {
|
||||
|
||||
// connect to database
|
||||
var err error
|
||||
dsn := fmt.Sprintf(
|
||||
"%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=True",
|
||||
config.MySQLUser,
|
||||
config.MySQLPassword,
|
||||
config.MySQLHost,
|
||||
config.MySQLPort,
|
||||
config.MySQLDatabase,
|
||||
)
|
||||
|
||||
db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// try ping
|
||||
sqlDB, err := db.DB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = sqlDB.Ping()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
a3interface.WriteArmaCallback("connectDB", `["Database connected", "INFO"]`)
|
||||
a3interface.WriteArmaCallback("connectDB", `["SUCCESS", "INFO"]`)
|
||||
|
||||
return nil
|
||||
}
|
||||
129
extension/AttendanceTracker/internal/logger/logger.go
Normal file
129
extension/AttendanceTracker/internal/logger/logger.go
Normal file
@@ -0,0 +1,129 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/indig0fox/a3go/a3interface"
|
||||
"github.com/rs/zerolog"
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
)
|
||||
|
||||
var ll *lumberjack.Logger
|
||||
var armaWriter *armaIoWriter
|
||||
|
||||
var Log, FileOnly, ArmaOnly zerolog.Logger
|
||||
var ActiveOptions *LoggerOptionsType = &LoggerOptionsType{}
|
||||
|
||||
type LoggerOptionsType struct {
|
||||
// LogPath is the path to the log file
|
||||
Path string
|
||||
// LogAddonName is the name of the addon that will be used to send log messages to arma
|
||||
AddonName string
|
||||
// LogExtensionName is the name of the extension that will be used to send log messages to arma
|
||||
ExtensionName string
|
||||
// ExtensionVersion is the version of this extension
|
||||
ExtensionVersion string
|
||||
// LogDebug determines if we should send Debug level messages to file & arma
|
||||
Debug bool
|
||||
// LogTrace is used to determine if file should receive trace level, regardless of debug
|
||||
Trace bool
|
||||
}
|
||||
|
||||
func RotateLogs() {
|
||||
ll.Rotate()
|
||||
}
|
||||
|
||||
// ArmaIoWriter is a custom type that implements the io.Writer interface and sends the output to Arma with the "log" callback
|
||||
type armaIoWriter struct{}
|
||||
|
||||
func (w *armaIoWriter) Write(p []byte) (n int, err error) {
|
||||
// write to arma log
|
||||
a3interface.WriteArmaCallback(ActiveOptions.ExtensionName, ":LOG:", string(p))
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
// console writer
|
||||
func InitLoggers(o *LoggerOptionsType) {
|
||||
ActiveOptions = o
|
||||
|
||||
// create a new lumberjack file logger (adds log rotation and compression)
|
||||
ll = &lumberjack.Logger{
|
||||
Filename: ActiveOptions.Path,
|
||||
MaxSize: 1,
|
||||
MaxBackups: 5,
|
||||
MaxAge: 14,
|
||||
Compress: true,
|
||||
LocalTime: true,
|
||||
}
|
||||
|
||||
// create a new io writer using the a3go callback function
|
||||
// this will be used to write to the arma log
|
||||
armaWriter = new(armaIoWriter)
|
||||
|
||||
// create format functions for RPT log messages
|
||||
armaLogFormatLevel := func(i interface{}) string {
|
||||
return strings.ToUpper(
|
||||
fmt.Sprintf(
|
||||
"(%s)",
|
||||
i,
|
||||
))
|
||||
}
|
||||
armaLogFormatTimestamp := func(i interface{}) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
FileOnly = zerolog.New(zerolog.ConsoleWriter{
|
||||
Out: ll,
|
||||
TimeFormat: time.RFC3339,
|
||||
NoColor: true,
|
||||
}).With().Timestamp().Caller().Logger()
|
||||
|
||||
if ActiveOptions.Trace {
|
||||
FileOnly = FileOnly.Level(zerolog.TraceLevel)
|
||||
} else if ActiveOptions.Debug {
|
||||
FileOnly = FileOnly.Level(zerolog.DebugLevel)
|
||||
} else {
|
||||
FileOnly = FileOnly.Level(zerolog.InfoLevel)
|
||||
}
|
||||
|
||||
ArmaOnly = zerolog.New(zerolog.ConsoleWriter{
|
||||
Out: armaWriter,
|
||||
TimeFormat: "",
|
||||
NoColor: true,
|
||||
FormatLevel: armaLogFormatLevel,
|
||||
FormatTimestamp: armaLogFormatTimestamp,
|
||||
}).With().Str("extension_version", ActiveOptions.ExtensionVersion).Logger()
|
||||
|
||||
if ActiveOptions.Debug {
|
||||
ArmaOnly = ArmaOnly.Level(zerolog.DebugLevel)
|
||||
} else {
|
||||
ArmaOnly = ArmaOnly.Level(zerolog.InfoLevel)
|
||||
}
|
||||
|
||||
// create something that can send the same message to both loggers
|
||||
// this is used to send messages to the arma log
|
||||
// and the file log
|
||||
Log = zerolog.New(zerolog.MultiLevelWriter(
|
||||
zerolog.ConsoleWriter{
|
||||
Out: ll,
|
||||
TimeFormat: time.RFC3339,
|
||||
NoColor: true,
|
||||
},
|
||||
zerolog.ConsoleWriter{
|
||||
Out: armaWriter,
|
||||
TimeFormat: "",
|
||||
NoColor: true,
|
||||
FormatTimestamp: armaLogFormatTimestamp,
|
||||
FormatLevel: armaLogFormatLevel,
|
||||
},
|
||||
)).With().Timestamp().Caller().Logger()
|
||||
|
||||
if ActiveOptions.Debug {
|
||||
Log = Log.Level(zerolog.DebugLevel)
|
||||
} else {
|
||||
Log = Log.Level(zerolog.InfoLevel)
|
||||
}
|
||||
|
||||
}
|
||||
65
extension/AttendanceTracker/internal/util/config.go
Normal file
65
extension/AttendanceTracker/internal/util/config.go
Normal file
@@ -0,0 +1,65 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var ConfigJSON = viper.New()
|
||||
|
||||
func LoadConfig(modulePathDir string) (string, error) {
|
||||
ConfigJSON.SetConfigName("AttendanceTracker.config")
|
||||
ConfigJSON.SetConfigType("json")
|
||||
ConfigJSON.AddConfigPath(".")
|
||||
ConfigJSON.AddConfigPath(modulePathDir)
|
||||
|
||||
ConfigJSON.SetDefault("armaConfig.dbUpdateInterval", "90s")
|
||||
ConfigJSON.SetDefault("armaConfig.debug", true)
|
||||
ConfigJSON.SetDefault("sqlConfig", map[string]interface{}{
|
||||
"mysqlHost": "localhost",
|
||||
"mysqlPort": 3306,
|
||||
"mysqlUser": "root",
|
||||
"mysqlPassword": "password",
|
||||
"mysqlDatabase": "a3attendance",
|
||||
})
|
||||
ConfigJSON.SetDefault("armaConfig", map[string]interface{}{
|
||||
"debug": true,
|
||||
"traceLogToFile": false,
|
||||
"dbUpdateIntervalS": 60,
|
||||
})
|
||||
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := ConfigJSON.ReadInConfig(); err != nil {
|
||||
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
|
||||
// Config file not found; ignore error if desired
|
||||
return "", fmt.Errorf(
|
||||
"config file not found, using defaults! searched in %s",
|
||||
[]string{
|
||||
ConfigJSON.ConfigFileUsed(),
|
||||
modulePathDir,
|
||||
wd,
|
||||
},
|
||||
)
|
||||
} else {
|
||||
// Config file was found but another error was produced
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
return "Config loaded successfully!", nil
|
||||
}
|
||||
|
||||
func ConfigArmaFormat() (string, error) {
|
||||
armaConfig := ConfigJSON.GetStringMap("armaConfig")
|
||||
bytes, err := json.Marshal(armaConfig)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(bytes), nil
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "extensionCallback.h"
|
||||
|
||||
extern void goRVExtension(char *output, size_t outputSize, char *input);
|
||||
extern void goRVExtensionVersion(char *output, size_t outputSize);
|
||||
extern void goRVExtensionArgs(char *output, size_t outputSize, char *input, char **argv, int argc);
|
||||
extern void goRVExtensionRegisterCallback(extensionCallback fnc);
|
||||
|
||||
#ifdef WIN64
|
||||
__declspec(dllexport) void RVExtension(char *output, size_t outputSize, char *input)
|
||||
{
|
||||
goRVExtension(output, outputSize, input);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void RVExtensionVersion(char *output, size_t outputSize)
|
||||
{
|
||||
goRVExtensionVersion(output, outputSize);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void RVExtensionArgs(char *output, size_t outputSize, char *input, char **argv, int argc)
|
||||
{
|
||||
goRVExtensionArgs(output, outputSize, input, argv, argc);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void RVExtensionRegisterCallback(extensionCallback fnc)
|
||||
{
|
||||
goRVExtensionRegisterCallback(fnc);
|
||||
}
|
||||
#else
|
||||
__declspec(dllexport) void __stdcall _RVExtension(char *output, size_t outputSize, char *input)
|
||||
{
|
||||
goRVExtension(output, outputSize, input);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void __stdcall _RVExtensionVersion(char *output, size_t outputSize)
|
||||
{
|
||||
goRVExtensionVersion(output, outputSize);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void __stdcall _RVExtensionArgs(char *output, size_t outputSize, char *input, char **argv, int argc)
|
||||
{
|
||||
goRVExtensionArgs(output, outputSize, input, argv, argc);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void __stdcall _RVExtensionRegisterCallback(extensionCallback fnc)
|
||||
{
|
||||
goRVExtensionRegisterCallback(fnc);
|
||||
}
|
||||
#endif
|
||||
// do this for all the other exported functions
|
||||
|
||||
// dll entrypoint
|
||||
// Path: RVExtension.c
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
$ENV:GOARCH = "amd64"
|
||||
$ENV:CGO_ENABLED = 1
|
||||
|
||||
go1.16.4 build -o ../@AttendanceTracker/AttendanceTracker_x64.dll -buildmode=c-shared .
|
||||
|
||||
go1.16.4 build -o buildDb.exe .
|
||||
Binary file not shown.
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef int (*extensionCallback)(char const *name, char const *function, char const *data);
|
||||
|
||||
/* https://golang.org/cmd/cgo/#hdr-C_references_to_Go */
|
||||
static inline int runExtensionCallback(extensionCallback fnc, char const *name, char const *function, char const *data)
|
||||
{
|
||||
return fnc(name, function, data);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
module main.go
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/go-sql-driver/mysql v1.7.0
|
||||
gorm.io/driver/mysql v1.5.1
|
||||
gorm.io/gorm v1.25.2
|
||||
)
|
||||
@@ -1,11 +0,0 @@
|
||||
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
|
||||
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
gorm.io/driver/mysql v1.5.1 h1:WUEH5VF9obL/lTtzjmML/5e6VfFR/788coz2uaVCAZw=
|
||||
gorm.io/driver/mysql v1.5.1/go.mod h1:Jo3Xu7mMhCyj8dlrb3WoCaRd1FhsVh+yMXb1jUInf5o=
|
||||
gorm.io/gorm v1.25.1/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
|
||||
gorm.io/gorm v1.25.2 h1:gs1o6Vsa+oVKG/a9ElL3XgyGfghFfkKA2SInQaCyMho=
|
||||
gorm.io/gorm v1.25.2/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
|
||||
@@ -1,742 +0,0 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "extensionCallback.h"
|
||||
*/
|
||||
import "C" // This is required to import the C code
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var EXTENSION_VERSION string = "0.0.1"
|
||||
var extensionCallbackFnc C.extensionCallback
|
||||
|
||||
// file paths
|
||||
var ADDON_FOLDER string = getDir() + "\\@AttendanceTracker"
|
||||
var LOG_FILE string = ADDON_FOLDER + "\\attendanceTracker.log"
|
||||
var CONFIG_FILE string = ADDON_FOLDER + "\\config.json"
|
||||
var SERVER_TIME_FILE string = ADDON_FOLDER + "\\lastServerTime.txt"
|
||||
|
||||
var ATTENDANCE_TABLE string = "attendance"
|
||||
var MISSIONS_TABLE string = "missions"
|
||||
var WORLDS_TABLE string = "worlds"
|
||||
|
||||
var LAST_SERVER_TIME uint64 = 0
|
||||
|
||||
// ! TODO make a hash to save key:netId from A3 value:rowId from join event
|
||||
|
||||
var Config AttendanceTrackerConfig
|
||||
var ATConfig ATSQLConfig
|
||||
var A3Config ArmaConfig
|
||||
|
||||
type ArmaConfig struct {
|
||||
DBUpdateIntervalSeconds int `json:"dbUpdateIntervalSeconds"`
|
||||
Debug bool `json:"debug"`
|
||||
ServerEventFillNullMinutes int `json:"serverEventFillNullMinutes"`
|
||||
MissionEventFillNullMinutes int `json:"missionEventFillNullMinutes"`
|
||||
}
|
||||
|
||||
type ATSQLConfig struct {
|
||||
MySQLHost string `json:"mysqlHost"`
|
||||
MySQLPort int `json:"mysqlPort"`
|
||||
MySQLUser string `json:"mysqlUser"`
|
||||
MySQLPassword string `json:"mysqlPassword"`
|
||||
MySQLDatabase string `json:"mysqlDatabase"`
|
||||
}
|
||||
|
||||
type AttendanceTrackerConfig struct {
|
||||
ArmaConfig ArmaConfig `json:"armaConfig"`
|
||||
SQLConfig ATSQLConfig `json:"sqlConfig"`
|
||||
}
|
||||
|
||||
// database connection
|
||||
var db *gorm.DB
|
||||
|
||||
// configure log output
|
||||
func init() {
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
// log to file
|
||||
f, err := os.OpenFile(LOG_FILE, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
||||
if err != nil {
|
||||
log.Fatalf("error opening file: %v", err)
|
||||
}
|
||||
// log to console as well
|
||||
// log.SetOutput(io.MultiWriter(f, os.Stdout))
|
||||
// log only to file
|
||||
log.SetOutput(f)
|
||||
}
|
||||
|
||||
func version() {
|
||||
functionName := "version"
|
||||
writeLog(functionName, fmt.Sprintf(`["AttendanceTracker Extension Version:%s", "INFO"]`, EXTENSION_VERSION))
|
||||
}
|
||||
|
||||
func getDir() string {
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
writeLog("getDir", fmt.Sprintf(`["Error getting working directory: %v", "ERROR"]`, err))
|
||||
return ""
|
||||
}
|
||||
return dir
|
||||
}
|
||||
|
||||
func loadConfig() {
|
||||
// load config from file as JSON
|
||||
functionName := "loadConfig"
|
||||
|
||||
// get location of this dll
|
||||
// dllPath, err := filepath.Abs(os.Args[0])
|
||||
// if err != nil {
|
||||
// writeLog(functionName, fmt.Sprintf(`["Error getting DLL path: %v", "ERROR"]`, err))
|
||||
// return
|
||||
// }
|
||||
|
||||
// set the addon directory to the parent directory of the dll
|
||||
// ADDON_FOLDER = filepath.Dir(dllPath)
|
||||
// LOG_FILE = ADDON_FOLDER + "\\attendanceTracker.log"
|
||||
// CONFIG_FILE = ADDON_FOLDER + "\\config.json"
|
||||
|
||||
file, err := os.OpenFile(CONFIG_FILE, os.O_RDONLY|os.O_CREATE, 0666)
|
||||
if err != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, err))
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
// log.Println("Loading config from", CONFIG_FILE)
|
||||
|
||||
decoder := json.NewDecoder(file)
|
||||
err = decoder.Decode(&Config)
|
||||
if err != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, err))
|
||||
return
|
||||
}
|
||||
A3Config = Config.ArmaConfig
|
||||
ATConfig = Config.SQLConfig
|
||||
|
||||
writeLog(functionName, `["Config loaded", "INFO"]`)
|
||||
}
|
||||
|
||||
func getSettings() string {
|
||||
// get settings from A3Config and send to Arma
|
||||
var settings string = `[`
|
||||
// iterate through keys in A3Config struct
|
||||
v := reflect.ValueOf(A3Config)
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
// get field name
|
||||
fieldName := v.Type().Field(i).Name
|
||||
// get field value
|
||||
fieldValue := v.Field(i).Interface()
|
||||
// if field value is a string, add quotes
|
||||
fieldValueString := fmt.Sprintf("%v", fieldValue)
|
||||
if reflect.TypeOf(fieldValue).Kind() == reflect.String {
|
||||
fieldValueString = fmt.Sprintf(`"%v"`, fieldValue)
|
||||
}
|
||||
// add to settings, key should be lowercase
|
||||
settings += fmt.Sprintf(`["%s", %s],`, strings.ToLower(fieldName), fieldValueString)
|
||||
}
|
||||
|
||||
// remove last comma
|
||||
settings = strings.TrimSuffix(settings, ",")
|
||||
settings += `]`
|
||||
|
||||
return settings
|
||||
}
|
||||
|
||||
func getMissionHash() string {
|
||||
functionName := "getMissionHash"
|
||||
// get md5 hash of string
|
||||
// https://stackoverflow.com/questions/2377881/how-to-get-a-md5-hash-from-a-string-in-golang
|
||||
hash := md5.Sum([]byte(time.Now().Format("2006-01-02 15:04:05")))
|
||||
|
||||
// convert to string
|
||||
hashString := fmt.Sprintf(`%x`, hash)
|
||||
writeLog(functionName, fmt.Sprintf(`["Mission hash: %s", "INFO"]`, hashString))
|
||||
return hashString
|
||||
}
|
||||
|
||||
func updateServerTime(serverTime uint64) {
|
||||
functionName := "updateServerTime"
|
||||
|
||||
var err error
|
||||
|
||||
// check .txt file for server time
|
||||
// first, check if it exists
|
||||
if _, err := os.Stat(SERVER_TIME_FILE); os.IsNotExist(err) {
|
||||
// file does not exist, create it and write serverTime to it
|
||||
writeLog(functionName, `["Server time file does not exist, creating it", "DEBUG"]`)
|
||||
err = ioutil.WriteFile(SERVER_TIME_FILE, []byte(strconv.FormatUint(serverTime, 10)), 0666)
|
||||
if err != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["Error writing server time to file: %v", "ERROR"]`, err))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// file exists, read it
|
||||
line, err := ioutil.ReadFile(SERVER_TIME_FILE)
|
||||
if err != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["Error reading server time file: %v", "ERROR"]`, err))
|
||||
return
|
||||
}
|
||||
|
||||
// convert to uint64
|
||||
LAST_SERVER_TIME, err := strconv.ParseUint(string(line), 10, 64)
|
||||
if err != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["Error converting server time to uint64: %v", "ERROR"]`, err))
|
||||
return
|
||||
}
|
||||
|
||||
// if serverTime is less than last server time, close server events
|
||||
if serverTime < LAST_SERVER_TIME {
|
||||
closeServerEvents()
|
||||
}
|
||||
LAST_SERVER_TIME = serverTime
|
||||
|
||||
// write server time to file
|
||||
err = ioutil.WriteFile(SERVER_TIME_FILE, []byte(strconv.FormatUint(serverTime, 10)), 0666)
|
||||
if err != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["Error writing server time to file: %v", "ERROR"]`, err))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func closeServerEvents() {
|
||||
functionName := "closeServerEvents"
|
||||
writeLog(functionName, `["Filling missing disconnect events due to server restart.", "DEBUG"]`)
|
||||
// get all events with null DisconnectTime & set DisconnectTime to current time
|
||||
var events []AttendanceItem
|
||||
db.Where("disconnect_time_utc = '0000-00-00 00:00:00'").Find(&events)
|
||||
for _, event := range events {
|
||||
|
||||
// if difference between JoinTime and current time is greater than threshold, set to threshold
|
||||
if event.EventType == "Server" {
|
||||
var timeThreshold time.Time = event.JoinTimeUTC.Add(-time.Duration(A3Config.ServerEventFillNullMinutes) * time.Minute)
|
||||
if event.JoinTimeUTC.Before(timeThreshold) {
|
||||
event.DisconnectTimeUTC = timeThreshold
|
||||
} else {
|
||||
event.DisconnectTimeUTC = time.Now()
|
||||
}
|
||||
} else if event.EventType == "Mission" {
|
||||
var timeThreshold time.Time = event.JoinTimeUTC.Add(-time.Duration(A3Config.MissionEventFillNullMinutes) * time.Minute)
|
||||
if event.JoinTimeUTC.Before(timeThreshold) {
|
||||
event.DisconnectTimeUTC = timeThreshold
|
||||
} else {
|
||||
event.DisconnectTimeUTC = time.Now()
|
||||
}
|
||||
}
|
||||
db.Save(&event)
|
||||
if db.Error != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["Error filling missing disconnects: %v", "ERROR"]`, db.Error))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// log how many
|
||||
writeLog(functionName, fmt.Sprintf(`["%d missing disconnects filled.", "INFO"]`, len(events)))
|
||||
}
|
||||
|
||||
func connectDB() error {
|
||||
|
||||
// load config
|
||||
loadConfig()
|
||||
|
||||
// connect to database
|
||||
var err error
|
||||
dsn := fmt.Sprintf(
|
||||
"%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=True",
|
||||
ATConfig.MySQLUser,
|
||||
ATConfig.MySQLPassword,
|
||||
ATConfig.MySQLHost,
|
||||
ATConfig.MySQLPort,
|
||||
ATConfig.MySQLDatabase,
|
||||
)
|
||||
|
||||
// log dsn and pause
|
||||
// writeLog("connectDB", fmt.Sprintf(`["DSN: %s", "INFO"]`, dsn))
|
||||
// fmt.Println(dsn)
|
||||
|
||||
if db != nil {
|
||||
// log success and return
|
||||
writeLog("connectDB", `["Database already connected", "INFO"]`)
|
||||
writeLog("connectDB", `["SUCCESS", "INFO"]`)
|
||||
return nil
|
||||
}
|
||||
|
||||
db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
|
||||
if err != nil {
|
||||
// log.Println(err)
|
||||
writeLog("connectDB", fmt.Sprintf(`["%s", "ERROR"]`, err))
|
||||
return err
|
||||
}
|
||||
|
||||
// Migrate the schema
|
||||
err = db.Set("gorm:table_options", "ENGINE=InnoDB").AutoMigrate(&World{}, &Mission{}, &AttendanceItem{})
|
||||
if err != nil {
|
||||
// log.Println(err)
|
||||
writeLog("connectDB", fmt.Sprintf(`["%s", "ERROR"]`, err))
|
||||
return err
|
||||
}
|
||||
|
||||
writeLog("connectDB", `["Database connected", "INFO"]`)
|
||||
writeLog("connectDB", `["SUCCESS", "INFO"]`)
|
||||
return nil
|
||||
}
|
||||
|
||||
type World struct {
|
||||
gorm.Model
|
||||
Author string `json:"author"`
|
||||
WorkshopID string `json:"workshopID"`
|
||||
DisplayName string `json:"displayName"`
|
||||
WorldName string `json:"worldName"`
|
||||
WorldNameOriginal string `json:"worldNameOriginal"`
|
||||
WorldSize float32 `json:"worldSize"`
|
||||
Latitude float32 `json:"latitude"`
|
||||
Longitude float32 `json:"longitude"`
|
||||
Missions []Mission
|
||||
}
|
||||
|
||||
func writeWorldInfo(worldInfo string) {
|
||||
functionName := "writeWorldInfo"
|
||||
// writeLog(functionName, fmt.Sprintf(`["%s", "DEBUG"]`, worldInfo))
|
||||
// worldInfo is json, parse it
|
||||
var wi World
|
||||
fixedString := fixEscapeQuotes(trimQuotes(worldInfo))
|
||||
err := json.Unmarshal([]byte(fixedString), &wi)
|
||||
if err != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, err))
|
||||
return
|
||||
}
|
||||
|
||||
// prevent crash
|
||||
if db == nil {
|
||||
err := connectDB()
|
||||
if err != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, err))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// write world if not exist
|
||||
var world World
|
||||
var returnId uint
|
||||
db.Where("world_name = ?", wi.WorldName).First(&world)
|
||||
if world.ID == 0 {
|
||||
writeLog(functionName, `["World not found, writing new world", "INFO"]`)
|
||||
result := db.Create(&wi)
|
||||
if result.Error != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, result.Error))
|
||||
return
|
||||
}
|
||||
writeLog(functionName, fmt.Sprintf(`["World written with ID %d", "INFO"]`, wi.ID))
|
||||
returnId = wi.ID
|
||||
} else {
|
||||
// return ID
|
||||
writeLog(functionName, fmt.Sprintf(`["World exists with ID %d", "INFO"]`, world.ID))
|
||||
returnId = world.ID
|
||||
}
|
||||
|
||||
writeLog(functionName, fmt.Sprintf(`["WORLD_ID", %d]`, returnId))
|
||||
}
|
||||
|
||||
type Mission struct {
|
||||
gorm.Model
|
||||
MissionName string `json:"missionName"`
|
||||
BriefingName string `json:"briefingName"`
|
||||
MissionNameSource string `json:"missionNameSource"`
|
||||
OnLoadName string `json:"onLoadName"`
|
||||
Author string `json:"author"`
|
||||
ServerName string `json:"serverName"`
|
||||
ServerProfile string `json:"serverProfile"`
|
||||
MissionStart time.Time `json:"missionStart" gorm:"type:datetime"`
|
||||
MissionHash string `json:"missionHash" gorm:"index"`
|
||||
WorldName string `json:"worldName" gorm:"-"`
|
||||
WorldID uint
|
||||
World World `gorm:"foreignkey:WorldID"`
|
||||
Attendees []AttendanceItem
|
||||
}
|
||||
|
||||
func writeMission(missionJSON string) {
|
||||
functionName := "writeMission"
|
||||
var err error
|
||||
// writeLog(functionName, fmt.Sprintf(`["%s", "DEBUG"]`, Mission))
|
||||
// Mission is json, parse it
|
||||
var mi Mission
|
||||
fixedString := fixEscapeQuotes(trimQuotes(missionJSON))
|
||||
err = json.Unmarshal([]byte(fixedString), &mi)
|
||||
if err != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, err))
|
||||
return
|
||||
}
|
||||
|
||||
// prevent crash
|
||||
if db == nil {
|
||||
err := connectDB()
|
||||
if err != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, err))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// get world from WorldName
|
||||
var world World
|
||||
db.Where("world_name = ?", mi.WorldName).First(&world)
|
||||
if world.ID == 0 {
|
||||
writeLog(functionName, fmt.Sprintf(`["World not found for %s, cannot write mission!", "ERROR"]`, mi.WorldName))
|
||||
return
|
||||
}
|
||||
mi.WorldID = world.ID
|
||||
|
||||
// write mission to database
|
||||
db.Create(&mi)
|
||||
if db.Error != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, db.Error))
|
||||
return
|
||||
}
|
||||
writeLog(functionName, fmt.Sprintf(`["Mission written with ID %d", "INFO"]`, mi.ID))
|
||||
writeLog(functionName, fmt.Sprintf(`["MISSION_ID", %d]`, mi.ID))
|
||||
}
|
||||
|
||||
type AttendanceItem struct {
|
||||
gorm.Model
|
||||
MissionHash string `json:"missionHash"`
|
||||
EventType string `json:"eventType"`
|
||||
PlayerId string `json:"playerId"`
|
||||
PlayerUID string `json:"playerUID"`
|
||||
JoinTimeUTC time.Time
|
||||
DisconnectTimeUTC time.Time
|
||||
ProfileName string `json:"profileName"`
|
||||
SteamName string `json:"steamName"`
|
||||
IsJIP bool `json:"isJIP" gorm:"column:is_jip"`
|
||||
RoleDescription string `json:"roleDescription"`
|
||||
MissionID uint
|
||||
Mission Mission `gorm:"foreignkey:MissionID"`
|
||||
}
|
||||
|
||||
func writeDisconnectEvent(data string) {
|
||||
functionName := "writeDisconnectEvent"
|
||||
var err error
|
||||
// data is json, parse it
|
||||
stringjson := fixEscapeQuotes(trimQuotes(data))
|
||||
var event AttendanceItem
|
||||
err = json.Unmarshal([]byte(stringjson), &event)
|
||||
if err != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, err))
|
||||
return
|
||||
}
|
||||
|
||||
// prevent crash
|
||||
if db == nil {
|
||||
err := connectDB()
|
||||
if err != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, err))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// get all attendance rows of type without disconnect rows
|
||||
var attendanceRows []AttendanceItem
|
||||
db.Where("player_uid = ? AND event_type = ? AND disconnect_time_utc = '0000-00-00 00:00:00'", event.PlayerUID, event.EventType).Find(&attendanceRows)
|
||||
for _, row := range attendanceRows {
|
||||
// update disconnect time
|
||||
if row.JoinTimeUTC.Before(time.Now().Add(-1*time.Hour)) && row.EventType == "Mission" {
|
||||
// if mission JoinTime is more than 1 hour ago, simplify this to write DisconnectTime as 1 hour from JoinTime. this to account for crashes where people don't immediately rejoin
|
||||
row.DisconnectTimeUTC = row.JoinTimeUTC.Add(-1 * time.Hour)
|
||||
} else if row.JoinTimeUTC.Before(time.Now().Add(-6*time.Hour)) && row.EventType == "Server" {
|
||||
// if server JoinTime is more than 6 hours ago, simplify this to write DisconnectTime as 6 hours from JoinTime. this to account for server crashes where people don't immediately rejoin without overwriting valid (potentially lengthy) server sessions
|
||||
row.DisconnectTimeUTC = row.JoinTimeUTC.Add(-6 * time.Hour)
|
||||
} else {
|
||||
// otherwise, update DisconnectTime to now
|
||||
row.DisconnectTimeUTC = time.Now()
|
||||
}
|
||||
db.Save(&row)
|
||||
}
|
||||
|
||||
writeLog(functionName, fmt.Sprintf(`["Disconnect events written for %s", "DEBUG"]`, event.PlayerUID))
|
||||
}
|
||||
|
||||
func writeAttendance(data string) {
|
||||
functionName := "writeAttendance"
|
||||
var err error
|
||||
// data is json, parse it
|
||||
stringjson := fixEscapeQuotes(trimQuotes(data))
|
||||
var event AttendanceItem
|
||||
err = json.Unmarshal([]byte(stringjson), &event)
|
||||
if err != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, err))
|
||||
return
|
||||
}
|
||||
|
||||
// prevent crash
|
||||
if db == nil {
|
||||
err := connectDB()
|
||||
if err != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, err))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var playerUid string
|
||||
var rowId uint
|
||||
if event.EventType == "Server" {
|
||||
// check for most recent existing attendance row
|
||||
var attendance AttendanceItem
|
||||
db.Where("player_id = ? AND player_uid = ? AND event_type = ?", event.PlayerId, event.PlayerUID, event.EventType).Order("join_time_utc desc").First(&attendance)
|
||||
if attendance.ID != 0 {
|
||||
// update disconnect time
|
||||
row := db.Model(&attendance).Update("disconnect_time_utc", time.Now())
|
||||
if row.Error != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, row.Error))
|
||||
return
|
||||
}
|
||||
rowId, playerUid = attendance.ID, attendance.PlayerUID
|
||||
|
||||
} else {
|
||||
// insert new row
|
||||
event.JoinTimeUTC = time.Now()
|
||||
row := db.Omit("MissionID").Omit("MissionHash").Create(&event)
|
||||
if row.Error != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, row.Error))
|
||||
return
|
||||
}
|
||||
rowId, playerUid = event.ID, event.PlayerUID
|
||||
}
|
||||
} else if event.EventType == "Mission" {
|
||||
// use gorm to associate this event with the mission sharing a mission hash
|
||||
var mission Mission
|
||||
db.Where("mission_hash = ?", event.MissionHash).First(&mission)
|
||||
if mission.ID != 0 {
|
||||
event.MissionID = uint(mission.ID)
|
||||
} else {
|
||||
writeLog(functionName, fmt.Sprintf(`["Mission not found for hash %s", "ERROR"]`, event.MissionHash))
|
||||
return
|
||||
}
|
||||
|
||||
// check for most recent JoinTime for this player and event type
|
||||
var attendance AttendanceItem
|
||||
db.Where("player_id = ? AND player_uid = ? AND event_type = ? AND mission_hash = ?", event.PlayerId, event.PlayerUID, event.EventType, event.MissionHash).Order("join_time_utc desc").First(&attendance)
|
||||
if attendance.ID != 0 {
|
||||
// update disconnect time
|
||||
row := db.Model(&attendance).Update("disconnect_time_utc", time.Now())
|
||||
if row.Error != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, row.Error))
|
||||
return
|
||||
}
|
||||
rowId, playerUid = attendance.ID, attendance.PlayerUID
|
||||
} else {
|
||||
event.JoinTimeUTC = time.Now()
|
||||
// insert new row
|
||||
row := db.Create(&event)
|
||||
if row.Error != nil {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, row.Error))
|
||||
return
|
||||
}
|
||||
rowId, playerUid = event.ID, event.PlayerUID
|
||||
}
|
||||
}
|
||||
|
||||
writeLog(functionName, fmt.Sprintf(`["Saved attendance for %s to row id %d", "DEBUG"]`, playerUid, rowId))
|
||||
}
|
||||
|
||||
func runExtensionCallback(name *C.char, function *C.char, data *C.char) C.int {
|
||||
return C.runExtensionCallback(extensionCallbackFnc, name, function, data)
|
||||
}
|
||||
|
||||
//export goRVExtensionVersion
|
||||
func goRVExtensionVersion(output *C.char, outputsize C.size_t) {
|
||||
result := C.CString(EXTENSION_VERSION)
|
||||
defer C.free(unsafe.Pointer(result))
|
||||
var size = C.strlen(result) + 1
|
||||
if size > outputsize {
|
||||
size = outputsize
|
||||
}
|
||||
C.memmove(unsafe.Pointer(output), unsafe.Pointer(result), size)
|
||||
}
|
||||
|
||||
//export goRVExtensionArgs
|
||||
func goRVExtensionArgs(output *C.char, outputsize C.size_t, input *C.char, argv **C.char, argc C.int) {
|
||||
var offset = unsafe.Sizeof(uintptr(0))
|
||||
var out []string
|
||||
for index := C.int(0); index < argc; index++ {
|
||||
out = append(out, C.GoString(*argv))
|
||||
argv = (**C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(argv)) + offset))
|
||||
}
|
||||
|
||||
// temp := fmt.Sprintf("Function: %s nb params: %d params: %s!", C.GoString(input), argc, out)
|
||||
temp := fmt.Sprintf("Function: %s nb params: %d", C.GoString(input), argc)
|
||||
|
||||
switch C.GoString(input) {
|
||||
case "writeAttendance":
|
||||
{ // callExtension ["logAttendance", [_hash] call CBA_fnc_encodeJSON]];
|
||||
if argc == 1 {
|
||||
go writeAttendance(out[0])
|
||||
}
|
||||
}
|
||||
case "writeDisconnectEvent":
|
||||
{ // callExtension ["writeDisconnectEvent", [_hash] call CBA_fnc_encodeJSON]];
|
||||
if argc == 1 {
|
||||
go writeDisconnectEvent(out[0])
|
||||
}
|
||||
}
|
||||
case "logMission":
|
||||
if argc == 1 {
|
||||
go writeMission(out[0])
|
||||
}
|
||||
case "logWorld":
|
||||
if argc == 1 {
|
||||
go writeWorldInfo(out[0])
|
||||
}
|
||||
case "updateServerTime":
|
||||
if argc == 1 {
|
||||
// convert to uint64
|
||||
serverTime, err := strconv.ParseUint(out[0], 10, 64)
|
||||
if err != nil {
|
||||
writeLog("updateServerTime", fmt.Sprintf(`["%s", "ERROR"]`, err))
|
||||
temp = "ERROR parsing server time"
|
||||
} else {
|
||||
go updateServerTime(serverTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return a result to Arma
|
||||
result := C.CString(temp)
|
||||
defer C.free(unsafe.Pointer(result))
|
||||
var size = C.strlen(result) + 1
|
||||
if size > outputsize {
|
||||
size = outputsize
|
||||
}
|
||||
|
||||
C.memmove(unsafe.Pointer(output), unsafe.Pointer(result), size)
|
||||
}
|
||||
|
||||
func callBackExample() {
|
||||
name := C.CString("arma")
|
||||
defer C.free(unsafe.Pointer(name))
|
||||
function := C.CString("funcToExecute")
|
||||
defer C.free(unsafe.Pointer(function))
|
||||
// Make a callback to Arma
|
||||
for i := 0; i < 3; i++ {
|
||||
time.Sleep(2 * time.Second)
|
||||
param := C.CString(fmt.Sprintf("Loop: %d", i))
|
||||
defer C.free(unsafe.Pointer(param))
|
||||
runExtensionCallback(name, function, param)
|
||||
}
|
||||
}
|
||||
|
||||
func getTimestamp() string {
|
||||
// get the current unix timestamp in nanoseconds
|
||||
// return time.Now().Local().Unix()
|
||||
return time.Now().Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
func trimQuotes(s string) string {
|
||||
// trim the start and end quotes from a string
|
||||
return strings.Trim(s, `"`)
|
||||
}
|
||||
|
||||
func fixEscapeQuotes(s string) string {
|
||||
// fix the escape quotes in a string
|
||||
return strings.Replace(s, `""`, `"`, -1)
|
||||
}
|
||||
|
||||
func writeLog(functionName string, data string) {
|
||||
// get calling function & line
|
||||
_, file, line, _ := runtime.Caller(1)
|
||||
log.Printf(`%s:%d:%s %s`, path.Base(file), line, functionName, data)
|
||||
|
||||
if extensionCallbackFnc == nil {
|
||||
return
|
||||
}
|
||||
|
||||
statusName := C.CString("AttendanceTracker")
|
||||
defer C.free(unsafe.Pointer(statusName))
|
||||
statusFunction := C.CString(functionName)
|
||||
defer C.free(unsafe.Pointer(statusFunction))
|
||||
statusParam := C.CString(data)
|
||||
defer C.free(unsafe.Pointer(statusParam))
|
||||
|
||||
runExtensionCallback(statusName, statusFunction, statusParam)
|
||||
}
|
||||
|
||||
func disconnectDB() {
|
||||
if db != nil {
|
||||
db = nil
|
||||
}
|
||||
}
|
||||
|
||||
//export goRVExtension
|
||||
func goRVExtension(output *C.char, outputsize C.size_t, input *C.char) {
|
||||
|
||||
var temp string
|
||||
|
||||
// logLine("goRVExtension", fmt.Sprintf(`["Input: %s", "DEBUG"]`, C.GoString(input)), true)
|
||||
|
||||
switch C.GoString(input) {
|
||||
case "version":
|
||||
temp = EXTENSION_VERSION
|
||||
case "getDir":
|
||||
temp = getDir()
|
||||
case "getSettings":
|
||||
loadConfig()
|
||||
temp = getSettings()
|
||||
case "getTimestamp":
|
||||
temp = fmt.Sprintf(`["%s"]`, getTimestamp())
|
||||
case "connectDB":
|
||||
temp = fmt.Sprintf(`["%s"]`, "Connecting to DB")
|
||||
connectDB()
|
||||
case "disconnectDB":
|
||||
temp = fmt.Sprintf(`["%s"]`, "Disconnecting from DB")
|
||||
disconnectDB()
|
||||
case "getMissionHash":
|
||||
temp = fmt.Sprintf(`["%s"]`, getMissionHash())
|
||||
default:
|
||||
temp = fmt.Sprintf(`["%s"]`, "Unknown Function")
|
||||
}
|
||||
|
||||
result := C.CString(temp)
|
||||
defer C.free(unsafe.Pointer(result))
|
||||
var size = C.strlen(result) + 1
|
||||
if size > outputsize {
|
||||
size = outputsize
|
||||
}
|
||||
|
||||
C.memmove(unsafe.Pointer(output), unsafe.Pointer(result), size)
|
||||
// return
|
||||
}
|
||||
|
||||
//export goRVExtensionRegisterCallback
|
||||
func goRVExtensionRegisterCallback(fnc C.extensionCallback) {
|
||||
extensionCallbackFnc = fnc
|
||||
}
|
||||
|
||||
func main() {
|
||||
loadConfig()
|
||||
fmt.Println("Running DB connect/migrate to build schema...")
|
||||
err := connectDB()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("DB connect/migrate complete!")
|
||||
}
|
||||
fmt.Scanln()
|
||||
}
|
||||
1833
include/x/cba/addons/main/script_macros_common.hpp
Normal file
1833
include/x/cba/addons/main/script_macros_common.hpp
Normal file
File diff suppressed because it is too large
Load Diff
118
include/x/cba/addons/xeh/script_xeh.hpp
Normal file
118
include/x/cba/addons/xeh/script_xeh.hpp
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
Header: script_xeh.hpp
|
||||
|
||||
Description:
|
||||
Used internally.
|
||||
*/
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// MACRO: EXTENDED_EVENTHANDLERS
|
||||
// Add all XEH event handlers
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define EXTENDED_EVENTHANDLERS init = "call cba_xeh_fnc_init"; \
|
||||
fired = "call cba_xeh_fnc_fired"; \
|
||||
animChanged = "call cba_xeh_fnc_animChanged"; \
|
||||
animDone = "call cba_xeh_fnc_animDone"; \
|
||||
animStateChanged = "call cba_xeh_fnc_animStateChanged"; \
|
||||
containerClosed = "call cba_xeh_fnc_containerClosed"; \
|
||||
containerOpened = "call cba_xeh_fnc_containerOpened"; \
|
||||
controlsShifted = "call cba_xeh_fnc_controlsShifted"; \
|
||||
dammaged = "call cba_xeh_fnc_dammaged"; \
|
||||
engine = "call cba_xeh_fnc_engine"; \
|
||||
epeContact = "call cba_xeh_fnc_epeContact"; \
|
||||
epeContactEnd = "call cba_xeh_fnc_epeContactEnd"; \
|
||||
epeContactStart = "call cba_xeh_fnc_epeContactStart"; \
|
||||
explosion = "call cba_xeh_fnc_explosion"; \
|
||||
firedNear = "call cba_xeh_fnc_firedNear"; \
|
||||
fuel = "call cba_xeh_fnc_cba_xeh_fuel"; \
|
||||
gear = "call cba_xeh_fnc_gear"; \
|
||||
getIn = "call cba_xeh_fnc_getIn"; \
|
||||
getInMan = "call cba_xeh_fnc_getInMan"; \
|
||||
getOut = "call cba_xeh_fnc_getOut"; \
|
||||
getOutMan = "call cba_xeh_fnc_getOutMan"; \
|
||||
handleHeal = "call cba_xeh_fnc_handleHeal"; \
|
||||
hit = "call cba_xeh_fnc_hit"; \
|
||||
hitPart = "call cba_xeh_fnc_hitPart"; \
|
||||
incomingMissile = "call cba_xeh_fnc_incomingMissile"; \
|
||||
inventoryClosed = "call cba_xeh_fnc_inventoryClosed"; \
|
||||
inventoryOpened = "call cba_xeh_fnc_inventoryOpened"; \
|
||||
killed = "call cba_xeh_fnc_killed"; \
|
||||
landedTouchDown = "call cba_xeh_fnc_landedTouchDown"; \
|
||||
landedStopped = "call cba_xeh_fnc_landedStopped"; \
|
||||
local = "call cba_xeh_fnc_local"; \
|
||||
respawn = "call cba_xeh_fnc_respawn"; \
|
||||
put = "call cba_xeh_fnc_put"; \
|
||||
take = "call cba_xeh_fnc_take"; \
|
||||
seatSwitched = "call cba_xeh_fnc_seatSwitched"; \
|
||||
seatSwitchedMan = "call cba_xeh_fnc_seatSwitchedMan"; \
|
||||
soundPlayed = "call cba_xeh_fnc_soundPlayed"; \
|
||||
weaponAssembled = "call cba_xeh_fnc_weaponAssembled"; \
|
||||
weaponDisassembled = "call cba_xeh_fnc_weaponDisassembled"; \
|
||||
weaponDeployed = "call cba_xeh_fnc_weaponDeployed"; \
|
||||
weaponRested = "call cba_xeh_fnc_weaponRested"; \
|
||||
reloaded = "call cba_xeh_fnc_reloaded"; \
|
||||
firedMan = "call cba_xeh_fnc_firedMan"; \
|
||||
turnIn = "call cba_xeh_fnc_turnIn"; \
|
||||
turnOut = "call cba_xeh_fnc_turnOut"; \
|
||||
deleted = "call cba_xeh_fnc_deleted"; \
|
||||
disassembled = "call cba_xeh_fnc_disassembled"; \
|
||||
Suppressed = "call cba_xeh_fnc_Suppressed"; \
|
||||
gestureChanged = "call cba_xeh_fnc_gestureChanged"; \
|
||||
gestureDone = "call cba_xeh_fnc_gestureDone";
|
||||
|
||||
/*
|
||||
MACRO: DELETE_EVENTHANDLERS
|
||||
|
||||
Removes all event handlers.
|
||||
*/
|
||||
|
||||
#define DELETE_EVENTHANDLERS init = ""; \
|
||||
fired = ""; \
|
||||
animChanged = ""; \
|
||||
animDone = ""; \
|
||||
animStateChanged = ""; \
|
||||
containerClosed = ""; \
|
||||
containerOpened = ""; \
|
||||
controlsShifted = ""; \
|
||||
dammaged = ""; \
|
||||
engine = ""; \
|
||||
epeContact = ""; \
|
||||
epeContactEnd = ""; \
|
||||
epeContactStart = ""; \
|
||||
explosion = ""; \
|
||||
firedNear = ""; \
|
||||
fuel = ""; \
|
||||
gear = ""; \
|
||||
getIn = ""; \
|
||||
getInMan = ""; \
|
||||
getOut = ""; \
|
||||
getOutMan = ""; \
|
||||
handleHeal = ""; \
|
||||
hit = ""; \
|
||||
hitPart = ""; \
|
||||
incomingMissile = ""; \
|
||||
inventoryClosed = ""; \
|
||||
inventoryOpened = ""; \
|
||||
killed = ""; \
|
||||
landedTouchDown = ""; \
|
||||
landedStopped = ""; \
|
||||
local = ""; \
|
||||
respawn = ""; \
|
||||
put = ""; \
|
||||
take = ""; \
|
||||
seatSwitched = ""; \
|
||||
seatSwitchedMan = ""; \
|
||||
soundPlayed = ""; \
|
||||
weaponAssembled = ""; \
|
||||
weaponDisassembled = ""; \
|
||||
weaponDeployed = ""; \
|
||||
weaponRested = ""; \
|
||||
reloaded = ""; \
|
||||
firedMan = ""; \
|
||||
turnIn = ""; \
|
||||
turnOut = ""; \
|
||||
deleted = ""; \
|
||||
disassembled = ""; \
|
||||
Suppressed = ""; \
|
||||
gestureChanged = ""; \
|
||||
gestureDone = ""
|
||||
BIN
releases/attendancetracker-0.2.0.20230919-f692b9.zip
Normal file
BIN
releases/attendancetracker-0.2.0.20230919-f692b9.zip
Normal file
Binary file not shown.
BIN
releases/attendancetracker-latest.zip
Normal file
BIN
releases/attendancetracker-latest.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user