Browse Source

Fix counter-attack counting

Ivan Savenko 11 months ago
parent
commit
e27ca391b1
2 changed files with 15 additions and 0 deletions
  1. 2 0
      lib/battle/CUnitState.cpp
  2. 13 0
      lib/bonuses/BonusCache.h

+ 2 - 0
lib/battle/CUnitState.cpp

@@ -359,6 +359,8 @@ CUnitState & CUnitState::operator=(const CUnitState & other)
 	waiting = other.waiting;
 	waitedThisTurn = other.waitedThisTurn;
 	casts = other.casts;
+	counterAttacks = other.counterAttacks;
+	shots = other.shots;
 	health = other.health;
 	cloneID = other.cloneID;
 	position = other.position;

+ 13 - 0
lib/bonuses/BonusCache.h

@@ -34,6 +34,19 @@ protected:
 	{
 		std::atomic<int64_t> version = 0;
 		std::atomic<int64_t> value = 0;
+
+		BonusCacheEntry() = default;
+		BonusCacheEntry(const BonusCacheEntry & other)
+			: version(other.version.load())
+			, value(other.value.load())
+		{
+		}
+		BonusCacheEntry & operator =(const BonusCacheEntry & other)
+		{
+			version = other.version.load();
+			value = other.value.load();
+			return *this;
+		}
 	};
 
 	int getBonusValueImpl(BonusCacheEntry & currentValue, const CSelector & selector, BonusCacheMode) const;