|
@@ -118,34 +118,28 @@ const std::set<std::string> deprecatedBonusSet = {
|
|
|
};
|
|
|
|
|
|
///CBonusProxy
|
|
|
-CBonusProxy::CBonusProxy(const IBonusBearer * Target, CSelector Selector)
|
|
|
- : bonusListCachedLast(0),
|
|
|
+CBonusProxy::CBonusProxy(const IBonusBearer * Target, CSelector Selector):
|
|
|
+ bonusListCachedLast(0),
|
|
|
target(Target),
|
|
|
- selector(Selector),
|
|
|
- bonusList(),
|
|
|
- currentBonusListIndex(0),
|
|
|
- swapGuard()
|
|
|
+ selector(std::move(Selector)),
|
|
|
+ currentBonusListIndex(0)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
-CBonusProxy::CBonusProxy(const CBonusProxy & other)
|
|
|
- : bonusListCachedLast(other.bonusListCachedLast),
|
|
|
+CBonusProxy::CBonusProxy(const CBonusProxy & other):
|
|
|
+ bonusListCachedLast(other.bonusListCachedLast),
|
|
|
target(other.target),
|
|
|
selector(other.selector),
|
|
|
- currentBonusListIndex(other.currentBonusListIndex),
|
|
|
- swapGuard()
|
|
|
+ currentBonusListIndex(other.currentBonusListIndex)
|
|
|
{
|
|
|
bonusList[currentBonusListIndex] = other.bonusList[currentBonusListIndex];
|
|
|
}
|
|
|
|
|
|
-CBonusProxy::CBonusProxy(CBonusProxy && other)
|
|
|
- : bonusListCachedLast(0),
|
|
|
+CBonusProxy::CBonusProxy(CBonusProxy && other) noexcept:
|
|
|
+ bonusListCachedLast(0),
|
|
|
target(other.target),
|
|
|
- selector(),
|
|
|
- bonusList(),
|
|
|
- currentBonusListIndex(0),
|
|
|
- swapGuard()
|
|
|
+ currentBonusListIndex(0)
|
|
|
{
|
|
|
std::swap(bonusListCachedLast, other.bonusListCachedLast);
|
|
|
std::swap(selector, other.selector);
|
|
@@ -164,7 +158,7 @@ CBonusProxy & CBonusProxy::operator=(const CBonusProxy & other)
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
-CBonusProxy & CBonusProxy::operator=(CBonusProxy && other)
|
|
|
+CBonusProxy & CBonusProxy::operator=(CBonusProxy && other) noexcept
|
|
|
{
|
|
|
std::swap(bonusListCachedLast, other.bonusListCachedLast);
|
|
|
std::swap(selector, other.selector);
|
|
@@ -180,7 +174,7 @@ void CBonusProxy::swapBonusList(TConstBonusListPtr other) const
|
|
|
// Because such use of shared ptr is not thread safe
|
|
|
// So to avoid this we change the second offline instance and swap active index
|
|
|
auto newCurrent = 1 - currentBonusListIndex;
|
|
|
- bonusList[newCurrent] = other;
|
|
|
+ bonusList[newCurrent] = std::move(other);
|
|
|
currentBonusListIndex = newCurrent;
|
|
|
}
|
|
|
|
|
@@ -212,15 +206,13 @@ const BonusList * CBonusProxy::operator->() const
|
|
|
return getBonusList().get();
|
|
|
}
|
|
|
|
|
|
-CTotalsProxy::CTotalsProxy(const IBonusBearer * Target, CSelector Selector, int InitialValue)
|
|
|
- : CBonusProxy(Target, Selector),
|
|
|
+CTotalsProxy::CTotalsProxy(const IBonusBearer * Target, CSelector Selector, int InitialValue):
|
|
|
+ CBonusProxy(Target, std::move(Selector)),
|
|
|
initialValue(InitialValue),
|
|
|
meleeCachedLast(0),
|
|
|
meleeValue(0),
|
|
|
rangedCachedLast(0),
|
|
|
- rangedValue(0),
|
|
|
- value(0),
|
|
|
- valueCachedLast(0)
|
|
|
+ rangedValue(0)
|
|
|
{
|
|
|
}
|
|
|
|
|
@@ -234,20 +226,6 @@ CTotalsProxy::CTotalsProxy(const CTotalsProxy & other)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-CTotalsProxy & CTotalsProxy::operator=(const CTotalsProxy & other)
|
|
|
-{
|
|
|
- CBonusProxy::operator=(other);
|
|
|
- initialValue = other.initialValue;
|
|
|
- meleeCachedLast = other.meleeCachedLast;
|
|
|
- meleeValue = other.meleeValue;
|
|
|
- rangedCachedLast = other.rangedCachedLast;
|
|
|
- rangedValue = other.rangedValue;
|
|
|
- value = other.value;
|
|
|
- valueCachedLast = other.valueCachedLast;
|
|
|
-
|
|
|
- return *this;
|
|
|
-}
|
|
|
-
|
|
|
int CTotalsProxy::getValue() const
|
|
|
{
|
|
|
const auto treeVersion = target->getTreeVersion();
|
|
@@ -308,21 +286,16 @@ int CTotalsProxy::getRangedValue() const
|
|
|
}
|
|
|
|
|
|
///CCheckProxy
|
|
|
-CCheckProxy::CCheckProxy(const IBonusBearer * Target, CSelector Selector)
|
|
|
- : target(Target),
|
|
|
- selector(Selector),
|
|
|
+CCheckProxy::CCheckProxy(const IBonusBearer * Target, CSelector Selector):
|
|
|
+ target(Target),
|
|
|
+ selector(std::move(Selector)),
|
|
|
cachedLast(0),
|
|
|
hasBonus(false)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-CCheckProxy::CCheckProxy(const CCheckProxy & other)
|
|
|
- : target(other.target),
|
|
|
- selector(other.selector),
|
|
|
- cachedLast(other.cachedLast),
|
|
|
- hasBonus(other.hasBonus)
|
|
|
-{
|
|
|
-}
|
|
|
+//This constructor should be placed here to avoid side effects
|
|
|
+CCheckProxy::CCheckProxy(const CCheckProxy & other) = default;
|
|
|
|
|
|
bool CCheckProxy::getHasBonus() const
|
|
|
{
|
|
@@ -337,9 +310,8 @@ bool CCheckProxy::getHasBonus() const
|
|
|
return hasBonus;
|
|
|
}
|
|
|
|
|
|
-CAddInfo::CAddInfo()
|
|
|
-{
|
|
|
-}
|
|
|
+//This constructor should be placed here to avoid side effects
|
|
|
+CAddInfo::CAddInfo() = default;
|
|
|
|
|
|
CAddInfo::CAddInfo(si32 value)
|
|
|
{
|
|
@@ -405,15 +377,13 @@ BonusList::BonusList(bool BelongsToTree) : belongsToTree(BelongsToTree)
|
|
|
|
|
|
}
|
|
|
|
|
|
-BonusList::BonusList(const BonusList &bonusList)
|
|
|
+BonusList::BonusList(const BonusList & bonusList): belongsToTree(false)
|
|
|
{
|
|
|
bonuses.resize(bonusList.size());
|
|
|
std::copy(bonusList.begin(), bonusList.end(), bonuses.begin());
|
|
|
- belongsToTree = false;
|
|
|
}
|
|
|
|
|
|
-BonusList::BonusList(BonusList&& other):
|
|
|
- belongsToTree(false)
|
|
|
+BonusList::BonusList(BonusList && other) noexcept: belongsToTree(false)
|
|
|
{
|
|
|
std::swap(belongsToTree, other.belongsToTree);
|
|
|
std::swap(bonuses, other.bonuses);
|
|
@@ -427,7 +397,7 @@ BonusList& BonusList::operator=(const BonusList &bonusList)
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
-void BonusList::changed()
|
|
|
+void BonusList::changed() const
|
|
|
{
|
|
|
if(belongsToTree)
|
|
|
CBonusSystemNode::treeHasChanged();
|
|
@@ -435,7 +405,7 @@ void BonusList::changed()
|
|
|
|
|
|
void BonusList::stackBonuses()
|
|
|
{
|
|
|
- boost::sort(bonuses, [](std::shared_ptr<Bonus> b1, std::shared_ptr<Bonus> b2) -> bool
|
|
|
+ boost::sort(bonuses, [](const std::shared_ptr<Bonus> & b1, const std::shared_ptr<Bonus> & b2) -> bool
|
|
|
{
|
|
|
if(b1 == b2)
|
|
|
return false;
|
|
@@ -451,7 +421,7 @@ void BonusList::stackBonuses()
|
|
|
size_t next = 1;
|
|
|
while(next < bonuses.size())
|
|
|
{
|
|
|
- bool remove;
|
|
|
+ bool remove = false;
|
|
|
std::shared_ptr<Bonus> last = bonuses[next-1];
|
|
|
std::shared_ptr<Bonus> current = bonuses[next];
|
|
|
|
|
@@ -491,7 +461,7 @@ int BonusList::totalValue() const
|
|
|
bool hasIndepMax = false;
|
|
|
bool hasIndepMin = false;
|
|
|
|
|
|
- for(std::shared_ptr<Bonus> b : bonuses)
|
|
|
+ for(const std::shared_ptr<Bonus> & b : bonuses)
|
|
|
{
|
|
|
switch(b->valType)
|
|
|
{
|
|
@@ -541,10 +511,10 @@ int BonusList::totalValue() const
|
|
|
if(hasIndepMin && hasIndepMax)
|
|
|
assert(any.indepMin < any.indepMax);
|
|
|
|
|
|
- const int notIndepBonuses = (int)std::count_if(bonuses.cbegin(), bonuses.cend(), [](const std::shared_ptr<Bonus>& b)
|
|
|
+ const int notIndepBonuses = static_cast<int>(std::count_if(bonuses.cbegin(), bonuses.cend(), [](const std::shared_ptr<Bonus>& b)
|
|
|
{
|
|
|
return b->valType != Bonus::INDEPENDENT_MAX && b->valType != Bonus::INDEPENDENT_MIN;
|
|
|
- });
|
|
|
+ }));
|
|
|
|
|
|
if (hasIndepMax)
|
|
|
{
|
|
@@ -576,7 +546,7 @@ std::shared_ptr<Bonus> BonusList::getFirst(const CSelector &select)
|
|
|
|
|
|
std::shared_ptr<const Bonus> BonusList::getFirst(const CSelector &selector) const
|
|
|
{
|
|
|
- for (auto & b : bonuses)
|
|
|
+ for(const auto & b : bonuses)
|
|
|
{
|
|
|
if(selector(b.get()))
|
|
|
return b;
|
|
@@ -587,7 +557,7 @@ std::shared_ptr<const Bonus> BonusList::getFirst(const CSelector &selector) cons
|
|
|
void BonusList::getBonuses(BonusList & out, const CSelector &selector, const CSelector &limit) const
|
|
|
{
|
|
|
out.reserve(bonuses.size());
|
|
|
- for (auto & b : bonuses)
|
|
|
+ for(const auto & b : bonuses)
|
|
|
{
|
|
|
//add matching bonuses that matches limit predicate or have NO_LIMIT if no given predicate
|
|
|
auto noFightLimit = b->effectRange == Bonus::NO_LIMIT;
|
|
@@ -598,7 +568,7 @@ void BonusList::getBonuses(BonusList & out, const CSelector &selector, const CSe
|
|
|
|
|
|
void BonusList::getAllBonuses(BonusList &out) const
|
|
|
{
|
|
|
- for(auto & b : bonuses)
|
|
|
+ for(const auto & b : bonuses)
|
|
|
out.push_back(b);
|
|
|
}
|
|
|
|
|
@@ -613,12 +583,12 @@ int BonusList::valOfBonuses(const CSelector &select) const
|
|
|
JsonNode BonusList::toJsonNode() const
|
|
|
{
|
|
|
JsonNode node(JsonNode::JsonType::DATA_VECTOR);
|
|
|
- for(std::shared_ptr<Bonus> b : bonuses)
|
|
|
+ for(const std::shared_ptr<Bonus> & b : bonuses)
|
|
|
node.Vector().push_back(b->toJsonNode());
|
|
|
return node;
|
|
|
}
|
|
|
|
|
|
-void BonusList::push_back(std::shared_ptr<Bonus> x)
|
|
|
+void BonusList::push_back(const std::shared_ptr<Bonus> & x)
|
|
|
{
|
|
|
bonuses.push_back(x);
|
|
|
changed();
|
|
@@ -636,7 +606,7 @@ void BonusList::clear()
|
|
|
changed();
|
|
|
}
|
|
|
|
|
|
-std::vector<BonusList*>::size_type BonusList::operator-=(std::shared_ptr<Bonus> const &i)
|
|
|
+std::vector<BonusList *>::size_type BonusList::operator-=(const std::shared_ptr<Bonus> & i)
|
|
|
{
|
|
|
auto itr = std::find(bonuses.begin(), bonuses.end(), i);
|
|
|
if(itr == bonuses.end())
|
|
@@ -646,7 +616,7 @@ std::vector<BonusList*>::size_type BonusList::operator-=(std::shared_ptr<Bonus>
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-void BonusList::resize(BonusList::TInternalContainer::size_type sz, std::shared_ptr<Bonus> c )
|
|
|
+void BonusList::resize(BonusList::TInternalContainer::size_type sz, const std::shared_ptr<Bonus> & c)
|
|
|
{
|
|
|
bonuses.resize(sz, c);
|
|
|
changed();
|
|
@@ -657,7 +627,7 @@ void BonusList::reserve(TInternalContainer::size_type sz)
|
|
|
bonuses.reserve(sz);
|
|
|
}
|
|
|
|
|
|
-void BonusList::insert(BonusList::TInternalContainer::iterator position, BonusList::TInternalContainer::size_type n, std::shared_ptr<Bonus> const &x)
|
|
|
+void BonusList::insert(BonusList::TInternalContainer::iterator position, BonusList::TInternalContainer::size_type n, const std::shared_ptr<Bonus> & x)
|
|
|
{
|
|
|
bonuses.insert(position, n, x);
|
|
|
changed();
|
|
@@ -687,7 +657,7 @@ int IBonusBearer::valOfBonuses(Bonus::BonusType type, const CSelector &selector)
|
|
|
int IBonusBearer::valOfBonuses(Bonus::BonusType type, int subtype) const
|
|
|
{
|
|
|
//This part is performance-critical
|
|
|
- std::string cachingStr = "type_" + std::to_string(int(type)) + "_" + std::to_string(subtype);
|
|
|
+ std::string cachingStr = "type_" + std::to_string(static_cast<int>(type)) + "_" + std::to_string(subtype);
|
|
|
|
|
|
CSelector s = Selector::type()(type);
|
|
|
if(subtype != -1)
|
|
@@ -716,7 +686,7 @@ bool IBonusBearer::hasBonus(const CSelector &selector, const CSelector &limit, c
|
|
|
bool IBonusBearer::hasBonusOfType(Bonus::BonusType type, int subtype) const
|
|
|
{
|
|
|
//This part is performance-ciritcal
|
|
|
- std::string cachingStr = "type_" + std::to_string(int(type)) + "_" + std::to_string(subtype);
|
|
|
+ std::string cachingStr = "type_" + std::to_string(static_cast<int>(type)) + "_" + std::to_string(subtype);
|
|
|
|
|
|
CSelector s = Selector::type()(type);
|
|
|
if(subtype != -1)
|
|
@@ -738,7 +708,7 @@ TConstBonusListPtr IBonusBearer::getBonuses(const CSelector &selector, const CSe
|
|
|
bool IBonusBearer::hasBonusFrom(Bonus::BonusSource source, ui32 sourceID) const
|
|
|
{
|
|
|
boost::format fmt("source_%did_%d");
|
|
|
- fmt % (int)source % sourceID;
|
|
|
+ fmt % static_cast<int>(source) % sourceID;
|
|
|
|
|
|
return hasBonus(Selector::source(source,sourceID), fmt.str());
|
|
|
}
|
|
@@ -888,7 +858,7 @@ const CStack * retrieveStackBattle(const CBonusSystemNode * node)
|
|
|
switch(node->getNodeType())
|
|
|
{
|
|
|
case CBonusSystemNode::STACK_BATTLE:
|
|
|
- return static_cast<const CStack*>(node);
|
|
|
+ return dynamic_cast<const CStack *>(node);
|
|
|
default:
|
|
|
return nullptr;
|
|
|
}
|
|
@@ -899,9 +869,9 @@ const CStackInstance * retrieveStackInstance(const CBonusSystemNode * node)
|
|
|
switch(node->getNodeType())
|
|
|
{
|
|
|
case CBonusSystemNode::STACK_INSTANCE:
|
|
|
- return (static_cast<const CStackInstance *>(node));
|
|
|
+ return (dynamic_cast<const CStackInstance *>(node));
|
|
|
case CBonusSystemNode::STACK_BATTLE:
|
|
|
- return (static_cast<const CStack*>(node))->base;
|
|
|
+ return (dynamic_cast<const CStack *>(node))->base;
|
|
|
default:
|
|
|
return nullptr;
|
|
|
}
|
|
@@ -935,7 +905,7 @@ std::shared_ptr<const Bonus> CBonusSystemNode::getBonusLocalFirst(const CSelecto
|
|
|
|
|
|
void CBonusSystemNode::getParents(TCNodes & out) const /*retrieves list of parent nodes (nodes to inherit bonuses from) */
|
|
|
{
|
|
|
- for (auto & elem : parents)
|
|
|
+ for(const auto & elem : parents)
|
|
|
{
|
|
|
const CBonusSystemNode *parent = elem;
|
|
|
out.insert(parent);
|
|
@@ -953,7 +923,7 @@ void CBonusSystemNode::getParents(TNodes &out)
|
|
|
|
|
|
void CBonusSystemNode::getAllParents(TCNodes & out) const //retrieves list of parent nodes (nodes to inherit bonuses from)
|
|
|
{
|
|
|
- for(auto parent : parents)
|
|
|
+ for(auto * parent : parents)
|
|
|
{
|
|
|
out.insert(parent);
|
|
|
parent->getAllParents(out);
|
|
@@ -968,7 +938,7 @@ void CBonusSystemNode::getAllBonusesRec(BonusList &out, const CSelector & select
|
|
|
TCNodes lparents;
|
|
|
getAllParents(lparents);
|
|
|
|
|
|
- if (lparents.size())
|
|
|
+ if(!lparents.empty())
|
|
|
{
|
|
|
//estimate on how many bonuses are missing yet - must be positive
|
|
|
beforeUpdate.reserve(std::max(out.capacity() - out.size(), bonuses.size()));
|
|
@@ -978,7 +948,7 @@ void CBonusSystemNode::getAllBonusesRec(BonusList &out, const CSelector & select
|
|
|
beforeUpdate.reserve(bonuses.size()); //at most all local bonuses
|
|
|
}
|
|
|
|
|
|
- for (auto parent : lparents)
|
|
|
+ for(const auto * parent : lparents)
|
|
|
{
|
|
|
parent->getAllBonusesRec(beforeUpdate, selector);
|
|
|
}
|
|
@@ -993,7 +963,7 @@ void CBonusSystemNode::getAllBonusesRec(BonusList &out, const CSelector & select
|
|
|
|
|
|
//do not add bonus with updater
|
|
|
bool bonusExists = false;
|
|
|
- for (auto const & bonus : out )
|
|
|
+ for(const auto & bonus : out)
|
|
|
{
|
|
|
if (bonus == updated)
|
|
|
bonusExists = true;
|
|
@@ -1065,7 +1035,8 @@ TConstBonusListPtr CBonusSystemNode::getAllBonusesWithoutCaching(const CSelector
|
|
|
auto ret = std::make_shared<BonusList>();
|
|
|
|
|
|
// Get bonus results without caching enabled.
|
|
|
- BonusList beforeLimiting, afterLimiting;
|
|
|
+ BonusList beforeLimiting;
|
|
|
+ BonusList afterLimiting;
|
|
|
getAllBonusesRec(beforeLimiting, selector);
|
|
|
|
|
|
if(!root || root == this)
|
|
@@ -1076,15 +1047,16 @@ TConstBonusListPtr CBonusSystemNode::getAllBonusesWithoutCaching(const CSelector
|
|
|
{
|
|
|
//We want to limit our query against an external node. We get all its bonuses,
|
|
|
// add the ones we're considering and see if they're cut out by limiters
|
|
|
- BonusList rootBonuses, limitedRootBonuses;
|
|
|
+ BonusList rootBonuses;
|
|
|
+ BonusList limitedRootBonuses;
|
|
|
getAllBonusesRec(rootBonuses, selector);
|
|
|
|
|
|
- for(auto b : beforeLimiting)
|
|
|
+ for(const auto & b : beforeLimiting)
|
|
|
rootBonuses.push_back(b);
|
|
|
|
|
|
root->limitBonuses(rootBonuses, limitedRootBonuses);
|
|
|
|
|
|
- for(auto b : beforeLimiting)
|
|
|
+ for(const auto & b : beforeLimiting)
|
|
|
if(vstd::contains(limitedRootBonuses, b))
|
|
|
afterLimiting.push_back(b);
|
|
|
|
|
@@ -1094,7 +1066,7 @@ TConstBonusListPtr CBonusSystemNode::getAllBonusesWithoutCaching(const CSelector
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-std::shared_ptr<Bonus> CBonusSystemNode::getUpdatedBonus(const std::shared_ptr<Bonus> & b, const TUpdaterPtr updater) const
|
|
|
+std::shared_ptr<Bonus> CBonusSystemNode::getUpdatedBonus(const std::shared_ptr<Bonus> & b, const TUpdaterPtr & updater) const
|
|
|
{
|
|
|
assert(updater);
|
|
|
return updater->createUpdatedBonus(b, * this);
|
|
@@ -1105,33 +1077,30 @@ CBonusSystemNode::CBonusSystemNode()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-CBonusSystemNode::CBonusSystemNode(bool isHypotetic)
|
|
|
- : bonuses(true),
|
|
|
+CBonusSystemNode::CBonusSystemNode(bool isHypotetic):
|
|
|
+ bonuses(true),
|
|
|
exportedBonuses(true),
|
|
|
nodeType(UNKNOWN),
|
|
|
cachedLast(0),
|
|
|
- sync(),
|
|
|
isHypotheticNode(isHypotetic)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-CBonusSystemNode::CBonusSystemNode(ENodeTypes NodeType)
|
|
|
- : bonuses(true),
|
|
|
+CBonusSystemNode::CBonusSystemNode(ENodeTypes NodeType):
|
|
|
+ bonuses(true),
|
|
|
exportedBonuses(true),
|
|
|
nodeType(NodeType),
|
|
|
cachedLast(0),
|
|
|
- sync(),
|
|
|
isHypotheticNode(false)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-CBonusSystemNode::CBonusSystemNode(CBonusSystemNode && other):
|
|
|
+CBonusSystemNode::CBonusSystemNode(CBonusSystemNode && other) noexcept:
|
|
|
bonuses(std::move(other.bonuses)),
|
|
|
exportedBonuses(std::move(other.exportedBonuses)),
|
|
|
nodeType(other.nodeType),
|
|
|
description(other.description),
|
|
|
cachedLast(0),
|
|
|
- sync(),
|
|
|
isHypotheticNode(other.isHypotheticNode)
|
|
|
{
|
|
|
std::swap(parents, other.parents);
|
|
@@ -1164,9 +1133,9 @@ CBonusSystemNode::~CBonusSystemNode()
|
|
|
{
|
|
|
detachFromAll();
|
|
|
|
|
|
- if(children.size())
|
|
|
+ if(!children.empty())
|
|
|
{
|
|
|
- while(children.size())
|
|
|
+ while(!children.empty())
|
|
|
children.front()->detachFrom(*this);
|
|
|
}
|
|
|
}
|
|
@@ -1229,7 +1198,7 @@ void CBonusSystemNode::reduceBonusDurations(const CSelector &s)
|
|
|
{
|
|
|
BonusList bl;
|
|
|
exportedBonuses.getBonuses(bl, s, Selector::all);
|
|
|
- for(auto b : bl)
|
|
|
+ for(const auto & b : bl)
|
|
|
{
|
|
|
b->turnsRemain--;
|
|
|
if(b->turnsRemain <= 0)
|
|
@@ -1277,7 +1246,7 @@ void CBonusSystemNode::removeBonuses(const CSelector & selector)
|
|
|
{
|
|
|
BonusList toRemove;
|
|
|
exportedBonuses.getBonuses(toRemove, selector, Selector::all);
|
|
|
- for(auto bonus : toRemove)
|
|
|
+ for(const auto & bonus : toRemove)
|
|
|
removeBonus(bonus);
|
|
|
}
|
|
|
|
|
@@ -1294,7 +1263,7 @@ bool CBonusSystemNode::actsAsBonusSourceOnly() const
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void CBonusSystemNode::propagateBonus(std::shared_ptr<Bonus> b, const CBonusSystemNode & source)
|
|
|
+void CBonusSystemNode::propagateBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & source)
|
|
|
{
|
|
|
if(b->propagator->shouldBeAttached(this))
|
|
|
{
|
|
@@ -1309,7 +1278,7 @@ void CBonusSystemNode::propagateBonus(std::shared_ptr<Bonus> b, const CBonusSyst
|
|
|
child->propagateBonus(b, source);
|
|
|
}
|
|
|
|
|
|
-void CBonusSystemNode::unpropagateBonus(std::shared_ptr<Bonus> b)
|
|
|
+void CBonusSystemNode::unpropagateBonus(const std::shared_ptr<Bonus> & b)
|
|
|
{
|
|
|
if(b->propagator->shouldBeAttached(this))
|
|
|
{
|
|
@@ -1340,7 +1309,7 @@ void CBonusSystemNode::childDetached(CBonusSystemNode & child)
|
|
|
|
|
|
void CBonusSystemNode::detachFromAll()
|
|
|
{
|
|
|
- while(parents.size())
|
|
|
+ while(!parents.empty())
|
|
|
detachFrom(*parents.front());
|
|
|
}
|
|
|
|
|
@@ -1351,7 +1320,7 @@ bool CBonusSystemNode::isIndependentNode() const
|
|
|
|
|
|
std::string CBonusSystemNode::nodeName() const
|
|
|
{
|
|
|
- return description.size()
|
|
|
+ return !description.empty()
|
|
|
? description
|
|
|
: std::string("Bonus system node of type ") + typeid(*this).name();
|
|
|
}
|
|
@@ -1412,7 +1381,7 @@ void CBonusSystemNode::getRedChildren(TNodes &out)
|
|
|
|
|
|
void CBonusSystemNode::newRedDescendant(CBonusSystemNode & descendant)
|
|
|
{
|
|
|
- for(auto b : exportedBonuses)
|
|
|
+ for(const auto & b : exportedBonuses)
|
|
|
{
|
|
|
if(b->propagator)
|
|
|
descendant.propagateBonus(b, *this);
|
|
@@ -1420,9 +1389,9 @@ void CBonusSystemNode::newRedDescendant(CBonusSystemNode & descendant)
|
|
|
TNodes redParents;
|
|
|
getRedAncestors(redParents); //get all red parents recursively
|
|
|
|
|
|
- for(auto parent : redParents)
|
|
|
+ for(auto * parent : redParents)
|
|
|
{
|
|
|
- for(auto b : parent->exportedBonuses)
|
|
|
+ for(const auto & b : parent->exportedBonuses)
|
|
|
{
|
|
|
if(b->propagator)
|
|
|
descendant.propagateBonus(b, *this);
|
|
@@ -1432,16 +1401,16 @@ void CBonusSystemNode::newRedDescendant(CBonusSystemNode & descendant)
|
|
|
|
|
|
void CBonusSystemNode::removedRedDescendant(CBonusSystemNode & descendant)
|
|
|
{
|
|
|
- for(auto b : exportedBonuses)
|
|
|
+ for(const auto & b : exportedBonuses)
|
|
|
if(b->propagator)
|
|
|
descendant.unpropagateBonus(b);
|
|
|
|
|
|
TNodes redParents;
|
|
|
getRedAncestors(redParents); //get all red parents recursively
|
|
|
|
|
|
- for(auto parent : redParents)
|
|
|
+ for(auto * parent : redParents)
|
|
|
{
|
|
|
- for(auto b : parent->exportedBonuses)
|
|
|
+ for(const auto & b : parent->exportedBonuses)
|
|
|
if(b->propagator)
|
|
|
descendant.unpropagateBonus(b);
|
|
|
}
|
|
@@ -1465,7 +1434,7 @@ void CBonusSystemNode::getRedDescendants(TNodes &out)
|
|
|
c->getRedChildren(out);
|
|
|
}
|
|
|
|
|
|
-void CBonusSystemNode::exportBonus(std::shared_ptr<Bonus> b)
|
|
|
+void CBonusSystemNode::exportBonus(const std::shared_ptr<Bonus> & b)
|
|
|
{
|
|
|
if(b->propagator)
|
|
|
propagateBonus(b, *this);
|
|
@@ -1477,7 +1446,7 @@ void CBonusSystemNode::exportBonus(std::shared_ptr<Bonus> b)
|
|
|
|
|
|
void CBonusSystemNode::exportBonuses()
|
|
|
{
|
|
|
- for(auto b : exportedBonuses)
|
|
|
+ for(const auto & b : exportedBonuses)
|
|
|
exportBonus(b);
|
|
|
}
|
|
|
|
|
@@ -1530,8 +1499,8 @@ void CBonusSystemNode::limitBonuses(const BonusList &allBonuses, BonusList &out)
|
|
|
{
|
|
|
assert(&allBonuses != &out); //todo should it work in-place?
|
|
|
|
|
|
- BonusList undecided = allBonuses,
|
|
|
- &accepted = out;
|
|
|
+ BonusList undecided = allBonuses;
|
|
|
+ BonusList & accepted = out;
|
|
|
|
|
|
while(true)
|
|
|
{
|
|
@@ -1687,7 +1656,7 @@ JsonNode durationToJson(ui16 duration)
|
|
|
else
|
|
|
{
|
|
|
JsonNode node(JsonNode::JsonType::DATA_VECTOR);
|
|
|
- for(std::string dur : durationNames)
|
|
|
+ for(const std::string & dur : durationNames)
|
|
|
node.Vector().push_back(JsonUtils::stringNode(dur));
|
|
|
return node;
|
|
|
}
|
|
@@ -1705,7 +1674,7 @@ JsonNode Bonus::toJsonNode() const
|
|
|
if(duration != 0)
|
|
|
{
|
|
|
JsonNode durationVec(JsonNode::JsonType::DATA_VECTOR);
|
|
|
- for(auto & kv : bonusDurationMap)
|
|
|
+ for(const auto & kv : bonusDurationMap)
|
|
|
{
|
|
|
if(duration & kv.second)
|
|
|
durationVec.Vector().push_back(JsonUtils::stringNode(kv.first));
|
|
@@ -1755,7 +1724,7 @@ std::string Bonus::nameForBonus() const
|
|
|
case Bonus::SPECIAL_PECULIAR_ENCHANT:
|
|
|
case Bonus::SPECIAL_ADD_VALUE_ENCHANT:
|
|
|
case Bonus::SPECIAL_FIXED_VALUE_ENCHANT:
|
|
|
- return (*VLC->spellh)[SpellID::ESpellID(subtype)]->identifier;
|
|
|
+ return (*VLC->spellh)[static_cast<SpellID::ESpellID>(subtype)]->identifier;
|
|
|
case Bonus::SPECIAL_UPGRADE:
|
|
|
return CreatureID::encode(subtype) + "2" + CreatureID::encode(additionalInfo[0]);
|
|
|
case Bonus::GENERATE_RESOURCE:
|
|
@@ -2005,40 +1974,34 @@ CSelector BonusParams::toSelector()
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-Bonus::Bonus(Bonus::BonusDuration Duration, BonusType Type, BonusSource Src, si32 Val, ui32 ID, std::string Desc, si32 Subtype)
|
|
|
- : duration((ui16)Duration), type(Type), subtype(Subtype), source(Src), val(Val), sid(ID), description(Desc)
|
|
|
+Bonus::Bonus(Bonus::BonusDuration Duration, BonusType Type, BonusSource Src, si32 Val, ui32 ID, std::string Desc, si32 Subtype):
|
|
|
+ duration(static_cast<ui16>(Duration)),
|
|
|
+ type(Type),
|
|
|
+ subtype(Subtype),
|
|
|
+ source(Src),
|
|
|
+ val(Val),
|
|
|
+ sid(ID),
|
|
|
+ description(std::move(Desc))
|
|
|
{
|
|
|
- turnsRemain = 0;
|
|
|
- valType = ADDITIVE_VALUE;
|
|
|
- effectRange = NO_LIMIT;
|
|
|
boost::algorithm::trim(description);
|
|
|
targetSourceType = OTHER;
|
|
|
}
|
|
|
|
|
|
-Bonus::Bonus(Bonus::BonusDuration Duration, BonusType Type, BonusSource Src, si32 Val, ui32 ID, si32 Subtype, ValueType ValType)
|
|
|
- : duration((ui16)Duration), type(Type), subtype(Subtype), source(Src), val(Val), sid(ID), valType(ValType)
|
|
|
+Bonus::Bonus(Bonus::BonusDuration Duration, BonusType Type, BonusSource Src, si32 Val, ui32 ID, si32 Subtype, ValueType ValType):
|
|
|
+ duration(static_cast<ui16>(Duration)),
|
|
|
+ type(Type),
|
|
|
+ subtype(Subtype),
|
|
|
+ source(Src),
|
|
|
+ val(Val),
|
|
|
+ sid(ID),
|
|
|
+ valType(ValType)
|
|
|
{
|
|
|
turnsRemain = 0;
|
|
|
effectRange = NO_LIMIT;
|
|
|
targetSourceType = OTHER;
|
|
|
}
|
|
|
|
|
|
-Bonus::Bonus()
|
|
|
-{
|
|
|
- duration = PERMANENT;
|
|
|
- turnsRemain = 0;
|
|
|
- type = NONE;
|
|
|
- subtype = -1;
|
|
|
-
|
|
|
- valType = ADDITIVE_VALUE;
|
|
|
- effectRange = NO_LIMIT;
|
|
|
- val = 0;
|
|
|
- source = OTHER;
|
|
|
- sid = 0;
|
|
|
- targetSourceType = OTHER;
|
|
|
-}
|
|
|
-
|
|
|
-std::shared_ptr<Bonus> Bonus::addPropagator(TPropagatorPtr Propagator)
|
|
|
+std::shared_ptr<Bonus> Bonus::addPropagator(const TPropagatorPtr & Propagator)
|
|
|
{
|
|
|
propagator = Propagator;
|
|
|
return this->shared_from_this();
|
|
@@ -2090,7 +2053,7 @@ namespace Selector
|
|
|
return type()(Type).And(subtype()(Subtype));
|
|
|
}
|
|
|
|
|
|
- CSelector DLL_LINKAGE typeSubtypeInfo(Bonus::BonusType type, TBonusSubtype subtype, CAddInfo info)
|
|
|
+ CSelector DLL_LINKAGE typeSubtypeInfo(Bonus::BonusType type, TBonusSubtype subtype, const CAddInfo & info)
|
|
|
{
|
|
|
return CSelectFieldEqual<Bonus::BonusType>(&Bonus::type)(type)
|
|
|
.And(CSelectFieldEqual<TBonusSubtype>(&Bonus::subtype)(subtype))
|
|
@@ -2137,9 +2100,9 @@ const CCreature * retrieveCreature(const CBonusSystemNode *node)
|
|
|
switch(node->getNodeType())
|
|
|
{
|
|
|
case CBonusSystemNode::CREATURE:
|
|
|
- return (static_cast<const CCreature *>(node));
|
|
|
+ return (dynamic_cast<const CCreature *>(node));
|
|
|
case CBonusSystemNode::STACK_BATTLE:
|
|
|
- return (static_cast<const CStack*>(node))->type;
|
|
|
+ return (dynamic_cast<const CStack *>(node))->type;
|
|
|
default:
|
|
|
const CStackInstance * csi = retrieveStackInstance(node);
|
|
|
if(csi)
|
|
@@ -2152,7 +2115,7 @@ DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const BonusList &bonusL
|
|
|
{
|
|
|
for (ui32 i = 0; i < bonusList.size(); i++)
|
|
|
{
|
|
|
- auto b = bonusList[i];
|
|
|
+ const auto & b = bonusList[i];
|
|
|
out << "Bonus " << i << "\n" << *b << std::endl;
|
|
|
}
|
|
|
return out;
|
|
@@ -2160,9 +2123,9 @@ DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const BonusList &bonusL
|
|
|
|
|
|
DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const Bonus &bonus)
|
|
|
{
|
|
|
- for(auto i = bonusNameMap.cbegin(); i != bonusNameMap.cend(); i++)
|
|
|
- if(i->second == bonus.type)
|
|
|
- out << "\tType: " << i->first << " \t";
|
|
|
+ for(const auto & i : bonusNameMap)
|
|
|
+ if(i.second == bonus.type)
|
|
|
+ out << "\tType: " << i.first << " \t";
|
|
|
|
|
|
#define printField(field) out << "\t" #field ": " << (int)bonus.field << "\n"
|
|
|
printField(val);
|
|
@@ -2187,7 +2150,7 @@ DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const Bonus &bonus)
|
|
|
return out;
|
|
|
}
|
|
|
|
|
|
-std::shared_ptr<Bonus> Bonus::addLimiter(TLimiterPtr Limiter)
|
|
|
+std::shared_ptr<Bonus> Bonus::addLimiter(const TLimiterPtr & Limiter)
|
|
|
{
|
|
|
if (limiter)
|
|
|
{
|
|
@@ -2210,10 +2173,6 @@ std::shared_ptr<Bonus> Bonus::addLimiter(TLimiterPtr Limiter)
|
|
|
return this->shared_from_this();
|
|
|
}
|
|
|
|
|
|
-ILimiter::~ILimiter()
|
|
|
-{
|
|
|
-}
|
|
|
-
|
|
|
int ILimiter::limit(const BonusLimitationContext &context) const /*return true to drop the bonus */
|
|
|
{
|
|
|
return false;
|
|
@@ -2245,13 +2204,7 @@ CCreatureTypeLimiter::CCreatureTypeLimiter(const CCreature & creature_, bool Inc
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-CCreatureTypeLimiter::CCreatureTypeLimiter()
|
|
|
-{
|
|
|
- creature = nullptr;
|
|
|
- includeUpgrades = false;
|
|
|
-}
|
|
|
-
|
|
|
-void CCreatureTypeLimiter::setCreature (CreatureID id)
|
|
|
+void CCreatureTypeLimiter::setCreature(const CreatureID & id)
|
|
|
{
|
|
|
creature = VLC->creh->objects[id];
|
|
|
}
|
|
@@ -2351,11 +2304,6 @@ JsonNode HasAnotherBonusLimiter::toJsonNode() const
|
|
|
return root;
|
|
|
}
|
|
|
|
|
|
-IPropagator::~IPropagator()
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
bool IPropagator::shouldBeAttached(CBonusSystemNode *dest)
|
|
|
{
|
|
|
return false;
|
|
@@ -2439,8 +2387,8 @@ CreatureFactionLimiter::CreatureFactionLimiter(TFaction creatureFaction)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-CreatureFactionLimiter::CreatureFactionLimiter()
|
|
|
- : faction((TFaction)-1)
|
|
|
+CreatureFactionLimiter::CreatureFactionLimiter():
|
|
|
+ faction(static_cast<TFaction>(-1))
|
|
|
{
|
|
|
}
|
|
|
|
|
@@ -2552,18 +2500,18 @@ StackOwnerLimiter::StackOwnerLimiter()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-StackOwnerLimiter::StackOwnerLimiter(PlayerColor Owner)
|
|
|
- : owner(Owner)
|
|
|
+StackOwnerLimiter::StackOwnerLimiter(const PlayerColor & Owner):
|
|
|
+ owner(Owner)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-OppositeSideLimiter::OppositeSideLimiter()
|
|
|
- : owner(PlayerColor::CANNOT_DETERMINE)
|
|
|
+OppositeSideLimiter::OppositeSideLimiter():
|
|
|
+ owner(PlayerColor::CANNOT_DETERMINE)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-OppositeSideLimiter::OppositeSideLimiter(PlayerColor Owner)
|
|
|
- : owner(Owner)
|
|
|
+OppositeSideLimiter::OppositeSideLimiter(const PlayerColor & Owner):
|
|
|
+ owner(Owner)
|
|
|
{
|
|
|
}
|
|
|
|
|
@@ -2576,7 +2524,7 @@ int OppositeSideLimiter::limit(const BonusLimitationContext & context) const
|
|
|
|
|
|
// Aggregate/Boolean Limiters
|
|
|
|
|
|
-void AggregateLimiter::add(TLimiterPtr limiter)
|
|
|
+void AggregateLimiter::add(const TLimiterPtr & limiter)
|
|
|
{
|
|
|
if(limiter)
|
|
|
limiters.push_back(limiter);
|
|
@@ -2586,7 +2534,7 @@ JsonNode AggregateLimiter::toJsonNode() const
|
|
|
{
|
|
|
JsonNode result(JsonNode::JsonType::DATA_VECTOR);
|
|
|
result.Vector().push_back(JsonUtils::stringNode(getAggregator()));
|
|
|
- for(auto l : limiters)
|
|
|
+ for(const auto & l : limiters)
|
|
|
result.Vector().push_back(l->toJsonNode());
|
|
|
return result;
|
|
|
}
|
|
@@ -2601,7 +2549,7 @@ int AllOfLimiter::limit(const BonusLimitationContext & context) const
|
|
|
{
|
|
|
bool wasntSure = false;
|
|
|
|
|
|
- for(auto limiter : limiters)
|
|
|
+ for(const auto & limiter : limiters)
|
|
|
{
|
|
|
auto result = limiter->limit(context);
|
|
|
if(result == ILimiter::DISCARD)
|
|
@@ -2623,7 +2571,7 @@ int AnyOfLimiter::limit(const BonusLimitationContext & context) const
|
|
|
{
|
|
|
bool wasntSure = false;
|
|
|
|
|
|
- for(auto limiter : limiters)
|
|
|
+ for(const auto & limiter : limiters)
|
|
|
{
|
|
|
auto result = limiter->limit(context);
|
|
|
if(result == ILimiter::ACCEPT)
|
|
@@ -2645,7 +2593,7 @@ int NoneOfLimiter::limit(const BonusLimitationContext & context) const
|
|
|
{
|
|
|
bool wasntSure = false;
|
|
|
|
|
|
- for(auto limiter : limiters)
|
|
|
+ for(const auto & limiter : limiters)
|
|
|
{
|
|
|
auto result = limiter->limit(context);
|
|
|
if(result == ILimiter::ACCEPT)
|
|
@@ -2659,16 +2607,12 @@ int NoneOfLimiter::limit(const BonusLimitationContext & context) const
|
|
|
|
|
|
// Updaters
|
|
|
|
|
|
-std::shared_ptr<Bonus> Bonus::addUpdater(TUpdaterPtr Updater)
|
|
|
+std::shared_ptr<Bonus> Bonus::addUpdater(const TUpdaterPtr & Updater)
|
|
|
{
|
|
|
updater = Updater;
|
|
|
return this->shared_from_this();
|
|
|
}
|
|
|
|
|
|
-IUpdater::~IUpdater()
|
|
|
-{
|
|
|
-}
|
|
|
-
|
|
|
std::shared_ptr<Bonus> IUpdater::createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context) const
|
|
|
{
|
|
|
return b;
|
|
@@ -2684,10 +2628,6 @@ JsonNode IUpdater::toJsonNode() const
|
|
|
return JsonNode(JsonNode::JsonType::DATA_NULL);
|
|
|
}
|
|
|
|
|
|
-GrowsWithLevelUpdater::GrowsWithLevelUpdater() : valPer20(0), stepSize(1)
|
|
|
-{
|
|
|
-}
|
|
|
-
|
|
|
GrowsWithLevelUpdater::GrowsWithLevelUpdater(int valPer20, int stepSize) : valPer20(valPer20), stepSize(stepSize)
|
|
|
{
|
|
|
}
|
|
@@ -2696,7 +2636,7 @@ std::shared_ptr<Bonus> GrowsWithLevelUpdater::createUpdatedBonus(const std::shar
|
|
|
{
|
|
|
if(context.getNodeType() == CBonusSystemNode::HERO)
|
|
|
{
|
|
|
- int level = static_cast<const CGHeroInstance &>(context).level;
|
|
|
+ int level = dynamic_cast<const CGHeroInstance &>(context).level;
|
|
|
int steps = stepSize ? level / stepSize : level;
|
|
|
//rounding follows format for HMM3 creature specialty bonus
|
|
|
int newVal = (valPer20 * steps + 19) / 20;
|
|
@@ -2725,15 +2665,11 @@ JsonNode GrowsWithLevelUpdater::toJsonNode() const
|
|
|
return root;
|
|
|
}
|
|
|
|
|
|
-TimesHeroLevelUpdater::TimesHeroLevelUpdater()
|
|
|
-{
|
|
|
-}
|
|
|
-
|
|
|
std::shared_ptr<Bonus> TimesHeroLevelUpdater::createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context) const
|
|
|
{
|
|
|
if(context.getNodeType() == CBonusSystemNode::HERO)
|
|
|
{
|
|
|
- int level = static_cast<const CGHeroInstance &>(context).level;
|
|
|
+ int level = dynamic_cast<const CGHeroInstance &>(context).level;
|
|
|
std::shared_ptr<Bonus> newBonus = std::make_shared<Bonus>(*b);
|
|
|
newBonus->val *= level;
|
|
|
return newBonus;
|
|
@@ -2801,23 +2737,18 @@ JsonNode ArmyMovementUpdater::toJsonNode() const
|
|
|
|
|
|
return root;
|
|
|
}
|
|
|
-
|
|
|
-TimesStackLevelUpdater::TimesStackLevelUpdater()
|
|
|
-{
|
|
|
-}
|
|
|
-
|
|
|
std::shared_ptr<Bonus> TimesStackLevelUpdater::createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context) const
|
|
|
{
|
|
|
if(context.getNodeType() == CBonusSystemNode::STACK_INSTANCE)
|
|
|
{
|
|
|
- int level = static_cast<const CStackInstance &>(context).getLevel();
|
|
|
+ int level = dynamic_cast<const CStackInstance &>(context).getLevel();
|
|
|
std::shared_ptr<Bonus> newBonus = std::make_shared<Bonus>(*b);
|
|
|
newBonus->val *= level;
|
|
|
return newBonus;
|
|
|
}
|
|
|
else if(context.getNodeType() == CBonusSystemNode::STACK_BATTLE)
|
|
|
{
|
|
|
- const CStack & stack = static_cast<const CStack &>(context);
|
|
|
+ const auto & stack = dynamic_cast<const CStack &>(context);
|
|
|
//only update if stack doesn't have an instance (summons, war machines)
|
|
|
//otherwise we'd end up multiplying twice
|
|
|
if(stack.base == nullptr)
|
|
@@ -2841,10 +2772,6 @@ JsonNode TimesStackLevelUpdater::toJsonNode() const
|
|
|
return JsonUtils::stringNode("TIMES_STACK_LEVEL");
|
|
|
}
|
|
|
|
|
|
-OwnerUpdater::OwnerUpdater()
|
|
|
-{
|
|
|
-}
|
|
|
-
|
|
|
std::string OwnerUpdater::toString() const
|
|
|
{
|
|
|
return "OwnerUpdater";
|
|
@@ -2862,8 +2789,8 @@ std::shared_ptr<Bonus> OwnerUpdater::createUpdatedBonus(const std::shared_ptr<Bo
|
|
|
if(owner == PlayerColor::UNFLAGGABLE)
|
|
|
owner = PlayerColor::NEUTRAL;
|
|
|
|
|
|
- std::shared_ptr<Bonus> updated = std::make_shared<Bonus>(
|
|
|
- (Bonus::BonusDuration)b->duration, b->type, b->source, b->val, b->sid, b->subtype, b->valType);
|
|
|
+ std::shared_ptr<Bonus> updated =
|
|
|
+ std::make_shared<Bonus>(static_cast<Bonus::BonusDuration>(b->duration), b->type, b->source, b->val, b->sid, b->subtype, b->valType);
|
|
|
updated->limiter = std::make_shared<OppositeSideLimiter>(owner);
|
|
|
return updated;
|
|
|
}
|