From 30a0237fb88f1869d3798f7cfa9b7fc22df1ddb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Sat, 28 Sep 2013 12:31:06 +0000 Subject: [PATCH] Merged the 092c-compat branch. --- AI/VCAI/VCAI.cpp | 8 ++++++++ lib/CCreatureSet.cpp | 6 ++++-- lib/CObjectHandler.cpp | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index 6bfe0bbf3..eeafdb98d 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -1020,6 +1020,14 @@ void VCAI::makeTurnInternal() auto reservedHeroesCopy = reservedHeroesMap; //work on copy => the map may be changed while iterating (eg because hero died when attempting a goal) for (auto hero : reservedHeroesCopy) { + if(reservedHeroesMap.count(hero.first)) + continue; //hero might have been removed while we were in this loop + if(!hero.first.validAndSet()) + { + logAi->errorStream() << "Hero " << hero.first.name << " present on reserved map. Shouldn't be. "; + continue; + } + cb->setSelection(hero.first.get()); boost::sort (hero.second, isCloser); for (auto obj : hero.second) diff --git a/lib/CCreatureSet.cpp b/lib/CCreatureSet.cpp index 354322907..ec3a28b09 100644 --- a/lib/CCreatureSet.cpp +++ b/lib/CCreatureSet.cpp @@ -420,11 +420,13 @@ bool CCreatureSet::canBeMergedWith(const CCreatureSet &cs, bool allowMergingStac else { CCreatureSet cres; + SlotID j; //get types of creatures that need their own slot for(auto & elem : cs.stacks) - cres.addToSlot(elem.first, elem.second->type->idNumber, 1, true); - SlotID j; + if ((j = cres.getSlotFor(elem.second->type)).validSlot()) + cres.addToSlot(j, elem.second->type->idNumber, 1, true); //merge if possible + //cres.addToSlot(elem.first, elem.second->type->idNumber, 1, true); for(auto & elem : stacks) { if ((j = cres.getSlotFor(elem.second->type)).validSlot()) diff --git a/lib/CObjectHandler.cpp b/lib/CObjectHandler.cpp index af518130f..890c0bb96 100644 --- a/lib/CObjectHandler.cpp +++ b/lib/CObjectHandler.cpp @@ -1167,7 +1167,7 @@ void CGHeroInstance::initObj() hs->addNewBonus(bonus); break; case 11://starting skill with mastery (Adrienne) - cb->changeSecSkill(this, SecondarySkill(spec.val), spec.additionalinfo); //simply give it and forget + setSecSkillLevel(SecondarySkill(spec.val), spec.additionalinfo, true); break; case 12://army speed bonus->type = Bonus::STACKS_SPEED;