WAR: 临时性解决点击棋谱后无反应的问题
因为 cmdlist 移动框 gameController 后,每次重新开局被清空后 就没有首行的 s2... 了,临时解决方式是先备份这一行,清空后再 插回去。
This commit is contained in:
parent
51e5f22f06
commit
26eb01e259
|
@ -472,7 +472,7 @@ int Position::pieces_in_hand_count()
|
|||
return pieceCountInHand[BLACK] + pieceCountInHand[WHITE];
|
||||
}
|
||||
|
||||
bool Position::set_position(const struct Rule *newRule)
|
||||
int Position::set_position(const struct Rule *newRule)
|
||||
{
|
||||
rule = *newRule;
|
||||
|
||||
|
@ -504,15 +504,10 @@ bool Position::set_position(const struct Rule *newRule)
|
|||
int r;
|
||||
for (r = 0; r < N_RULES; r++) {
|
||||
if (strcmp(rule.name, RULES[r].name) == 0)
|
||||
break;
|
||||
return r;
|
||||
}
|
||||
|
||||
if (sprintf(cmdline, "r%1u s%03u t%02u", r + 1, rule.maxStepsLedToDraw, rule.maxTimeLedToLose) > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
cmdline[0] = '\0';
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool Position::reset()
|
||||
|
@ -878,7 +873,7 @@ bool Position::command(const char *cmd)
|
|||
return false;
|
||||
}
|
||||
|
||||
return set_position(&RULES[ruleIndex - 1]);
|
||||
return set_position(&RULES[ruleIndex - 1]) >= 0 ? true : false;
|
||||
}
|
||||
|
||||
args = sscanf(cmd, "(%1u,%1u)->(%1u,%1u) %2u:%2u", &file1, &rank1, &file2, &rank2, &mm, &ss);
|
||||
|
|
|
@ -115,7 +115,7 @@ public:
|
|||
|
||||
/// Mill Game
|
||||
|
||||
bool set_position(const struct Rule *rule);
|
||||
int set_position(const struct Rule *rule);
|
||||
|
||||
time_t get_elapsed_time(int us);
|
||||
time_t start_timeb() const;
|
||||
|
|
|
@ -154,6 +154,7 @@ extern deque<int> openingBookDequeBak;
|
|||
|
||||
void GameController::gameStart()
|
||||
{
|
||||
//cmdlist.clear();
|
||||
position.start();
|
||||
|
||||
// 每隔100毫秒调用一次定时器处理函数
|
||||
|
@ -182,9 +183,14 @@ void GameController::gameReset()
|
|||
timeID = 0;
|
||||
|
||||
// 重置游戏
|
||||
position.reset();
|
||||
|
||||
// WAR
|
||||
if (cmdlist.size() > 1) {
|
||||
string bak = cmdlist[0];
|
||||
cmdlist.clear();
|
||||
cmdlist.emplace_back(bak);
|
||||
}
|
||||
|
||||
position.reset();
|
||||
|
||||
// 停掉线程
|
||||
if (!gameOptions.getAutoRestart()) {
|
||||
|
@ -332,12 +338,18 @@ void GameController::setRule(int ruleNo, Step stepLimited /*= -1*/, int timeLimi
|
|||
}
|
||||
|
||||
// 设置模型规则,重置游戏
|
||||
position.set_position(&RULES[ruleNo]);
|
||||
int r = position.set_position(&RULES[ruleNo]);
|
||||
|
||||
char cmdline[64] = { 0 };
|
||||
if (sprintf(cmdline, "r%1u s%03u t%02u", r + 1, rule.maxStepsLedToDraw, rule.maxTimeLedToLose) <= 0) {
|
||||
assert(0);
|
||||
}
|
||||
string cmd(cmdline);
|
||||
cmdlist.clear();
|
||||
cmdlist.emplace_back(cmd);
|
||||
|
||||
// 重置游戏
|
||||
gameReset();
|
||||
|
||||
cmdlist.clear();
|
||||
}
|
||||
|
||||
void GameController::setEngine(int color, bool arg)
|
||||
|
|
Loading…
Reference in New Issue