Better maintain

Intensive commands are processed on the client only, as opposed to
twice. an array of objects, their corresponding UID and ID are sent to
the server. Sending the objects as an array, despite the size the array
can reach, should be better than the way this was set up before.

Needs testing on a full server however.
This commit is contained in:
icomrade
2016-08-03 19:54:06 -04:00
parent b2eacfbe73
commit 657fe60f26
5 changed files with 55 additions and 51 deletions

View File

@@ -17,16 +17,18 @@ _objects = nearestObjects [_target, _objectClasses, _range];
//filter to only those that have 10% damage
_objects_filtered = [];
_count = 0;
{
if (damage _x >= DZE_DamageBeforeMaint) then {
_objects_filtered set [count _objects_filtered, _x];
_objectUID = _x getVariable ["ObjectUID","0"];
_objectID = _x getVariable ["ObjectID","0"];
_objects_filtered set [count _objects_filtered, [_x, _objectID, _objectUID]];
_count = _count + 1;
};
} count _objects;
_objects = _objects_filtered;
// TODO dynamic requirements based on used building parts?
_count = count _objects;
if (_count == 0) exitWith {
format[localize "STR_EPOCH_ACTIONS_22",_count] call dayz_rollingMessages;
DZE_ActionInProgress = false;
@@ -97,7 +99,7 @@ switch _option do {
// all required items removed from player gear
if (_tobe_removed_total == _removed_total) then {
format[localize "STR_EPOCH_ACTIONS_4",_count] call dayz_rollingMessages;
PVDZE_maintainArea = [player,1,_target];
PVDZE_maintainArea = [player,1, _objects];
publicVariableServer "PVDZE_maintainArea";
} else {
{player addMagazine _x;} count _temp_removed_array;

View File

@@ -78,7 +78,7 @@ if (_proceed) then {
// all parts removed proceed
if (_tobe_removed_total == _removed_total) then {
format[localize "STR_EPOCH_ACTIONS_4",1] call dayz_rollingMessages;
PVDZE_maintainArea = [player,2,_obj];
PVDZE_maintainArea = [player,2,[_obj, _objectID, _objectUID]];
publicVariableServer "PVDZE_maintainArea";
} else {
{player addMagazine _x;} count _temp_removed_array;

View File

@@ -16,15 +16,18 @@ _range = DZE_PlotPole select 0;
_objects = nearestObjects [_target, _objectClasses, _range];
_objects_filtered = [];
_count = 0;
{
if (damage _x >= DZE_DamageBeforeMaint) then {
_objects_filtered set [count _objects_filtered, _x];
_objectUID = _x getVariable ["ObjectUID","0"];
_objectID = _x getVariable ["ObjectID","0"];
_objects_filtered set [count _objects_filtered, [_x, _objectID, _objectUID]];
_count = _count + 1;
};
} count _objects;
_objects = _objects_filtered;
_count = count _objects;
// TODO dynamic requirements based on used building parts?
if (_count == 0) exitWith {
_ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012);
_result = format[localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_OBJECTS", _count];
@@ -99,7 +102,7 @@ switch _option do {
// all required items removed from player gear
if (_tobe_removed_total == _removed_total) then {
format[localize "STR_EPOCH_ACTIONS_4", _count] call dayz_rollingMessages;
PVDZE_maintainArea = [player,1,_target];
PVDZE_maintainArea = [player,1,_objects];
publicVariableServer "PVDZE_maintainArea";
_ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012);
_result = format[localize "STR_EPOCH_PLOTMANAGEMENT_OBJECTS_MAINTAINED_SUCCESS", _count];

View File

@@ -18,14 +18,17 @@ _objects = nearestObjects [_target, _objectClasses, _range];
_objects_filtered = [];
{
if (damage _x >= DZE_DamageBeforeMaint) then {
_objects_filtered set [count _objects_filtered, _x];
_objectUID = _x getVariable ["ObjectUID","0"];
_objectID = _x getVariable ["ObjectID","0"];
_objects_filtered set [count _objects_filtered, [_x, _objectID, _objectUID]];
_count = _count + 1;
};
} count _objects;
_objects = _objects_filtered;
_count = count _objects;
// TODO dynamic requirements based on used building parts?
if (_count == 0) exitWith {
_ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012);
_result = format["Objects to maintain: %1" , _count];
_ctrl ctrlSetText _result;
@@ -47,7 +50,7 @@ _option = _this select 0;
switch _option do {
case "maintain": {
_wealth = player getVariable["cashMoney",0];
_wealth = player getVariable[Z_MoneyVariable,0];
_missing = "";
_missingQty = 0;
_proceed = true;
@@ -62,10 +65,10 @@ switch _option do {
player playActionNow "Medic";
[player,_range,true,(getPosATL player)] spawn player_alertZombies;
player setVariable["cashMoney",_newWealth,true];
player setVariable[Z_MoneyVariable,_newWealth,true];
call player_forceSave;
PVDZE_maintainArea = [player,1,_target];
PVDZE_maintainArea = [player,1,_objects];
publicVariableServer "PVDZE_maintainArea";

View File

@@ -1,50 +1,46 @@
/* Maintain Area - written by Skaronator */
private ["_player","_name","_ObjArray","_uniqueID","_objects","_key"];
/*
1: PVDZE_maintainArea = [player,1,[[Object, _objectID, _objectUID],[Object, _objectID, _objectUID]...etc]];
2: PVDZE_maintainArea = [player,2,[Object, _objectID, _objectUID]];
*/
private ["_player","_name","_ObjArray","_uniqueID","_key"];
_player = _this select 0;
_option = _this select 1;
/*
1: PVDZE_maintainArea = [player,1,_target];
2: PVDZE_maintainArea = [player,2,_object];
*/
_targetObj = _this select 2;
_objectsInfo = _this select 2;
if (_option == 1) then {
_objects = nearestObjects [_targetObj, DZE_maintainClasses, DZE_maintainRange];
{
if (damage _x >= DZE_DamageBeforeMaint) then {
_objectID = _x getVariable ["ObjectID","0"];
if (_objectID == "0") then {
_objectUID = _x getVariable ["ObjectUID","0"];
if (_objectUID != "0") then {
_x setDamage 0;
_key = format["CHILD:397:%1:", _objectUID]; // use UID if not "0" && ID is "0"
_data = "HiveExt" callExtension _key;
_obj = _x select 0;
_ID = _x select 1;
_UID = _x select 2;
if (_ID == "0") then {
if (_UID != "0") then {
_obj setDamage 0;
_key = format["CHILD:397:%1:", _UID];
_key call server_hiveWrite;
};
} else {
_x setDamage 0;
_key = format["CHILD:396:%1:", _objectID]; //Use ID instead of UID because ID is shorter
_data = "HiveExt" callExtension _key;
_obj setDamage 0;
_key = format["CHILD:396:%1:", _ID];
_key call server_hiveWrite;
};
};
} count _objects;
} count _objectsInfo;
_name = if (alive _player) then { name _player; } else { "Dead Player"; };
diag_log format ["MAINTAIN AREA BY %1 - %2 Objects at %3", _name, count _objects, (getPosATL _player)];
};
if (_option == 2) then {
if (damage _targetObj >= DZE_DamageBeforeMaint) then {
_objectID = _targetObj getVariable ["ObjectID","0"];
if (_objectID == "0") then {
_objectUID = _targetObj getVariable ["ObjectUID","0"];
if (_objectUID != "0") then {
_targetObj setDamage 0;
_key = format["CHILD:397:%1:", _objectUID]; // use UID if not "0" && ID is "0"
_data = "HiveExt" callExtension _key;
diag_log format ["MAINTAIN AREA BY %1 - %2 Objects at %3", _name, (count _objectsInfo), (getPosATL _player)];
} else {
_obj = _objectsInfo select 0;
_ID = _objectsInfo select 1;
_UID = _objectsInfo select 2;
if (_ID == "0") then {
if (_UID != "0") then {
_obj setDamage 0;
_key = format["CHILD:397:%1:", _UID];
_key call server_hiveWrite;
};
} else {
_targetObj setDamage 0;
_key = format["CHILD:396:%1:", _objectID]; //Use ID instead of UID because ID is shorter
_data = "HiveExt" callExtension _key;
_obj setDamage 0;
_key = format["CHILD:396:%1:", _ID];
_key call server_hiveWrite;
};
};
};