Split player_death into scheduled and unscheduled #1833

Death message was sometimes showing incorrectly due to spawn delay.

Also the sched_corpses two minute loop was occasionally deleting bodies
right away because bodyName setVariable was delayed by the time it took
PVDZ_plr_death to send (up to a few seconds). See #1825
This commit is contained in:
ebaydayz
2016-12-28 16:16:39 -05:00
parent b807648cc6
commit d509c15c82
12 changed files with 147 additions and 149 deletions

View File

@@ -1,7 +1,6 @@
/*
WARNING: The player object is deleted by Arma shortly after onPlayerDisconnected fires
because DayZ uses disabledAI=true:
https://community.bistudio.com/wiki/Description.ext#disabledAI
WARNING: Alive player objects are deleted by Arma shortly after onPlayerDisconnected fires
because DayZ uses disabledAI=1 https://community.bistudio.com/wiki/Description.ext#disabledAI
References to the player object after that point will return objNull, so this function
and server_playerSync must be fast or the player will not save.
@@ -12,14 +11,14 @@ _playerUID = _this select 0;
_playerName = _this select 1;
_playerObj = nil;
//Lets search all playerable units looking for the objects that matches our playerUID
//Lets search all players looking for the object that matches our UID
{
if ((getPlayerUID _x) == _playerUID) exitWith { _playerObj = _x; _playerPos = getPosATL _playerObj;};
} count playableUnits;
//If for some reason the playerOBj does not exist lets exit the disconnect system.
//If playerObj is not in playableUnits then lets exit the disconnect system.
if (isNil "_playerObj") exitWith {
diag_log format["%1: nil player object, _this:%2", __FILE__, _this];
diag_log format["%1: Player object is not in playableUnits. This is normal if the player just died. _this:%2", __FILE__, _this];
};
//diag_log format["get: %1 (%2), sent: %3 (%4)",typeName (getPlayerUID _playerObj), getPlayerUID _playerObj, typeName _playerUID, _playerUID];
@@ -31,7 +30,8 @@ _inCombat = _playerObj getVariable ["inCombat",false];
_Sepsis = _playerObj getVariable["USEC_Sepsis",false];
//Login processing do not sync
if (_playerUID in dayz_ghostPlayers) exitwith {
if (_playerUID in dayz_ghostPlayers) exitWith {
//Note player is alive (see set in dayz_ghostPlayers below)
diag_log format["ERROR: Cannot Sync Character [%1,%2] Still processing login",_playerName,_playerUID];
//Lets remove the object.
@@ -81,7 +81,7 @@ if (_characterID != "?") then {
{[_x,"gear"] call server_updateObject} count (nearestObjects [_playerPos,DayZ_GearedObjects,10]);
};
[_playerUID,_characterID,3,_playerName,((getPosATL _playerObj) call fa_coor2str)] call dayz_recordLogin;
[_playerUID,_characterID,3,_playerName,(_playerPos call fa_coor2str)] call dayz_recordLogin;
};
if (alive _playerObj) then {

View File

@@ -63,6 +63,7 @@ if (_playerName != "unknown" or _sourceName != "unknown") then {
if (toLower DZE_DeathMsgChat != "none" or DZE_DeathMsgRolling or DZE_DeathMsgDynamicText) then {
PVDZE_deathMessage = _message;
//Don't use regular PV here since JIP clients don't need it
owner _newObject publicVariableClient "PVDZE_deathMessage"; //Send to dead player (not in playableUnits)
{
if (isPlayer _x) then {
owner _x publicVariableClient "PVDZE_deathMessage";

View File

@@ -41,8 +41,8 @@ sched_corpses = {
} else {
//Only spawn flies on actual dead player, otherwise delete the body (clean up left over ghost from relogging, sometimes it is not deleted automatically by Arma or onPlayerDisconnect)
//AI mods will need to setVariable "bodyName" on their dead units to prevent them being cleaned up
_deathTime = _x getVariable ["sched_co_deathTime", -1];
if (_x getVariable["bodyName",""] != "") then {
_deathTime = _x getVariable ["sched_co_deathTime", -1];
if (_deathTime == -1) then {
_deathPos = _x getVariable ["deathPos",respawn_west_original];
/*_cpos = getPosATL _x;
@@ -101,8 +101,16 @@ sched_corpses = {
publicVariable "PVCDZ_flies";
};
} else {
_x call sched_co_deleteVehicle;
_delQtyG = _delQtyG + 1;
if (_deathTime == -1) then {
_deathTime = diag_tickTime;
_x setVariable ["sched_co_deathTime", _deathTime];
} else {
// Wait 30s to make sure the server had time to setVariable "bodyName". PVDZ_plr_Death can be delayed by a few seconds.
if (diag_tickTime - _deathTime > 30) then {
_x call sched_co_deleteVehicle;
_delQtyG = _delQtyG + 1;
};
};
};
};
};