mirror of
https://github.com/indig0fox/Arma3-AttendanceTracker.git/
synced 2025-12-08 09:51:47 -06:00
bug fixing
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -23,6 +23,7 @@ class CfgFunctions {
|
||||
class timestamp {};
|
||||
class getMissionHash {};
|
||||
class getWorldInfo {};
|
||||
class missionLoaded {};
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -21,11 +21,16 @@ addMissionEventHandler ["ExtensionCallback", {
|
||||
false;
|
||||
};
|
||||
|
||||
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],
|
||||
@@ -66,8 +71,12 @@ addMissionEventHandler ["ExtensionCallback", {
|
||||
};
|
||||
case "writeAttendance": {
|
||||
if (_response#0 == "ATT_LOG") then {
|
||||
_response params ["_netId", "_rowId"];
|
||||
((AttendanceTracker getVariable ["allUsers", createHashMap]) get _netId) append _rowID;
|
||||
(_response#1) params ["_eventType", "_netId", "_rowId"];
|
||||
private _storeIndex = ["SERVER", "MISSION"] find _eventType;
|
||||
((AttendanceTracker getVariable ["rowIds", createHashMap]) getOrDefault [
|
||||
_netId,
|
||||
[nil, nil]
|
||||
]) set [_storeIndex, _rowId];
|
||||
};
|
||||
};
|
||||
default {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
};
|
||||
|
||||
(AttendanceTracker getVariable ["allUsers", createHashMap]) set [_networkId, _userInfo];
|
||||
(AttendanceTracker getVariable ["rowIds", createHashMap]) set [_networkId, [nil, nil]]; // reset rowId on connect
|
||||
[
|
||||
"Server",
|
||||
_playerID,
|
||||
@@ -30,16 +31,25 @@
|
||||
|
||||
[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", "_rowId"];
|
||||
_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;
|
||||
};
|
||||
|
||||
private _rowId = ((AttendanceTracker getVariable ["rowIds", createHashMap]) getOrDefault [
|
||||
_networkId,
|
||||
[nil, nil]
|
||||
]) select 0;
|
||||
|
||||
[
|
||||
"Server",
|
||||
_playerID,
|
||||
@@ -54,6 +64,10 @@
|
||||
|
||||
[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;
|
||||
@@ -82,6 +96,10 @@
|
||||
|
||||
[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;
|
||||
@@ -92,6 +110,11 @@
|
||||
[format ["(EventHandler) HandleDisconnect: %1 is HC, skipping", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
|
||||
};
|
||||
|
||||
private _rowId = ((AttendanceTracker getVariable ["rowIds", createHashMap]) getOrDefault [
|
||||
_idstr,
|
||||
[nil, nil]
|
||||
]) select 1;
|
||||
|
||||
[
|
||||
"Mission",
|
||||
_playerID,
|
||||
@@ -105,5 +128,53 @@
|
||||
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
private _rowId = ((AttendanceTracker getVariable ["rowIds", createHashMap]) getOrDefault [
|
||||
_networkId,
|
||||
[nil, nil]
|
||||
]) select 0;
|
||||
|
||||
[
|
||||
"Server",
|
||||
_playerID,
|
||||
_playerUID,
|
||||
_profileName,
|
||||
_steamName,
|
||||
(if (!isNil "_rowId") then {_rowId} else {nil}) // send rowId on d/c only
|
||||
] call attendanceTracker_fnc_logServerEvent;
|
||||
|
||||
|
||||
private _rowId = ((AttendanceTracker getVariable ["rowIds", createHashMap]) getOrDefault [
|
||||
_networkId,
|
||||
[nil, nil]
|
||||
]) select 1;
|
||||
[
|
||||
"Mission",
|
||||
_playerID,
|
||||
_playerUID,
|
||||
_profileName,
|
||||
_steamName,
|
||||
nil // send rowId on d/c only
|
||||
] call attendanceTracker_fnc_logMissionEvent;
|
||||
}]
|
||||
];
|
||||
@@ -0,0 +1 @@
|
||||
!(getClientStateNumber <= 5 || getClientStateNumber isEqualTo 11);
|
||||
@@ -22,6 +22,7 @@ AttendanceTracker setVariable ["missionContext", createHashMapFromArray [
|
||||
|
||||
// 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];
|
||||
missionNamespace setVariable ["AttendanceTracker_debug", false];
|
||||
|
||||
call attendanceTracker_fnc_connectDB;
|
||||
|
||||
Binary file not shown.
@@ -179,7 +179,7 @@ type WorldInfo struct {
|
||||
|
||||
func writeWorldInfo(worldInfo string) {
|
||||
functionName := "writeWorldInfo"
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "DEBUG"]`, worldInfo))
|
||||
// writeLog(functionName, fmt.Sprintf(`["%s", "DEBUG"]`, worldInfo))
|
||||
// worldInfo is json, parse it
|
||||
var wi WorldInfo
|
||||
fixedString := fixEscapeQuotes(trimQuotes(worldInfo))
|
||||
@@ -188,8 +188,8 @@ func writeWorldInfo(worldInfo string) {
|
||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, err))
|
||||
return
|
||||
}
|
||||
// write to log
|
||||
writeLog(functionName, fmt.Sprintf(`["Author:%s WorkshopID:%s DisplayName:%s WorldName:%s WorldNameOriginal:%s WorldSize:%d Latitude:%f Longitude:%f", "INFO"]`, wi.Author, wi.WorkshopID, wi.DisplayName, wi.WorldName, wi.WorldNameOriginal, wi.WorldSize, wi.Latitude, wi.Longitude))
|
||||
// write to log as json
|
||||
// writeLog(functionName, fmt.Sprintf(`["%s", "DEBUG"]`, json.Marshal(wi)))
|
||||
|
||||
// write to database
|
||||
// check if world exists
|
||||
@@ -273,8 +273,8 @@ func writeMissionInfo(missionInfo string) {
|
||||
|
||||
// get MySQL friendly datetime
|
||||
|
||||
// write to log
|
||||
writeLog(functionName, fmt.Sprintf(`["MissionName:%s BriefingName:%s MissionNameSource:%s OnLoadName:%s Author:%s ServerName:%s ServerProfile:%s MissionStart:%s MissionHash:%s", "INFO"]`, mi.MissionName, mi.BriefingName, mi.MissionNameSource, mi.OnLoadName, mi.Author, mi.ServerName, mi.ServerProfile, mi.MissionStart, mi.MissionHash))
|
||||
// write to log as json
|
||||
// writeLog(functionName, fmt.Sprintf(`["%s", "DEBUG"]`, mi))
|
||||
|
||||
// write to database
|
||||
// every mission is unique, so insert it
|
||||
@@ -364,13 +364,17 @@ func writeAttendance(data string) {
|
||||
}
|
||||
|
||||
writeLog(functionName, fmt.Sprintf(`["Saved attendance for %s to row id %d", "INFO"]`, event.ProfileName, id))
|
||||
writeLog(functionName, fmt.Sprintf(`["ATT_LOG", ["%s", "%d"]]`, event.PlayerId, id))
|
||||
if event.EventType == "Server" {
|
||||
writeLog(functionName, fmt.Sprintf(`["ATT_LOG", ["SERVER", "%s", "%d"]]`, event.PlayerId, id))
|
||||
} else if event.EventType == "Mission" {
|
||||
writeLog(functionName, fmt.Sprintf(`["ATT_LOG", ["MISSION", "%s", "%d"]]`, event.PlayerId, id))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
type DisconnectItem struct {
|
||||
PlayerId string `json:"playerId"`
|
||||
RowId int64 `json:"rowId"`
|
||||
RowId string `json:"rowId"`
|
||||
}
|
||||
|
||||
func writeDisconnectEvent(data string) {
|
||||
@@ -416,7 +420,7 @@ func writeDisconnectEvent(data string) {
|
||||
}
|
||||
|
||||
if rowsAffected == 1 {
|
||||
writeLog(functionName, fmt.Sprintf(`["Saved disconnect event for %s to row id %d", "INFO"]`, event.PlayerId, event.RowId))
|
||||
writeLog(functionName, fmt.Sprintf(`["Saved disconnect event for %s to row id %s", "INFO"]`, event.PlayerId, event.RowId))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user