diff --git a/SQF/dayz_code/compile/BIS_fnc/fn_vectorAdd.sqf b/SQF/dayz_code/compile/BIS_fnc/fn_vectorAdd.sqf index 33429912b..51360b0cc 100644 --- a/SQF/dayz_code/compile/BIS_fnc/fn_vectorAdd.sqf +++ b/SQF/dayz_code/compile/BIS_fnc/fn_vectorAdd.sqf @@ -14,22 +14,31 @@ Returns a vector that is the sum of and . ************************************************************/ -private["_p1","_p2","_return","_i"]; +private["_p1","_p2","_return"]; _p1 = _this select 0; _p2 = _this select 1; if ((count _p1) != (count _p2)) then {textLogFormat ["BIS_FNC Error: vectors not of same size"]}; +_c = (count _p1) max (count _p2); + _return = []; -_i = 0; -{ - if(_i <= (count(_p2) - 1)) then { - _return = _return + [_x + (_p2 select _i)]; - } else { - _return = _return + [_x]; - }; - _i = _i + 1; -} forEach _p1; + +for "_i" from 0 to (_c - 1) do { + if(_i < (count _p1)) then { + if(_i < (count _p2)) then { + _return = _return + [(_p1 select _i) + (_p2 select _i)]; + } else { + _return = _return + [(_p1 select _i)]; + }; + } else { + if(_i < (count _p1)) then { + _return = _return + [(_p2 select _i) + (_p1 select _i)]; + } else { + _return = _return + [(_p2 select _i)]; + }; + }; +}; _return \ No newline at end of file