Commit 1e87a918 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix clazy warning

parent 104c80e6
......@@ -35,7 +35,7 @@ struct PathNode
int G;
float H;
float F;
PathNode( const FieldPos& fpos, PathNode* p = nullptr, int g=0, int h=0 )
PathNode( FieldPos fpos, PathNode* p = nullptr, int g=0, int h=0 )
: pos(fpos), parent(p), G(g), H(h), F(g+h) { }
};
......@@ -43,7 +43,7 @@ struct PathNode
// returns:
// -1 - if position not found
// index of node in list if position is found
static inline int indexOfNodeWithPos( const FieldPos& pos, const QList<PathNode*>& list )
static inline int indexOfNodeWithPos( FieldPos pos, const QList<PathNode*>& list )
{
for(int i=0;i<list.count(); ++i)
if( list.at(i)->pos == pos )
......@@ -76,7 +76,7 @@ bool KLinesAnimator::isAnimating() const
|| m_removeTimeLine.state() == QTimeLine::Running);
}
bool KLinesAnimator::animateMove( const FieldPos& from, const FieldPos& to )
bool KLinesAnimator::animateMove( FieldPos from, FieldPos to )
{
findPath(from, to);
......@@ -186,7 +186,7 @@ void KLinesAnimator::bornAnimationFrame(int frame)
ball->color(), frame) );
}
void KLinesAnimator::findPath( const FieldPos& from, const FieldPos& to )
void KLinesAnimator::findPath( FieldPos from, FieldPos to )
{
// Implementation of A* pathfinding algorithm
// Thanks to Patrick Lester for excellent tutorial on gamedev.net.
......
......@@ -45,7 +45,7 @@ public:
*
* @return true is there exists a path (from,to), false otherwise
*/
bool animateMove( const FieldPos& from, const FieldPos& to );
bool animateMove(FieldPos from, FieldPos to );
/**
* Starts animation of ball deletion from field.
* Note that it doesn't do actual deletion - it just runs
......@@ -88,7 +88,7 @@ private:
/**
* Implements A* pathfinding algorithm.
*/
void findPath(const FieldPos& from, const FieldPos& to);
void findPath(FieldPos from, FieldPos to);
/**
* Timeline used to control movement animation
*/
......
......@@ -22,7 +22,7 @@
********************************************************************/
#ifndef COMMONDEFS_H
#define COMMONDEFS_H
#include <QObject>
enum BallColor { Blue=0, Brown, Cyan, Green, Red, Violet, Yellow, NumColors };
......@@ -32,10 +32,10 @@ struct FieldPos
int y;
FieldPos( int _x=-1, int _y=-1) : x(_x), y(_y) { }
bool isValid() const { return (x != -1 && y != -1); }
bool operator==(const FieldPos& other) const
bool operator==(FieldPos other) const
{
return (x == other.x && y == other.y);
}
};
Q_DECLARE_TYPEINFO(FieldPos, Q_MOVABLE_TYPE);
#endif
......@@ -126,7 +126,7 @@ QPixmap KLinesRenderer::backgroundTilePixmap()
return getPixmap(QStringLiteral("field_cell"));
}
QPixmap KLinesRenderer::backgroundPixmap(const QSize& size)
QPixmap KLinesRenderer::backgroundPixmap(QSize size)
{
return getPixmap(QStringLiteral("background"), size);
}
......@@ -160,7 +160,7 @@ void KLinesRenderer::setCellSize(int cellSize)
m_cellSize = cellSize;
}
QPixmap KLinesRenderer::getPixmap(const QString& svgName, const QSize& customSize)
QPixmap KLinesRenderer::getPixmap(const QString& svgName, QSize customSize)
{
if (m_cellSize == 0)
return QPixmap();
......@@ -172,7 +172,7 @@ QPixmap KLinesRenderer::getPixmap(const QString& svgName, const QSize& customSiz
return pix;
}
QPixmap KLinesRenderer::backgroundBorderPixmap(const QSize& size)
QPixmap KLinesRenderer::backgroundBorderPixmap(QSize size)
{
if (!hasBorderElement())
return QPixmap();
......
......@@ -68,14 +68,14 @@ public:
/**
* @return pixmap for background painting.
*/
static QPixmap backgroundPixmap(const QSize& size);
static QPixmap backgroundPixmap(QSize size);
/**
* @return pixmap for border surrounding the play field.
* Will return an invalid QPixmap if no such element exists
* in theme's svg file.
* @see hasBorderElement
*/
static QPixmap backgroundBorderPixmap(const QSize& size);
static QPixmap backgroundBorderPixmap(QSize size);
/**
* @return pixmap of background tile (cell)
*/
......@@ -152,7 +152,7 @@ private:
*
* @return rendered pixmap
*/
static QPixmap getPixmap(const QString& svgName, const QSize& customSize = QSize());
static QPixmap getPixmap(const QString& svgName, QSize customSize = QSize());
/**
* This is the size of the scene's cell.
......
......@@ -34,7 +34,7 @@
#include <KGamePopupItem>
#include <KLocalizedString>
inline uint qHash( const FieldPos& pos )
inline uint qHash( FieldPos pos )
{
return qHash( QPair<int,int>(pos.x,pos.y) );
}
......@@ -272,7 +272,7 @@ void KLinesScene::mousePressEvent( QGraphicsSceneMouseEvent* ev )
selectOrMove( pixToField(ev->scenePos()) );
}
void KLinesScene::selectOrMove( const FieldPos& fpos )
void KLinesScene::selectOrMove( FieldPos fpos )
{
if (fpos.x < 0 || fpos.y < 0) {
return;
......
......@@ -74,7 +74,7 @@ public:
* Returns ballitem in field position pos or 0 if there
* is no item there
*/
BallItem* ballAt( const FieldPos& pos ) { return m_field[pos.x][pos.y]; }
BallItem* ballAt( FieldPos pos ) { return m_field[pos.x][pos.y]; }
/**
* Overloaded above function
*/
......@@ -82,7 +82,7 @@ public:
/**
* Field coords to pixel coords
*/
inline QPointF fieldToPix(const FieldPos& fpos) const
inline QPointF fieldToPix(FieldPos fpos) const
{
return QPointF( m_playFieldRect.x() + m_playFieldBorderSize + fpos.x*m_cellSize,
m_playFieldRect.y() + m_playFieldBorderSize + fpos.y*m_cellSize );
......@@ -90,7 +90,7 @@ public:
/**
* Pixel coords to field coords
*/
inline FieldPos pixToField( const QPointF& p ) const
inline FieldPos pixToField( QPointF p ) const
{
return FieldPos(static_cast<int>(( p.x()-m_playFieldRect.x()-m_playFieldBorderSize )/m_cellSize),
static_cast<int>(( p.y()-m_playFieldRect.y()-m_playFieldBorderSize )/m_cellSize));
......@@ -158,7 +158,7 @@ private:
* a selected ball in some other cell it will be moved to fpos
* (if the move is possible, of course)
*/
void selectOrMove( const FieldPos& fpos );
void selectOrMove(FieldPos fpos );
/**
* Saves game state information to be used during undo
*/
......
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