From a68e4b273be19fb6da5be00aea07643c5b24fff3 Mon Sep 17 00:00:00 2001 From: oiad Date: Sun, 22 Jan 2017 11:01:42 +1300 Subject: [PATCH] fix epoch_tempKeys.sqf making massive arrays. (#1884) * fix epoch_tempKeys.sqf making massive arrays. epoch_tempKeys was making a massive array every time it was called due to them setting the array size to the _ownerKeyId instead of count _temp_keys_names. For example: Call this function 10k times in testkit and see it lag the client due to making a massive array over and over again. ```"[[["9379"],[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,> "CfgWeapons" >> _x)) in _key_colors) then { _ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid"); _ownerKeyName = getText(configFile >> "CfgWeapons" >> _x >> "displayName"); - _temp_keys_names set [_ownerKeyId,_ownerKeyName]; + _temp_keys_names set [count _temp_keys_names,_ownerKeyName]; _temp_keys set [count _temp_keys,str(_ownerKeyId)]; }; } count (items player); + [_temp_keys,_temp_keys_names] \ No newline at end of file diff --git a/SQF/dayz_code/compile/fn_selfActions.sqf b/SQF/dayz_code/compile/fn_selfActions.sqf index 767a9d82c..588aa560e 100644 --- a/SQF/dayz_code/compile/fn_selfActions.sqf +++ b/SQF/dayz_code/compile/fn_selfActions.sqf @@ -120,10 +120,11 @@ if (_inVehicle) then { _temp_keys_names = _totalKeys select 1; _hasKey = _vehicleOwnerID in _temp_keys; _oldOwner = (_vehicleOwnerID == _uid); + _text = getText (configFile >> "CfgVehicles" >> (typeOf DZE_myVehicle) >> "displayName"); if (locked DZE_myVehicle) then { if (_hasKey || _oldOwner) then { - _unlock = DZE_myVehicle addAction [format[localize "STR_EPOCH_ACTIONS_UNLOCK",_text], "\z\addons\dayz_code\actions\unlock_veh.sqf",[DZE_myVehicle,(_temp_keys_names select (parseNumber _vehicleOwnerID))], 2, false, true]; + _unlock = DZE_myVehicle addAction [format[localize "STR_EPOCH_ACTIONS_UNLOCK",_text], "\z\addons\dayz_code\actions\unlock_veh.sqf",[DZE_myVehicle,(_temp_keys_names select (_temp_keys find _vehicleOwnerID))], 2, false, true]; s_player_lockUnlockInside set [count s_player_lockUnlockInside,_unlock]; s_player_lockUnlockInside_ctrl = 1; } else { @@ -692,7 +693,7 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur _oldOwner = (_characterID == _uid); if (locked _cursorTarget) then { if (_hasKey || _oldOwner) then { - _unlock = player addAction [format[localize "STR_EPOCH_ACTIONS_UNLOCK",_text], "\z\addons\dayz_code\actions\unlock_veh.sqf",[_cursorTarget,(_temp_keys_names select (parseNumber _characterID))], 2, true, true]; + _unlock = player addAction [format[localize "STR_EPOCH_ACTIONS_UNLOCK",_text], "\z\addons\dayz_code\actions\unlock_veh.sqf",[_cursorTarget,(_temp_keys_names select (_temp_keys find _characterID))], 2, true, true]; s_player_lockunlock set [count s_player_lockunlock,_unlock]; s_player_lockUnlock_crtl = 1; } else {