From 9bc06b941a1499543a51c2c2032042d18596badd Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sat, 3 Jun 2023 12:34:53 +0200 Subject: Debug duplicated move in games --- src/game_tab/Game.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/game_tab/Game.cpp') 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(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); } -- cgit v1.2.3