diff --git a/global.h b/global.h index 3f7f652e3..e75c8d6d1 100644 --- a/global.h +++ b/global.h @@ -102,9 +102,11 @@ const int NAMES_PER_TOWN=16; const int CREATURES_PER_TOWN = 7; //without upgrades const int MAX_BUILDING_PER_TURN = 1; const int SPELL_LEVELS = 5; -const int CREEP_SIZE = 4000; // neutral stacks won't grow beyon this number +//const int CREEP_SIZE = 4000; // neutral stacks won't grow beyon this number +const int CREEP_SIZE = 2000000000; const int WEEKLY_GROWTH = 10; //percent const int AVAILABLE_HEROES_PER_PLAYER = 2; +const bool DWELLINGS_ACCUMULATE_CREATURES = true; const int BFIELD_WIDTH = 17; const int BFIELD_HEIGHT = 11; diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index af4858b55..4bca7c761 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -1495,7 +1495,7 @@ void CGHeroInstance::getParents(TCNodes &out, const CBonusSystemNode *root /*= N { CArmedInstance::getParents(out, root); - if((root == this || contains(static_cast(root))) && visitedTown) + if((root == this || contains(static_cast(root))) && visitedTown && !dynamic_cast(root)) { out.insert(visitedTown); } @@ -1749,7 +1749,7 @@ void CGDwelling::newTurn() const { CCreature *cre = VLC->creh->creatures[creatures[i].second[0]]; TQuantity amount = cre->growth * (1 + cre->valOfBonuses(Bonus::CREATURE_GROWTH_PERCENT)/100) + cre->valOfBonuses(Bonus::CREATURE_GROWTH); - if(false /*accumulate creatures*/) + if (DWELLINGS_ACCUMULATE_CREATURES) sac.creatures[i].first += amount; else sac.creatures[i].first = amount; diff --git a/hch/CObjectHandler.h b/hch/CObjectHandler.h index 285040073..5220d2be6 100644 --- a/hch/CObjectHandler.h +++ b/hch/CObjectHandler.h @@ -635,7 +635,7 @@ public: si32 gainedArtifact; //ID of artifact gained to hero, -1 if none ui8 neverFlees; //if true, the troops will never flee ui8 notGrowingTeam; //if true, number of units won't grow - ui32 temppower; //used to handle fractional stack growth for tiny stacks + ui64 temppower; //used to handle fractional stack growth for tiny stacks void fight(const CGHeroInstance *h) const; void onHeroVisit(const CGHeroInstance * h) const; diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index e0a247cf5..e979421a1 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -4479,34 +4479,16 @@ PlayerState::PlayerState() void PlayerState::getParents(TCNodes &out, const CBonusSystemNode *root /*= NULL*/) const { - //an issue - this way we get quadratic complexity at the moment all objects are called - for (std::vector::const_iterator it = heroes.begin(); it != heroes.end(); it++) - { - out.insert(*it); - } - /* - for (std::vector::const_iterator it = towns.begin(); it != towns.end(); it++) - { - out.insert(*it); - } - */ - if (root != this) - { - out.erase(out.find(root)); //don't use yourself - root = this; //get all nodes ONLY once - see Armed Instance::getParents - } + return; //no loops possible } void PlayerState::getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *root /*= NULL*/) const { - if (Selector::matchesType(selector, Bonus::CREATURE_GROWTH_PERCENT)) - CBonusSystemNode::getBonuses(out, selector, this); //no recursive loops for PlayerState - /* //universal solution - if (root == this) // called directly - CBonusSystemNode::getBonuses(out, selector, this); //no recursive loops for PlayerState - else //unused yet - CBonusSystemNode::getBonuses(out, selector && Selector::effectRange(Bonus::GLOBAL), root); //only very specific bonuses can be propagated this way - */ + for (std::vector::const_iterator it = heroes.begin(); it != heroes.end(); it++) + { + if (*it != root) + (*it)->getBonuses(out, selector, this); + } } InfoAboutHero::InfoAboutHero() diff --git a/lib/HeroBonus.cpp b/lib/HeroBonus.cpp index 91e0b8650..3b1ac8772 100644 --- a/lib/HeroBonus.cpp +++ b/lib/HeroBonus.cpp @@ -181,9 +181,14 @@ Bonus * CBonusSystemNode::getBonus(const CSelector &selector) if(ret) return ret; - FOREACH_PARENT(p, this) - if(ret = p->getBonus(selector)) + //FOREACH_PARENT(p, this) + TNodes parents; + getParents (parents, this); + BOOST_FOREACH (CBonusSystemNode *pname, parents) + { + if(ret = pname->getBonus(selector)) return ret; + } return NULL; }