Skip to content

Commit

Permalink
Stop using the biased modulo random operation.
Browse files Browse the repository at this point in the history
Co-authored-by: KoBeWi <KoBeWi@users.noreply.github.com>
  • Loading branch information
RadiantUwU and KoBeWi committed Apr 21, 2024
1 parent 4a01602 commit b6b4342
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/variant/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ Variant Array::back() const {

Variant Array::pick_random() const {
ERR_FAIL_COND_V_MSG(_p->array.is_empty(), Variant(), "Can't take value from empty array.");
return operator[](Math::rand() % _p->array.size());
return operator[](Math::random(0, _p->array.size() - 1));
}

int Array::find(const Variant &p_value, int p_from) const {
Expand Down

0 comments on commit b6b4342

Please sign in to comment.