summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederik Schwarzer <[email protected]>2016-05-10 20:10:53 +0200
committerFrederik Schwarzer <[email protected]>2016-05-10 20:10:53 +0200
commit763a4b5c8ad7b535dfa8c563efd5a0372fba948f (patch)
tree3cf72e68747affb6725846ac780e37abc07c3bdb
parent9186c005e29242ce195d34df6ac208cc1096282c (diff)
Get rid of parameter as it serves no purpose.
-rw-r--r--src/board.cpp44
-rw-r--r--src/board.h9
2 files changed, 24 insertions, 29 deletions
diff --git a/src/board.cpp b/src/board.cpp
index 62eae77..d46fdcb 100644
--- a/src/board.cpp
+++ b/src/board.cpp
@@ -217,13 +217,13 @@ int Board::field(TilePos const & tilePos) const
return m_field.at(tilePos.y() * xTiles() + tilePos.x());
}
-void Board::gravity(bool update)
+void Board::gravity()
{
if (!m_gravityFlag) {
return;
}
for (int i = 0; i < xTiles(); ++i) {
- if (gravity(i, update)) {
+ if (gravity(i)) {
if (Prefs::sounds()) {
m_soundFall.start();
}
@@ -231,30 +231,26 @@ void Board::gravity(bool update)
}
}
-bool Board::gravity(int column, bool update)
+bool Board::gravity(int column)
{
bool isAffected = false;
- if (m_gravityFlag) {
- int rptr = yTiles() - 1;
- int wptr = yTiles() - 1;
- while (rptr >= 0) {
- if (field(TilePos(column, wptr)) != EMPTY) {
- --rptr;
+ int rptr = yTiles() - 1;
+ int wptr = yTiles() - 1;
+ while (rptr >= 0) {
+ if (field(TilePos(column, wptr)) != EMPTY) {
+ --rptr;
+ --wptr;
+ } else {
+ if (field(TilePos(column, rptr)) != EMPTY) {
+ setField(TilePos(column, wptr), field(TilePos(column, rptr)));
+ setField(TilePos(column, rptr), EMPTY);
+ updateField(TilePos(column, rptr));
+ updateField(TilePos(column, wptr));
--wptr;
+ --rptr;
+ isAffected = true;
} else {
- if (field(TilePos(column, rptr)) != EMPTY) {
- setField(TilePos(column, wptr), field(TilePos(column, rptr)));
- setField(TilePos(column, rptr), EMPTY);
- isAffected = true;
- if (update) {
- updateField(TilePos(column, rptr));
- updateField(TilePos(column, wptr));
- }
- --wptr;
- --rptr;
- } else {
- --rptr;
- }
+ --rptr;
}
}
}
@@ -1336,7 +1332,7 @@ void Board::undrawConnection()
emit tileCountChanged();
}
- gravity(true); // why is this called here? (schwarzer)
+ gravity(); // why is this called here? (schwarzer)
// is already undrawn?
if (m_connection.empty()) {
@@ -1663,7 +1659,7 @@ void Board::redo()
setField(TilePos(move->x2(), move->y2()), EMPTY);
updateField(TilePos(move->x1(), move->y1()));
updateField(TilePos(move->x2(), move->y2()));
- gravity(true);
+ gravity();
m_undo.push_back(move);
emit changed();
}
diff --git a/src/board.h b/src/board.h
index 86b3060..fc1a35b 100644
--- a/src/board.h
+++ b/src/board.h
@@ -193,9 +193,9 @@ private slots:
/** Returns whether the given column is affected by gravity.
* @param column The column to check
- * @param update FIXME: What is it for?
+ * @return If column was affected.
*/
- bool gravity(int column, bool update);
+ bool gravity(int column);
protected:
virtual QSize sizeHint() const;
@@ -268,10 +268,9 @@ private: // functions
void marked(TilePos const & tilePos);
void madeMove(TilePos const & tilePos1, TilePos const & tilePos2, Path slide = Path());
- /** Checks all columns and populate the affected columns in m_gravCols.
- * @param update FIXME: What is it for?
+ /** Applies gravity to all columns.
*/
- void gravity(bool update);
+ void gravity();
/** Returns True if @p tilePos is a valid position on Board.
* @return Wether @p tiePos is valid.