mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
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"],[<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<n "Test script finished. Code took 0.440002 seconds to run" ``` With fixed code: ```"[[["9379"],["Yellow Key (65d0)"]],false]" "Test script finished. Code took 0.000991821 seconds to run" ``` * Update fn_selfActions to support fixed epoch_tempKeys fix. Forgot this from my previous commit, this will select the right key now for displaying in the unlock_veh.sqf (I broke this with my previous commit) * Rework
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
private ["_temp_keys","_temp_keys_names","_key_colors","_ownerKeyId","_ownerKeyName"];
|
||||
_temp_keys = [];
|
||||
_temp_keys_names = [];
|
||||
// find available keys
|
||||
|
||||
_key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
|
||||
|
||||
{
|
||||
if (configName(inheritsFrom(configFile >> "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]
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user