|
@@ -96,6 +96,13 @@ BonusList::BonusList(const BonusList &bonusList)
|
|
|
belongsToTree = false;
|
|
|
}
|
|
|
|
|
|
+BonusList::BonusList(BonusList&& other):
|
|
|
+ belongsToTree(false)
|
|
|
+{
|
|
|
+ std::swap(belongsToTree, other.belongsToTree);
|
|
|
+ std::swap(bonuses, other.bonuses);
|
|
|
+}
|
|
|
+
|
|
|
BonusList& BonusList::operator=(const BonusList &bonusList)
|
|
|
{
|
|
|
bonuses.resize(bonusList.size());
|
|
@@ -104,6 +111,12 @@ BonusList& BonusList::operator=(const BonusList &bonusList)
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
+void BonusList::changed()
|
|
|
+{
|
|
|
+ if(belongsToTree)
|
|
|
+ CBonusSystemNode::treeHasChanged();
|
|
|
+}
|
|
|
+
|
|
|
int BonusList::totalValue() const
|
|
|
{
|
|
|
int base = 0;
|
|
@@ -257,24 +270,19 @@ void BonusList::eliminateDuplicates()
|
|
|
void BonusList::push_back(Bonus* const &x)
|
|
|
{
|
|
|
bonuses.push_back(x);
|
|
|
-
|
|
|
- if (belongsToTree)
|
|
|
- CBonusSystemNode::treeHasChanged();
|
|
|
+ changed();
|
|
|
}
|
|
|
|
|
|
std::vector<Bonus*>::iterator BonusList::erase(const int position)
|
|
|
{
|
|
|
- if (belongsToTree)
|
|
|
- CBonusSystemNode::treeHasChanged();
|
|
|
+ changed();
|
|
|
return bonuses.erase(bonuses.begin() + position);
|
|
|
}
|
|
|
|
|
|
void BonusList::clear()
|
|
|
{
|
|
|
bonuses.clear();
|
|
|
-
|
|
|
- if (belongsToTree)
|
|
|
- CBonusSystemNode::treeHasChanged();
|
|
|
+ changed();
|
|
|
}
|
|
|
|
|
|
std::vector<BonusList*>::size_type BonusList::operator-=(Bonus* const &i)
|
|
@@ -283,26 +291,20 @@ std::vector<BonusList*>::size_type BonusList::operator-=(Bonus* const &i)
|
|
|
if(itr == bonuses.end())
|
|
|
return false;
|
|
|
bonuses.erase(itr);
|
|
|
-
|
|
|
- if (belongsToTree)
|
|
|
- CBonusSystemNode::treeHasChanged();
|
|
|
+ changed();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
void BonusList::resize(std::vector<Bonus*>::size_type sz, Bonus* c )
|
|
|
{
|
|
|
bonuses.resize(sz, c);
|
|
|
-
|
|
|
- if (belongsToTree)
|
|
|
- CBonusSystemNode::treeHasChanged();
|
|
|
+ changed();
|
|
|
}
|
|
|
|
|
|
void BonusList::insert(std::vector<Bonus*>::iterator position, std::vector<Bonus*>::size_type n, Bonus* const &x)
|
|
|
{
|
|
|
bonuses.insert(position, n, x);
|
|
|
-
|
|
|
- if (belongsToTree)
|
|
|
- CBonusSystemNode::treeHasChanged();
|
|
|
+ changed();
|
|
|
}
|
|
|
|
|
|
int IBonusBearer::valOfBonuses(Bonus::BonusType type, const CSelector &selector) const
|
|
@@ -708,6 +710,36 @@ CBonusSystemNode::CBonusSystemNode() : bonuses(true), exportedBonuses(true), nod
|
|
|
{
|
|
|
}
|
|
|
|
|
|
+CBonusSystemNode::CBonusSystemNode(CBonusSystemNode && other):
|
|
|
+ bonuses(std::move(other.bonuses)),
|
|
|
+ exportedBonuses(std::move(other.exportedBonuses)),
|
|
|
+ nodeType(other.nodeType),
|
|
|
+ description(other.description),
|
|
|
+ cachedLast(0)
|
|
|
+{
|
|
|
+ std::swap(parents, other.parents);
|
|
|
+ std::swap(children, other.children);
|
|
|
+
|
|
|
+ //fixing bonus tree without recalculation
|
|
|
+
|
|
|
+ for(CBonusSystemNode * n : parents)
|
|
|
+ {
|
|
|
+ n->children -= &other;
|
|
|
+ n->children.push_back(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ for(CBonusSystemNode * n : children)
|
|
|
+ {
|
|
|
+ n->parents -= &other;
|
|
|
+ n->parents.push_back(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ //cache ignored
|
|
|
+
|
|
|
+ //cachedBonuses
|
|
|
+ //cachedRequests
|
|
|
+}
|
|
|
+
|
|
|
CBonusSystemNode::~CBonusSystemNode()
|
|
|
{
|
|
|
detachFromAll();
|