From 7c7e26cc16ba51afaaa85a1ec09ca7628d87d885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Sat, 30 Mar 2013 19:25:34 +0100 Subject: [PATCH] Hints: fix a bug in WordLettersHint. The letters of a word containing digraph tiles (like the Catalan 'QU') were sorted incorrectly. For example, "AQUIETE" was sorted as "AEEIQTU" instead of "AEEITQU". Note: it would be even better as "AEEIQUT", but this is a different problem... --- game/hints.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/game/hints.cpp b/game/hints.cpp index 126a971..4f67238 100644 --- a/game/hints.cpp +++ b/game/hints.cpp @@ -19,6 +19,7 @@ *****************************************************************************/ #include +#include #include "config.h" #if ENABLE_NLS @@ -146,9 +147,17 @@ WordLettersHint::WordLettersHint() string WordLettersHint::giveHint(const Move &iMove) const { ASSERT(iMove.isValid(), "Hints only make sense for valid moves"); - wstring word = iMove.getRound().getWord(); - // Sort the letters - std::sort(word.begin(), word.end()); + vector tiles = iMove.getRound().getTiles(); + // Sort the letters (we cannot sort directly the wstring from + // Round::getWord(), because it would break digraph characters) + std::sort(tiles.begin(), tiles.end()); + + // Get the word + wstring word; + BOOST_FOREACH(const Tile &tile, tiles) + { + word += tile.getDisplayStr(); + } return str(boost::format(_("Word letters: %1%")) % lfw(word));