|
@@ -1016,7 +1016,7 @@ TConstBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, co
|
|
|
|
|
|
// If a bonus system request comes with a caching string then look up in the map if there are any
|
|
|
// pre-calculated bonus results. Limiters can't be cached so they have to be calculated.
|
|
|
- if (cachingStr != "")
|
|
|
+ if(!cachingStr.empty())
|
|
|
{
|
|
|
auto it = cachedRequests.find(cachingStr);
|
|
|
if(it != cachedRequests.end())
|
|
@@ -1032,7 +1032,7 @@ TConstBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, co
|
|
|
cachedBonuses.getBonuses(*ret, selector, limit);
|
|
|
|
|
|
// Save the results in the cache
|
|
|
- if(cachingStr != "")
|
|
|
+ if(!cachingStr.empty())
|
|
|
cachedRequests[cachingStr] = ret;
|
|
|
|
|
|
return ret;
|
|
@@ -1150,53 +1150,53 @@ CBonusSystemNode::~CBonusSystemNode()
|
|
|
if(children.size())
|
|
|
{
|
|
|
while(children.size())
|
|
|
- children.front()->detachFrom(this);
|
|
|
+ children.front()->detachFrom(*this);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void CBonusSystemNode::attachTo(CBonusSystemNode *parent)
|
|
|
+void CBonusSystemNode::attachTo(CBonusSystemNode & parent)
|
|
|
{
|
|
|
- assert(!vstd::contains(parents, parent));
|
|
|
- parents.push_back(parent);
|
|
|
+ assert(!vstd::contains(parents, &parent));
|
|
|
+ parents.push_back(&parent);
|
|
|
|
|
|
if(!isHypothetic())
|
|
|
{
|
|
|
- if(parent->actsAsBonusSourceOnly())
|
|
|
- parent->newRedDescendant(this);
|
|
|
+ if(parent.actsAsBonusSourceOnly())
|
|
|
+ parent.newRedDescendant(*this);
|
|
|
else
|
|
|
newRedDescendant(parent);
|
|
|
|
|
|
- parent->newChildAttached(this);
|
|
|
+ parent.newChildAttached(*this);
|
|
|
}
|
|
|
|
|
|
CBonusSystemNode::treeHasChanged();
|
|
|
}
|
|
|
|
|
|
-void CBonusSystemNode::detachFrom(CBonusSystemNode *parent)
|
|
|
+void CBonusSystemNode::detachFrom(CBonusSystemNode & parent)
|
|
|
{
|
|
|
- assert(vstd::contains(parents, parent));
|
|
|
+ assert(vstd::contains(parents, &parent));
|
|
|
|
|
|
if(!isHypothetic())
|
|
|
{
|
|
|
- if(parent->actsAsBonusSourceOnly())
|
|
|
- parent->removedRedDescendant(this);
|
|
|
+ if(parent.actsAsBonusSourceOnly())
|
|
|
+ parent.removedRedDescendant(*this);
|
|
|
else
|
|
|
removedRedDescendant(parent);
|
|
|
}
|
|
|
|
|
|
- if (vstd::contains(parents, parent))
|
|
|
+ if (vstd::contains(parents, &parent))
|
|
|
{
|
|
|
- parents -= parent;
|
|
|
+ parents -= &parent;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
logBonus->error("Error on Detach. Node %s (nodeType=%d) has not parent %s (nodeType=%d)"
|
|
|
- , nodeShortInfo(), nodeType, parent->nodeShortInfo(), parent->nodeType);
|
|
|
+ , nodeShortInfo(), nodeType, parent.nodeShortInfo(), parent.nodeType);
|
|
|
}
|
|
|
|
|
|
if(!isHypothetic())
|
|
|
{
|
|
|
- parent->childDetached(this);
|
|
|
+ parent.childDetached(*this);
|
|
|
}
|
|
|
CBonusSystemNode::treeHasChanged();
|
|
|
}
|
|
@@ -1304,27 +1304,27 @@ void CBonusSystemNode::unpropagateBonus(std::shared_ptr<Bonus> b)
|
|
|
child->unpropagateBonus(b);
|
|
|
}
|
|
|
|
|
|
-void CBonusSystemNode::newChildAttached(CBonusSystemNode *child)
|
|
|
+void CBonusSystemNode::newChildAttached(CBonusSystemNode & child)
|
|
|
{
|
|
|
- assert(!vstd::contains(children, child));
|
|
|
- children.push_back(child);
|
|
|
+ assert(!vstd::contains(children, &child));
|
|
|
+ children.push_back(&child);
|
|
|
}
|
|
|
|
|
|
-void CBonusSystemNode::childDetached(CBonusSystemNode *child)
|
|
|
+void CBonusSystemNode::childDetached(CBonusSystemNode & child)
|
|
|
{
|
|
|
- if(vstd::contains(children, child))
|
|
|
- children -= child;
|
|
|
+ if(vstd::contains(children, &child))
|
|
|
+ children -= &child;
|
|
|
else
|
|
|
{
|
|
|
logBonus->error("Error on Detach. Node %s (nodeType=%d) is not a child of %s (nodeType=%d)"
|
|
|
- , child->nodeShortInfo(), child->nodeType, nodeShortInfo(), nodeType);
|
|
|
+ , child.nodeShortInfo(), child.nodeType, nodeShortInfo(), nodeType);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void CBonusSystemNode::detachFromAll()
|
|
|
{
|
|
|
while(parents.size())
|
|
|
- detachFrom(parents.front());
|
|
|
+ detachFrom(*parents.front());
|
|
|
}
|
|
|
|
|
|
bool CBonusSystemNode::isIndependentNode() const
|
|
@@ -1393,12 +1393,12 @@ void CBonusSystemNode::getRedChildren(TNodes &out)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void CBonusSystemNode::newRedDescendant(CBonusSystemNode * descendant)
|
|
|
+void CBonusSystemNode::newRedDescendant(CBonusSystemNode & descendant)
|
|
|
{
|
|
|
for(auto b : exportedBonuses)
|
|
|
{
|
|
|
if(b->propagator)
|
|
|
- descendant->propagateBonus(b, *this);
|
|
|
+ descendant.propagateBonus(b, *this);
|
|
|
}
|
|
|
TNodes redParents;
|
|
|
getRedAncestors(redParents); //get all red parents recursively
|
|
@@ -1408,16 +1408,16 @@ void CBonusSystemNode::newRedDescendant(CBonusSystemNode * descendant)
|
|
|
for(auto b : parent->exportedBonuses)
|
|
|
{
|
|
|
if(b->propagator)
|
|
|
- descendant->propagateBonus(b, *this);
|
|
|
+ descendant.propagateBonus(b, *this);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void CBonusSystemNode::removedRedDescendant(CBonusSystemNode *descendant)
|
|
|
+void CBonusSystemNode::removedRedDescendant(CBonusSystemNode & descendant)
|
|
|
{
|
|
|
for(auto b : exportedBonuses)
|
|
|
if(b->propagator)
|
|
|
- descendant->unpropagateBonus(b);
|
|
|
+ descendant.unpropagateBonus(b);
|
|
|
|
|
|
TNodes redParents;
|
|
|
getRedAncestors(redParents); //get all red parents recursively
|
|
@@ -1426,7 +1426,7 @@ void CBonusSystemNode::removedRedDescendant(CBonusSystemNode *descendant)
|
|
|
{
|
|
|
for(auto b : parent->exportedBonuses)
|
|
|
if(b->propagator)
|
|
|
- descendant->unpropagateBonus(b);
|
|
|
+ descendant.unpropagateBonus(b);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1708,9 +1708,9 @@ JsonNode Bonus::toJsonNode() const
|
|
|
root["val"].Integer() = val;
|
|
|
if(valType != ADDITIVE_VALUE)
|
|
|
root["valueType"].String() = vstd::findKey(bonusValueMap, valType);
|
|
|
- if(stacking != "")
|
|
|
+ if(!stacking.empty())
|
|
|
root["stacking"].String() = stacking;
|
|
|
- if(description != "")
|
|
|
+ if(!description.empty())
|
|
|
root["description"].String() = description;
|
|
|
if(effectRange != NO_LIMIT)
|
|
|
root["effectRange"].String() = vstd::findKey(bonusLimitEffect, effectRange);
|