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();
|
||||
}
|
||||
|
||||
// Normalization (to be tolerant to faulty inputs)
|
||||
if (minLength != maxLength)
|
||||
// Make sure we have a constant number of fields on the lines
|
||||
if (!data.empty() && minLength != maxLength)
|
||||
{
|
||||
boost::format fmt(_("Invalid CSV file (variable number of fields, from %1% to %2%)"));
|
||||
throw CsvException((fmt % minLength % maxLength).str());
|
||||
|
|
|
@ -514,10 +514,10 @@ void Board::checkDouble()
|
|||
{
|
||||
for (int col = BOARD_MIN; col <= BOARD_MAX; col++)
|
||||
{
|
||||
if (m_tilesRow[row][col] != m_tilesCol[col][row])
|
||||
printf("tiles diff %d %d\n", row, col);
|
||||
if (m_jokerRow[row][col] != m_jokerCol[col][row])
|
||||
printf("joker diff %d %d\n", row, col);
|
||||
ASSERT(m_tilesRow[row][col] == m_tilesCol[col][row],
|
||||
"Tiles inconsistency at " << row << "x" << col);
|
||||
ASSERT(m_jokerRow[row][col] == m_jokerCol[col][row],
|
||||
"Jokers inconsistency at " << row << "x" << col);
|
||||
// The crossckecks and the points have no reason to be the same
|
||||
// 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 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_wordMultipliers[BOARD_REALDIM][BOARD_REALDIM];
|
||||
|
||||
/**
|
||||
* board_cross.c
|
||||
*/
|
||||
void buildCross(const Dictionary &iDic);
|
||||
|
||||
int checkRoundAux(const Matrix<Tile> &iTilesMx,
|
||||
const Matrix<Cross> &iCrossMx,
|
||||
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
|
||||
wchar_t leftTiles [BOARD_DIM + 1];
|
||||
wchar_t rightTiles[BOARD_DIM + 1];
|
||||
wstring leftTiles;
|
||||
wstring rightTiles;
|
||||
|
||||
for (int i = left; i < index; i++)
|
||||
leftTiles[i - left] = towupper(iTiles[i].toChar());
|
||||
leftTiles[index - left] = 0;
|
||||
leftTiles.push_back(towupper(iTiles[i].toChar()));
|
||||
|
||||
int i;
|
||||
for (i = index + 1; !iTiles[i].isEmpty(); i++)
|
||||
rightTiles[i - index - 1] = towupper(iTiles[i].toChar());
|
||||
rightTiles[i - index - 1] = 0;
|
||||
for (int i = index + 1; !iTiles[i].isEmpty(); i++)
|
||||
rightTiles.push_back(towupper(iTiles[i].toChar()));
|
||||
|
||||
/* Tiles that can be played */
|
||||
unsigned int node, succ;
|
||||
node = iDic.charLookup(iDic.getRoot(), leftTiles);
|
||||
node = iDic.charLookup(iDic.getRoot(), leftTiles.c_str());
|
||||
if (node == 0)
|
||||
{
|
||||
oCross.setNone();
|
||||
|
@ -69,7 +66,7 @@ static void Board_checkout_tile(const Dictionary &iDic,
|
|||
|
||||
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)));
|
||||
if (iDic.isLast(succ))
|
||||
break;
|
||||
|
|
|
@ -83,13 +83,13 @@ void BoardSearch::search(Rack &iRack, Results &oResults, Coord::Direction iDir)
|
|||
{
|
||||
partialWord.accessCoord().setCol(lastanchor + 1);
|
||||
extendRight(iRack, partialWord, oResults,
|
||||
Dic_root(m_dic), row, lastanchor + 1, col);
|
||||
m_dic.getRoot(), row, lastanchor + 1, col);
|
||||
}
|
||||
else
|
||||
{
|
||||
partialWord.accessCoord().setCol(col);
|
||||
leftPart(iRack, partialWord, oResults,
|
||||
Dic_root(m_dic), row, col, col - lastanchor - 1);
|
||||
m_dic.getRoot(), row, col, col - lastanchor - 1);
|
||||
}
|
||||
lastanchor = col;
|
||||
#else
|
||||
|
|
Loading…
Reference in a new issue