big refactor, WIP!
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
params [
|
||||
["_player", objNull, [objNull]],
|
||||
["_base", objNull, [objNull]],
|
||||
@@ -6,51 +8,54 @@ params [
|
||||
|
||||
if (!isServer) exitWith {
|
||||
[
|
||||
"respawn_reinsertion",
|
||||
LEVEL_ERROR,
|
||||
QUOTE(COMPONENT),
|
||||
"ATTEMPTED RUN ON CLIENT",
|
||||
[
|
||||
["player", _player],
|
||||
["base", _base]
|
||||
]
|
||||
] call milsim_util_fnc_log;
|
||||
] call EFUNC(common,log);
|
||||
["ATTEMPTED RUN ON CLIENT"] call BIS_fnc_error;
|
||||
};
|
||||
if (
|
||||
isNull _player ||
|
||||
isNull _base
|
||||
) exitWith {
|
||||
[
|
||||
"respawn_reinsertion",
|
||||
LEVEL_ERROR,
|
||||
QUOTE(COMPONENT),
|
||||
"NULL PARAMETERS",
|
||||
[
|
||||
["player", _player],
|
||||
["base", _base]
|
||||
]
|
||||
] call milsim_util_fnc_log;
|
||||
] call EFUNC(common,log);
|
||||
["NULL PARAMETERS"] call BIS_fnc_error;
|
||||
};
|
||||
|
||||
|
||||
private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_maxRangeToReady", 400];
|
||||
private _maxRangeToReady = missionNamespace getVariable [QGVAR(setting_maxRangeToReady), 400];
|
||||
// nearest base here is the same as the base sent
|
||||
private _nearestBase = _base;
|
||||
|
||||
milsim_reinsert_reinsertionQueue pushBackUnique [
|
||||
GVAR(reinsertionQueue) pushBackUnique [
|
||||
_player, _base, _timeFiled
|
||||
];
|
||||
// broadcast new list to all machines
|
||||
publicVariable "milsim_reinsert_reinsertionQueue";
|
||||
publicVariable QGVAR(reinsertionQueue);
|
||||
|
||||
// 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_INFO,
|
||||
QUOTE(COMPONENT),
|
||||
"PLAYER FILED REQUEST",
|
||||
_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);
|
||||
@@ -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;
|
||||
};
|
||||
@@ -3,48 +3,51 @@
|
||||
// if a player's time in the queue exceeds the configured timeout, a message will be posted every 5 minutes on a cycle based around
|
||||
// the player's time in the queue stating how long they have been waiting, their name, and their group's name
|
||||
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
if (!isServer) exitWith {};
|
||||
|
||||
// array of all respawn modules in the mission, used as 'base' locations for reinsertion
|
||||
milsim_baseObjects = allMissionObjects "ModuleRespawnPosition_F";
|
||||
publicVariable "milsim_baseObjects";
|
||||
|
||||
// register queue
|
||||
milsim_reinsert_reinsertionQueue = [];
|
||||
publicVariable "milsim_reinsert_reinsertionQueue";
|
||||
|
||||
GVAR(reinsertionQueue) = [];
|
||||
publicVariable QGVAR(reinsertionQueue);
|
||||
|
||||
// server mission start time
|
||||
milsim_reinsert_missionStartServerTime = serverTime;
|
||||
GVAR(missionStartServerTime) = serverTime;
|
||||
|
||||
// FILE REQUEST CBA HANDLER
|
||||
["milsim_reinsert_fileReinsertRequest", {
|
||||
[QGVAR(fileReinsertRequest), {
|
||||
params ["_player", "_base"];
|
||||
[_player, _base] call milsim_reinsert_fnc_addToQueue;
|
||||
[_player, _base] call FUNC(addToQueue);
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
// REMOVE REQUEST CBA HANDLER
|
||||
["milsim_reinsert_removeReinsertRequest", {
|
||||
[QGVAR(removeReinsertRequest), {
|
||||
params ["_player"];
|
||||
[_player] call milsim_reinsert_fnc_removeFromQueue;
|
||||
[_player] call FUNC(removeFromQueue);
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
|
||||
// automated wait threshold timer
|
||||
milsim_reinsert_reinsertionOverTimeoutLastNotificationTime = 0;
|
||||
GVAR(overTimeoutLastNotificationTime) = 0;
|
||||
|
||||
[{ // every 60 seconds
|
||||
|
||||
// validate queue
|
||||
call milsim_reinsert_fnc_validateQueue;
|
||||
call FUNC(validateQueue);
|
||||
|
||||
// check if last overTimeout notification was sent more than X minutes ago
|
||||
if (
|
||||
diag_tickTime - milsim_reinsert_reinsertionOverTimeoutLastNotificationTime > 60*5
|
||||
diag_tickTime - GVAR(overTimeoutLastNotificationTime) > 60*5
|
||||
) then {
|
||||
// show global queue notification with any players that are over timeout
|
||||
call milsim_reinsert_fnc_globalShowQueue;
|
||||
call FUNC(globalShowQueue);
|
||||
};
|
||||
|
||||
}, 60] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
[
|
||||
LEVEL_DEBUG,
|
||||
QUOTE(COMPONENT),
|
||||
"postInit complete",
|
||||
[]
|
||||
] call EFUNC(common,log);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
params [["_player", objNull, [objNull]]];
|
||||
|
||||
if (!isServer) exitWith {
|
||||
@@ -20,16 +22,16 @@ if (isNull _player) exitWith {
|
||||
};
|
||||
|
||||
// get entries for this player from queue
|
||||
private _unitArrs = milsim_reinsert_reinsertionQueue select {_x#0 isEqualTo _player};
|
||||
private _unitArrs = GVAR(reinsertionQueue) select {_x#0 isEqualTo _player};
|
||||
// if player not in queue, skip
|
||||
if (count _unitArrs isEqualTo 0) exitWith {};
|
||||
|
||||
private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_maxRangeToReady", 400];
|
||||
private _maxRangeToReady = missionNamespace getVariable [QGVAR(setting_maxRangeToReady), 400];
|
||||
|
||||
// remove player from queue
|
||||
milsim_reinsert_reinsertionQueue = milsim_reinsert_reinsertionQueue - _unitArrs;
|
||||
GVAR(reinsertionQueue) = GVAR(reinsertionQueue) - _unitArrs;
|
||||
// broadcast new list to all machines
|
||||
publicVariable "milsim_reinsert_reinsertionQueue";
|
||||
publicVariable QGVAR(reinsertionQueue);
|
||||
|
||||
// sort _unitArrs by time in queue, descending, to get longest wait (if for some reason there's a duplicate)
|
||||
[_unitArrs, [], {
|
||||
@@ -39,17 +41,17 @@ publicVariable "milsim_reinsert_reinsertionQueue";
|
||||
// get first entry (longest wait)
|
||||
(_unitArrs#0) params ["_player", "_base", "_timeFiled"]; // _unitArr = [unit, base, timeInQueue]
|
||||
// get the closest base to the player
|
||||
private _nearestBase = [_player] call milsim_util_fnc_getNearestBase;
|
||||
private _nearestBase = [_player] call EFUNC(common,getNearestBase);
|
||||
// log to rpt
|
||||
private _logParams = [
|
||||
["filedAtBase", [_base] call milsim_util_fnc_getNameOfBase],
|
||||
["filedAtBase", [_base] call EFUNC(common,getNameOfBase)],
|
||||
["filedAtBaseDistance", _player distance _base],
|
||||
["closestBase", [_nearestBase] call milsim_util_fnc_getNameOfBase],
|
||||
["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)],
|
||||
["closestBaseDistance", _player distance _nearestBase],
|
||||
["maxDistanceSetting", _maxRangeToReady],
|
||||
["inQueueDuration", diag_tickTime - _timeFiled]
|
||||
];
|
||||
_logParams = [_player, _logParams] call milsim_util_fnc_addPlayerInfoToArray;
|
||||
_logParams = [_player, _logParams] call EFUNC(common,addPlayerInfoToArray);
|
||||
[
|
||||
"respawn_reinsertion",
|
||||
"PLAYER RESCINDED REQUEST",
|
||||
|
||||
@@ -25,16 +25,16 @@ if (isNull _userObject) exitWith {
|
||||
};
|
||||
|
||||
// log to rpt
|
||||
private _logParams = [_userObject, []] call milsim_util_fnc_addPlayerInfoToArray;
|
||||
private _logParams = [_userObject, []] call EFUNC(common,addPlayerInfoToArray);
|
||||
[
|
||||
"respawn_reinsertion",
|
||||
"SHOW QUEUE REQUESTED",
|
||||
_logParams
|
||||
] call milsim_util_fnc_log;
|
||||
|
||||
private _queue = missionNamespace getVariable ["milsim_reinsert_reinsertionQueue", []];
|
||||
private _queue = missionNamespace getVariable [QGVAR(reinsertionQueue), []];
|
||||
// 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;
|
||||
|
||||
@@ -48,7 +48,7 @@ if (count _basesWithPeople isEqualTo 0) then {
|
||||
// forEach _basesWithPeople
|
||||
{
|
||||
private _thisBase = _x;
|
||||
private _baseName = [_thisBase] call milsim_util_fnc_getNameOfBase;
|
||||
private _baseName = [_thisBase] call EFUNC(common,getNameOfBase);
|
||||
|
||||
// generate player lines for this base
|
||||
private _playerLines = _queue select {
|
||||
|
||||
@@ -1,32 +1,35 @@
|
||||
// revalidate any players in the queue
|
||||
// compare their distance to the nearest base, and remove them if they're too far away (or dead)
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
private _stillValid = [];
|
||||
private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_setting_reinsertion_maxRangeToReady", 400];
|
||||
private _maxRangeToReady = missionNamespace getVariable [QGVAR(setting_maxRangeToReady), 400];
|
||||
{
|
||||
_x params ["_player", "_base", "_timeFiled"]; // _unitArr = [unit, baseName, timeInQueue]
|
||||
|
||||
private _distanceToOriginalBase = _player distance _base;
|
||||
// get the closest base to the player
|
||||
private _nearestBase = [_player] call milsim_util_fnc_getNearestBase;
|
||||
private _nearestBase = [_player] call EFUNC(common,getNearestBase);
|
||||
private _isCloseEnoughToAnyBase = (_player distance _nearestBase) < _maxRangeToReady;
|
||||
|
||||
if (not _isCloseEnoughToAnyBase || not (alive _player)) then {
|
||||
// don't include player in updated queue
|
||||
// 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;
|
||||
private _logParams = ;
|
||||
_logParams = ;
|
||||
[
|
||||
"respawn_reinsertion",
|
||||
LEVEL_INFO,
|
||||
QUOTE(COMPONENT),
|
||||
"PLAYER DEQUEUED AUTOMATICALLY",
|
||||
_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);
|
||||
// continue loop
|
||||
continue
|
||||
};
|
||||
@@ -36,22 +39,22 @@ private _maxRangeToReady = missionNamespace getVariable ["milsim_reinsert_settin
|
||||
// if player's base has changed, log to rpt
|
||||
if (_base != _nearestBase) then {
|
||||
private _logParams = [
|
||||
["filedAtBase", [_base] call milsim_util_fnc_getNameOfBase],
|
||||
["filedAtBase", [_base] call EFUNC(common,getNameOfBase)],
|
||||
["filedAtBaseDistance", _player distance _base],
|
||||
["closestBase", [_nearestBase] call milsim_util_fnc_getNameOfBase],
|
||||
["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)],
|
||||
["closestBaseDistance", _player distance _nearestBase],
|
||||
["maxDistanceSetting", _maxRangeToReady],
|
||||
["inQueueDuration", diag_tickTime - _timeFiled]
|
||||
];
|
||||
_logParams = [_player, _logParams] call milsim_util_fnc_addPlayerInfoToArray;
|
||||
_logParams = [_player, _logParams] call EFUNC(common,addPlayerInfoToArray);
|
||||
[
|
||||
"respawn_reinsertion",
|
||||
"PLAYER BASE WAS UPDATED",
|
||||
_logParams
|
||||
] call milsim_util_fnc_log;
|
||||
};
|
||||
} forEach milsim_reinsert_reinsertionQueue;
|
||||
} forEach GVAR(reinsertionQueue);
|
||||
|
||||
// broadcast new list to all machines
|
||||
milsim_reinsert_reinsertionQueue = _stillValid;
|
||||
publicVariable "milsim_reinsert_reinsertionQueue";
|
||||
GVAR(reinsertionQueue) = _stillValid;
|
||||
publicVariable QGVAR(reinsertionQueue);
|
||||
Reference in New Issue
Block a user