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...
This commit is contained in:
Olivier Teulière 2013-03-30 19:25:34 +01:00
parent 3b51da76ce
commit 7c7e26cc16

View file

@ -19,6 +19,7 @@
*****************************************************************************/ *****************************************************************************/
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/foreach.hpp>
#include "config.h" #include "config.h"
#if ENABLE_NLS #if ENABLE_NLS
@ -146,9 +147,17 @@ WordLettersHint::WordLettersHint()
string WordLettersHint::giveHint(const Move &iMove) const string WordLettersHint::giveHint(const Move &iMove) const
{ {
ASSERT(iMove.isValid(), "Hints only make sense for valid moves"); ASSERT(iMove.isValid(), "Hints only make sense for valid moves");
wstring word = iMove.getRound().getWord(); vector<Tile> tiles = iMove.getRound().getTiles();
// Sort the letters // Sort the letters (we cannot sort directly the wstring from
std::sort(word.begin(), word.end()); // 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%")) return str(boost::format(_("Word letters: %1%"))
% lfw(word)); % lfw(word));