Move server_getDiff to missionNameSpace

Vanilla commits:

dc984fd219

d82f430c28
This commit is contained in:
ebayShopper
2017-11-25 12:47:25 -05:00
parent 90487cde10
commit 1e65d5d324
8 changed files with 43 additions and 60 deletions

View File

@@ -79,6 +79,7 @@
[FIXED] A locked door can now be auto unlocked right after placement by the player who built it [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] A rare error in keyboard.sqf for certain combination binds.
[FIXED] Floating loot positions in hotel (Land_HouseB_Tenement) [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. [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. [FIXED] Fixed food and drink going down 10x faster from melee and other "working" actions.

View File

@@ -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; //_playerUID = _this select 0;
_charID = _this select 1; _charID = _this select 1;
_model = _this select 2; _model = _this select 2;
@@ -11,9 +11,6 @@ _old removeAllEventHandlers "Fired";
_old allowDamage false; _old allowDamage false;
_old AddEventHandler ["HandleDamage", {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; dayz_unsaved = true;
//Logout //Logout
_humanity = player getVariable ["humanity",0]; _humanity = player getVariable ["humanity",0];

View File

@@ -91,6 +91,8 @@ if (_characterID != "?") then {
[_playerUID,_characterID,3,_playerName,(_playerPos call fa_coor2str)] call dayz_recordLogin; [_playerUID,_characterID,3,_playerName,(_playerPos call fa_coor2str)] call dayz_recordLogin;
}; };
missionNamespace setVariable [_playerUID,nil];
if (alive _playerObj) then { if (alive _playerObj) then {
_playerObj call sched_co_deleteVehicle; _playerObj call sched_co_deleteVehicle;
}; };

View File

@@ -32,13 +32,11 @@ if (_characterID != "0") then {
_key call server_hiveWrite; _key call server_hiveWrite;
}; };
#ifdef PLAYER_DEBUG
diag_log format ["Player UID#%3 CID#%4 %1 as %5 died at %2", diag_log format ["Player UID#%3 CID#%4 %1 as %5 died at %2",
_newObject call fa_plr2str, _pos call fa_coor2str, _newObject call fa_plr2str, _pos call fa_coor2str,
_playerID, _characterID, _playerID, _characterID,
typeOf _newObject typeOf _newObject
]; ];
#endif
// DEATH MESSAGES // DEATH MESSAGES
_suicide = ((_sourceName == _playerName) or (_method == "suicide")); _suicide = ((_sourceName == _playerName) or (_method == "suicide"));

View File

@@ -134,7 +134,7 @@ if (count _medical > 0) then {
}; };
if (count _stats > 0) then { if (count _stats > 0) then {
//register stats //register stats Global
_playerObj setVariable ["zombieKills",(_stats select 0),true]; _playerObj setVariable ["zombieKills",(_stats select 0),true];
_playerObj setVariable ["headShots",(_stats select 1),true]; _playerObj setVariable ["headShots",(_stats select 1),true];
_playerObj setVariable ["humanKills",(_stats select 2),true]; _playerObj setVariable ["humanKills",(_stats select 2),true];
@@ -150,15 +150,7 @@ if (count _stats > 0) then {
_score = score _playerObj; _score = score _playerObj;
_playerObj addScore ((_stats select 0) - _score); _playerObj addScore ((_stats select 0) - _score);
//record for Server JIP checks missionNamespace setVariable [_playerID,[_humanity,(_stats select 0),(_stats select 1),(_stats select 2),(_stats select 3)]];
_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];
};
} else { } else {
//register stats //register stats
_playerObj setVariable ["zombieKills",0,true]; _playerObj setVariable ["zombieKills",0,true];
@@ -170,9 +162,7 @@ if (count _stats > 0) then {
_playerObj setVariable ["ConfirmedHumanKills",0,true]; _playerObj setVariable ["ConfirmedHumanKills",0,true];
_playerObj setVariable ["ConfirmedBanditKills",0,true]; _playerObj setVariable ["ConfirmedBanditKills",0,true];
//record for Server JIP checks missionNamespace setVariable [_playerID,[_humanity,0,0,0,0]];
_playerObj setVariable ["zombieKills_CHK",0];
_playerObj setVariable ["headShots_CHK",0];
}; };
if (_randomSpot) then { if (_randomSpot) then {
@@ -220,7 +210,6 @@ if (_randomSpot) then {
//record player pos locally for server checking //record player pos locally for server checking
_playerObj setVariable ["characterID",_characterID,true]; _playerObj setVariable ["characterID",_characterID,true];
_playerObj setVariable ["humanity",_humanity,true]; _playerObj setVariable ["humanity",_humanity,true];
_playerObj setVariable ["humanity_CHK",_humanity];
_playerObj setVariable ["lastPos",getPosATL _playerObj]; _playerObj setVariable ["lastPos",getPosATL _playerObj];
_clientID = owner _playerObj; _clientID = owner _playerObj;

View File

@@ -1,8 +1,10 @@
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
private ["_distanceFoot","_playerPos","_lastPos","_playerGear","_medical","_currentModel","_currentAnim", private ["_distanceFoot","_playerPos","_lastPos","_playerGear","_medical","_currentModel","_currentAnim",
"_currentWpn","_muzzles","_array","_coins","_key","_globalCoins","_bankCoins","_playerBackp","_exitReason", "_currentWpn","_muzzles","_array","_coins","_key","_globalCoins","_bankCoins","_playerBackp","_exitReason",
"_backpack","_kills","_killsB","_killsH","_headShots","_humanity","_lastTime","_timeGross","_timeSince", "_backpack","_kills","_killsB","_killsH","_headShots","_humanity","_lastTime","_timeGross","_timeSince",
"_timeLeft","_config","_onLadder","_isTerminal","_modelChk","_temp","_currentState","_character", "_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] //[player,array]
_character = _this select 0; _character = _this select 0;
@@ -45,17 +47,13 @@ _lastTime = _character getVariable ["lastTime",-1];
_modelChk = _character getVariable ["model_CHK",""]; _modelChk = _character getVariable ["model_CHK",""];
_temp = round (_character getVariable ["temperature",100]); _temp = round (_character getVariable ["temperature",100]);
_lastMagazines = _character getVariable ["ServerMagArray",[[],""]]; _lastMagazines = _character getVariable ["ServerMagArray",[[],""]];
/* //Get difference between current stats and stats at last sync
Check previous stats against what client had when they logged in _statsDiff = [_character,_playerUID] call server_getStatsDiff;
this helps prevent JIP issues, where a new player wouldn't have received _humanity = _statsDiff select 0;
the old players updates. Only valid for stats where clients could have _kills = _statsDiff select 1;
be recording results from their local objects (such as agent zombies) _headShots = _statsDiff select 2;
*/ _killsH = _statsDiff select 3;
_kills = ["zombieKills",_character] call server_getDiff; _killsB = _statsDiff select 4;
_killsB = ["banditKills",_character] call server_getDiff;
_killsH = ["humanKills",_character] call server_getDiff;
_headShots = ["headShots",_character] call server_getDiff;
_humanity = ["humanity",_character] call server_getDiff2;
_charPosLen = count _charPos; _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] 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; _key call server_hiveWrite;
if (Z_SingleCurrency) then { //update global coins if (Z_SingleCurrency) then { //update global coins

View File

@@ -12,7 +12,7 @@ Please request permission to use/alter/distribute from project leader (R4Z0R49)
//#define OBJECT_DEBUG //#define OBJECT_DEBUG
// comment this out if you don't want any PLAYER (WORLDSPACE/INVENTORY/ETC) related 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 // comment this out if you don't want any misc SERVER (ZOMBIE, LOOT, CLEANUP) related debug
//#define SERVER_DEBUG //#define SERVER_DEBUG

View File

@@ -183,32 +183,29 @@ server_hiveReadWrite = {
onPlayerDisconnected "[_uid,_name] call server_onPlayerDisconnect;"; onPlayerDisconnected "[_uid,_name] call server_onPlayerDisconnect;";
server_getDiff = { server_getStatsDiff = {
private ["_variable","_object","_vNew","_vOld","_result"]; private ["_player","_playerUID","_new","_old","_result","_statsArray"];
_variable = _this select 0; _player = _this select 0;
_object = _this select 1; _playerUID = _this select 1;
_vNew = _object getVariable [_variable,0]; _result = [];
_vOld = _object getVariable [(_variable + "_CHK"),_vNew]; _statsArray = missionNamespace getVariable _playerUID;
_result = 0;
if (_vNew < _vOld) then { if (isNil "_statsArray") exitWith {
//JIP issues diag_log format["Server_getStatsDiff error: playerUID %1 not found on server",_playerUID];
_vNew = _vNew + _vOld; [0,0,0,0,0]
_object getVariable [(_variable + "_CHK"),_vNew];
} else {
_result = _vNew - _vOld;
_object setVariable [(_variable + "_CHK"),_vNew];
}; };
_result
}; {
_new = _player getVariable [_x,0];
server_getDiff2 = { _old = _statsArray select _forEachIndex;
private ["_variable","_object","_vNew","_vOld","_result"]; _result set [_forEachIndex, (_new - _old)];
_variable = _this select 0; _statsArray set [_forEachIndex, _new]; //updates original var too
_object = _this select 1; } forEach ["humanity","zombieKills","headShots","humanKills","banditKills"];
_vNew = _object getVariable [_variable,0];
_vOld = _object getVariable [(_variable + "_CHK"),_vNew]; #ifdef PLAYER_DEBUG
_result = _vNew - _vOld; diag_log format["Server_getStatsDiff - Object:%1 Diffs:%2 New:%3",_player,_result,_statsArray];
_object setVariable [(_variable + "_CHK"),_vNew]; #endif
_result _result
}; };