mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Removed bonus system loop in GameState.
Moved some game settings to global.h
This commit is contained in:
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 CREATURES_PER_TOWN = 7; //without upgrades
|
||||||
const int MAX_BUILDING_PER_TURN = 1;
|
const int MAX_BUILDING_PER_TURN = 1;
|
||||||
const int SPELL_LEVELS = 5;
|
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 WEEKLY_GROWTH = 10; //percent
|
||||||
const int AVAILABLE_HEROES_PER_PLAYER = 2;
|
const int AVAILABLE_HEROES_PER_PLAYER = 2;
|
||||||
|
const bool DWELLINGS_ACCUMULATE_CREATURES = true;
|
||||||
|
|
||||||
const int BFIELD_WIDTH = 17;
|
const int BFIELD_WIDTH = 17;
|
||||||
const int BFIELD_HEIGHT = 11;
|
const int BFIELD_HEIGHT = 11;
|
||||||
|
@@ -1495,7 +1495,7 @@ void CGHeroInstance::getParents(TCNodes &out, const CBonusSystemNode *root /*= N
|
|||||||
{
|
{
|
||||||
CArmedInstance::getParents(out, root);
|
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);
|
out.insert(visitedTown);
|
||||||
}
|
}
|
||||||
@@ -1749,7 +1749,7 @@ void CGDwelling::newTurn() const
|
|||||||
{
|
{
|
||||||
CCreature *cre = VLC->creh->creatures[creatures[i].second[0]];
|
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);
|
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;
|
sac.creatures[i].first += amount;
|
||||||
else
|
else
|
||||||
sac.creatures[i].first = amount;
|
sac.creatures[i].first = amount;
|
||||||
|
@@ -635,7 +635,7 @@ public:
|
|||||||
si32 gainedArtifact; //ID of artifact gained to hero, -1 if none
|
si32 gainedArtifact; //ID of artifact gained to hero, -1 if none
|
||||||
ui8 neverFlees; //if true, the troops will never flee
|
ui8 neverFlees; //if true, the troops will never flee
|
||||||
ui8 notGrowingTeam; //if true, number of units won't grow
|
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 fight(const CGHeroInstance *h) const;
|
||||||
void onHeroVisit(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
|
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
|
return; //no loops possible
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerState::getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *root /*= NULL*/) const
|
void PlayerState::getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *root /*= NULL*/) const
|
||||||
{
|
{
|
||||||
if (Selector::matchesType(selector, Bonus::CREATURE_GROWTH_PERCENT))
|
for (std::vector<CGHeroInstance *>::const_iterator it = heroes.begin(); it != heroes.end(); it++)
|
||||||
CBonusSystemNode::getBonuses(out, selector, this); //no recursive loops for PlayerState
|
{
|
||||||
/* //universal solution
|
if (*it != root)
|
||||||
if (root == this) // called directly
|
(*it)->getBonuses(out, selector, this);
|
||||||
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
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InfoAboutHero::InfoAboutHero()
|
InfoAboutHero::InfoAboutHero()
|
||||||
|
@@ -181,9 +181,14 @@ Bonus * CBonusSystemNode::getBonus(const CSelector &selector)
|
|||||||
if(ret)
|
if(ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
FOREACH_PARENT(p, this)
|
//FOREACH_PARENT(p, this)
|
||||||
if(ret = p->getBonus(selector))
|
TNodes parents;
|
||||||
|
getParents (parents, this);
|
||||||
|
BOOST_FOREACH (CBonusSystemNode *pname, parents)
|
||||||
|
{
|
||||||
|
if(ret = pname->getBonus(selector))
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user