diff --git a/CHANGE LOG 1.0.6.2.txt b/CHANGE LOG 1.0.6.2.txt index 0ce004c4f..c376f5bfa 100644 --- a/CHANGE LOG 1.0.6.2.txt +++ b/CHANGE LOG 1.0.6.2.txt @@ -79,6 +79,7 @@ [FIXED] A locked door can now be auto unlocked right after placement by the player who built it [FIXED] A rare error in keyboard.sqf for certain combination binds. [FIXED] Floating loot positions in hotel (Land_HouseB_Tenement) +[FIXED] Updates to humanity and player stats after a skin change not always saving in hive (server_getDiff) [NOTE] Fixes below were included in hotfix 1.0.6.1A (March 10th 2017) and are now in the default files. [FIXED] Fixed food and drink going down 10x faster from melee and other "working" actions. diff --git a/SQF/dayz_code/compile/player_humanityMorph.sqf b/SQF/dayz_code/compile/player_humanityMorph.sqf index 789f5ed52..2e5cda575 100644 --- a/SQF/dayz_code/compile/player_humanityMorph.sqf +++ b/SQF/dayz_code/compile/player_humanityMorph.sqf @@ -1,4 +1,4 @@ -private ["_charID","_newmodel","_old","_updates","_humanity","_medical","_worldspace","_zombieKills","_headShots","_humanKills","_combattimeout","_inCombat","_banditKills","_fractures","_wpnType","_ismelee","_survivalTime","_coins","_bankCoins","_globalCoins"]; +private ["_charID","_newmodel","_old","_humanity","_medical","_worldspace","_zombieKills","_headShots","_humanKills","_combattimeout","_inCombat","_banditKills","_fractures","_wpnType","_ismelee","_survivalTime","_coins","_bankCoins","_globalCoins"]; //_playerUID = _this select 0; _charID = _this select 1; _model = _this select 2; @@ -11,9 +11,6 @@ _old removeAllEventHandlers "Fired"; _old allowDamage false; _old AddEventHandler ["HandleDamage", {False}]; -_updates = player getVariable ["updatePlayer",[false,false,false,false,false]]; -_updates set [0,true]; -player setVariable ["updatePlayer",_updates,true]; dayz_unsaved = true; //Logout _humanity = player getVariable ["humanity",0]; diff --git a/SQF/dayz_server/compile/server_onPlayerDisconnect.sqf b/SQF/dayz_server/compile/server_onPlayerDisconnect.sqf index 79102fb91..947eef702 100644 --- a/SQF/dayz_server/compile/server_onPlayerDisconnect.sqf +++ b/SQF/dayz_server/compile/server_onPlayerDisconnect.sqf @@ -91,6 +91,8 @@ if (_characterID != "?") then { [_playerUID,_characterID,3,_playerName,(_playerPos call fa_coor2str)] call dayz_recordLogin; }; +missionNamespace setVariable [_playerUID,nil]; + if (alive _playerObj) then { _playerObj call sched_co_deleteVehicle; }; \ No newline at end of file diff --git a/SQF/dayz_server/compile/server_playerDied.sqf b/SQF/dayz_server/compile/server_playerDied.sqf index b74d44523..559afa78e 100644 --- a/SQF/dayz_server/compile/server_playerDied.sqf +++ b/SQF/dayz_server/compile/server_playerDied.sqf @@ -32,13 +32,11 @@ if (_characterID != "0") then { _key call server_hiveWrite; }; -#ifdef PLAYER_DEBUG diag_log format ["Player UID#%3 CID#%4 %1 as %5 died at %2", _newObject call fa_plr2str, _pos call fa_coor2str, _playerID, _characterID, typeOf _newObject ]; -#endif // DEATH MESSAGES _suicide = ((_sourceName == _playerName) or (_method == "suicide")); diff --git a/SQF/dayz_server/compile/server_playerSetup.sqf b/SQF/dayz_server/compile/server_playerSetup.sqf index e39ddf0eb..132eb829a 100644 --- a/SQF/dayz_server/compile/server_playerSetup.sqf +++ b/SQF/dayz_server/compile/server_playerSetup.sqf @@ -134,7 +134,7 @@ if (count _medical > 0) then { }; if (count _stats > 0) then { - //register stats + //register stats Global _playerObj setVariable ["zombieKills",(_stats select 0),true]; _playerObj setVariable ["headShots",(_stats select 1),true]; _playerObj setVariable ["humanKills",(_stats select 2),true]; @@ -150,15 +150,7 @@ if (count _stats > 0) then { _score = score _playerObj; _playerObj addScore ((_stats select 0) - _score); - //record for Server JIP checks - _playerObj setVariable ["zombieKills_CHK",(_stats select 0)]; - _playerObj setVariable ["headShots_CHK",(_stats select 1)]; - - if (count _stats > 4) then { - if !(_stats select 3) then {_playerObj setVariable ["selectSex",true,true];}; - } else { - _playerObj setVariable ["selectSex",true,true]; - }; + missionNamespace setVariable [_playerID,[_humanity,(_stats select 0),(_stats select 1),(_stats select 2),(_stats select 3)]]; } else { //register stats _playerObj setVariable ["zombieKills",0,true]; @@ -170,9 +162,7 @@ if (count _stats > 0) then { _playerObj setVariable ["ConfirmedHumanKills",0,true]; _playerObj setVariable ["ConfirmedBanditKills",0,true]; - //record for Server JIP checks - _playerObj setVariable ["zombieKills_CHK",0]; - _playerObj setVariable ["headShots_CHK",0]; + missionNamespace setVariable [_playerID,[_humanity,0,0,0,0]]; }; if (_randomSpot) then { @@ -220,7 +210,6 @@ if (_randomSpot) then { //record player pos locally for server checking _playerObj setVariable ["characterID",_characterID,true]; _playerObj setVariable ["humanity",_humanity,true]; -_playerObj setVariable ["humanity_CHK",_humanity]; _playerObj setVariable ["lastPos",getPosATL _playerObj]; _clientID = owner _playerObj; diff --git a/SQF/dayz_server/compile/server_playerSync.sqf b/SQF/dayz_server/compile/server_playerSync.sqf index bf36f9b10..e8460d0e5 100644 --- a/SQF/dayz_server/compile/server_playerSync.sqf +++ b/SQF/dayz_server/compile/server_playerSync.sqf @@ -1,8 +1,10 @@ +#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp" + private ["_distanceFoot","_playerPos","_lastPos","_playerGear","_medical","_currentModel","_currentAnim", "_currentWpn","_muzzles","_array","_coins","_key","_globalCoins","_bankCoins","_playerBackp","_exitReason", "_backpack","_kills","_killsB","_killsH","_headShots","_humanity","_lastTime","_timeGross","_timeSince", "_timeLeft","_config","_onLadder","_isTerminal","_modelChk","_temp","_currentState","_character", -"_magazines","_characterID","_charPos","_isInVehicle","_name","_inDebug","_newPos","_count","_maxDist","_relocate","_playerUID"]; +"_magazines","_characterID","_charPos","_isInVehicle","_name","_inDebug","_newPos","_count","_maxDist","_relocate","_playerUID","_statsDiff"]; //[player,array] _character = _this select 0; @@ -45,17 +47,13 @@ _lastTime = _character getVariable ["lastTime",-1]; _modelChk = _character getVariable ["model_CHK",""]; _temp = round (_character getVariable ["temperature",100]); _lastMagazines = _character getVariable ["ServerMagArray",[[],""]]; -/* - Check previous stats against what client had when they logged in - this helps prevent JIP issues, where a new player wouldn't have received - the old players updates. Only valid for stats where clients could have - be recording results from their local objects (such as agent zombies) -*/ -_kills = ["zombieKills",_character] call server_getDiff; -_killsB = ["banditKills",_character] call server_getDiff; -_killsH = ["humanKills",_character] call server_getDiff; -_headShots = ["headShots",_character] call server_getDiff; -_humanity = ["humanity",_character] call server_getDiff2; +//Get difference between current stats and stats at last sync +_statsDiff = [_character,_playerUID] call server_getStatsDiff; +_humanity = _statsDiff select 0; +_kills = _statsDiff select 1; +_headShots = _statsDiff select 2; +_killsH = _statsDiff select 3; +_killsB = _statsDiff select 4; _charPosLen = count _charPos; @@ -225,8 +223,9 @@ _key = if (Z_SingleCurrency) then { str formatText["CHILD:201:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:",_characterID,_playerPos,_playerGear,_playerBackp,_medical,false,false,_kills,_headShots,_distanceFoot,_timeSince,_currentState,_killsH,_killsB,_currentModel,_humanity] }; -//diag_log str formatText["INFO - %2(UID:%3) PlayerSync, %1",_key,_name,_playerUID]; - +#ifdef PLAYER_DEBUG + diag_log str formatText["INFO - %2(UID:%4,CID:%3) PlayerSync, %1",_key,_name,_characterID,_playerUID]; +#endif _key call server_hiveWrite; if (Z_SingleCurrency) then { //update global coins diff --git a/SQF/dayz_server/compile/server_toggle_debug.hpp b/SQF/dayz_server/compile/server_toggle_debug.hpp index 93236a8cf..64247b75e 100644 --- a/SQF/dayz_server/compile/server_toggle_debug.hpp +++ b/SQF/dayz_server/compile/server_toggle_debug.hpp @@ -12,7 +12,7 @@ Please request permission to use/alter/distribute from project leader (R4Z0R49) //#define OBJECT_DEBUG // comment this out if you don't want any PLAYER (WORLDSPACE/INVENTORY/ETC) related debug -#define PLAYER_DEBUG +//#define PLAYER_DEBUG // comment this out if you don't want any misc SERVER (ZOMBIE, LOOT, CLEANUP) related debug //#define SERVER_DEBUG diff --git a/SQF/dayz_server/init/server_functions.sqf b/SQF/dayz_server/init/server_functions.sqf index 24532cbaf..30784bbec 100644 --- a/SQF/dayz_server/init/server_functions.sqf +++ b/SQF/dayz_server/init/server_functions.sqf @@ -183,32 +183,29 @@ server_hiveReadWrite = { onPlayerDisconnected "[_uid,_name] call server_onPlayerDisconnect;"; -server_getDiff = { - private ["_variable","_object","_vNew","_vOld","_result"]; - _variable = _this select 0; - _object = _this select 1; - _vNew = _object getVariable [_variable,0]; - _vOld = _object getVariable [(_variable + "_CHK"),_vNew]; - _result = 0; - if (_vNew < _vOld) then { - //JIP issues - _vNew = _vNew + _vOld; - _object getVariable [(_variable + "_CHK"),_vNew]; - } else { - _result = _vNew - _vOld; - _object setVariable [(_variable + "_CHK"),_vNew]; +server_getStatsDiff = { + private ["_player","_playerUID","_new","_old","_result","_statsArray"]; + _player = _this select 0; + _playerUID = _this select 1; + _result = []; + _statsArray = missionNamespace getVariable _playerUID; + + if (isNil "_statsArray") exitWith { + diag_log format["Server_getStatsDiff error: playerUID %1 not found on server",_playerUID]; + [0,0,0,0,0] }; - _result -}; - -server_getDiff2 = { - private ["_variable","_object","_vNew","_vOld","_result"]; - _variable = _this select 0; - _object = _this select 1; - _vNew = _object getVariable [_variable,0]; - _vOld = _object getVariable [(_variable + "_CHK"),_vNew]; - _result = _vNew - _vOld; - _object setVariable [(_variable + "_CHK"),_vNew]; + + { + _new = _player getVariable [_x,0]; + _old = _statsArray select _forEachIndex; + _result set [_forEachIndex, (_new - _old)]; + _statsArray set [_forEachIndex, _new]; //updates original var too + } forEach ["humanity","zombieKills","headShots","humanKills","banditKills"]; + + #ifdef PLAYER_DEBUG + diag_log format["Server_getStatsDiff - Object:%1 Diffs:%2 New:%3",_player,_result,_statsArray]; + #endif + _result };