Commit 96dbf1fd authored by Frederik Schwarzer's avatar Frederik Schwarzer

Merge two methods, they are shorter that way.

parent 956a62bf
...@@ -222,18 +222,7 @@ void Board::applyGravity() ...@@ -222,18 +222,7 @@ void Board::applyGravity()
if (!m_gravityFlag) { if (!m_gravityFlag) {
return; return;
} }
for (int i = 0; i < xTiles(); ++i) { for (int column = 0; column < xTiles(); ++column) {
if (applyGravity(i)) {
if (Prefs::sounds()) {
m_soundFall.start();
}
}
}
}
bool Board::applyGravity(int column)
{
bool isAffected = false;
int rptr = yTiles() - 1; int rptr = yTiles() - 1;
int wptr = yTiles() - 1; int wptr = yTiles() - 1;
while (rptr >= 0) { while (rptr >= 0) {
...@@ -248,13 +237,15 @@ bool Board::applyGravity(int column) ...@@ -248,13 +237,15 @@ bool Board::applyGravity(int column)
updateField(TilePos(column, wptr)); updateField(TilePos(column, wptr));
--wptr; --wptr;
--rptr; --rptr;
isAffected = true; if (Prefs::sounds()) {
m_soundFall.start();
}
} else { } else {
--rptr; --rptr;
} }
} }
} }
return isAffected; }
} }
void Board::unmarkTile() void Board::unmarkTile()
......
...@@ -266,12 +266,6 @@ private: // functions ...@@ -266,12 +266,6 @@ private: // functions
*/ */
void applyGravity(); void applyGravity();
/** Applies gravity to the given column and returns whether it was affected.
* @param column The column to check
* @return If column was affected.
*/
bool applyGravity(int column);
/** Returns True if @p tilePos is a valid position on Board. /** Returns True if @p tilePos is a valid position on Board.
* @return Wether @p tiePos is valid. * @return Wether @p tiePos is valid.
*/ */
......
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