mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-18 10:26:15 +01:00
Various minor improvements (no functional change)
This commit is contained in:
parent
25f3bccdd1
commit
cbdf6d010d
5 changed files with 20 additions and 23 deletions
|
@ -114,8 +114,8 @@ vector<CsvHelper::DataRow> CsvHelper::readStream(istream &input)
|
||||||
maxLength = row.size();
|
maxLength = row.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalization (to be tolerant to faulty inputs)
|
// Make sure we have a constant number of fields on the lines
|
||||||
if (minLength != maxLength)
|
if (!data.empty() && minLength != maxLength)
|
||||||
{
|
{
|
||||||
boost::format fmt(_("Invalid CSV file (variable number of fields, from %1% to %2%)"));
|
boost::format fmt(_("Invalid CSV file (variable number of fields, from %1% to %2%)"));
|
||||||
throw CsvException((fmt % minLength % maxLength).str());
|
throw CsvException((fmt % minLength % maxLength).str());
|
||||||
|
|
|
@ -514,10 +514,10 @@ void Board::checkDouble()
|
||||||
{
|
{
|
||||||
for (int col = BOARD_MIN; col <= BOARD_MAX; col++)
|
for (int col = BOARD_MIN; col <= BOARD_MAX; col++)
|
||||||
{
|
{
|
||||||
if (m_tilesRow[row][col] != m_tilesCol[col][row])
|
ASSERT(m_tilesRow[row][col] == m_tilesCol[col][row],
|
||||||
printf("tiles diff %d %d\n", row, col);
|
"Tiles inconsistency at " << row << "x" << col);
|
||||||
if (m_jokerRow[row][col] != m_jokerCol[col][row])
|
ASSERT(m_jokerRow[row][col] == m_jokerCol[col][row],
|
||||||
printf("joker diff %d %d\n", row, col);
|
"Jokers inconsistency at " << row << "x" << col);
|
||||||
// The crossckecks and the points have no reason to be the same
|
// The crossckecks and the points have no reason to be the same
|
||||||
// in both directions
|
// in both directions
|
||||||
}
|
}
|
||||||
|
|
10
game/board.h
10
game/board.h
|
@ -76,11 +76,6 @@ public:
|
||||||
void search(const Dictionary &iDic, const Rack &iRack, Results &oResults) const;
|
void search(const Dictionary &iDic, const Rack &iRack, Results &oResults) const;
|
||||||
void searchFirst(const Dictionary &iDic, const Rack &iRack, Results &oResults) const;
|
void searchFirst(const Dictionary &iDic, const Rack &iRack, Results &oResults) const;
|
||||||
|
|
||||||
/**
|
|
||||||
* board_cross.c
|
|
||||||
*/
|
|
||||||
void buildCross(const Dictionary &iDic);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -117,6 +112,11 @@ private:
|
||||||
static const int m_tileMultipliers[BOARD_REALDIM][BOARD_REALDIM];
|
static const int m_tileMultipliers[BOARD_REALDIM][BOARD_REALDIM];
|
||||||
static const int m_wordMultipliers[BOARD_REALDIM][BOARD_REALDIM];
|
static const int m_wordMultipliers[BOARD_REALDIM][BOARD_REALDIM];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* board_cross.c
|
||||||
|
*/
|
||||||
|
void buildCross(const Dictionary &iDic);
|
||||||
|
|
||||||
int checkRoundAux(const Matrix<Tile> &iTilesMx,
|
int checkRoundAux(const Matrix<Tile> &iTilesMx,
|
||||||
const Matrix<Cross> &iCrossMx,
|
const Matrix<Cross> &iCrossMx,
|
||||||
const Matrix<int> &iPointsMx,
|
const Matrix<int> &iPointsMx,
|
||||||
|
|
|
@ -46,21 +46,18 @@ static void Board_checkout_tile(const Dictionary &iDic,
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: create temporary strings until the dictionary uses Tile objects
|
// FIXME: create temporary strings until the dictionary uses Tile objects
|
||||||
wchar_t leftTiles [BOARD_DIM + 1];
|
wstring leftTiles;
|
||||||
wchar_t rightTiles[BOARD_DIM + 1];
|
wstring rightTiles;
|
||||||
|
|
||||||
for (int i = left; i < index; i++)
|
for (int i = left; i < index; i++)
|
||||||
leftTiles[i - left] = towupper(iTiles[i].toChar());
|
leftTiles.push_back(towupper(iTiles[i].toChar()));
|
||||||
leftTiles[index - left] = 0;
|
|
||||||
|
|
||||||
int i;
|
for (int i = index + 1; !iTiles[i].isEmpty(); i++)
|
||||||
for (i = index + 1; !iTiles[i].isEmpty(); i++)
|
rightTiles.push_back(towupper(iTiles[i].toChar()));
|
||||||
rightTiles[i - index - 1] = towupper(iTiles[i].toChar());
|
|
||||||
rightTiles[i - index - 1] = 0;
|
|
||||||
|
|
||||||
/* Tiles that can be played */
|
/* Tiles that can be played */
|
||||||
unsigned int node, succ;
|
unsigned int node, succ;
|
||||||
node = iDic.charLookup(iDic.getRoot(), leftTiles);
|
node = iDic.charLookup(iDic.getRoot(), leftTiles.c_str());
|
||||||
if (node == 0)
|
if (node == 0)
|
||||||
{
|
{
|
||||||
oCross.setNone();
|
oCross.setNone();
|
||||||
|
@ -69,7 +66,7 @@ static void Board_checkout_tile(const Dictionary &iDic,
|
||||||
|
|
||||||
for (succ = iDic.getSucc(node); succ; succ = iDic.getNext(succ))
|
for (succ = iDic.getSucc(node); succ; succ = iDic.getNext(succ))
|
||||||
{
|
{
|
||||||
if (iDic.isEndOfWord(iDic.charLookup(succ, rightTiles)))
|
if (iDic.isEndOfWord(iDic.charLookup(succ, rightTiles.c_str())))
|
||||||
oCross.insert(Tile(iDic.getChar(succ)));
|
oCross.insert(Tile(iDic.getChar(succ)));
|
||||||
if (iDic.isLast(succ))
|
if (iDic.isLast(succ))
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -83,13 +83,13 @@ void BoardSearch::search(Rack &iRack, Results &oResults, Coord::Direction iDir)
|
||||||
{
|
{
|
||||||
partialWord.accessCoord().setCol(lastanchor + 1);
|
partialWord.accessCoord().setCol(lastanchor + 1);
|
||||||
extendRight(iRack, partialWord, oResults,
|
extendRight(iRack, partialWord, oResults,
|
||||||
Dic_root(m_dic), row, lastanchor + 1, col);
|
m_dic.getRoot(), row, lastanchor + 1, col);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
partialWord.accessCoord().setCol(col);
|
partialWord.accessCoord().setCol(col);
|
||||||
leftPart(iRack, partialWord, oResults,
|
leftPart(iRack, partialWord, oResults,
|
||||||
Dic_root(m_dic), row, col, col - lastanchor - 1);
|
m_dic.getRoot(), row, col, col - lastanchor - 1);
|
||||||
}
|
}
|
||||||
lastanchor = col;
|
lastanchor = col;
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in a new issue