From 468deeb2521a4de0cdd1f809572bf12d48e95ea7 Mon Sep 17 00:00:00 2001 From: vbawol Date: Sun, 1 Jan 2017 12:33:04 -0600 Subject: [PATCH] test making player revive work similar to load #693 on revive, use reveal against new player object. send loadABS value from server and wait client side for a match before using selectPlayer. Note: may need some form of code lock to prevent duplicate calls Todo: Look into changing revive system to A3's own. --- Sources/epoch_code/System/player_login.fsm | 4 +- .../compile/setup/EPOCH_clientRevive.sqf | 59 +++++++++++++------ .../EPOCH_server_revivePlayer.sqf | 2 +- 3 files changed, 44 insertions(+), 21 deletions(-) diff --git a/Sources/epoch_code/System/player_login.fsm b/Sources/epoch_code/System/player_login.fsm index eb087244..ebec1765 100644 --- a/Sources/epoch_code/System/player_login.fsm +++ b/Sources/epoch_code/System/player_login.fsm @@ -207,7 +207,7 @@ class FSM "};" \n "" \n "_finalPlayerObjectCheck = {" \n - " (_mass == (loadAbs _playerObject))" \n + " (_mass isEqualTo (loadAbs _playerObject))" \n "};" \n "" \n "EPOCH_loginFSM = _thisFSM;" \n @@ -1423,4 +1423,4 @@ class FSM "Reject_without_B", }; }; -/*%FSM*/ \ No newline at end of file +/*%FSM*/ diff --git a/Sources/epoch_code/compile/setup/EPOCH_clientRevive.sqf b/Sources/epoch_code/compile/setup/EPOCH_clientRevive.sqf index feb5788f..e9607047 100644 --- a/Sources/epoch_code/compile/setup/EPOCH_clientRevive.sqf +++ b/Sources/epoch_code/compile/setup/EPOCH_clientRevive.sqf @@ -18,36 +18,59 @@ Parameter(s): _this select 0: OBJECT - player object _this select 1: STRING - personal token + _this select 2: NUMBER - loadABS Returns: NOTHING */ //[[[cog import generate_private_arrays ]]] -private ["_group","_playerObject","_ply"]; +private ["_prevPlayerObject"]; //[[[end]]] -_playerObject = _this select 0; +params [ + ["_playerObject",objNull,[objNull]], + ["_personalToken","",[""]], + ["_loadAbs",0,[0]] +]; +if (isNull _playerObject) exitWith { diag_log "EPOCH-DEBUG: New Player Object was Null cannot revive." }; if !(alive player && alive _playerObject && !isPlayer _playerObject) then { - _ply = player; - _group = group player; - selectPlayer _playerObject; - deleteVehicle _ply; - Epoch_canBeRevived = false; - Epoch_personalToken = _this select 1; + // reveal new player object (to hopefully propigate info faster). + player reveal _playerObject; - [] spawn EPOCH_masterLoop; - [5, 100] call EPOCH_niteLight; + // spawn a thread to wait for loadAbs to sync before using selectPlayer + [_playerObject,_personalToken,_loadAbs] spawn { + params ["_playerObject","_personalToken","_loadAbs"]; - closeDialog 0; - ("BIS_fnc_respawnCounter" call BIS_fnc_rscLayer) cutText ["","PLAIN"]; + // get current player object + _prevPlayerObjectect = player; - { - player removeEventHandler [_x, 0]; - player addEventHandler [_x,(["CfgEpochClient", _x, ""] call EPOCH_fnc_returnConfigEntryV2)]; - } forEach (["CfgEpochClient", "addEventHandler", []] call EPOCH_fnc_returnConfigEntryV2); + // wait for loadAbs to sync - // reset blood Pressure to warning level - EPOCH_playerBloodP = 120; + // switch to new playerObject + selectPlayer _playerObject; + + // delete previous player object + deleteVehicle _prevPlayerObject; + + // set token and can revive to false + Epoch_canBeRevived = false; + Epoch_personalToken = _personalToken; + + // restart masterloop + [] spawn EPOCH_masterLoop; + [5, 100] call EPOCH_niteLight; + + closeDialog 0; + ("BIS_fnc_respawnCounter" call BIS_fnc_rscLayer) cutText ["","PLAIN"]; + + { + player removeEventHandler [_x, 0]; + player addEventHandler [_x,(["CfgEpochClient", _x, ""] call EPOCH_fnc_returnConfigEntryV2)]; + } forEach (["CfgEpochClient", "addEventHandler", []] call EPOCH_fnc_returnConfigEntryV2); + + // reset blood Pressure to warning level + EPOCH_playerBloodP = 120; + }; } else { deleteVehicle _playerObject; }; diff --git a/Sources/epoch_server/compile/epoch_player/EPOCH_server_revivePlayer.sqf b/Sources/epoch_server/compile/epoch_player/EPOCH_server_revivePlayer.sqf index 251c3af9..0d9151d5 100644 --- a/Sources/epoch_server/compile/epoch_player/EPOCH_server_revivePlayer.sqf +++ b/Sources/epoch_server/compile/epoch_player/EPOCH_server_revivePlayer.sqf @@ -265,7 +265,7 @@ if (!local _player) then { }; // send to player - [_newPlyr, _token] remoteExec ['EPOCH_clientRevive',_player]; + [_newPlyr, _token, loadAbs _newPlyr] remoteExec ['EPOCH_clientRevive',_player]; }; }; };