mirror of
https://github.com/indig0fox/Arma3-AttendanceTracker.git/
synced 2025-12-08 09:51:47 -06:00
bug fixes/debugging
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -21,7 +21,8 @@ class CfgFunctions {
|
|||||||
class logMissionEvent {};
|
class logMissionEvent {};
|
||||||
class logServerEvent {};
|
class logServerEvent {};
|
||||||
class timestamp {};
|
class timestamp {};
|
||||||
class getHash {};
|
class getMissionHash {};
|
||||||
|
class getWorldInfo {};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -61,13 +61,13 @@ addMissionEventHandler ["ExtensionCallback", {
|
|||||||
};
|
};
|
||||||
case "writeMissionInfo": {
|
case "writeMissionInfo": {
|
||||||
if (_response#0 == "MISSION_ID") then {
|
if (_response#0 == "MISSION_ID") then {
|
||||||
AttendanceTracker_missionId = parseNumber _response;
|
AttendanceTracker_missionId = parseNumber (_response#1);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
case "writeAttendance": {
|
case "writeAttendance": {
|
||||||
if (_response#0 == "ATT_LOG") then {
|
if (_response#0 == "ATT_LOG") then {
|
||||||
_response params ["_netId", "_rowId"];
|
_response params ["_netId", "_rowId"];
|
||||||
((AttendanceTracker getVariable ["allUsers", createHashMap]) get _netId) set ["_rowID", _rowID];
|
((AttendanceTracker getVariable ["allUsers", createHashMap]) get _netId) append _rowID;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
default {
|
default {
|
||||||
|
|||||||
@@ -5,8 +5,14 @@
|
|||||||
[format ["(EventHandler) OnUserConnected fired: %1", _this], "DEBUG"] call attendanceTracker_fnc_log;
|
[format ["(EventHandler) OnUserConnected fired: %1", _this], "DEBUG"] call attendanceTracker_fnc_log;
|
||||||
|
|
||||||
private _userInfo = (getUserInfo _networkId);
|
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"];
|
_userInfo params ["_playerID", "_ownerId", "_playerUID", "_profileName", "_displayName", "_steamName", "_clientState", "_isHC", "_adminState", "_networkInfo", "_unit"];
|
||||||
if (_isHC) exitWith {};
|
if (_isHC) exitWith {
|
||||||
|
[format ["(EventHandler) OnUserConnected: %1 is HC, skipping", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
|
||||||
|
};
|
||||||
|
|
||||||
(AttendanceTracker getVariable ["allUsers", createHashMap]) set [_networkId, _userInfo];
|
(AttendanceTracker getVariable ["allUsers", createHashMap]) set [_networkId, _userInfo];
|
||||||
[
|
[
|
||||||
@@ -16,7 +22,7 @@
|
|||||||
_profileName,
|
_profileName,
|
||||||
_steamName,
|
_steamName,
|
||||||
nil // send rowId on d/c only
|
nil // send rowId on d/c only
|
||||||
] call attendanceTracker_fnc_writeAttendance;
|
] call attendanceTracker_fnc_logServerEvent;
|
||||||
|
|
||||||
}],
|
}],
|
||||||
["OnUserDisconnected", {
|
["OnUserDisconnected", {
|
||||||
@@ -25,10 +31,14 @@
|
|||||||
[format ["(EventHandler) OnUserDisconnected fired: %1", _this], "DEBUG"] call attendanceTracker_fnc_log;
|
[format ["(EventHandler) OnUserDisconnected fired: %1", _this], "DEBUG"] call attendanceTracker_fnc_log;
|
||||||
|
|
||||||
private _userInfo = (AttendanceTracker getVariable ["allUsers", createHashMap]) get _networkId;
|
private _userInfo = (AttendanceTracker getVariable ["allUsers", createHashMap]) get _networkId;
|
||||||
if (isNil "_userInfo") exitWith {};
|
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", "_rowId"];
|
||||||
if (_isHC) exitWith {};
|
if (_isHC) exitWith {
|
||||||
|
[format ["(EventHandler) OnUserDisconnected: %1 is HC, skipping", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
|
||||||
|
};
|
||||||
|
|
||||||
[
|
[
|
||||||
"Server",
|
"Server",
|
||||||
@@ -37,7 +47,7 @@
|
|||||||
_profileName,
|
_profileName,
|
||||||
_steamName,
|
_steamName,
|
||||||
(if (!isNil "_rowId") then {_rowId} else {nil}) // send rowId on d/c only
|
(if (!isNil "_rowId") then {_rowId} else {nil}) // send rowId on d/c only
|
||||||
] call attendanceTracker_fnc_writeAttendance;
|
] call attendanceTracker_fnc_logServerEvent;
|
||||||
}],
|
}],
|
||||||
["PlayerConnected", {
|
["PlayerConnected", {
|
||||||
params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
|
params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
|
||||||
@@ -45,10 +55,14 @@
|
|||||||
[format ["(EventHandler) PlayerConnected fired: %1", _this], "DEBUG"] call attendanceTracker_fnc_log;
|
[format ["(EventHandler) PlayerConnected fired: %1", _this], "DEBUG"] call attendanceTracker_fnc_log;
|
||||||
|
|
||||||
private _userInfo = (getUserInfo _idstr);
|
private _userInfo = (getUserInfo _idstr);
|
||||||
if (isNil "_userInfo") exitWith {};
|
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"];
|
_userInfo params ["_playerID", "_ownerId", "_playerUID", "_profileName", "_displayName", "_steamName", "_clientState", "_isHC", "_adminState", "_networkInfo", "_unit"];
|
||||||
if (_isHC) exitWith {};
|
if (_isHC) exitWith {
|
||||||
|
[format ["(EventHandler) PlayerConnected: %1 is HC, skipping", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
|
||||||
|
};
|
||||||
|
|
||||||
(AttendanceTracker getVariable ["allUsers", createHashMap]) set [_playerID, _userInfo];
|
(AttendanceTracker getVariable ["allUsers", createHashMap]) set [_playerID, _userInfo];
|
||||||
[
|
[
|
||||||
@@ -74,7 +88,9 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
_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", "_rowId"];
|
||||||
if (_isHC) exitWith {};
|
if (_isHC) exitWith {
|
||||||
|
[format ["(EventHandler) HandleDisconnect: %1 is HC, skipping", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
|
||||||
|
};
|
||||||
|
|
||||||
[
|
[
|
||||||
"Mission",
|
"Mission",
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ params [
|
|||||||
|
|
||||||
|
|
||||||
private _hash = + (AttendanceTracker getVariable ["missionContext", createHashMap]);
|
private _hash = + (AttendanceTracker getVariable ["missionContext", createHashMap]);
|
||||||
_hash set ["networkId", netID player]
|
_hash set ["networkId", netID player];
|
||||||
_hash set ["eventType", _eventType];
|
_hash set ["eventType", _eventType];
|
||||||
_hash set ["playerId", _playerId];
|
_hash set ["playerId", _playerId];
|
||||||
_hash set ["playerUID", _playerUID];
|
_hash set ["playerUID", _playerUID];
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ systemTimeUTC params [
|
|||||||
"_day",
|
"_day",
|
||||||
"_hour",
|
"_hour",
|
||||||
"_minute",
|
"_minute",
|
||||||
"_second"
|
"_second",
|
||||||
"_millisecond"
|
"_millisecond"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -18,7 +18,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -38,6 +37,8 @@ var ATTENDANCE_TABLE string = "attendance"
|
|||||||
var MISSIONS_TABLE string = "missions"
|
var MISSIONS_TABLE string = "missions"
|
||||||
var WORLDS_TABLE string = "worlds"
|
var WORLDS_TABLE string = "worlds"
|
||||||
|
|
||||||
|
// ! TODO make a hash to save key:netId from A3 value:rowId from join event
|
||||||
|
|
||||||
var ATConfig AttendanceTrackerConfig
|
var ATConfig AttendanceTrackerConfig
|
||||||
|
|
||||||
type AttendanceTrackerConfig struct {
|
type AttendanceTrackerConfig struct {
|
||||||
@@ -117,7 +118,7 @@ func getMissionHash() string {
|
|||||||
hash := md5.Sum([]byte(time.Now().Format("2006-01-02 15:04:05")))
|
hash := md5.Sum([]byte(time.Now().Format("2006-01-02 15:04:05")))
|
||||||
|
|
||||||
// convert to string
|
// convert to string
|
||||||
hashString := fmt.Sprintf("%x", hash)
|
hashString := fmt.Sprintf(`%x`, hash)
|
||||||
writeLog(functionName, fmt.Sprintf(`["Mission hash: %s", "INFO"]`, hashString))
|
writeLog(functionName, fmt.Sprintf(`["Mission hash: %s", "INFO"]`, hashString))
|
||||||
return hashString
|
return hashString
|
||||||
}
|
}
|
||||||
@@ -260,7 +261,7 @@ type MissionInfo struct {
|
|||||||
|
|
||||||
func writeMissionInfo(missionInfo string) {
|
func writeMissionInfo(missionInfo string) {
|
||||||
functionName := "writeMissionInfo"
|
functionName := "writeMissionInfo"
|
||||||
writeLog(functionName, fmt.Sprintf(`["%s", "DEBUG"]`, missionInfo))
|
// writeLog(functionName, fmt.Sprintf(`["%s", "DEBUG"]`, missionInfo))
|
||||||
// missionInfo is json, parse it
|
// missionInfo is json, parse it
|
||||||
var mi MissionInfo
|
var mi MissionInfo
|
||||||
fixedString := fixEscapeQuotes(trimQuotes(missionInfo))
|
fixedString := fixEscapeQuotes(trimQuotes(missionInfo))
|
||||||
@@ -271,15 +272,9 @@ func writeMissionInfo(missionInfo string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get MySQL friendly datetime
|
// get MySQL friendly datetime
|
||||||
// first, convert string to int
|
|
||||||
missionStartTime, err := strconv.ParseInt(mi.MissionStart, 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
writeLog(functionName, fmt.Sprintf(`["%s", "ERROR"]`, err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t := time.Unix(0, missionStartTime).Format("2006-01-02 15:04:05")
|
|
||||||
// write to log
|
// 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, t, mi.MissionHash))
|
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 database
|
// write to database
|
||||||
// every mission is unique, so insert it
|
// every mission is unique, so insert it
|
||||||
|
|||||||
Reference in New Issue
Block a user