From 4ff088c80cb2705d55d8c675dedd4865f8db28cd Mon Sep 17 00:00:00 2001 From: ebaydayz Date: Sat, 9 Jul 2016 14:34:38 -0400 Subject: [PATCH] Remove redundant access checks for upgrade and downgrade Access control for upgrade and downgrade is now included in fn_selfActions as per #1706 I moved _upgrade down in fn_selfActions so it is only checked it if the right conditions are met. --- .../actions/player_buildingDowngrade.sqf | 34 +------------------ SQF/dayz_code/actions/player_upgrade.sqf | 28 +-------------- SQF/dayz_code/compile/fn_check_access.sqf | 2 +- SQF/dayz_code/compile/fn_selfActions.sqf | 2 +- 4 files changed, 4 insertions(+), 62 deletions(-) diff --git a/SQF/dayz_code/actions/player_buildingDowngrade.sqf b/SQF/dayz_code/actions/player_buildingDowngrade.sqf index 338144028..2d6a30a7d 100644 --- a/SQF/dayz_code/actions/player_buildingDowngrade.sqf +++ b/SQF/dayz_code/actions/player_buildingDowngrade.sqf @@ -2,7 +2,7 @@ DayZ Base Building Upgrades Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com. */ -private ["_location","_dir","_classname","_text","_object","_objectID","_objectUID","_newclassname","_refund","_obj","_upgrade","_objectCharacterID","_canBuildOnPlot","_friendlies","_nearestPole","_ownerID","_distance","_needText","_findNearestPoles","_findNearestPole","_IsNearPlot","_i","_invResult","_itemOut","_countOut","_abortInvAdd","_addedItems"]; +private ["_location","_dir","_classname","_text","_object","_objectID","_objectUID","_newclassname","_refund","_obj","_upgrade","_objectCharacterID","_ownerID","_i","_invResult","_itemOut","_countOut","_abortInvAdd","_addedItems"]; if (DZE_ActionInProgress) exitWith {localize "str_epoch_player_48" call dayz_rollingMessages;}; DZE_ActionInProgress = true; @@ -10,39 +10,7 @@ DZE_ActionInProgress = true; player removeAction s_player_downgrade_build; s_player_downgrade_build = 1; -_distance = DZE_PlotPole select 0; -_needText = localize "str_epoch_player_246"; _playerUID = [player] call FNC_GetPlayerUID; -_canBuildOnPlot = false; -_plotcheck = [player, false] call FNC_find_plots; -_IsNearPlot = _plotcheck select 1; -_nearestPole = _plotcheck select 2; - -if(_IsNearPlot == 0) then { - _canBuildOnPlot = true; -} else { - _ownerID = _nearestPole getVariable["CharacterID","0"]; - if(dayz_characterID == _ownerID) then { - _canBuildOnPlot = true; - } else { - if (DZE_permanentPlot) then { - _buildcheck = [player, _nearestPole] call FNC_check_access; - _isowner = _buildcheck select 0; - _isfriendly = ((_buildcheck select 1) or (_buildcheck select 3)); - if (_isowner || _isfriendly) then { - _canBuildOnPlot = true; - }; - } else { - _friendlies = player getVariable ["friendlyTo",[]]; - if(_ownerID in _friendlies) then { - _canBuildOnPlot = true; - }; - }; - }; -}; - -// exit if not allowed due to plot pole -if(!_canBuildOnPlot) exitWith { DZE_ActionInProgress = false; format[localize "str_epoch_player_141",_needText,_distance] call dayz_rollingMessages; }; // get cursortarget from addaction _obj = _this select 3; diff --git a/SQF/dayz_code/actions/player_upgrade.sqf b/SQF/dayz_code/actions/player_upgrade.sqf index 4c86960a7..c7cf91d06 100644 --- a/SQF/dayz_code/actions/player_upgrade.sqf +++ b/SQF/dayz_code/actions/player_upgrade.sqf @@ -2,39 +2,13 @@ DayZ Base Building Upgrades Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com. */ -private ["_location","_dir","_classname","_missing","_text","_proceed","_num_removed","_object","_missingQty","_itemIn","_countIn","_qty","_removed","_removed_total","_tobe_removed_total","_objectID","_objectUID","_temp_removed_array","_textMissing","_newclassname","_requirements","_obj","_upgrade","_lockable","_combination_1","_combination_2","_combination_3","_combination","_objectCharacterID","_canBuildOnPlot","_nearestPole","_ownerID","_distance","_needText","_IsNearPlot"]; +private ["_location","_dir","_classname","_missing","_text","_proceed","_num_removed","_object","_missingQty","_itemIn","_countIn","_qty","_removed","_removed_total","_tobe_removed_total","_objectID","_objectUID","_temp_removed_array","_textMissing","_newclassname","_requirements","_obj","_upgrade","_lockable","_combination_1","_combination_2","_combination_3","_combination","_objectCharacterID","_ownerID"]; if (DZE_ActionInProgress) exitWith {localize "str_epoch_player_52" call dayz_rollingMessages;}; DZE_ActionInProgress = true; player removeAction s_player_upgrade_build; s_player_upgrade_build = 1; -_distance = DZE_PlotPole select 0; -_needText = localize "str_epoch_player_246"; -_canBuildOnPlot = false; - -_plotcheck = [player, false] call FNC_find_plots; -_IsNearPlot = _plotcheck select 1; -_nearestPole = _plotcheck select 2; - -if(_IsNearPlot == 0) then { - _canBuildOnPlot = true; -} else { - _ownerID = _nearestPole getVariable["CharacterID","0"]; - if(dayz_characterID == _ownerID) then { - _canBuildOnPlot = true; - } else { - _buildcheck = [player, _nearestPole] call FNC_check_access; - _isowner = _buildcheck select 0; - _isfriendly = ((_buildcheck select 1) or (_buildcheck select 3)); - if (_isowner || _isfriendly) then { - _canBuildOnPlot = true; - }; - }; -}; - -// exit if not allowed due to plot pole -if(!_canBuildOnPlot) exitWith { DZE_ActionInProgress = false; format[localize "str_epoch_player_157",_needText,_distance] call dayz_rollingMessages; }; // get cursortarget from addaction _obj = _this select 3; diff --git a/SQF/dayz_code/compile/fn_check_access.sqf b/SQF/dayz_code/compile/fn_check_access.sqf index 59ac7600c..7445b2968 100644 --- a/SQF/dayz_code/compile/fn_check_access.sqf +++ b/SQF/dayz_code/compile/fn_check_access.sqf @@ -136,7 +136,7 @@ if(_targetType == "DOOR") then { // RESULT [ _isOwner , _isFriendly -, _isPlotOwner // Same as _isOwner if _target is a PlotPole +, _isPlotOwner , _isPlotFriend , _isPlotAdmin , _isTargetFriend diff --git a/SQF/dayz_code/compile/fn_selfActions.sqf b/SQF/dayz_code/compile/fn_selfActions.sqf index 88cb1a8c3..669ad5bb6 100644 --- a/SQF/dayz_code/compile/fn_selfActions.sqf +++ b/SQF/dayz_code/compile/fn_selfActions.sqf @@ -248,7 +248,6 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur _upgradeItems = ["TentStorage","TentStorage0","TentStorage1","TentStorage2","TentStorage3","StashSmall","StashSmall1","StashSmall2","StashSmall3","StashSmall4","StashMedium","StashMedium1","StashMedium2","StashMedium3","DomeTentStorage","DomeTentStorage0","DomeTentStorage1","DomeTentStorage2","DomeTentStorage3","DomeTentStorage4"]; _isCampSite = _cursorTarget isKindOf "IC_Fireplace1"; _characterID = _cursorTarget getVariable ["CharacterID","0"]; - _upgrade = getArray (configFile >> "CfgVehicles" >> (typeOf _cursorTarget) >> "upgradeBuilding"); if (DZE_permanentPlot) then { _id = [player] call FNC_GetPlayerUID; @@ -887,6 +886,7 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur }; if (s_player_upgrade_build < 0) then { _isowner = [player, _cursorTarget] call FNC_check_access; + _upgrade = getArray (configFile >> "CfgVehicles" >> (typeOf _cursorTarget) >> "upgradeBuilding"); if (((_isowner select 0) or (_isowner select 2) or (_isowner select 3)) && (count _upgrade) > 0) then { s_player_lastTarget set [0,_cursorTarget]; s_player_upgrade_build = player addAction [format[localize "str_upgrade",_text], "\z\addons\dayz_code\actions\player_upgrade.sqf",_cursorTarget, -1, false, true];