Skip to content

Commit

Permalink
-Crash fix: Random teleport with only very far distances.
Browse files Browse the repository at this point in the history
  • Loading branch information
mostlikely4r committed Feb 8, 2024
1 parent a1ea0f5 commit 01d44d3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions playerbot/TravelMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,14 @@ namespace ai
, W first_weight, W last_weight
, URBG&& g)
{
//Only shuffle if there is atleast 1 non-zero value.
W check_weight = first_weight;
while (check_weight != last_weight && !*check_weight)
++check_weight;

if (check_weight == last_weight)
return;

while (first != last && first_weight != last_weight)
{
std::discrete_distribution<int> dd(first_weight, last_weight);
Expand Down

0 comments on commit 01d44d3

Please sign in to comment.