mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-20 10:00:02 +01:00
Crash fix for RPG weights 0 (#1590)
This commit is contained in:
parent
2dad8bf01d
commit
5f00b9bbd5
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user