mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-12-25 21:59:30 +01:00
Replace the use of convertToMb() and convertToWc() with macros
This commit is contained in:
parent
867ac96b4d
commit
cfa88072a3
21 changed files with 71 additions and 71 deletions
|
@ -90,7 +90,7 @@ void CompDic::addLetter(wchar_t chr, int points, int frequency,
|
||||||
if (!iswalpha(chr) && chr != L'?')
|
if (!iswalpha(chr) && chr != L'?')
|
||||||
{
|
{
|
||||||
ostringstream ss;
|
ostringstream ss;
|
||||||
ss << fmt(_("'%1%' is not a valid letter.")) % convertToMb(chr) << endl;
|
ss << fmt(_("'%1%' is not a valid letter.")) % lfw(chr) << endl;
|
||||||
ss << fmt(_("For technical reasons, Eliot currently only supports "
|
ss << fmt(_("For technical reasons, Eliot currently only supports "
|
||||||
"alphabetical characters as internal character "
|
"alphabetical characters as internal character "
|
||||||
"representation, even if the tile has a display string "
|
"representation, even if the tile has a display string "
|
||||||
|
@ -324,7 +324,7 @@ Header CompDic::generateDawg(const string &iWordListFile,
|
||||||
const string &iDawgFile,
|
const string &iDawgFile,
|
||||||
const string &iDicName)
|
const string &iDicName)
|
||||||
{
|
{
|
||||||
m_headerInfo.dicName = convertToWc(iDicName);
|
m_headerInfo.dicName = wfl(iDicName);
|
||||||
// We are not (yet) able to build the GADDAG format
|
// We are not (yet) able to build the GADDAG format
|
||||||
m_headerInfo.dawg = true;
|
m_headerInfo.dawg = true;
|
||||||
|
|
||||||
|
|
|
@ -427,7 +427,7 @@ bool Dictionary::searchRegExp(const wstring &iRegexp,
|
||||||
if (!parsingOk)
|
if (!parsingOk)
|
||||||
{
|
{
|
||||||
delete root;
|
delete root;
|
||||||
throw InvalidRegexpException(convertToMb(iRegexp));
|
throw InvalidRegexpException(lfw(iRegexp));
|
||||||
}
|
}
|
||||||
|
|
||||||
int ptl[REGEXP_MAX+1];
|
int ptl[REGEXP_MAX+1];
|
||||||
|
|
|
@ -220,7 +220,7 @@ Header::Header(const DictHeaderInfo &iInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_compressDate = time(NULL);
|
m_compressDate = time(NULL);
|
||||||
m_userHost = convertToWc(ELIOT_COMPILE_BY + string("@") + ELIOT_COMPILE_HOST);
|
m_userHost = wfl(ELIOT_COMPILE_BY + string("@") + ELIOT_COMPILE_HOST);
|
||||||
m_root = iInfo.root;
|
m_root = iInfo.root;
|
||||||
m_nbWords = iInfo.nwords;
|
m_nbWords = iInfo.nwords;
|
||||||
m_nodesUsed = iInfo.nodesused;
|
m_nodesUsed = iInfo.nodesused;
|
||||||
|
@ -307,7 +307,7 @@ unsigned int Header::getCodeFromChar(wchar_t iChar) const
|
||||||
char s[5];
|
char s[5];
|
||||||
sprintf(s, "%d", iChar);
|
sprintf(s, "%d", iChar);
|
||||||
format fmt(_("Header::getCodeFromChar: No code for letter '%1%' (val=%2%)"));
|
format fmt(_("Header::getCodeFromChar: No code for letter '%1%' (val=%2%)"));
|
||||||
fmt % convertToMb(iChar) % s;
|
fmt % lfw(iChar) % s;
|
||||||
throw DicException(fmt.str());
|
throw DicException(fmt.str());
|
||||||
}
|
}
|
||||||
return pair->second;
|
return pair->second;
|
||||||
|
@ -624,13 +624,13 @@ wstring Header::writeDisplayAndInput() const
|
||||||
void Header::print() const
|
void Header::print() const
|
||||||
{
|
{
|
||||||
#define fmt(x) boost::format(x)
|
#define fmt(x) boost::format(x)
|
||||||
cout << fmt(_("Dictionary name: %1%")) % convertToMb(m_dicName) << endl;
|
cout << fmt(_("Dictionary name: %1%")) % lfw(m_dicName) << endl;
|
||||||
char buf[150];
|
char buf[150];
|
||||||
strftime(buf, sizeof(buf), "%c", gmtime(&m_compressDate));
|
strftime(buf, sizeof(buf), "%c", gmtime(&m_compressDate));
|
||||||
cout << fmt(_("Compressed on: %1%")) % buf << endl;
|
cout << fmt(_("Compressed on: %1%")) % buf << endl;
|
||||||
cout << fmt(_("Compressed using a binary compiled by: %1%")) % convertToMb(m_userHost) << endl;
|
cout << fmt(_("Compressed using a binary compiled by: %1%")) % lfw(m_userHost) << endl;
|
||||||
cout << fmt(_("Dictionary type: %1%")) % (m_type == kDAWG ? "DAWG" : "GADDAG") << endl;
|
cout << fmt(_("Dictionary type: %1%")) % (m_type == kDAWG ? "DAWG" : "GADDAG") << endl;
|
||||||
cout << fmt(_("Letters: %1%")) % convertToMb(m_letters) << endl;
|
cout << fmt(_("Letters: %1%")) % lfw(m_letters) << endl;
|
||||||
cout << fmt(_("Number of letters: %1%")) % m_letters.size() << endl;
|
cout << fmt(_("Number of letters: %1%")) % m_letters.size() << endl;
|
||||||
cout << fmt(_("Number of words: %1%")) % m_nbWords << endl;
|
cout << fmt(_("Number of words: %1%")) % m_nbWords << endl;
|
||||||
long unsigned int size = sizeof(Dict_header_old) +
|
long unsigned int size = sizeof(Dict_header_old) +
|
||||||
|
@ -668,7 +668,7 @@ void Header::print() const
|
||||||
first = false;
|
first = false;
|
||||||
else
|
else
|
||||||
s += " ";
|
s += " ";
|
||||||
s += convertToMb(inputs[j]);
|
s += lfw(inputs[j]);
|
||||||
}
|
}
|
||||||
fmter % s;
|
fmter % s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ static void printDicRec(ostream &out, const Dictionary &iDic, const wchar_t * co
|
||||||
if (edge.term) /* edge points at a complete word */
|
if (edge.term) /* edge points at a complete word */
|
||||||
{
|
{
|
||||||
*s = '\0';
|
*s = '\0';
|
||||||
out << convertToMb(buf) << endl;
|
out << lfw(buf) << endl;
|
||||||
}
|
}
|
||||||
if (edge.ptr)
|
if (edge.ptr)
|
||||||
{ /* Compute index: is it non-zero ? */
|
{ /* Compute index: is it non-zero ? */
|
||||||
|
|
|
@ -94,12 +94,12 @@ int main(int argc, char* argv[])
|
||||||
vector<wstring> wordList;
|
vector<wstring> wordList;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dic.searchRegExp(convertToWc(line), wordList, 1, 15);
|
dic.searchRegExp(wfl(line), wordList, 1, 15);
|
||||||
cout << _("result:") << endl;
|
cout << _("result:") << endl;
|
||||||
vector<wstring>::const_iterator it;
|
vector<wstring>::const_iterator it;
|
||||||
for (it = wordList.begin(); it != wordList.end(); it++)
|
for (it = wordList.begin(); it != wordList.end(); it++)
|
||||||
{
|
{
|
||||||
cout << convertToMb(*it) << endl;
|
cout << lfw(*it) << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (InvalidRegexpException &e)
|
catch (InvalidRegexpException &e)
|
||||||
|
|
|
@ -58,7 +58,7 @@ Tile::Tile(wchar_t c)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ostringstream ss;
|
ostringstream ss;
|
||||||
ss << "Tile::Tile: Unknown character: " << convertToMb(c);
|
ss << "Tile::Tile: Unknown character: " << lfw(c);
|
||||||
throw DicException(ss.str());
|
throw DicException(ss.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ unsigned int Bag::getNbConsonants() const
|
||||||
void Bag::takeTile(const Tile &iTile)
|
void Bag::takeTile(const Tile &iTile)
|
||||||
{
|
{
|
||||||
ASSERT(in(iTile),
|
ASSERT(in(iTile),
|
||||||
"The bag does not contain the letter " + convertToMb(iTile.getDisplayStr()));
|
"The bag does not contain the letter " + lfw(iTile.getDisplayStr()));
|
||||||
|
|
||||||
m_tilesMap[iTile]--;
|
m_tilesMap[iTile]--;
|
||||||
m_ntiles--;
|
m_ntiles--;
|
||||||
|
@ -92,7 +92,7 @@ void Bag::takeTile(const Tile &iTile)
|
||||||
void Bag::replaceTile(const Tile &iTile)
|
void Bag::replaceTile(const Tile &iTile)
|
||||||
{
|
{
|
||||||
ASSERT(in(iTile) < iTile.maxNumber(),
|
ASSERT(in(iTile) < iTile.maxNumber(),
|
||||||
"Cannot replace tile: " + convertToMb(iTile.getDisplayStr()));
|
"Cannot replace tile: " + lfw(iTile.getDisplayStr()));
|
||||||
|
|
||||||
m_tilesMap[iTile]++;
|
m_tilesMap[iTile]++;
|
||||||
m_ntiles++;
|
m_ntiles++;
|
||||||
|
|
|
@ -76,7 +76,7 @@ void Coord::setFromString(const wstring &iWStr)
|
||||||
{
|
{
|
||||||
// TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
|
// TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
|
||||||
// Temporary implementation: convert the wchar_t* string into a char* one
|
// Temporary implementation: convert the wchar_t* string into a char* one
|
||||||
string iStr = convertToMb(iWStr);
|
string iStr = lfw(iWStr);
|
||||||
|
|
||||||
char l[4];
|
char l[4];
|
||||||
int col;
|
int col;
|
||||||
|
|
|
@ -187,7 +187,7 @@ void Duplicate::tryEndTurn()
|
||||||
|
|
||||||
void Duplicate::recordPlayerMove(const Move &iMove, Player &ioPlayer, bool isForHuman)
|
void Duplicate::recordPlayerMove(const Move &iMove, Player &ioPlayer, bool isForHuman)
|
||||||
{
|
{
|
||||||
LOG_INFO("Player " << ioPlayer.getId() << " plays: " << convertToMb(iMove.toString()));
|
LOG_INFO("Player " << ioPlayer.getId() << " plays: " << lfw(iMove.toString()));
|
||||||
Command *pCmd = new PlayerMoveCmd(ioPlayer, iMove);
|
Command *pCmd = new PlayerMoveCmd(ioPlayer, iMove);
|
||||||
pCmd->setAutoExecution(!isForHuman);
|
pCmd->setAutoExecution(!isForHuman);
|
||||||
accessNavigation().addAndExecute(pCmd);
|
accessNavigation().addAndExecute(pCmd);
|
||||||
|
|
|
@ -116,7 +116,7 @@ void FreeGame::playAI(unsigned int p)
|
||||||
void FreeGame::recordPlayerMove(const Move &iMove, Player &ioPlayer,
|
void FreeGame::recordPlayerMove(const Move &iMove, Player &ioPlayer,
|
||||||
bool isForHuman)
|
bool isForHuman)
|
||||||
{
|
{
|
||||||
LOG_INFO("Player " << ioPlayer.getId() << " plays: " << convertToMb(iMove.toString()));
|
LOG_INFO("Player " << ioPlayer.getId() << " plays: " << lfw(iMove.toString()));
|
||||||
Command *pCmd = new PlayerMoveCmd(ioPlayer, iMove);
|
Command *pCmd = new PlayerMoveCmd(ioPlayer, iMove);
|
||||||
pCmd->setAutoExecution(!isForHuman);
|
pCmd->setAutoExecution(!isForHuman);
|
||||||
accessNavigation().addAndExecute(pCmd);
|
accessNavigation().addAndExecute(pCmd);
|
||||||
|
|
|
@ -344,8 +344,8 @@ PlayedRack Game::helperSetRackRandom(const PlayedRack &iPld,
|
||||||
// Get the best word
|
// Get the best word
|
||||||
const Round & bestRound = res.get(0);
|
const Round & bestRound = res.get(0);
|
||||||
LOG_DEBUG("helperSetRackRandom(): initial rack: "
|
LOG_DEBUG("helperSetRackRandom(): initial rack: "
|
||||||
<< convertToMb(pld.toString()) << " (best word: "
|
<< lfw(pld.toString()) << " (best word: "
|
||||||
<< convertToMb(bestRound.getWord()) << ")");
|
<< lfw(bestRound.getWord()) << ")");
|
||||||
|
|
||||||
// Identify the joker
|
// Identify the joker
|
||||||
for (unsigned int i = 0; i < bestRound.getWordLen(); ++i)
|
for (unsigned int i = 0; i < bestRound.getWordLen(); ++i)
|
||||||
|
@ -355,7 +355,7 @@ PlayedRack Game::helperSetRackRandom(const PlayedRack &iPld,
|
||||||
const Tile &jokerTile = bestRound.getTile(i);
|
const Tile &jokerTile = bestRound.getTile(i);
|
||||||
Tile replacingTile(towupper(jokerTile.toChar()));
|
Tile replacingTile(towupper(jokerTile.toChar()));
|
||||||
LOG_DEBUG("helperSetRackRandom(): replacing Joker with "
|
LOG_DEBUG("helperSetRackRandom(): replacing Joker with "
|
||||||
<< convertToMb(replacingTile.toChar()));
|
<< lfw(replacingTile.toChar()));
|
||||||
|
|
||||||
// If the bag does not contain this letter anymore,
|
// If the bag does not contain this letter anymore,
|
||||||
// simply keep the joker in the rack.
|
// simply keep the joker in the rack.
|
||||||
|
@ -459,7 +459,7 @@ void Game::addPlayer(Player *iPlayer)
|
||||||
iPlayer->setId(getNPlayers());
|
iPlayer->setId(getNPlayers());
|
||||||
m_players.push_back(iPlayer);
|
m_players.push_back(iPlayer);
|
||||||
|
|
||||||
LOG_INFO("Adding player '" << convertToMb(iPlayer->getName())
|
LOG_INFO("Adding player '" << lfw(iPlayer->getName())
|
||||||
<< "' (" << (iPlayer->isHuman() ? "human" : "AI") << ")"
|
<< "' (" << (iPlayer->isHuman() ? "human" : "AI") << ")"
|
||||||
<< " with ID " << iPlayer->getId());
|
<< " with ID " << iPlayer->getId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,10 +152,10 @@ Game *GameFactory::createFromCmdLine(int argc, char **argv)
|
||||||
// TODO: use Boost.Format
|
// TODO: use Boost.Format
|
||||||
char s[200];
|
char s[200];
|
||||||
snprintf(s, 200, _("Player %u"), m_players.size() + 1);
|
snprintf(s, 200, _("Player %u"), m_players.size() + 1);
|
||||||
name = convertToWc(s);
|
name = wfl(s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
name = convertToWc(optarg);
|
name = wfl(optarg);
|
||||||
m_players.push_back(make_pair<bool, wstring>(res == 'u', name));
|
m_players.push_back(make_pair<bool, wstring>(res == 'u', name));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -128,7 +128,7 @@ Game* Game::gameLoadFormat_14(FILE *fin, const Dictionary& iDic)
|
||||||
|
|
||||||
/* rack */
|
/* rack */
|
||||||
strncpy(rack, token, sizeof(rack));
|
strncpy(rack, token, sizeof(rack));
|
||||||
static_cast<Training*>(pGame)->setRackManual(false, convertToWc(rack));
|
static_cast<Training*>(pGame)->setRackManual(false, wfl(rack));
|
||||||
|
|
||||||
/* word */
|
/* word */
|
||||||
token = strtok(NULL, delim);
|
token = strtok(NULL, delim);
|
||||||
|
@ -164,7 +164,7 @@ Game* Game::gameLoadFormat_14(FILE *fin, const Dictionary& iDic)
|
||||||
//debug("%s)", token);
|
//debug("%s)", token);
|
||||||
strncat(pos, token, sizeof(pos) - strlen(pos) - 1);
|
strncat(pos, token, sizeof(pos) - strlen(pos) - 1);
|
||||||
|
|
||||||
if ((ret = pGame->play(convertToWc(pos), convertToWc(word))))
|
if ((ret = pGame->play(wfl(pos), wfl(word))))
|
||||||
{
|
{
|
||||||
GameFactory::Instance()->releaseGame(*pGame);
|
GameFactory::Instance()->releaseGame(*pGame);
|
||||||
char tmp1[10];
|
char tmp1[10];
|
||||||
|
@ -327,11 +327,11 @@ Game* Game::gameLoadFormat_15(FILE *fin, const Dictionary& iDic)
|
||||||
|
|
||||||
// Build a rack for the correct player
|
// Build a rack for the correct player
|
||||||
PlayedRack pldrack;
|
PlayedRack pldrack;
|
||||||
if (!iDic.validateLetters(convertToWc(rack)))
|
if (!iDic.validateLetters(wfl(rack)))
|
||||||
{
|
{
|
||||||
throw GameException("Rack invalid for the current dictionary");
|
throw GameException("Rack invalid for the current dictionary");
|
||||||
}
|
}
|
||||||
pldrack.setManual(convertToWc(rack));
|
pldrack.setManual(wfl(rack));
|
||||||
|
|
||||||
// Build a round
|
// Build a round
|
||||||
Round round;
|
Round round;
|
||||||
|
@ -339,7 +339,7 @@ Game* Game::gameLoadFormat_15(FILE *fin, const Dictionary& iDic)
|
||||||
if (bonus == '*')
|
if (bonus == '*')
|
||||||
round.setBonus(1);
|
round.setBonus(1);
|
||||||
|
|
||||||
wstring word = convertToWc(tmpWord);
|
wstring word = wfl(tmpWord);
|
||||||
Tile tile;
|
Tile tile;
|
||||||
if (isalpha(ref[0]))
|
if (isalpha(ref[0]))
|
||||||
{
|
{
|
||||||
|
@ -411,7 +411,7 @@ Game* Game::gameLoadFormat_15(FILE *fin, const Dictionary& iDic)
|
||||||
{
|
{
|
||||||
// Create the played rack
|
// Create the played rack
|
||||||
PlayedRack pldrack;
|
PlayedRack pldrack;
|
||||||
pldrack.setManual(convertToWc(letters));
|
pldrack.setManual(wfl(letters));
|
||||||
// Give the rack to the player
|
// Give the rack to the player
|
||||||
pGame->m_players[nb]->setCurrentRack(pldrack);
|
pGame->m_players[nb]->setCurrentRack(pldrack);
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,7 +193,7 @@ void Navigation::print() const
|
||||||
int index = 0;
|
int index = 0;
|
||||||
BOOST_FOREACH(const Command *c, m_turnCommands)
|
BOOST_FOREACH(const Command *c, m_turnCommands)
|
||||||
{
|
{
|
||||||
LOG_DEBUG(index << " " << convertToMb(c->toString()));
|
LOG_DEBUG(index << " " << lfw(c->toString()));
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ Rack::Rack()
|
||||||
void Rack::remove(const Tile &t)
|
void Rack::remove(const Tile &t)
|
||||||
{
|
{
|
||||||
ASSERT(in(t),
|
ASSERT(in(t),
|
||||||
"The rack does not contain the letter " + convertToMb(t.getDisplayStr()));
|
"The rack does not contain the letter " + lfw(t.getDisplayStr()));
|
||||||
m_tiles[t.toCode()]--;
|
m_tiles[t.toCode()]--;
|
||||||
m_ntiles--;
|
m_ntiles--;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ int Training::play(const wstring &iCoord, const wstring &iWord)
|
||||||
|
|
||||||
void Training::recordPlayerMove(const Move &iMove, Player &ioPlayer)
|
void Training::recordPlayerMove(const Move &iMove, Player &ioPlayer)
|
||||||
{
|
{
|
||||||
LOG_INFO("Player " << ioPlayer.getId() << " plays: " << convertToMb(iMove.toString()));
|
LOG_INFO("Player " << ioPlayer.getId() << " plays: " << lfw(iMove.toString()));
|
||||||
// Update the rack and the score of the current player
|
// Update the rack and the score of the current player
|
||||||
// PlayerMoveCmd::execute() must be called before Game::helperPlayMove()
|
// PlayerMoveCmd::execute() must be called before Game::helperPlayMove()
|
||||||
// (called in this class in endTurn()).
|
// (called in this class in endTurn()).
|
||||||
|
@ -183,7 +183,7 @@ void Training::addPlayer(Player *iPlayer)
|
||||||
ASSERT(getNPlayers() == 0,
|
ASSERT(getNPlayers() == 0,
|
||||||
"Only one player can be added in Training mode");
|
"Only one player can be added in Training mode");
|
||||||
// Force the name of the player
|
// Force the name of the player
|
||||||
iPlayer->setName(convertToWc(_("Training")));
|
iPlayer->setName(wfl(_("Training")));
|
||||||
Game::addPlayer(iPlayer);
|
Game::addPlayer(iPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -284,12 +284,12 @@ void XmlReader::endElement(const string& namespaceURI,
|
||||||
throw LoadGameException("Rack invalid for the current dictionary: " + m_data);
|
throw LoadGameException("Rack invalid for the current dictionary: " + m_data);
|
||||||
}
|
}
|
||||||
pldrack.setManual(rackStr);
|
pldrack.setManual(rackStr);
|
||||||
LOG_DEBUG("loaded rack: " << convertToMb(pldrack.toString()));
|
LOG_DEBUG("loaded rack: " << lfw(pldrack.toString()));
|
||||||
|
|
||||||
Player &p = getPlayer(m_players, m_attributes["playerid"]);
|
Player &p = getPlayer(m_players, m_attributes["playerid"]);
|
||||||
PlayerRackCmd *cmd = new PlayerRackCmd(p, pldrack);
|
PlayerRackCmd *cmd = new PlayerRackCmd(p, pldrack);
|
||||||
m_game->accessNavigation().addAndExecute(cmd);
|
m_game->accessNavigation().addAndExecute(cmd);
|
||||||
LOG_DEBUG("rack: " << convertToMb(pldrack.toString()));
|
LOG_DEBUG("rack: " << lfw(pldrack.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (tag == "PlayerMove")
|
else if (tag == "PlayerMove")
|
||||||
|
|
|
@ -77,7 +77,7 @@ static void writeMove(ostream &out, const Move &iMove,
|
||||||
else if (iMove.getType() == Move::PASS)
|
else if (iMove.getType() == Move::PASS)
|
||||||
out << "pass\" />";
|
out << "pass\" />";
|
||||||
else
|
else
|
||||||
throw SaveGameException("Unsupported move: " + convertToMb(iMove.toString()));
|
throw SaveGameException("Unsupported move: " + lfw(iMove.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlWriter::write(const Game &iGame, const string &iFileName)
|
void XmlWriter::write(const Game &iGame, const string &iFileName)
|
||||||
|
@ -197,7 +197,7 @@ void XmlWriter::write(const Game &iGame, const string &iFileName)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// XXX
|
// XXX
|
||||||
//throw SaveGameException("Unsupported command: " + convertToMb(cmd->toString()));
|
//throw SaveGameException("Unsupported command: " + lfw(cmd->toString()));
|
||||||
}
|
}
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,9 +376,9 @@ void commonCommands(PublicGame &iGame, const vector<wstring> &tokens)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (iGame.getDic().searchWord(word))
|
if (iGame.getDic().searchWord(word))
|
||||||
printf("le mot -%s- existe\n", convertToMb(word).c_str());
|
printf("le mot -%s- existe\n", lfw(word).c_str());
|
||||||
else
|
else
|
||||||
printf("le mot -%s- n'existe pas\n", convertToMb(word).c_str());
|
printf("le mot -%s- n'existe pas\n", lfw(word).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tokens[0][0] == L'h')
|
else if (tokens[0][0] == L'h')
|
||||||
|
@ -431,7 +431,7 @@ void commonCommands(PublicGame &iGame, const vector<wstring> &tokens)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
iGame.save(convertToMb(word));
|
iGame.save(lfw(word));
|
||||||
}
|
}
|
||||||
catch (std::exception &e)
|
catch (std::exception &e)
|
||||||
{
|
{
|
||||||
|
@ -477,7 +477,7 @@ void handleRegexp(const Dictionary& iDic, const vector<wstring> &tokens)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("search for %s (%d,%d,%d)\n", convertToMb(regexp).c_str(),
|
printf("search for %s (%d,%d,%d)\n", lfw(regexp).c_str(),
|
||||||
nres, lmin, lmax);
|
nres, lmin, lmax);
|
||||||
|
|
||||||
vector<wdstring> wordList;
|
vector<wdstring> wordList;
|
||||||
|
@ -493,7 +493,7 @@ void handleRegexp(const Dictionary& iDic, const vector<wstring> &tokens)
|
||||||
|
|
||||||
BOOST_FOREACH(const wdstring &wstr, wordList)
|
BOOST_FOREACH(const wdstring &wstr, wordList)
|
||||||
{
|
{
|
||||||
printf("%s\n", convertToMb(wstr).c_str());
|
printf("%s\n", lfw(wstr).c_str());
|
||||||
}
|
}
|
||||||
printf("%lu printed results\n", (long unsigned)wordList.size());
|
printf("%lu printed results\n", (long unsigned)wordList.size());
|
||||||
}
|
}
|
||||||
|
@ -518,7 +518,7 @@ void setSetting(const vector<wstring> &tokens)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string setting = convertToMb(settingWide);
|
string setting = lfw(settingWide);
|
||||||
if (type == L"i")
|
if (type == L"i")
|
||||||
{
|
{
|
||||||
Settings::Instance().setInt(setting, wtoi(value.c_str()));
|
Settings::Instance().setInt(setting, wtoi(value.c_str()));
|
||||||
|
@ -596,7 +596,7 @@ void loopTraining(PublicGame &iGame)
|
||||||
vector<wdstring> wordList;
|
vector<wdstring> wordList;
|
||||||
iGame.getDic().searchBenj(word, wordList);
|
iGame.getDic().searchBenj(word, wordList);
|
||||||
BOOST_FOREACH(const wdstring &wstr, wordList)
|
BOOST_FOREACH(const wdstring &wstr, wordList)
|
||||||
cout << convertToMb(wstr) << endl;
|
cout << lfw(wstr) << endl;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case L'p':
|
case L'p':
|
||||||
|
@ -607,10 +607,10 @@ void loopTraining(PublicGame &iGame)
|
||||||
for (it = wordMap.begin(); it != wordMap.end(); ++it)
|
for (it = wordMap.begin(); it != wordMap.end(); ++it)
|
||||||
{
|
{
|
||||||
if (it->first != 0)
|
if (it->first != 0)
|
||||||
cout << "+" << convertToMb(iGame.getDic().getHeader().getDisplayStr(it->first)) << endl;
|
cout << "+" << lfw(iGame.getDic().getHeader().getDisplayStr(it->first)) << endl;
|
||||||
BOOST_FOREACH(const wdstring &wstr, it->second)
|
BOOST_FOREACH(const wdstring &wstr, it->second)
|
||||||
{
|
{
|
||||||
cout << " " << convertToMb(wstr) << endl;
|
cout << " " << lfw(wstr) << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -620,7 +620,7 @@ void loopTraining(PublicGame &iGame)
|
||||||
vector<wdstring> wordList;
|
vector<wdstring> wordList;
|
||||||
iGame.getDic().searchRacc(word, wordList);
|
iGame.getDic().searchRacc(word, wordList);
|
||||||
BOOST_FOREACH(const wdstring &wstr, wordList)
|
BOOST_FOREACH(const wdstring &wstr, wordList)
|
||||||
cout << convertToMb(wstr) << endl;
|
cout << lfw(wstr) << endl;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -861,7 +861,7 @@ void mainLoop(const Dictionary &iDic)
|
||||||
const wstring &wfileName = checkFileNameToken(tokens, 1);
|
const wstring &wfileName = checkFileNameToken(tokens, 1);
|
||||||
if (wfileName != L"")
|
if (wfileName != L"")
|
||||||
{
|
{
|
||||||
string filename = convertToMb(wfileName);
|
string filename = lfw(wfileName);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PublicGame *game = PublicGame::load(filename, iDic);
|
PublicGame *game = PublicGame::load(filename, iDic);
|
||||||
|
|
|
@ -115,7 +115,7 @@ void GameIO::printBoardJoker(ostream &out, const PublicGame &iGame)
|
||||||
{
|
{
|
||||||
bool j = iGame.getBoard().isJoker(row, col);
|
bool j = iGame.getBoard().isJoker(row, col);
|
||||||
out << (j ? " ." : " ")
|
out << (j ? " ." : " ")
|
||||||
<< convertToMb(iGame.getBoard().getDisplayStr(row, col));
|
<< lfw(iGame.getBoard().getDisplayStr(row, col));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out << endl;
|
out << endl;
|
||||||
|
@ -183,7 +183,7 @@ void GameIO::printBoardMultipliers2(ostream &out, const PublicGame &iGame)
|
||||||
if (iGame.getBoard().isVacant(row, col))
|
if (iGame.getBoard().isVacant(row, col))
|
||||||
out << "-";
|
out << "-";
|
||||||
else
|
else
|
||||||
out << convertToMb(iGame.getBoard().getDisplayStr(row, col));
|
out << lfw(iGame.getBoard().getDisplayStr(row, col));
|
||||||
}
|
}
|
||||||
out << endl;
|
out << endl;
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ void GameIO::printNonPlayed(ostream &out, const PublicGame &iGame)
|
||||||
{
|
{
|
||||||
if (bag.in(tile) > 9)
|
if (bag.in(tile) > 9)
|
||||||
out << " ";
|
out << " ";
|
||||||
out << setw(2) << convertToMb(tile.getDisplayStr());
|
out << setw(2) << lfw(tile.getDisplayStr());
|
||||||
}
|
}
|
||||||
out << endl;
|
out << endl;
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ void GameIO::printNonPlayed(ostream &out, const PublicGame &iGame)
|
||||||
|
|
||||||
void GameIO::printPlayedRack(ostream &out, const PublicGame &iGame, int __UNUSED__ n)
|
void GameIO::printPlayedRack(ostream &out, const PublicGame &iGame, int __UNUSED__ n)
|
||||||
{
|
{
|
||||||
out << convertToMb(iGame.getCurrentPlayer().getCurrentRack().toString(PlayedRack::RACK_SIMPLE)) << endl;
|
out << lfw(iGame.getCurrentPlayer().getCurrentRack().toString(PlayedRack::RACK_SIMPLE)) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ void GameIO::printAllRacks(ostream &out, const PublicGame &iGame)
|
||||||
for (unsigned int j = 0; j < iGame.getNbPlayers(); j++)
|
for (unsigned int j = 0; j < iGame.getNbPlayers(); j++)
|
||||||
{
|
{
|
||||||
out << "Rack " << j << ": ";
|
out << "Rack " << j << ": ";
|
||||||
out << convertToMb(iGame.getPlayer(j).getCurrentRack().toString(PlayedRack::RACK_EXTRA)) << endl;
|
out << lfw(iGame.getPlayer(j).getCurrentRack().toString(PlayedRack::RACK_EXTRA)) << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,10 +231,10 @@ static void searchResultLine(ostream &out, const Results &iResults, int num)
|
||||||
const wstring &word = r.getWord();
|
const wstring &word = r.getWord();
|
||||||
if (word.empty())
|
if (word.empty())
|
||||||
return;
|
return;
|
||||||
out << convertToMb(word) << string(16 - word.size(), ' ')
|
out << lfw(word) << string(16 - word.size(), ' ')
|
||||||
<< (r.getBonus() ? '*' : ' ')
|
<< (r.getBonus() ? '*' : ' ')
|
||||||
<< setw(4) << r.getPoints()
|
<< setw(4) << r.getPoints()
|
||||||
<< ' ' << convertToMb(r.getCoord().toString());
|
<< ' ' << lfw(r.getCoord().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -257,12 +257,12 @@ void CursesIntf::drawBoard(WINDOW *win, int y, int x) const
|
||||||
if (m_game->getBoard().isJoker(row, col))
|
if (m_game->getBoard().isJoker(row, col))
|
||||||
{
|
{
|
||||||
wattron(win, A_BOLD | COLOR_PAIR(COLOR_GREEN));
|
wattron(win, A_BOLD | COLOR_PAIR(COLOR_GREEN));
|
||||||
mvwprintw(win, y + row + 1, x + 3 * col + 2 + offset, convertToMb(chr).c_str());
|
mvwprintw(win, y + row + 1, x + 3 * col + 2 + offset, lfw(chr).c_str());
|
||||||
wattroff(win, A_BOLD);
|
wattroff(win, A_BOLD);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mvwprintw(win, y + row + 1, x + 3 * col + 2 + offset, convertToMb(chr).c_str());
|
mvwprintw(win, y + row + 1, x + 3 * col + 2 + offset, lfw(chr).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -298,7 +298,7 @@ void CursesIntf::drawScoresRacks(WINDOW *win, int y, int x) const
|
||||||
if (m_game->getMode() != PublicGame::kTRAINING && i == currId)
|
if (m_game->getMode() != PublicGame::kTRAINING && i == currId)
|
||||||
attron(A_BOLD);
|
attron(A_BOLD);
|
||||||
mvwprintw(win, y + i + 1, x + 2, _("%s: %d"),
|
mvwprintw(win, y + i + 1, x + 2, _("%s: %d"),
|
||||||
truncOrPad(convertToMb(m_game->getPlayer(i).getName()),
|
truncOrPad(lfw(m_game->getPlayer(i).getName()),
|
||||||
maxForScores).c_str(),
|
maxForScores).c_str(),
|
||||||
m_game->getPlayer(i).getPoints());
|
m_game->getPlayer(i).getPoints());
|
||||||
if (m_game->getMode() != PublicGame::kTRAINING && i == currId)
|
if (m_game->getMode() != PublicGame::kTRAINING && i == currId)
|
||||||
|
@ -320,7 +320,7 @@ void CursesIntf::drawScoresRacks(WINDOW *win, int y, int x) const
|
||||||
attron(A_BOLD);
|
attron(A_BOLD);
|
||||||
wstring rack = m_game->getPlayer(i).getCurrentRack().toString(PlayedRack::RACK_SIMPLE);
|
wstring rack = m_game->getPlayer(i).getCurrentRack().toString(PlayedRack::RACK_SIMPLE);
|
||||||
mvwprintw(win, y + yOff + i + 1, x + 2, _("%s: %ls"),
|
mvwprintw(win, y + yOff + i + 1, x + 2, _("%s: %ls"),
|
||||||
truncOrPad(convertToMb(m_game->getPlayer(i).getName()),
|
truncOrPad(lfw(m_game->getPlayer(i).getName()),
|
||||||
maxForRacks).c_str(),
|
maxForRacks).c_str(),
|
||||||
rack.c_str());
|
rack.c_str());
|
||||||
if (m_game->getMode() != PublicGame::kTRAINING && i == currId)
|
if (m_game->getMode() != PublicGame::kTRAINING && i == currId)
|
||||||
|
@ -359,7 +359,7 @@ void CursesIntf::drawResults(Box &ioBox) const
|
||||||
ioBox.printDataLine(i, x, "%3d %s %3s",
|
ioBox.printDataLine(i, x, "%3d %s %3s",
|
||||||
r.getPoints(),
|
r.getPoints(),
|
||||||
padAndConvert(r.getWord(), ioBox.getWidth() - 9, false).c_str(),
|
padAndConvert(r.getWord(), ioBox.getWidth() - 9, false).c_str(),
|
||||||
convertToMb(coord).c_str());
|
lfw(coord).c_str());
|
||||||
}
|
}
|
||||||
// Complete the list with empty lines, to avoid trails
|
// Complete the list with empty lines, to avoid trails
|
||||||
for (; i < (unsigned int)ioBox.getLastLine(); i++)
|
for (; i < (unsigned int)ioBox.getLastLine(); i++)
|
||||||
|
@ -419,7 +419,7 @@ void CursesIntf::drawHistory(Box &ioBox) const
|
||||||
// The move corresponds to a passed turn or changed letters
|
// The move corresponds to a passed turn or changed letters
|
||||||
wstring action;
|
wstring action;
|
||||||
if (m.getType() == Move::PASS)
|
if (m.getType() == Move::PASS)
|
||||||
action = convertToWc(_("(PASS)"));
|
action = wfl(_("(PASS)"));
|
||||||
else if (m.getType() == Move::CHANGE_LETTERS)
|
else if (m.getType() == Move::CHANGE_LETTERS)
|
||||||
action = L"(-" + m.getChangedLetters() + L")";
|
action = L"(-" + m.getChangedLetters() + L")";
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ void CursesIntf::drawBag(Box &ioBox) const
|
||||||
padAndConvert(allTiles[i].getDisplayStr(), 2).c_str(),
|
padAndConvert(allTiles[i].getDisplayStr(), 2).c_str(),
|
||||||
allTiles[i].getPoints(),
|
allTiles[i].getPoints(),
|
||||||
allTiles[i].maxNumber(),
|
allTiles[i].maxNumber(),
|
||||||
convertToMb(str).c_str());
|
lfw(str).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
int nbLines = min(i + 2 - ioBox.getFirstLine(),
|
int nbLines = min(i + 2 - ioBox.getFirstLine(),
|
||||||
|
@ -620,7 +620,7 @@ void CursesIntf::saveGame(WINDOW *win, int y, int x)
|
||||||
char s[100];
|
char s[100];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_game->save(convertToMb(filename));
|
m_game->save(lfw(filename));
|
||||||
snprintf(s, 100, _("Game saved in '%ls'"), filename.c_str());
|
snprintf(s, 100, _("Game saved in '%ls'"), filename.c_str());
|
||||||
drawStatus(win, s, false);
|
drawStatus(win, s, false);
|
||||||
}
|
}
|
||||||
|
@ -646,7 +646,7 @@ void CursesIntf::loadGame(WINDOW *win, int y, int x)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PublicGame *loaded = PublicGame::load(convertToMb(filename), m_game->getDic());
|
PublicGame *loaded = PublicGame::load(lfw(filename), m_game->getDic());
|
||||||
//GameFactory::Instance()->releaseGame(*m_game);
|
//GameFactory::Instance()->releaseGame(*m_game);
|
||||||
delete m_game;
|
delete m_game;
|
||||||
m_game = loaded;
|
m_game = loaded;
|
||||||
|
@ -751,7 +751,7 @@ bool CursesIntf::readString(WINDOW *win, int y, int x, int n, wstring &oString,
|
||||||
int len = pos;
|
int len = pos;
|
||||||
x = x0;
|
x = x0;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
mvwprintw(win, y, x0, "%s", convertToMb(oString + wstring(len, L' ')).c_str());
|
mvwprintw(win, y, x0, "%s", lfw(oString + wstring(len, L' ')).c_str());
|
||||||
wmove(win, y, x);
|
wmove(win, y, x);
|
||||||
}
|
}
|
||||||
else if (res == KEY_CODE_YES)
|
else if (res == KEY_CODE_YES)
|
||||||
|
@ -761,13 +761,13 @@ bool CursesIntf::readString(WINDOW *win, int y, int x, int n, wstring &oString,
|
||||||
x--;
|
x--;
|
||||||
pos--;
|
pos--;
|
||||||
oString.erase(pos, 1);
|
oString.erase(pos, 1);
|
||||||
mvwprintw(win, y, x0, "%s", convertToMb(oString + L" ").c_str());
|
mvwprintw(win, y, x0, "%s", lfw(oString + L" ").c_str());
|
||||||
wmove(win, y, x);
|
wmove(win, y, x);
|
||||||
}
|
}
|
||||||
else if (c == KEY_DC)
|
else if (c == KEY_DC)
|
||||||
{
|
{
|
||||||
oString.erase(pos, 1);
|
oString.erase(pos, 1);
|
||||||
mvwprintw(win, y, x0, "%s", convertToMb(oString + L" ").c_str());
|
mvwprintw(win, y, x0, "%s", lfw(oString + L" ").c_str());
|
||||||
wmove(win, y, x);
|
wmove(win, y, x);
|
||||||
}
|
}
|
||||||
else if (c == KEY_LEFT && pos != 0)
|
else if (c == KEY_LEFT && pos != 0)
|
||||||
|
@ -801,14 +801,14 @@ bool CursesIntf::readString(WINDOW *win, int y, int x, int n, wstring &oString,
|
||||||
{
|
{
|
||||||
x++;
|
x++;
|
||||||
oString.insert(pos++, 1, c);
|
oString.insert(pos++, 1, c);
|
||||||
mvwprintw(win, y, x0, "%s", convertToMb(oString).c_str());
|
mvwprintw(win, y, x0, "%s", lfw(oString).c_str());
|
||||||
wmove(win, y, x);
|
wmove(win, y, x);
|
||||||
}
|
}
|
||||||
else if (flag & kJOKER && c == L'?')
|
else if (flag & kJOKER && c == L'?')
|
||||||
{
|
{
|
||||||
x++;
|
x++;
|
||||||
oString.insert(pos++, 1, c);
|
oString.insert(pos++, 1, c);
|
||||||
mvwprintw(win, y, x0, "%s", convertToMb(oString).c_str());
|
mvwprintw(win, y, x0, "%s", lfw(oString).c_str());
|
||||||
wmove(win, y, x);
|
wmove(win, y, x);
|
||||||
}
|
}
|
||||||
else if (flag & kFILENAME)
|
else if (flag & kFILENAME)
|
||||||
|
@ -817,7 +817,7 @@ bool CursesIntf::readString(WINDOW *win, int y, int x, int n, wstring &oString,
|
||||||
{
|
{
|
||||||
x++;
|
x++;
|
||||||
oString += c;
|
oString += c;
|
||||||
mvwprintw(win, y, x0, "%s", convertToMb(oString).c_str());
|
mvwprintw(win, y, x0, "%s", lfw(oString).c_str());
|
||||||
wmove(win, y, x);
|
wmove(win, y, x);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue