1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-30 23:18:08 +02:00

HeroBonus: use 64 bit for tree counter (to be more robust)

This commit is contained in:
Konstantin 2023-03-29 14:17:09 +03:00
parent 0e69aac96f
commit 777818b388
2 changed files with 4 additions and 5 deletions

View File

@ -369,8 +369,8 @@ JsonNode CAddInfo::toJsonNode() const
}
}
std::atomic<int32_t> CBonusSystemNode::treeChanged(1);
const bool CBonusSystemNode::cachingEnabled = true;
std::atomic<int64_t> CBonusSystemNode::treeChanged(1);
constexpr bool CBonusSystemNode::cachingEnabled = true;
BonusList::BonusList(bool BelongsToTree) : belongsToTree(BelongsToTree)
{
@ -1534,8 +1534,7 @@ void CBonusSystemNode::treeHasChanged()
int64_t CBonusSystemNode::getTreeVersion() const
{
int64_t ret = treeChanged;
return ret << 32;
return treeChanged;
}
std::string Bonus::Description(boost::optional<si32> customValue) const

View File

@ -781,7 +781,7 @@ private:
static const bool cachingEnabled;
mutable BonusList cachedBonuses;
mutable int64_t cachedLast;
static std::atomic<int32_t> treeChanged;
static std::atomic<int64_t> treeChanged;
// Setting a value to cachingStr before getting any bonuses caches the result for later requests.
// This string needs to be unique, that's why it has to be setted in the following manner: