mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +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:
parent
2ba3b20928
commit
85f49bc968
@ -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
|
||||
|
@ -205,7 +205,7 @@ public:
|
||||
void putArtifact(ArtifactPosition pos, CArtifactInstance *art);
|
||||
void putInBackpack(CArtifactInstance *art);
|
||||
void initExp();
|
||||
void initArmy(IArmyDescriptor *dst = nullptr);
|
||||
void initArmy(CRandomGenerator & rand, IArmyDescriptor *dst = nullptr);
|
||||
//void giveArtifact (ui32 aid);
|
||||
void pushPrimSkill(PrimarySkill::PrimarySkill which, int val);
|
||||
ui8 maxlevelsToMagicSchool() const;
|
||||
|
@ -1518,7 +1518,7 @@ void CGameHandler::newTurn()
|
||||
if(CGHeroInstance *h = gs->hpool.pickHeroFor(j == 0, elem.first, getNativeTown(elem.first), pool, getRandomGenerator(), banned))
|
||||
{
|
||||
sah.hid[j] = h->subID;
|
||||
h->initArmy(&sah.army[j]);
|
||||
h->initArmy(getRandomGenerator(), &sah.army[j]);
|
||||
banned = h->type->heroClass;
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user