From 75e1e730205df1c46a7cf8fc1e21890e94082f62 Mon Sep 17 00:00:00 2001 From: A Man Date: Wed, 12 Jan 2022 19:14:05 +0100 Subject: [PATCH] Update fn_getModelName to be much faster Made by @Victor-the-Cleaner --- SQF/dayz_code/compile/fn_getModelName.sqf | 35 +++++++++-------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/SQF/dayz_code/compile/fn_getModelName.sqf b/SQF/dayz_code/compile/fn_getModelName.sqf index a5de785d0..c8d265a50 100644 --- a/SQF/dayz_code/compile/fn_getModelName.sqf +++ b/SQF/dayz_code/compile/fn_getModelName.sqf @@ -1,25 +1,18 @@ -private ["_i","_k","_lenInfo","_objInfo","_objName"]; +local _model = ""; -_objInfo = toArray(str(_this)); -_lenInfo = count _objInfo - 1; -_objName = []; -_i = 0; -// determine where the object name starts -{ - if (58 == _objInfo select _i) exitWith {}; - _i = _i + 1; -} count _objInfo; +if (!isNull _this) then { -_i = _i + 2; // skip the ": " part + local _array = toArray (str _this); + local _begin = (_array find 58) + 2; // ": " + local _array2 = []; -for "_k" from _i to _lenInfo do { - _objName set [(count _objName), (_objInfo select _k)]; + for "_i" from _begin to ((count _array) - 1) do { + _array2 = _array2 + [_array select _i]; + }; + if (!local _this) then { + _array2 resize ((count _array2) - 7); // " REMOTE" + }; + + _model = toLower (toString _array2); }; - -if (!local _this) then { - //Strip " remote" from the end to return the same name for local and remote objects - _objName resize ((count _objName) - 7); -}; - -_objName = toLower(toString(_objName)); -_objName \ No newline at end of file +_model \ No newline at end of file