Merge pull request #2134 from F507DMT/patch-27

private fix fn_buildWeightedArray.sqf
This commit is contained in:
A Man
2021-05-05 08:23:15 +02:00
committed by GitHub

View File

@@ -18,9 +18,9 @@ scriptName "Functions\arrays\fn_selectRandomWeighted.sqf";
[*] Algorithm is inefficient? [*] Algorithm is inefficient?
*/ */
private["_weighted"]; private["_weights","_weighted","_weight"];
_array = _this select 0; // _array = _this select 0;
_weights = _this select 1; _weights = _this select 1;
/* /*
@@ -34,7 +34,6 @@ if ((count _array) > (count _weights)) exitWith {debugLog "Log: [selectRandomWei
_weighted = []; _weighted = [];
for "_i" from 0 to ((count _weights) - 1) do for "_i" from 0 to ((count _weights) - 1) do
{ {
private ["_weight"];
_weight = _weights select _i; _weight = _weights select _i;
//Ensure the weight is a Number. //Ensure the weight is a Number.
@@ -53,4 +52,4 @@ for "_i" from 0 to ((count _weights) - 1) do
_weighted set [(count _weighted), _i]; _weighted set [(count _weighted), _i];
}; };
}; };
_weighted _weighted