diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index 680ada40f..d002bfce5 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -1517,7 +1517,7 @@ void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const } } for (std::vector::const_iterator i = bonusingBuildings.begin(); i != bonusingBuildings.end(); i++) - (*i)->onHeroVisit (h); + (*i)->onHeroVisit (h); //does not work cb->heroVisitCastle(id, h->id); } @@ -3810,7 +3810,7 @@ void CBank::initObj() } void CBank::reset(ui16 var1, ui16 var2) //prevents desync { - int chance = 0; + ui8 chance = 0; for (ui8 i = 0; i < VLC->objh->banksInfo[index].size(); i++) { if (var1 < (chance += VLC->objh->banksInfo[index][i].chance)) @@ -4020,9 +4020,12 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons iw.player = h->getOwner(); //grant resources for (int it = 0; it < bc->resources.size(); it++) - { - iw.components.push_back (Component (Component::RESOURCE, it, bc->resources[it], 0)); - cb->giveResource (h->getOwner(), it, bc->resources[it]); + { + if (bc->resources[it] != 0) + { + iw.components.push_back (Component (Component::RESOURCE, it, bc->resources[it], 0)); + cb->giveResource (h->getOwner(), it, bc->resources[it]); + } } //grant artifacts for (std::vector::const_iterator it = artifacts.begin(); it != artifacts.end(); it++) @@ -4031,6 +4034,7 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons iw.text.addReplacement (MetaString::ART_NAMES, *it); cb->giveHeroArtifact (*it, h->id ,-2); } + cb->showInfoDialog(&iw); //grant creatures CCreatureSet ourArmy; for (std::vector< std::pair >::const_iterator it = bc->creatures.begin(); it != bc->creatures.end(); it++) @@ -4038,8 +4042,8 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons int slot = ourArmy.getSlotFor (it->second); ourArmy.slots[slot] = *it; //assuming we're not going to add multiple stacks of same creature } - cb->giveCreatures (id, cb->getHero (cb->getSelectedHero()), &ourArmy); - cb->setObjProperty (id, 15, 0); //bc = NULL + cb->giveCreatures (id, cb->getHero (h->getOwner()), &ourArmy); + cb->setObjProperty (id, 15, 0); //bc = NULL } else cb->setObjProperty (id, 14, ran()); //reset diff --git a/hch/CObjectHandler.h b/hch/CObjectHandler.h index 437d90bcc..04ddecca4 100644 --- a/hch/CObjectHandler.h +++ b/hch/CObjectHandler.h @@ -849,8 +849,8 @@ public: } }; -class DLL_EXPORT CGOnceVisitable - : public CPlayersVisited //wagon, corpse, lean to, warriors tomb +class DLL_EXPORT CGOnceVisitable : public CPlayersVisited +///wagon, corpse, lean to, warriors tomb { public: ui8 artOrRes; //0 - nothing; 1 - artifact; 2 - resource @@ -948,8 +948,7 @@ struct BankConfig template void serialize(Handler &h, const int version) { - h & level & chance & upgradeChance & guards & combatValue & resources & creatures & artifacts - & value & rewardDifficulty & easiest; + h & level & chance & upgradeChance & guards & combatValue & resources & creatures & artifacts & value & rewardDifficulty & easiest; } }; diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 7868fb836..42c9a56d8 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -1486,6 +1486,8 @@ void CGameHandler::giveResource(int player, int which, int val) } void CGameHandler::giveCreatures (int objid, const CGHeroInstance * h, CCreatureSet *creatures) { + if (creatures->slots.size() <= 0) + return; CCreatureSet heroArmy = h->army; while(creatures) {