mirror of
https://github.com/vcmi/vcmi.git
synced 2025-12-22 00:27:58 +02:00
CGHeroInstance::initArmy: don't use GS RNG. Get RNG through a ref
This function used by both server-side and gamestate so it's must use appropriate random source.
This commit is contained in:
@@ -302,7 +302,7 @@ void CGHeroInstance::initHero()
|
||||
setFormation(false);
|
||||
if (!stacksCount()) //standard army//initial army
|
||||
{
|
||||
initArmy();
|
||||
initArmy(cb->gameState()->getRandomGenerator());
|
||||
}
|
||||
assert(validTypes());
|
||||
|
||||
@@ -326,13 +326,13 @@ void CGHeroInstance::initHero()
|
||||
mana = manaLimit();
|
||||
}
|
||||
|
||||
void CGHeroInstance::initArmy(IArmyDescriptor *dst /*= nullptr*/)
|
||||
void CGHeroInstance::initArmy(CRandomGenerator & rand, IArmyDescriptor *dst /*= nullptr*/)
|
||||
{
|
||||
if(!dst)
|
||||
dst = this;
|
||||
|
||||
int howManyStacks = 0; //how many stacks will hero receives <1 - 3>
|
||||
int pom = cb->getRandomGenerator().nextInt(99);
|
||||
int pom = rand.nextInt(99);
|
||||
int warMachinesGiven = 0;
|
||||
|
||||
if(pom < 9)
|
||||
@@ -348,7 +348,7 @@ void CGHeroInstance::initArmy(IArmyDescriptor *dst /*= nullptr*/)
|
||||
{
|
||||
auto & stack = type->initialArmy[stackNo];
|
||||
|
||||
int count = cb->getRandomGenerator().nextInt(stack.minAmount, stack.maxAmount);
|
||||
int count = rand.nextInt(stack.minAmount, stack.maxAmount);
|
||||
|
||||
if(stack.creature >= CreatureID::CATAPULT &&
|
||||
stack.creature <= CreatureID::ARROW_TOWERS) //war machine
|
||||
|
||||
Reference in New Issue
Block a user