Skip to content

Commit

Permalink
Merge pull request #92 from themrrobert/fix-eco-is-one-move-behind
Browse files Browse the repository at this point in the history
Fixed: ECO Classification is a move behind
  • Loading branch information
Isarhamster committed Jul 1, 2024
2 parents e3f82ce + e44a185 commit 4a6c1ec
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/database/gamex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1739,15 +1739,20 @@ QString GameX::ecoClassify() const
}
g.m_moves.moveToEnd();

//search backwards for the first eco position
while(g.m_moves.backward())
// Because we now only move backward() after the loop, we must ensure there are some moves
if (g.m_moves.countMoves() == 0) {
return QString();
}

// Search backwards for the first eco position
do
{
QString eco;
if (EcoPositions::isEcoPosition(g.board(),eco))
{
return eco;
}
}
} while(g.m_moves.backward());

return QString();
}
Expand Down

0 comments on commit 4a6c1ec

Please sign in to comment.