mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-13 11:40:38 +02:00
Removed bonus system loop in GameState.
Moved some game settings to global.h
This commit is contained in:
parent
fd7dffc8ef
commit
e481a4375b
4
global.h
4
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;
|
||||
|
@ -1495,7 +1495,7 @@ void CGHeroInstance::getParents(TCNodes &out, const CBonusSystemNode *root /*= N
|
||||
{
|
||||
CArmedInstance::getParents(out, root);
|
||||
|
||||
if((root == this || contains(static_cast<const CStackInstance *>(root))) && visitedTown)
|
||||
if((root == this || contains(static_cast<const CStackInstance *>(root))) && visitedTown && !dynamic_cast<const PlayerState*>(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;
|
||||
|
@ -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;
|
||||
|
@ -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<CGHeroInstance *>::const_iterator it = heroes.begin(); it != heroes.end(); it++)
|
||||
{
|
||||
out.insert(*it);
|
||||
}
|
||||
/*
|
||||
for (std::vector<CGTownInstance *>::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<CGHeroInstance *>::const_iterator it = heroes.begin(); it != heroes.end(); it++)
|
||||
{
|
||||
if (*it != root)
|
||||
(*it)->getBonuses(out, selector, this);
|
||||
}
|
||||
}
|
||||
|
||||
InfoAboutHero::InfoAboutHero()
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user