2
0
Эх сурвалжийг харах

Merge pull request #2466 from IvanSavenko/battle_assertions_fix

(1.3.1) Fix assertion failures in battle
Ivan Savenko 2 жил өмнө
parent
commit
c3d8607c8b

+ 2 - 0
client/battle/BattleInterface.cpp

@@ -445,6 +445,8 @@ void BattleInterface::spellCast(const BattleSpellCast * sc)
 			stacksController->addNewAnim(new EffectAnimation(*this, side ? "SP07_B.DEF" : "SP07_A.DEF", rightHero));
 		});
 	}
+
+	// animations will be executed by spell effects
 }
 
 void BattleInterface::battleStacksEffectsSet(const SetStackEffect & sse)

+ 1 - 1
client/battle/BattleStacksController.cpp

@@ -499,7 +499,7 @@ void BattleStacksController::stacksAreAttacked(std::vector<StackAttackedInfo> at
 void BattleStacksController::stackTeleported(const CStack *stack, std::vector<BattleHex> destHex, int distance)
 {
 	assert(destHex.size() > 0);
-	owner.checkForAnimations();
+	//owner.checkForAnimations(); // NOTE: at this point spellcast animations were added, but not executed
 
 	owner.addToAnimationStage(EAnimationEvents::HIT, [=](){
 		addNewAnim( new ColorTransformAnimation(owner, stack, "teleportFadeOut", nullptr) );

+ 9 - 7
client/gui/CursorHandler.h

@@ -31,8 +31,6 @@ namespace Cursor
 	};
 
 	enum class Combat {
-		INVALID        = -1,
-
 		BLOCKED        = 0,
 		MOVE           = 1,
 		FLY            = 2,
@@ -157,12 +155,16 @@ public:
 	template<typename Index>
 	Index get()
 	{
-		assert((std::is_same<Index, Cursor::Default>::value   )|| type != Cursor::Type::DEFAULT );
-		assert((std::is_same<Index, Cursor::Map>::value       )|| type != Cursor::Type::ADVENTURE );
-		assert((std::is_same<Index, Cursor::Combat>::value    )|| type != Cursor::Type::COMBAT );
-		assert((std::is_same<Index, Cursor::Spellcast>::value )|| type != Cursor::Type::SPELLBOOK );
+		bool typeValid = true;
+
+		typeValid &= (std::is_same<Index, Cursor::Default>::value   )|| type != Cursor::Type::DEFAULT;
+		typeValid &= (std::is_same<Index, Cursor::Map>::value       )|| type != Cursor::Type::ADVENTURE;
+		typeValid &= (std::is_same<Index, Cursor::Combat>::value    )|| type != Cursor::Type::COMBAT;
+		typeValid &= (std::is_same<Index, Cursor::Spellcast>::value )|| type != Cursor::Type::SPELLBOOK;
 
-		return static_cast<Index>(frame);
+		if (typeValid)
+			return static_cast<Index>(frame);
+		return Index::POINTER;
 	}
 
 	Point getPivotOffsetDefault(size_t index);