big refactor, WIP!

This commit is contained in:
2024-02-06 01:52:25 -08:00
parent f588ffa4a0
commit 0a64d9e170
74 changed files with 1024 additions and 701 deletions

View File

@@ -1,8 +1,10 @@
#include "..\script_component.hpp"
if (!isServer) exitWith {};
// if at least 1 player in the queue has been waiting longer than the configured timeout, notify all players
private _timeout = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_max_wait", 60*20]; // default 20 minutes
private _timeoutPlayers = milsim_reinsert_reinsertionQueue select {
private _timeout = missionNamespace getVariable [QGVAR(setting_maxWait), 60*20]; // default 20 minutes
private _timeoutPlayers = GVAR(reinsertionQueue) select {
_x params ["_player", "_base", "_timeFiled"];
alive (_player) &&
(diag_tickTime - (_timeFiled)) > _timeout
@@ -10,10 +12,10 @@ private _timeoutPlayers = milsim_reinsert_reinsertionQueue select {
if (count _timeoutPlayers > 0) then {
// GLOBAL CBA NOTIFY
private _playerLines = [["Players are still waiting for Re-insert!", 1.2, [1, 0.64, 0, 1]]];
private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_maxRangeToReady", 400];
private _maxRangeToReady = missionNamespace getVariable [QGVAR(setting_maxRangeToReady), 400];
// get base objects from queue
private _basesWithPeople = (missionNamespace getVariable ["milsim_reinsert_reinsertionQueue", []]) apply {_x#1};
private _basesWithPeople = (missionNamespace getVariable [QGVAR(reinsertionQueue), []]) apply {_x#1};
// get unique base objects
private _basesWithPeople = _basesWithPeople arrayIntersect _basesWithPeople;
@@ -21,7 +23,7 @@ if (count _timeoutPlayers > 0) then {
private _thisBase = _x;
// Add line for base name
_playerLines pushBack ([[_thisBase] call milsim_util_fnc_getNameOfBase, 1, [0,1,0,1]]);
_playerLines pushBack ([[_thisBase] call EFUNC(common,getNameOfBase), 1, [0,1,0,1]]);
// Get players under this base
private _thisBasePlayers = _timeoutPlayers select {_x#1 isEqualTo _thisBase};
@@ -35,7 +37,7 @@ if (count _timeoutPlayers > 0) then {
{ // for each player under this base, add a line
_x params ["_player", "_base", "_timeFiled"];
// get the closest base to the player
private _nearestBase = [_player] call milsim_util_fnc_getNearestBase;
private _nearestBase = [_player] call EFUNC(common,getNearestBase);
// add player to array of players under bases
_playerLines pushBack ([format [
@@ -46,25 +48,24 @@ if (count _timeoutPlayers > 0) then {
], 0.8, [0.8, 0.8, 0.8, 1]]);
// log to rpt
private _logParams = [
["filedAtBase", [_base] call milsim_util_fnc_getNameOfBase],
["filedAtBaseDistance", _player distance _base],
["closestBase", [_nearestBase] call milsim_util_fnc_getNameOfBase],
["closestBaseDistance", _player distance _nearestBase],
["maxDistanceSetting", _maxRangeToReady],
["inQueueDuration", diag_tickTime - _timeFiled]
];
_logParams = [_player, _logParams] call milsim_util_fnc_addPlayerInfoToArray;
[
"respawn_reinsertion",
LEVEL_WARNING,
QUOTE(COMPONENT),
"PLAYER WAITING OVER TIMEOUT",
_logParams
] call milsim_util_fnc_log;
[_player, [
["filedAtBase", [_base] call EFUNC(common,getNameOfBase)],
["filedAtBaseDistance", _player distance _base],
["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)],
["closestBaseDistance", _player distance _nearestBase],
["maxDistanceSetting", _maxRangeToReady],
["inQueueDuration", diag_tickTime - _timeFiled]
]] call EFUNC(common,addPlayerInfoToArray)
] call EFUNC(common,log);
} forEach _thisBasePlayers;
} forEach _basesWithPeople;
// SEND NOTIFY
_playerLines remoteExec ["CBA_fnc_notify", [0, -2] select isDedicated];
// RESET NOTIFICATION TIMER
milsim_reinsert_reinsertionOverTimeoutLastNotificationTime = diag_tickTime;
GVAR(overTimeoutLastNotificationTime) = diag_tickTime;
};