More server_updateobject optimization

This commit is contained in:
Merlijn
2019-11-04 20:24:02 +01:00
parent 8acc827b14
commit 6954452aa7
3 changed files with 31 additions and 35 deletions

View File

@@ -4,6 +4,8 @@ if (isNil "sm_done") exitWith {};
private ["_class","_objectID","_objectUID","_isNotOk","_object","_type","_forced","_totalDmg"]; private ["_class","_objectID","_objectUID","_isNotOk","_object","_type","_forced","_totalDmg"];
_object = _this select 0; _object = _this select 0;
if ((isNil "_object") || {isNull _object}) exitWith {diag_log "server_updateObject.sqf _object null or nil, could not update object"};
_type = _this select 1; _type = _this select 1;
_forced = if (count _this > 2) then {_this select 2} else {false}; _forced = if (count _this > 2) then {_this select 2} else {false};
_totalDmg = if (count _this > 3) then {_this select 3} else {false}; _totalDmg = if (count _this > 3) then {_this select 3} else {false};
@@ -11,7 +13,6 @@ _isNotOk = false;
_objectID = "0"; _objectID = "0";
_objectUID = "0"; _objectUID = "0";
if ((isNil "_object") || {isNull _object}) exitWith {diag_log "server_updateObject.sqf _object null or nil, could not update object"};
_objectID = _object getVariable ["ObjectID","0"]; _objectID = _object getVariable ["ObjectID","0"];
_objectUID = _object getVariable ["ObjectUID","0"]; _objectUID = _object getVariable ["ObjectUID","0"];
_class = typeOf _object; _class = typeOf _object;
@@ -48,15 +49,15 @@ _object setVariable ["lastUpdate",diag_ticktime,true];
call { call {
if (_type == "all") exitwith { if (_type == "all") exitwith {
[_object,_objectID] call server_obj_pos; [_object,_objectID,_class] call server_obj_pos;
[_object,_objectID,_objectUID] call server_obj_inv; [_object,_objectID,_objectUID,_class] call server_obj_inv;
[_object,_objectID,_objectUID,_forced,_totalDmg] call server_obj_dam; [_object,_objectID,_objectUID,_forced,_totalDmg] call server_obj_dam;
}; };
if (_type == "position") exitwith { if (_type == "position") exitwith {
[_object,_objectID] call server_obj_pos; [_object,_objectID,_class] call server_obj_pos;
}; };
if (_type == "gear") exitwith { if (_type == "gear") exitwith {
[_object,_objectID,_objectUID] call server_obj_inv; [_object,_objectID,_objectUID,_class] call server_obj_inv;
}; };
if (_type == "damage" || {_type == "repair"}) exitwith { if (_type == "damage" || {_type == "repair"}) exitwith {
[_object,_objectID,_objectUID,_forced,_totalDmg] call server_obj_dam; [_object,_objectID,_objectUID,_forced,_totalDmg] call server_obj_dam;
@@ -70,10 +71,11 @@ call {
_playerUID = _this select 4; _playerUID = _this select 4;
_clientKey = _this select 5; _clientKey = _this select 5;
[_object,_objectID,_objectUID,_playerUID,_clientKey] call server_obj_killed; [_object,_objectID,_objectUID,_playerUID,_clientKey,_class] call server_obj_killed;
}; };
if (_type == "coins") exitwith { if (_type == "coins") exitwith {
_object setVariable ["lastInventory",["forceUpdate"]]; _object setVariable ["lastInventory",["forceUpdate"]];
[_object,_objectID,_objectUID] call server_obj_inv; [_object,_objectID,_objectUID] call server_obj_inv;
}; };
"";
}; };

View File

@@ -16,20 +16,20 @@ _player = _this select 5;
_index = dayz_serverPUIDArray find _playerUID; _index = dayz_serverPUIDArray find _playerUID;
_exitReason = switch true do { _exitReason = call {
//If object or player is null distance returns 9999+ //If object or player is null distance returns 9999+
//If object or player was moved with setPos on client, position takes a second to update on server //If object or player was moved with setPos on client, position takes a second to update on server
//Coordinates can be used in place of object //Coordinates can be used in place of object
case (_objPos distance _player > (Z_VehicleDistance + 10)): { if (_objPos distance _player > (Z_VehicleDistance + 10)) exitwith {
format["%1 error: Verification failed, player is too far from object. Distance: %2m/%3m limit PV ARRAY: %4",_function,round (_objPos distance _player),Z_VehicleDistance + 10,_params] format["%1 error: Verification failed, player is too far from object. Distance: %2m/%3m limit PV ARRAY: %4",_function,round (_objPos distance _player),Z_VehicleDistance + 10,_params]
}; };
case (_index < 0): { if (_index < 0) exitwith {
format["%1 error: PUID NOT FOUND ON SERVER. PV ARRAY: %2",_function,_params] format["%1 error: PUID NOT FOUND ON SERVER. PV ARRAY: %2",_function,_params]
}; };
case (((dayz_serverClientKeys select _index) select 0 != owner _player) or ((dayz_serverClientKeys select _index) select 1 != _clientKey)): { if (((dayz_serverClientKeys select _index) select 0 != owner _player) or ((dayz_serverClientKeys select _index) select 1 != _clientKey)) exitwith {
format["%1 error: CLIENT AUTH KEY INCORRECT OR UNRECOGNIZED. PV ARRAY: %2",_function,_params] format["%1 error: CLIENT AUTH KEY INCORRECT OR UNRECOGNIZED. PV ARRAY: %2",_function,_params]
}; };
default {""}; "";
}; };
_exitReason _exitReason

View File

@@ -5,7 +5,7 @@ server_obj_pos = {
_object = _this select 0; _object = _this select 0;
_objectID = _this select 1; _objectID = _this select 1;
_class = typeOf _object; _class = _this select 2;
_position = getPosATL _object; _position = getPosATL _object;
//_worldspace = [round (direction _object),_position]; //_worldspace = [round (direction _object),_position];
@@ -26,27 +26,21 @@ server_obj_inv = {
_object = _this select 0; _object = _this select 0;
_objectID = _this select 1; _objectID = _this select 1;
_objectUID = _this select 2; _objectUID = _this select 2;
_class = typeOf _object; _class = _this select 3;
if (_class isKindOf "TrapItems") then { _inventory = call {
_inventory = [["armed",_object getVariable ["armed",false]]]; if (DZE_permanentPlot && {_class == "Plastic_Pole_EP1_DZ"}) exitwith {
} else { _object getVariable ["plotfriends", []] //We're replacing the inventory with UIDs for this item
_isNormal = true; };
if (DZE_doorManagement && {_class in DZE_DoorsLocked}) exitwith {
if (DZE_permanentPlot && {_class == "Plastic_Pole_EP1_DZ"}) then { _object getVariable ["doorfriends", []] //We're replacing the inventory with UIDs for this item
_isNormal = false; };
_inventory = _object getVariable ["plotfriends", []]; //We're replacing the inventory with UIDs for this item if (_class isKindOf "TrapItems") exitwith {
}; [["armed",_object getVariable ["armed",false]]]
if (DZE_doorManagement && {_class in DZE_DoorsLocked}) then {
_isNormal = false;
_inventory = _object getVariable ["doorfriends", []]; //We're replacing the inventory with UIDs for this item
};
if (_isNormal) then {
_inventory = [getWeaponCargo _object, getMagazineCargo _object, getBackpackCargo _object];
}; };
[getWeaponCargo _object, getMagazineCargo _object, getBackpackCargo _object]
}; };
_previous = str(_object getVariable["lastInventory",[]]); _previous = str(_object getVariable["lastInventory",[]]);
if (str _inventory != _previous) then { if (str _inventory != _previous) then {
@@ -137,8 +131,8 @@ server_obj_killed = {
_objectUID = _this select 2; _objectUID = _this select 2;
_playerUID = _this select 3; _playerUID = _this select 3;
_clientKey = _this select 4; _clientKey = _this select 4;
_class = _this select 5;
_class = typeOf _object;
_index = dayz_serverPUIDArray find _playerUID; _index = dayz_serverPUIDArray find _playerUID;
_exitReason = call { _exitReason = call {
@@ -150,10 +144,10 @@ server_obj_killed = {
if ((dayz_serverClientKeys select _index) select 1 != _clientKey) exitwith { if ((dayz_serverClientKeys select _index) select 1 != _clientKey) exitwith {
format["Server_UpdateObject error: CLIENT AUTH KEY INCORRECT OR UNRECOGNIZED. PV ARRAY: %1",_this] format["Server_UpdateObject error: CLIENT AUTH KEY INCORRECT OR UNRECOGNIZED. PV ARRAY: %1",_this]
}; };
if (alive _object && {!(_class isKindOf "TentStorage_base" or _class isKindOf "IC_Tent")}) exitwith { if (alive _object or {!(_class isKindOf "TentStorage_base" or _class isKindOf "IC_Tent")}) exitwith {
format["Server_UpdateObject error: object kill request on living object. PV ARRAY: %1",_this] format["Server_UpdateObject error: object kill request on living object. PV ARRAY: %1",_this]
}; };
if (1==1) exitwith {""}; "";
}; };
if (_exitReason != "") exitWith {diag_log _exitReason}; if (_exitReason != "") exitWith {diag_log _exitReason};