diff --git a/dic/csv_helper.cpp b/dic/csv_helper.cpp index 13f56df..1188fbc 100644 --- a/dic/csv_helper.cpp +++ b/dic/csv_helper.cpp @@ -114,8 +114,8 @@ vector 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()); diff --git a/game/board.cpp b/game/board.cpp index aff50ec..78084e5 100644 --- a/game/board.cpp +++ b/game/board.cpp @@ -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 } diff --git a/game/board.h b/game/board.h index 4d1c1e3..249c7a2 100644 --- a/game/board.h +++ b/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 &iTilesMx, const Matrix &iCrossMx, const Matrix &iPointsMx, diff --git a/game/board_cross.cpp b/game/board_cross.cpp index ba55a1d..2ef2fce 100644 --- a/game/board_cross.cpp +++ b/game/board_cross.cpp @@ -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; diff --git a/game/board_search.cpp b/game/board_search.cpp index ad7b882..bb43f12 100644 --- a/game/board_search.cpp +++ b/game/board_search.cpp @@ -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