mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
CGHeroInstance::nextPrimarySkill: don't use GS RNG directly
Code used from both GS and CGameHandler.
This commit is contained in:
parent
c8bcb14d34
commit
ca819b3cda
@ -1337,10 +1337,10 @@ std::vector<SecondarySkill> CGHeroInstance::getLevelUpProposedSecondarySkills()
|
||||
return skills;
|
||||
}
|
||||
|
||||
PrimarySkill::PrimarySkill CGHeroInstance::nextPrimarySkill() const
|
||||
PrimarySkill::PrimarySkill CGHeroInstance::nextPrimarySkill(CRandomGenerator & rand) const
|
||||
{
|
||||
assert(gainsLevel());
|
||||
int randomValue = cb->gameState()->getRandomGenerator().nextInt(99), pom = 0, primarySkill = 0;
|
||||
int randomValue = rand.nextInt(99), pom = 0, primarySkill = 0;
|
||||
const auto & skillChances = (level > 9) ? type->heroClass->primarySkillLowLevel : type->heroClass->primarySkillHighLevel;
|
||||
|
||||
for(; primarySkill < GameConstants::PRIMARY_SKILLS; ++primarySkill)
|
||||
@ -1456,7 +1456,7 @@ void CGHeroInstance::levelUpAutomatically()
|
||||
{
|
||||
while(gainsLevel())
|
||||
{
|
||||
const auto primarySkill = nextPrimarySkill();
|
||||
const auto primarySkill = nextPrimarySkill(cb->gameState()->getRandomGenerator());
|
||||
setPrimarySkill(primarySkill, 1, false);
|
||||
|
||||
auto proposedSecondarySkills = getLevelUpProposedSecondarySkills();
|
||||
|
@ -163,7 +163,7 @@ public:
|
||||
bool gainsLevel() const;
|
||||
|
||||
/// Returns the next primary skill on level up. Can only be called if hero can gain a level up.
|
||||
PrimarySkill::PrimarySkill nextPrimarySkill() const;
|
||||
PrimarySkill::PrimarySkill nextPrimarySkill(CRandomGenerator & rand) const;
|
||||
|
||||
/// Returns the next secondary skill randomly on level up. Can only be called if hero can gain a level up.
|
||||
boost::optional<SecondarySkill> nextSecondarySkill() const;
|
||||
|
@ -204,7 +204,7 @@ void CGameHandler::levelUpHero(const CGHeroInstance * hero)
|
||||
|
||||
// give primary skill
|
||||
logGlobal->trace("%s got level %d", hero->name, hero->level);
|
||||
auto primarySkill = hero->nextPrimarySkill();
|
||||
auto primarySkill = hero->nextPrimarySkill(getRandomGenerator());
|
||||
|
||||
SetPrimSkill sps;
|
||||
sps.id = hero->id;
|
||||
|
Loading…
Reference in New Issue
Block a user