diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2023-06-03 12:34:53 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2023-06-03 12:34:53 +0200 |
| commit | 9bc06b941a1499543a51c2c2032042d18596badd (patch) | |
| tree | 151c5016cfcd79e2ea7aeba50a79a499bbeb2c15 /src/game_tab/Game.cpp | |
| parent | d60a8bb5c12d906dce3b0880a39640a3e3f08837 (diff) | |
Debug duplicated move in games
Diffstat (limited to 'src/game_tab/Game.cpp')
| -rw-r--r-- | src/game_tab/Game.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/game_tab/Game.cpp b/src/game_tab/Game.cpp index c7ecced..2ddd968 100644 --- a/src/game_tab/Game.cpp +++ b/src/game_tab/Game.cpp @@ -120,13 +120,28 @@ bool Game::Play(std::string move,char promotion) { m->SetCapture(capture); } if (current != nullptr) { - current->AddMove(m); + if(current->GetMainline()!=nullptr){ + HalfMove* curmainline=static_cast<HalfMove*>(current->GetMainline()); + HalfMove* movefound=curmainline->GetCurrentMoveWithFEN(arbiter.GetFEN()); + if(movefound!=nullptr){ + current=movefound; + } + else { + current->AddMove(m); + current = m; + } + } + else{ + current->AddMove(m); + current = m; + } } else if (moves != nullptr) { moves->AddVariation(m); + current = m; } - current = m; if (moves == nullptr) { moves = m; + current = m; } return (true); } |
