Speed up onPlayerDisconnect some more

Moved combat log setVariables to playerSync. Now the player object is no
longer needed for any of the code at the bottom of playerSync or
onPlayerDisconnected.

Update objects is already performed at the bottom of playerSync. There
is no reason to do it again in playerDisconnect since it calls
playerSync.
This commit is contained in:
ebaydayz
2016-09-17 15:02:00 -04:00
parent da70306291
commit 5f0c2fcc49
2 changed files with 45 additions and 42 deletions

View File

@@ -50,20 +50,21 @@ if (_characterID != "?") exitwith {
//if player object is alive lets sync the player and remove the body and if ghosting is active add the player id to the array //if player object is alive lets sync the player and remove the body and if ghosting is active add the player id to the array
if (alive _playerObj) then { if (alive _playerObj) then {
// High priority. Sync must finish fast before player object isNull // High priority. Sync must finish fast before player object isNull
[_playerObj,nil,true,true] call server_playerSync; [_playerObj,nil,true,_inCombat] call server_playerSync;
/*
Low priority code below this point where
_playerObj is no longer needed and may be Null.
*/
//Punish combat log //Punish combat log
if (_inCombat > 0) then { if (_inCombat > 0) then {
_playerObj setVariable ["NORRN_unconscious",true,true]; // Set status to unconscious // Moved setVariables to server_playerSync since they are high priority
_playerObj setVariable ["unconsciousTime",150,true]; // Set knock out timer to 2 minutes 30 seconds // Messages are low priority. Player object not needed
//_playerObj setVariable ["USEC_injured",true]; // Set status to bleeding
//_playerObj setVariable ["USEC_BloodQty",3000]; // Set blood to 3000
// Low priority. Player object not needed
diag_log format["PLAYER COMBAT LOGGED: %1(%3) at location %2",_playerName,_playerPos,_playerUID]; diag_log format["PLAYER COMBAT LOGGED: %1(%3) at location %2",_playerName,_playerPos,_playerUID];
[nil, nil, rTitleText, format["PLAYER COMBAT LOGGED: %1",_playerName], "PLAIN"] call RE; // Message whole server [nil, nil, rTitleText, format["PLAYER COMBAT LOGGED: %1",_playerName], "PLAIN"] call RE; // Message whole server
}; };
// Low priority. Player object not needed
if (dayz_enableGhosting) then { if (dayz_enableGhosting) then {
//diag_log format["GhostPlayers: %1, ActivePlayers: %2",dayz_ghostPlayers,dayz_activePlayers]; //diag_log format["GhostPlayers: %1, ActivePlayers: %2",dayz_ghostPlayers,dayz_activePlayers];
if (!(_playerUID in dayz_ghostPlayers)) then { if (!(_playerUID in dayz_ghostPlayers)) then {
@@ -75,14 +76,7 @@ if (_characterID != "?") exitwith {
}; };
}; };
/*
Low priority code below this point where
_playerObj is no longer needed and may be Null.
*/
[_playerUID,_characterID,2,_playerName] call dayz_recordLogin; [_playerUID,_characterID,2,_playerName] call dayz_recordLogin;
//Lets scan the area near the player logout position and save all objects.
{ [_x,"gear"] call server_updateObject } foreach (nearestObjects [_playerPos, DayZ_GearedObjects, 10]);
}; };
if (isNull _playerObj) then { diag_log("Player Object does not esist"); }; if (isNull _playerObj) then { diag_log("Player Object does not esist"); };

View File

@@ -148,24 +148,32 @@ if (_currentModel == _modelChk) then {
_currentModel = str _currentModel; _currentModel = str _currentModel;
_character setVariable ["model_CHK",typeOf _character]; _character setVariable ["model_CHK",typeOf _character];
}; };
if ((count _this) > 3 && {_isInVehicle}) then { //calling from player_onDisconnect if (count _this > 3) then { //calling from player_onDisconnect
//if the player object is inside a vehicle lets eject the player if (_this select 3 > 0) then { //combat logged
_relocate = if (vehicle _character isKindOf "Air") then {true} else {false}; _character setVariable ["NORRN_unconscious",true,true]; // Set status to unconscious
_character action ["eject", vehicle _character]; _character setVariable ["unconsciousTime",150,true]; // Set knock out timer to 2 minutes 30 seconds
//_character setVariable ["USEC_injured",true]; // Set status to bleeding
// Prevent relog in parachute, heli or plane above base exploit to get inside //_character setVariable ["USEC_BloodQty",3000]; // Set blood to 3000
if (_relocate) then { };
_count = 0; if (_isInVehicle) then {
_maxDist = 800; //if the player object is inside a vehicle lets eject the player
_newPos = [_charPos, 80, _maxDist, 10, 1, 0, 0, [], [_charPos,_charPos]] call BIS_fnc_findSafePos; _relocate = if (vehicle _character isKindOf "Air") then {true} else {false};
_character action ["eject", vehicle _character];
while {_newPos distance _charPos == 0} do { // Prevent relog in parachute, heli or plane above base exploit to get inside
_count = _count + 1; if (_relocate) then {
if (_count > 4) exitWith {_newPos = _charPos;}; // Max 4km away fail safe (needs to finish fast so server_playerSync runs below) _count = 0;
_newPos = [_charPos, 80, (_maxDist + 800), 10, 1, 0, 0, [], [_charPos,_charPos]] call BIS_fnc_findSafePos; _maxDist = 800;
_newPos = [_charPos, 80, _maxDist, 10, 1, 0, 0, [], [_charPos,_charPos]] call BIS_fnc_findSafePos;
while {_newPos distance _charPos == 0} do {
_count = _count + 1;
if (_count > 4) exitWith {_newPos = _charPos;}; // Max 4km away fail safe (needs to finish fast so server_playerSync runs below)
_newPos = [_charPos, 80, (_maxDist + 800), 10, 1, 0, 0, [], [_charPos,_charPos]] call BIS_fnc_findSafePos;
};
_charPos = _newPos;
diag_log format["%1(%2) logged out in air vehicle. Relocated to safePos %3m from logout position.",_name,_playerUID,_charPos distance _newPos];
}; };
_charPos = _newPos;
diag_log format["%1(%2) logged out in air vehicle. Relocated to safePos %3m from logout position.",_name,_playerUID,_charPos distance _newPos];
}; };
}; };
if (_onLadder or _isInVehicle or _isTerminal) then { if (_onLadder or _isInVehicle or _isTerminal) then {
@@ -189,8 +197,19 @@ if (_isInVehicle) then {
}; };
_currentState = [[_currentWpn,_currentAnim,_temp],[]]; _currentState = [[_currentWpn,_currentAnim,_temp],[]];
// If player is in a vehicle, keep its position updated
if (vehicle _character != _character) then {
[vehicle _character, "position"] call server_updateObject;
};
//Reset timer
if (_timeSince > 0) then {
_character setVariable ["lastTime",(diag_ticktime - _timeLeft)];
};
/* /*
Everything is ready, now publish to HIVE Everything is ready, now publish to HIVE
Low priority code below this point where _character object is no longer needed and may be Null.
*/ */
if (count _playerPos > 0) then { if (count _playerPos > 0) then {
_array = []; _array = [];
@@ -220,15 +239,5 @@ if (DZE_groupManagement) then { //update player group
_key call server_hiveWrite; _key call server_hiveWrite;
}; };
// If player is in a vehicle, keep its position updated
if (vehicle _character != _character) then {
[vehicle _character, "position"] call server_updateObject;
};
// Force gear updates for nearby vehicles/tents // Force gear updates for nearby vehicles/tents
{[_x,"gear"] call server_updateObject;} count nearestObjects [_character,DayZ_GearedObjects,10]; {[_x,"gear"] call server_updateObject;} count nearestObjects [_charPos,DayZ_GearedObjects,10];
//Reset timer
if (_timeSince > 0) then {
_character setVariable ["lastTime",(diag_ticktime - _timeLeft)];
};