Prechádzať zdrojové kódy

jnmap.bin要使用assic编码;修复FindJNShortCut函数。

Jeff 4 rokov pred
rodič
commit
951023bc0a

+ 34 - 8
GameAssist/GameAssist/GameAssistDlg.cpp

@@ -670,7 +670,7 @@ void BattleYS(HWND hWnd, const char* lpszJN)
 				}
 
 				GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
-				SRAND(230, 350);
+				SRAND(300, 350);
 				// 下一页中查看;
 				rc = FindMatchIcon(hWnd, pJN);
 				if (!rc.IsRectEmpty() && !rc.IsRectNull())
@@ -678,6 +678,7 @@ void BattleYS(HWND hWnd, const char* lpszJN)
 					// 找到目标,单击;
 					GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
 					SRAND(300, 500);
+					// 移动下,防止高亮识别失败;
 					GAssist::MouseMoveEx(hWnd, {rc.left, rc.top}, {rc.right+rand()%10, rc.bottom + rand()%10});
 					SRAND(150, 200);
 					ClickDlgSetup(hWnd, _T("img\\确定.bmp"));
@@ -734,21 +735,21 @@ void BattleYS(HWND hWnd, const char* lpszJN)
 		// 人物:Alt+S显示技能,双击选择技能,单击怪物发动技能;
 		// 注:有的人物技能太多,导致会有滚动条:这是有难点;
 		// 使用快捷键来处理:读取配置文件
-		auto FindJNShortCut = [&]()->int {
+		auto FindJNShortCut = [](LPCTSTR lpSkillName)->int {
 			// 读取文件:jnmap.bin
 			// 格式:技能=快捷键的键值;
 			std::string line;
 			std::ifstream ifJN("img\\jnmap.bin");
 			if (ifJN)
 			{
-				TCHAR szJNValue[MAX_PATH] = { 0 };
-				TCHAR szJN[MAX_PATH] = { 0 };
+				TCHAR szKeyValue[MAX_PATH] = { 0 };
+				TCHAR szSkillName[MAX_PATH] = { 0 };
 				while (std::getline(ifJN, line))
 				{
-					int nRet = _stscanf_s(line.c_str(), _T("%s=%s"), szJN, MAX_PATH, szJNValue, MAX_PATH);
-					if (nRet == 2 && _tcsicmp(lpszJN, szJN) == 0) {
+					int nRet = _stscanf_s(line.c_str(), _T("%[^=]%s"), szSkillName, MAX_PATH, szKeyValue, MAX_PATH);
+					if (nRet == 2 && _tcsicmp(lpSkillName, szSkillName) == 0) {
 						// 将快捷键值
-						return atol(szJNValue);
+						return atol(szKeyValue);
 					}
 				}
 			}
@@ -757,7 +758,8 @@ void BattleYS(HWND hWnd, const char* lpszJN)
 			return -1;
 		};
 
-		int KeyValue = FindJNShortCut();
+		int KeyValue = FindJNShortCut(lpszJN);
+		DebugLog("快捷键值=%ld", KeyValue);
 		if (KeyValue != -1)
 		{
 			// 快捷键;
@@ -1197,6 +1199,30 @@ void CGameAssistDlg::OnBnClickedButton2()  // 
 	HWND hProWnd = GAssist::GetProcessMainWnd();
 	//IsWattingAttack(hProWnd, 1);
 	BattleYS(hProWnd, "缚神诀");
+	auto FindJNShortCut = [](LPCTSTR lpSkillName)->int {
+		// 读取文件:jnmap.bin
+		// 格式:技能=快捷键的键值;
+		std::string line;
+		std::ifstream ifJN("..\\img\\jnmap.bin");
+		if (ifJN)
+		{
+			TCHAR szKeyValue[MAX_PATH] = { 0 };
+			TCHAR szSkillName[MAX_PATH] = { 0 };
+			while (std::getline(ifJN, line))
+			{
+				int nRet = _stscanf_s(line.c_str(), _T("%[^=]%s"), szSkillName, MAX_PATH, szKeyValue, MAX_PATH);
+				if (nRet == 2 && _tcsicmp(lpSkillName, szSkillName) == 0) {
+					// 将快捷键值
+					return atol(szKeyValue);
+				}
+	}
+}
+
+		// 没有找到jnmap.bin文件;
+		return -1;
+		};
+
+	int KeyValue = FindJNShortCut("缚神诀");
 #endif
 
 #if 0

+ 1 - 1
GameAssist/img/jnmap.bin

@@ -1 +1 @@
-Г╪ Г╔·Х╞─=118
+╦©иЯ╬В=118