fix some compiler warnings
All checks were successful
Linux arm64 / Build (push) Successful in 2m27s
All checks were successful
Linux arm64 / Build (push) Successful in 2m27s
This commit is contained in:
@@ -20,10 +20,10 @@ Board::Board(int width, int height) :
|
||||
}
|
||||
|
||||
void Board::changeBlock(const Position& position, Block block) {
|
||||
if (position.x < 0 || position.x >= this->width || position.y < 0) return;
|
||||
if (position.x < 0 || static_cast<unsigned>(position.x) >= this->width || position.y < 0) return;
|
||||
|
||||
// resize the grid if needed
|
||||
if (position.y >= this->grid.size()) {
|
||||
if (static_cast<unsigned>(position.y) >= this->grid.size()) {
|
||||
for (int j = this->grid.size(); j <= position.y; j++) {
|
||||
this->grid.push_back(this->emptyRow);
|
||||
}
|
||||
@@ -34,7 +34,7 @@ void Board::changeBlock(const Position& position, Block block) {
|
||||
|
||||
void Board::insertRow(int height, int holePosition, Block blockType) {
|
||||
std::vector<Block> insertedRow;
|
||||
for (int i = 0; i < this->width; i++) {
|
||||
for (unsigned i = 0; i < this->width; i++) {
|
||||
if (i == holePosition) {
|
||||
insertedRow.push_back(NOTHING);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ int Board::clearRows() {
|
||||
int clearedLines = 0;
|
||||
for (int j = this->grid.size() - 1; j >= 0; j--) {
|
||||
bool lineIsFull = true;
|
||||
int i = 0;
|
||||
unsigned i = 0;
|
||||
while (lineIsFull && (i < width)) {
|
||||
if (this->grid.at(j).at(i) == NOTHING) {
|
||||
lineIsFull = false;
|
||||
|
||||
@@ -13,8 +13,8 @@ class Board {
|
||||
private:
|
||||
std::vector<std::vector<Block>> grid; // the grid, (0,0) is downleft
|
||||
std::vector<Block> emptyRow; // an empty row of blocks
|
||||
int width; // the width of the grid
|
||||
int height; // the base height of the grid, which can extend indefinitely
|
||||
unsigned width; // the width of the grid
|
||||
unsigned height; // the base height of the grid, which can extend indefinitely
|
||||
|
||||
public:
|
||||
/**
|
||||
|
||||
@@ -27,12 +27,12 @@ PiecesList::PiecesList() {
|
||||
this->pushBackEmptyVectors();
|
||||
}
|
||||
|
||||
bool PiecesList::loadPieces(int max_size) {
|
||||
bool PiecesList::loadPieces(unsigned max_size) {
|
||||
if (max_size < 1) return false;
|
||||
if (max_size <= this->highestLoadedSize) return true;
|
||||
|
||||
PiecesFiles piecesFiles;
|
||||
for (int i = this->highestLoadedSize + 1; i <= max_size; i++) {
|
||||
for (unsigned i = this->highestLoadedSize + 1; i <= max_size; i++) {
|
||||
if (!piecesFiles.loadPieces(i, this->loadedPieces.at(i), this->convexPieces.at(i), this->holelessPieces.at(i), this->otherPieces.at(i))) {
|
||||
return false;
|
||||
}
|
||||
@@ -45,14 +45,14 @@ bool PiecesList::loadPieces(int max_size) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PiecesList::selectPiece(int size, int number) {
|
||||
bool PiecesList::selectPiece(unsigned size, unsigned number) {
|
||||
if (size < 1 || size > this->highestLoadedSize || number >= this->loadedPieces.at(size).size()) return false;
|
||||
|
||||
this->selectedPieces.push_back(std::pair<int, int>(size, number));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PiecesList::selectAllPieces(int size) {
|
||||
bool PiecesList::selectAllPieces(unsigned size) {
|
||||
if (size < 1 || size > this->highestLoadedSize) return false;
|
||||
|
||||
for (int i = 0; i < this->loadedPieces.at(size).size(); i++) {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
class PiecesList {
|
||||
private:
|
||||
int highestLoadedSize; // the highest size of pieces currently loaded
|
||||
unsigned highestLoadedSize; // the highest size of pieces currently loaded
|
||||
std::vector<std::vector<Piece>> loadedPieces; // every loaded pieces by size
|
||||
std::vector<std::vector<int>> convexPieces; // the list of convex loaded pieces by size
|
||||
std::vector<std::vector<int>> holelessPieces; // the list of holeless loaded pieces by size
|
||||
@@ -33,19 +33,19 @@ class PiecesList {
|
||||
* Makes the list load all pieces up to the specified size
|
||||
* @return If all pieces up to the specified size are correctly loaded
|
||||
*/
|
||||
[[nodiscard]] bool loadPieces(int max_size);
|
||||
[[nodiscard]] bool loadPieces(unsigned max_size);
|
||||
|
||||
/**
|
||||
* Selects the specified piece
|
||||
* @return If the piece could be selected
|
||||
*/
|
||||
bool selectPiece(int size, int number);
|
||||
bool selectPiece(unsigned size, unsigned number);
|
||||
|
||||
/**
|
||||
* Selects all pieces of the specified size
|
||||
* @return If the pieces could be selected
|
||||
*/
|
||||
bool selectAllPieces(int size);
|
||||
bool selectAllPieces(unsigned size);
|
||||
|
||||
/**
|
||||
* Selects all convex pieces of the specified size
|
||||
|
||||
Reference in New Issue
Block a user