From 910ab43a01c421318138c7aa18294eb1ec98e68a Mon Sep 17 00:00:00 2001 From: AirwavesMan Date: Tue, 8 Sep 2020 16:02:53 +0200 Subject: [PATCH] Update Maintain - The maintain animation can be interrupted now - Fix a potential crash exploit if maintain buildings to often in a row in a very short time frame. --- .../Configs/RscDisplay/plotManagement.hpp | 6 +- SQF/dayz_code/actions/maintain_area.sqf | 84 ++++++++++--------- .../plotManagement/plotToggleMarkers.sqf | 11 +-- SQF/dayz_code/stringtable.xml | 4 +- 4 files changed, 52 insertions(+), 53 deletions(-) diff --git a/SQF/dayz_code/Configs/RscDisplay/plotManagement.hpp b/SQF/dayz_code/Configs/RscDisplay/plotManagement.hpp index e5f3be552..a10515ad1 100644 --- a/SQF/dayz_code/Configs/RscDisplay/plotManagement.hpp +++ b/SQF/dayz_code/Configs/RscDisplay/plotManagement.hpp @@ -32,7 +32,7 @@ class PlotManagement x = 0.31 * safezoneW + safezoneX; y = 0.22 * safezoneH + safezoneY; w = 0.08 * safezoneW; - onButtonClick = "call PlotPreview;"; + onButtonClick = "[] spawn PlotPreview;"; }; class RscShortcutButton_7010: ZSC_RscButtonMenu @@ -42,7 +42,7 @@ class PlotManagement x = 0.41 * safezoneW + safezoneX; y = 0.22 * safezoneH + safezoneY; w = 0.08 * safezoneW; - onButtonClick = "'maintain' call MaintainPlot;"; + onButtonClick = "'maintain' spawn MaintainPlot;"; }; class RscShortcutButton_7011: ZSC_RscButtonMenu @@ -52,7 +52,7 @@ class PlotManagement x = 0.51 * safezoneW + safezoneX; y = 0.22 * safezoneH + safezoneY; w = 0.08 * safezoneW; - onButtonClick = "'force' call MaintainPlot;"; + onButtonClick = "'force' spawn MaintainPlot;"; }; class RscText_7012: ZSC_RscText diff --git a/SQF/dayz_code/actions/maintain_area.sqf b/SQF/dayz_code/actions/maintain_area.sqf index a4f2fd353..4f03c2543 100644 --- a/SQF/dayz_code/actions/maintain_area.sqf +++ b/SQF/dayz_code/actions/maintain_area.sqf @@ -17,12 +17,11 @@ Please see configVariables.sqf for the value of gems (DZE_GemWorthArray) and the */ -private ["_objectID","_objectUID","_target","_objects","_requirements","_count","_objects_filtered","_itemText","_type","_amount","_success","_wealth","_message1","_message2","_option","_line1","_line2","_plotDialog"]; -disableSerialization; - if (dayz_actionInProgress) exitWith {localize "STR_EPOCH_ACTIONS_2" call dayz_rollingMessages;}; dayz_actionInProgress = true; +private ["_maintain","_req","_objectID","_objectUID","_target","_objects","_requirements","_count","_objects_filtered","_message1","_message2","_option","_line1","_line2","_plotDialog"]; + player removeAction s_player_maintain_area; s_player_maintain_area = 1; player removeAction s_player_maintain_area_force; @@ -36,9 +35,6 @@ _objects = nearestObjects [_target, DZE_maintainClasses, DZE_maintainRange]; _objects_filtered = []; _requirements = []; _count = 0; -_plotDialog = findDisplay 711194; -_line1 = _plotDialog displayCtrl 7012; -_line2 = _plotDialog displayCtrl 7013; _req = { private ["_count","_amount","_itemText"]; @@ -51,7 +47,7 @@ _req = { }; _maintain = { - private ["_requirements","_count","_amount","_itemText","_wealth","_success","_message1","_message2","_enoughMoney","_moneyInfo"]; + private ["_requirements","_count","_amount","_itemText","_wealth","_success","_message1","_message2","_enoughMoney","_moneyInfo","_finished"]; _count = count (_this select 0); _requirements = _count call _req; @@ -76,34 +72,31 @@ _maintain = { if (!_success && _enoughMoney) exitWith { systemChat localize "STR_EPOCH_TRADE_GEAR_AND_BAG_FULL"; }; // Not enough room in gear or bag to accept change if (_enoughMoney) then { + + closeDialog 1; + [player,"repair",0,false,20] call dayz_zombieSpeak; + [player,DZE_maintainRange,true,(getPosATL player)] spawn player_alertZombies; + + _finished = ["Medic",1] call fn_loopAction; + if !(_finished) exitWith {}; + _success = if (Z_SingleCurrency) then {_amount <= _wealth} else {[player,_amount,_moneyInfo,false,0] call Z_payDefault}; if (_success) then { + ["Working",0,[100,15,10,0]] call dayz_NutritionSystem; PVDZE_maintainArea = [player,1,_this select 0]; publicVariableServer "PVDZE_maintainArea"; - systemChat format[localize "STR_EPOCH_ACTIONS_4",_count]; if (Z_SingleCurrency) then { player setVariable[(["cashMoney","globalMoney"] select Z_persistentMoney),(_wealth - _amount),true]; _message1 = format [localize "STR_EPOCH_PLOTMANAGEMENT_OBJECTS_MAINTAINED_SUCCESS",_count,[_amount] call BIS_fnc_numberText,_itemText]; } else { _message1 = format [localize "STR_EPOCH_PLOTMANAGEMENT_OBJECTS_MAINTAINED_SUCCESS",_count,_itemText,""]; }; - _message2 = " "; - call player_forceSave; // Call player_forceSave BEFORE the medic animation because it can override the animation and make it finish prematurely. - - player playActionNow "Medic"; - [player,"repair",0,false,20] call dayz_zombieSpeak; - [player,DZE_maintainRange,true,(getPosATL player)] spawn player_alertZombies; - ["Working",0,[100,15,10,0]] call dayz_NutritionSystem; - - if (DZE_permanentPlot) then { - _line1 ctrlSetText _message1; - _line2 ctrlSetText _message2; - } else { - _message1 call dayz_rollingMessages; - }; + call player_forceSave; + _message1 call dayz_rollingMessages; + systemChat _message1; } else { systemChat localize "STR_EPOCH_TRADE_DEBUG"; }; @@ -113,8 +106,14 @@ _maintain = { } else { _message1 = format[localize "STR_EPOCH_PLOTMANAGEMENT_OBJECTS_MAINTAINED_FAILED",_count,_itemText,""]; }; - _message2 = " "; + if (DZE_permanentPlot) then { + disableSerialization; + + _plotDialog = findDisplay 711194; + _line1 = _plotDialog displayCtrl 7012; + _line2 = _plotDialog displayCtrl 7013; + _message2 = " "; _line1 ctrlSetText _message1; _line2 ctrlSetText _message2; } else { @@ -134,15 +133,33 @@ _maintain = { _option = if (typeName _this == "ARRAY") then {_this select 3} else {_this}; -switch _option do { - case "maintain": { +call { + if (_option == "maintain") exitwith { if (_count != 0) then { [_objects_filtered] call _maintain; } else { systemChat localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_NONE"; }; }; - case "preview": { + if (_option == "force") exitwith { + _count = 0; + _objects_filtered = []; + { + _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_filtered] call _maintain; + }; + if (_option == "preview") exitwith { + disableSerialization; + + _plotDialog = findDisplay 711194; + _line1 = _plotDialog displayCtrl 7012; + _line2 = _plotDialog displayCtrl 7013; + if (_count == 0) then { _message1 = localize "STR_EPOCH_PLOTMANAGEMENT_MAINTAIN_NONE"; if (DZE_permanentPlot) then { @@ -178,21 +195,6 @@ switch _option do { }; }; }; - case "force": { - _count = 0; - _objects_filtered = []; - { - _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_filtered] call _maintain; - }; }; dayz_actionInProgress = false; -s_player_maintain_area = -1; -s_player_maintain_area_force = -1; -s_player_maintain_area_preview = -1; diff --git a/SQF/dayz_code/actions/plotManagement/plotToggleMarkers.sqf b/SQF/dayz_code/actions/plotManagement/plotToggleMarkers.sqf index 980dec9ce..4107ec6d0 100644 --- a/SQF/dayz_code/actions/plotManagement/plotToggleMarkers.sqf +++ b/SQF/dayz_code/actions/plotManagement/plotToggleMarkers.sqf @@ -1,20 +1,17 @@ //Zero Remorse, big thanks to their scripter for this! -private ["_speed","_density","_model","_thePlot","_center","_radius","_angle","_count","_axis","_obj","_idx","_a","_b"]; +private ["_density","_model","_thePlot","_center","_radius","_angle","_count","_axis","_obj","_idx","_a","_b"]; -_speed = 4; // multiplier for speed of sphere rotation/wobble _density = 3; // density of markers per ring _model = "Sign_sphere100cm_EP1"; // marker model to use on rings -// Possible ones to use :: Sign_sphere10cm_EP1 Sign_sphere25cm_EP1 Sign_sphere100cm_EP1 +// Possible ones to use :: Sign_sphere10cm_EP1 Sign_sphere25cm_EP1 Sign_sphere100cm_EP1 _thePlot = (([player] call FNC_getPos) nearEntities ["Plastic_Pole_EP1_DZ",15]) select 0; _center = getPosASL _thePlot; _radius = DZE_PlotPole select 0; _obj = false; -_tmp = -1; if (!isNil "PP_Marks") then { if (((PP_Marks select 0) distance _thePlot) < 10) then { _obj = true; }; - _tmp = (PP_Marks select 0) distance _thePlot; { deleteVehicle _x; } count PP_Marks; PP_Marks = nil; }; @@ -29,7 +26,7 @@ if ((isNil "PP_Marks") && (!_obj)) then { _axis = _obj; _obj setVectorUp [0, 0, 0]; PP_Marks set [count PP_Marks, _obj]; - _angle = 0; + _angle = 0; for "_idx" from 0 to _count do { _a = (_center select 0) + (sin(_angle)*_radius); _b = (_center select 1) + (cos(_angle)*_radius); @@ -77,4 +74,4 @@ if ((isNil "PP_Marks") && (!_obj)) then { PP_Marks set [count PP_Marks, _obj]; _angle = _angle + (360/_count); }; -}; \ No newline at end of file +}; diff --git a/SQF/dayz_code/stringtable.xml b/SQF/dayz_code/stringtable.xml index a169f6344..55466b281 100644 --- a/SQF/dayz_code/stringtable.xml +++ b/SQF/dayz_code/stringtable.xml @@ -26075,8 +26075,8 @@ Success! %1 objects maintained for %2 %3 - Du hast %1 Objekt(e) erfolgreich saniert für %2 %3. - Успешно! Обслужено объектов: %1 за %2 %3. + Du hast %1 Objekt(e) erfolgreich saniert für %2 %3 + Успешно! Обслужено объектов: %1 за %2 %3 Price to force maintain %1 objects: %2 %3