Commit a1e5a7e9 authored by Laurent Montel's avatar Laurent Montel 😁

Fix clazy warning

parent cb8883bf
......@@ -196,7 +196,7 @@ int Board::tiles() const
return m_field.size();
}
void Board::setField(TilePos const & tilePos, int value)
void Board::setField(TilePos tilePos, int value)
{
if (!isValidPos(tilePos)) {
qCCritical(KSHISEN_General) << "Attempted write to invalid field position:"
......@@ -208,7 +208,7 @@ void Board::setField(TilePos const & tilePos, int value)
m_field.at(tilePos.y() * xTiles() + tilePos.x()) = value;
}
int Board::field(TilePos const & tilePos) const
int Board::field(TilePos tilePos) const
{
if (!isValidPosWithOutline(tilePos)) {
qCCritical(KSHISEN_General) << "Attempted read from invalid field position:"
......@@ -574,7 +574,7 @@ bool Board::tilesMatch(int tile1, int tile2) const
return false;
}
bool Board::isTileHighlighted(TilePos const & tilePos) const
bool Board::isTileHighlighted(TilePos tilePos) const
{
if (tilePos.x() == m_markX && tilePos.y() == m_markY) {
return true;
......@@ -599,7 +599,7 @@ bool Board::isTileHighlighted(TilePos const & tilePos) const
return false;
}
void Board::repaintTile(TilePos const & tilePos)
void Board::repaintTile(TilePos tilePos)
{
auto const r = QRect(xOffset() + tilePos.x() * m_tiles.qWidth() * 2,
yOffset() + tilePos.y() * m_tiles.qHeight() * 2,
......@@ -707,7 +707,7 @@ void Board::paintEvent(QPaintEvent * e)
p.end();
}
void Board::reverseSlide(TilePos const & tilePos, Slide const & slide)
void Board::reverseSlide(TilePos tilePos, Slide const & slide)
{
// slide[XY]2 is the current location of the last tile to slide
// slide[XY]1 is its destination
......@@ -767,7 +767,7 @@ void Board::reverseSlide(TilePos const & tilePos, Slide const & slide)
}
}
void Board::performSlide(TilePos const & tilePos, Slide const & slide)
void Board::performSlide(TilePos tilePos, Slide const & slide)
{
// check if there is something to slide
if (slide.empty()) {
......@@ -892,7 +892,7 @@ void Board::performMove(PossibleMove & possibleMoves)
#endif
}
void Board::marked(TilePos const & tilePos)
void Board::marked(TilePos tilePos)
{
if (field(tilePos) == EMPTY) { // click on empty space on the board
if (m_possibleMoves.size() > 1) { // if the click is on any of the current possible moves, make that move
......@@ -1001,7 +1001,7 @@ void Board::clearHighlight()
}
}
bool Board::canMakePath(TilePos const & tilePos1, TilePos const & tilePos2) const
bool Board::canMakePath(TilePos tilePos1, TilePos tilePos2) const
{
if (tilePos1.x() == tilePos2.x()) {
for (auto i = qMin(tilePos1.y(), tilePos2.y()) + 1; i < qMax(tilePos1.y(), tilePos2.y()); ++i) {
......@@ -1024,7 +1024,7 @@ bool Board::canMakePath(TilePos const & tilePos1, TilePos const & tilePos2) cons
return false;
}
bool Board::canSlideTiles(TilePos const & tilePos1, TilePos const & tilePos2, Slide & slide) const
bool Board::canSlideTiles(TilePos tilePos1, TilePos tilePos2, Slide & slide) const
{
auto distance = -1;
slide.clear();
......@@ -1184,7 +1184,7 @@ bool Board::canSlideTiles(TilePos const & tilePos1, TilePos const & tilePos2, Sl
return false;
}
int Board::findPath(TilePos const & tilePos1, TilePos const & tilePos2, PossibleMoves & possibleMoves) const
int Board::findPath(TilePos tilePos1, TilePos tilePos2, PossibleMoves & possibleMoves) const
{
possibleMoves.clear();
......@@ -1217,7 +1217,7 @@ int Board::findPath(TilePos const & tilePos1, TilePos const & tilePos2, Possible
return numberOfPaths;
}
int Board::findSimplePath(TilePos const & tilePos1, TilePos const & tilePos2, PossibleMoves & possibleMoves) const
int Board::findSimplePath(TilePos tilePos1, TilePos tilePos2, PossibleMoves & possibleMoves) const
{
auto numberOfPaths = 0;
Path path;
......@@ -1366,7 +1366,7 @@ void Board::undrawConnection()
m_paintInProgress = false;
}
QPoint Board::midCoord(TilePos const & tilePos) const
QPoint Board::midCoord(TilePos tilePos) const
{
QPoint p;
auto const w = m_tiles.qWidth() * 2;
......@@ -1404,7 +1404,7 @@ int Board::delay() const
return m_delay;
}
void Board::madeMove(TilePos const & tilePos1, TilePos const & tilePos2, Slide slide)
void Board::madeMove(TilePos tilePos1, TilePos tilePos2, Slide slide)
{
std::unique_ptr<Move> move;
if (slide.empty()) {
......@@ -1956,7 +1956,7 @@ void Board::setSoundsEnabled(bool enabled)
Prefs::self()->save();
}
bool Board::isValidPos(TilePos const & tilePos) const
bool Board::isValidPos(TilePos tilePos) const
{
return tilePos.x() >= 0
&& tilePos.y() >= 0
......@@ -1964,7 +1964,7 @@ bool Board::isValidPos(TilePos const & tilePos) const
&& tilePos.y() < yTiles();
}
bool Board::isValidPosWithOutline(TilePos const & tilePos) const
bool Board::isValidPosWithOutline(TilePos tilePos) const
{
return tilePos.x() >= -1
&& tilePos.y() >= -1
......
......@@ -212,16 +212,16 @@ private: // functions
* @param tilePos Position to be modified.
* @param value Type of the tile to place.
*/
void setField(TilePos const & tilePos, int value);
void setField(TilePos tilePos, int value);
/** Returns the kind of tile residing at the given position @p tilePos
* @param TilePos Position to look at.
* @return Type of the tile.
*/
int field(TilePos const & tilePos) const;
int field(TilePos tilePos) const;
/** Repaints the area of the given @p TilePos.
* @param TilePos Position of the tile to repaint.
*/
void repaintTile(TilePos const & tilePos);
void repaintTile(TilePos tilePos);
void showInfoRect(QPainter &, const QString & message);
void drawTiles(QPainter &, QPaintEvent *);
void clearHighlight();
......@@ -237,14 +237,14 @@ private: // functions
* @param tilePos1 coordinates of the first tile
* @param tilePos2 coordinates of the second tile
*/
bool canMakePath(TilePos const & tilePos1, TilePos const & tilePos2) const;
bool canMakePath(TilePos tilePos1, TilePos tilePos2) const;
/** Checks if the tile at \p tilePos1 can be slid to \p tilePos2.
* @param tilePos1 coordinates of the slide's initial position
* @param tilePos2 coordinates of the slide's final position
* @param slide The movement of the last tile slid will be stored in @p slide
*/
bool canSlideTiles(TilePos const & tilePos1, TilePos const & tilePos2, Slide & slide) const;
bool canSlideTiles(TilePos tilePos1, TilePos tilePos2, Slide & slide) const;
/** Checks if a path between two tiles can be made with 2 or 3 lines.
* @param tilePos1 coordinates of the first tile
......@@ -252,7 +252,7 @@ private: // functions
* @param possibleMoves All the possible moves are stored here
* @return The number of paths found
*/
int findPath(TilePos const & tilePos1, TilePos const & tilePos2, PossibleMoves & possibleMoves) const;
int findPath(TilePos tilePos1, TilePos tilePos2, PossibleMoves & possibleMoves) const;
/** Find a path of 1 or 2 segments between tiles.
* @param tilePos1 coordinates of the first tile
......@@ -260,21 +260,21 @@ private: // functions
* @param possibleMoves all the possible moves are stored here
* @return The number of paths found
*/
int findSimplePath(TilePos const & tilePos1, TilePos const & tilePos2, PossibleMoves & possibleMoves) const;
int findSimplePath(TilePos tilePos1, TilePos tilePos2, PossibleMoves & possibleMoves) const;
void performMove(PossibleMove & possibleMoves);
void performSlide(TilePos const & tilePos, Slide const & slide);
void reverseSlide(TilePos const & tilePos, Slide const & slide);
bool isTileHighlighted(TilePos const & tilePos) const;
void performSlide(TilePos tilePos, Slide const & slide);
void reverseSlide(TilePos tilePos, Slide const & slide);
bool isTileHighlighted(TilePos tilePos) const;
void drawConnection();
void drawPossibleMoves(bool b);
/** Calculated the middle coordinates of the given tile position.
* @param tilePos tile position
* @return The middle coordinates of the tile at \p tilePos
*/
QPoint midCoord(TilePos const & tilePos) const;
QPoint midCoord(TilePos tilePos) const;
void unmarkTile();
void marked(TilePos const & tilePos);
void madeMove(TilePos const & tilePos1, TilePos const & tilePos2, Slide slide = Slide());
void marked(TilePos tilePos);
void madeMove(TilePos tilePos1, TilePos tilePos2, Slide slide = Slide());
/// Applies gravity to all columns.
void applyGravity();
......@@ -282,12 +282,12 @@ private: // functions
/** Returns True if @p tilePos is a valid position on Board.
* @return Whether @p tiePos is valid.
*/
bool isValidPos(TilePos const & tilePos) const;
bool isValidPos(TilePos tilePos) const;
/** Returns True if @p tilePos is a valid position on Board including outline.
* @return Whether @p tiePos is valid.
*/
bool isValidPosWithOutline(TilePos const & tilePos) const;
bool isValidPosWithOutline(TilePos tilePos) const;
/** Returns True if @p tile is of kind FLOWERS.
* @return Whether @p tile is within the range of the Flower tiles.
......
......@@ -21,7 +21,7 @@
namespace KShisen
{
Move::Move(TilePos const & tilePos1, TilePos const & tilePos2, int tile1, int tile2)
Move::Move(TilePos tilePos1, TilePos tilePos2, int tile1, int tile2)
: m_tilePos1(tilePos1)
, m_tilePos2(tilePos2)
, m_tile1(tile1)
......@@ -31,7 +31,7 @@ Move::Move(TilePos const & tilePos1, TilePos const & tilePos2, int tile1, int ti
{
}
Move::Move(TilePos const & tilePos1, TilePos const & tilePos2, int tile1, int tile2, Slide const & slide)
Move::Move(TilePos tilePos1, TilePos tilePos2, int tile1, int tile2, Slide const & slide)
: m_tilePos1(tilePos1)
, m_tilePos2(tilePos2)
, m_tile1(tile1)
......
......@@ -31,8 +31,8 @@ namespace KShisen
class Move
{
public:
Move(TilePos const & tilePos1, TilePos const & tilePos2, int tile1, int tile2);
Move(TilePos const & tilePos1, TilePos const & tilePos2, int tile1, int tile2, Slide const & slide);
Move(TilePos tilePos1, TilePos tilePos2, int tile1, int tile2);
Move(TilePos tilePos1, TilePos tilePos2, int tile1, int tile2, Slide const & slide);
int x1() const;
int y1() const;
......
......@@ -38,7 +38,7 @@ PossibleMove::PossibleMove(Path & path, Slide & slide)
{
}
bool PossibleMove::isInPath(TilePos const & tilePos) const
bool PossibleMove::isInPath(TilePos tilePos) const
{
if (tilePos.x() == m_path.back().x() && tilePos.y() == m_path.back().y()) {
return false;
......
......@@ -37,7 +37,7 @@ public:
explicit PossibleMove(Path & path);
PossibleMove(Path & path, Slide & slide);
bool isInPath(TilePos const & tilePos) const;
bool isInPath(TilePos tilePos) const;
void Debug() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment