From 5f00b9bbd5a5f8fe5cd8223a8c1c6b9b472ba8ba Mon Sep 17 00:00:00 2001 From: NoxMax <50133316+NoxMax@users.noreply.github.com> Date: Tue, 26 Aug 2025 10:25:19 -0600 Subject: [PATCH] Crash fix for RPG weights 0 (#1590) --- src/strategy/rpg/NewRpgBaseAction.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/strategy/rpg/NewRpgBaseAction.cpp b/src/strategy/rpg/NewRpgBaseAction.cpp index 5e71c5c5..9af540dc 100644 --- a/src/strategy/rpg/NewRpgBaseAction.cpp +++ b/src/strategy/rpg/NewRpgBaseAction.cpp @@ -1060,6 +1060,13 @@ bool NewRpgBaseAction::RandomChangeStatus(std::vector 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; -} \ No newline at end of file +}