git repos / blockattack-game

commit 32754436

Poul Sander · 2020-08-15 15:12
327544363fbd688097c0ee765a32dedf16b6e8af patch · browse files
parent fbd9841c30ebb5cb68a7bc36b2b5591498092ad4

Added explicit and fixed some flawed code

Changed files

M source/code/BlockGameSdl.inc before
M source/code/MenuSystem.cpp before
M source/code/MenuSystem.h before
M source/code/ReadKeyboard.h before
M source/code/levelselect.cpp before
diff --git a/source/code/BlockGameSdl.inc b/source/code/BlockGameSdl.inc index d42161e..abc0c32 100644 --- a/source/code/BlockGameSdl.inc +++ b/source/code/BlockGameSdl.inc
@@ -168,8 +168,8 @@ public:
private:
//Draws all the bricks to the board (including garbage)
void PaintBricks() const {
- for (int i=0; ((i<13)&&(i<30)); i++) {
- for (int j=0; j<6; j++) {
+ for (int i=0; i<13; ++i) {
+ for (int j=0; j<6; ++j) {
int basicBrick = board[j][i]%10; //The basic brick, stored on the least significant digit
if ((basicBrick > -1) && (basicBrick < 7) && ((board[j][i]/1000000)%10==0)) {
DrawImgBoardBounded(bricks[basicBrick], j*bsize, bsize*12-i*bsize-pixels);
@@ -265,18 +265,8 @@ private:
if ((board[j][i]/1000000)%10==1) {
int left, right, over, under;
int number = board[j][i];
- if (j<1) {
- left = -1;
- }
- else {
- left = board[j-1][i];
- }
- if (j>5) {
- right = -1;
- }
- else {
- right = board[j+1][i];
- }
+ left = -1;
+ right = board[j+1][i];
if (i>28) {
over = -1;
}
diff --git a/source/code/MenuSystem.cpp b/source/code/MenuSystem.cpp index 1729eb0..66de773 100644 --- a/source/code/MenuSystem.cpp +++ b/source/code/MenuSystem.cpp
@@ -59,7 +59,6 @@ sago::SagoTextField* ButtonGfx::getLabel(const std::string& text) {
return labels[text].get();
}
-
Button::Button(const Button& b) : action{b.action}, label{b.label}, marked{b.marked} {
}
diff --git a/source/code/MenuSystem.h b/source/code/MenuSystem.h index 02d643b..882ca1e 100644 --- a/source/code/MenuSystem.h +++ b/source/code/MenuSystem.h
@@ -104,7 +104,7 @@ public:
//numberOfItems is the expected numberOfItems for vector initialization
//SubMenu is true by default
Menu(SDL_Renderer *screen,bool isSubmenu);
- Menu(SDL_Renderer *screen);
+ explicit Menu(SDL_Renderer *screen);
Menu(SDL_Renderer *screen, const std::string& title, bool isSubmenu);
virtual ~Menu() {}
diff --git a/source/code/ReadKeyboard.h b/source/code/ReadKeyboard.h index db8f508..9f46542 100644 --- a/source/code/ReadKeyboard.h +++ b/source/code/ReadKeyboard.h
@@ -41,7 +41,7 @@ private:
public:
ReadKeyboard(void);
~ReadKeyboard(void);
- ReadKeyboard(const char*);
+ explicit ReadKeyboard(const char*);
int CharsBeforeCursor(); //Where should the cursor be placed?
void putchar(const std::string& );
bool cursorLeft();
diff --git a/source/code/levelselect.cpp b/source/code/levelselect.cpp index 6f0730b..004a385 100644 --- a/source/code/levelselect.cpp +++ b/source/code/levelselect.cpp
@@ -66,8 +66,6 @@ int PuzzleLevelSelect(int Type) {
//Loads the levels, if they havn't been loaded:
if (Type == 0) {
LoadPuzzleStages();
- }
- if (Type == 0) {
nrOfLevels = PuzzleGetNumberOfPuzzles();
}
if (Type == 1) {
@@ -211,4 +209,4 @@ int PuzzleLevelSelect(int Type) {
}
DrawBackground(globalData.screen);
return levelNr;
-}
\ No newline at end of file
+}