Crash fix for RPG weights 0 (#1590)

This commit is contained in:
NoxMax
2025-08-26 10:25:19 -06:00
committed by GitHub
parent 2dad8bf01d
commit 5f00b9bbd5

View File

@@ -1060,6 +1060,13 @@ bool NewRpgBaseAction::RandomChangeStatus(std::vector<NewRpgStatus> candidateSta
probSum += sPlayerbotAIConfig->RpgStatusProbWeight[status];
}
}
// Safety check. Default to "rest" if all RPG weights = 0
if (availableStatus.empty() || probSum == 0)
{
botAI->rpgInfo.ChangeToRest();
bot->SetStandState(UNIT_STAND_STATE_SIT);
return true;
}
uint32 rand = urand(1, probSum);
uint32 accumulate = 0;
NewRpgStatus chosenStatus = RPG_STATUS_END;
@@ -1218,4 +1225,4 @@ bool NewRpgBaseAction::CheckRpgStatusAvailable(NewRpgStatus status)
return false;
}
return false;
}
}