1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Little more. Doesn't crash on startup.

This commit is contained in:
Michał W. Urbańczyk 2010-11-18 22:22:51 +00:00
parent cdf7b2b4d9
commit b2a4d857b5
2 changed files with 30 additions and 3 deletions

View File

@ -349,8 +349,11 @@ void CBonusSystemNode::popBonuses(const CSelector &s)
{
//TODO
//prop
BonusList bl;
exportedBonuses.getBonuses(bl, s);
BOOST_FOREACH(Bonus *b, bl)
removeBonus(b);
bonuses.remove_if(s);
BOOST_FOREACH(CBonusSystemNode *child, children)
child->popBonuses(s);
}
@ -362,12 +365,20 @@ void CBonusSystemNode::addNewBonus(const Bonus &b)
void CBonusSystemNode::addNewBonus(Bonus *b)
{
exportedBonuses.push_back(b);
if(!b->propagator)
bonuses.push_back(b);
else
{
//prop
}
}
void CBonusSystemNode::removeBonus(Bonus *b)
{
//TODO
exportedBonuses -= b;
//TODO: prop
}
int NBonus::valOf(const CBonusSystemNode *obj, Bonus::BonusType type, int subtype /*= -1*/)
@ -435,6 +446,7 @@ Bonus::Bonus(ui8 Dur, ui8 Type, ui8 Src, si32 Val, ui32 ID, std::string Desc, si
valType = ADDITIVE_VALUE;
effectRange = NO_LIMIT;
limiter = NULL;
propagator = NULL;
boost::algorithm::trim(description);
}
@ -445,6 +457,7 @@ Bonus::Bonus(ui8 Dur, ui8 Type, ui8 Src, si32 Val, ui32 ID, si32 Subtype/*=-1*/,
turnsRemain = 0;
effectRange = NO_LIMIT;
limiter = NULL;
propagator = NULL;
}
Bonus::Bonus()
@ -455,6 +468,7 @@ Bonus::Bonus()
valType = ADDITIVE_VALUE;
effectRange = NO_LIMIT;
limiter = NULL;
propagator = NULL;
}
CSelector DLL_EXPORT operator&&(const CSelector &first, const CSelector &second)
@ -603,3 +617,8 @@ bool HasAnotherBonusLimiter::limit( const Bonus *b, const CBonusSystemNode &node
return !node.hasBonusOfType(static_cast<Bonus::BonusType>(type));
}
}
IPropagator::~IPropagator()
{
}

View File

@ -24,6 +24,7 @@ class CSpell;
struct Bonus;
class CBonusSystemNode;
class ILimiter;
class IPropagator;
typedef std::vector<std::pair<int,std::string> > TModDescr; //modifiers values and their descriptions
typedef std::set<CBonusSystemNode*> TNodes;
@ -229,6 +230,7 @@ struct DLL_EXPORT Bonus
ui8 effectRange; //if not NO_LIMIT, bonus will be ommitted by default
ILimiter *limiter;
IPropagator *propagator;
std::string description;
@ -331,6 +333,12 @@ public:
DLL_EXPORT std::ostream & operator<<(std::ostream &out, const BonusList &bonusList);
class DLL_EXPORT IPropagator
{
public:
virtual ~IPropagator();
};
class DLL_EXPORT ILimiter
{
public:
@ -346,7 +354,7 @@ class DLL_EXPORT CBonusSystemNode
{
public:
BonusList bonuses; //wielded bonuses (local and up-propagated here)
std::vector<Bonus*> exportedBonuses;
BonusList exportedBonuses;
std::vector<CBonusSystemNode *> parents, //parents -> we inherit bonuses from them, we may attach our bonuses to them
children;