1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-03 00:46:55 +02:00

Possible fix for #1348

This commit is contained in:
DjWarmonger
2013-07-22 09:48:25 +00:00
parent 3aec2daca1
commit 103a75e763
2 changed files with 9 additions and 7 deletions

View File

@ -3249,6 +3249,7 @@ void CGCreature::initObj()
amount = 1;
}
}
formation.randomFormation = rand();
temppower = stacks[SlotID(0)]->count * 1000;
refusedJoining = false;
@ -3279,7 +3280,7 @@ void CGCreature::setPropertyDer(ui8 what, ui32 val)
giveStackExp(val);
break;
case ObjProperty::MONSTER_RESTORE_TYPE:
restore.basicType = val;
formation.basicType = val;
break;
case ObjProperty::MONSTER_REFUSED_JOIN:
refusedJoining = val;
@ -3462,7 +3463,7 @@ void CGCreature::fight( const CGHeroInstance *h ) const
}
if (stacksCount > 1)
{
if (rand()%100 < 50) //upgrade
if (formation.randomFormation % 100 < 50) //upgrade
{
SlotID slotId = SlotID(stacks.size() / 2);
if(ui32 upgradesSize = getStack(slotId).type->upgrades.size())
@ -3513,7 +3514,7 @@ void CGCreature::battleFinished(const CGHeroInstance *hero, const BattleResult &
//merge stacks into one
TSlots::const_iterator i;
CCreature * cre = VLC->creh->creatures[restore.basicType];
CCreature * cre = VLC->creh->creatures[formation.basicType];
for (i = stacks.begin(); i != stacks.end(); i++)
{
if (cre->isMyUpgrade(i->second->type))

View File

@ -760,20 +760,21 @@ public:
void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
struct DLL_LINKAGE RestoredCreature // info about merging stacks after battle back into one
struct DLL_LINKAGE formationInfo // info about merging stacks after battle back into one
{
si32 basicType;
ui32 randomFormation; //random seed used to determine number of stacks and is there's upgraded stack
template <typename Handler> void serialize(Handler &h, const int version)
{
h & basicType;
h & basicType & randomFormation;
}
} restore;
} formation;
template <typename Handler> void serialize(Handler &h, const int version)
{
h & static_cast<CArmedInstance&>(*this);
h & identifier & character & message & resources & gainedArtifact & neverFlees & notGrowingTeam & temppower;
h & refusedJoining & restore;
h & refusedJoining & formation;
}
protected:
void setPropertyDer(ui8 what, ui32 val) override;