mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Crash fix for RPG weights 0 (#1590)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user