浏览代码

Fix assertion failure on swiping during spellcast

Ivan Savenko 2 年之前
父节点
当前提交
57d7dc97bf
共有 1 个文件被更改,包括 9 次插入7 次删除
  1. 9 7
      client/gui/CursorHandler.h

+ 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);