git repos / blockattack-game

commit c98e567e

sago007 · 2016-03-25 09:39
c98e567ed37e9e1e0349eead32295706b8f78161 patch · browse files
parent 9f2c006a8dd8422e90efc4c40b77a1416b4b97f8

We are now using C++11, so initialize all variables all the time.

Changed files

M source/code/BlockGame.cpp before
M source/code/BlockGame.hpp before
M source/code/main.cpp before
diff --git a/source/code/BlockGame.cpp b/source/code/BlockGame.cpp index 46c79d8..fe5fd87 100644 --- a/source/code/BlockGame.cpp +++ b/source/code/BlockGame.cpp
@@ -115,10 +115,11 @@ BlockGame::BlockGame() {
pushedPixelAt = gameStartedAt;
nextGarbageNumber = 10;
handicap=0;
- for (int i=0; i<7; i++)
+ for (int i=0; i<7; i++) {
for (int j=0; j<30; j++) {
board[i][j] = -1;
}
+ }
for (int i=0; i<NUMBEROFCHAINS; i++) {
chainUsed[i]=false;
chainSize[i] = 0;
diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp index 9cc4efd..e6690a2 100644 --- a/source/code/BlockGame.hpp +++ b/source/code/BlockGame.hpp
@@ -109,41 +109,45 @@ private:
//public:
protected:
- int lastCounter;
+ int lastCounter = 0;
std::string strHolder;
- bool bDraw;
- unsigned int ticks;
- unsigned int gameStartedAt;
- unsigned int gameEndedAfter; //How long did the game last?
- int linesCleared;
- int TowerHeight;
+ bool bDraw = false;
+ unsigned int ticks = 0;
+ unsigned int gameStartedAt = 0;
+ unsigned int gameEndedAfter = 0; //How long did the game last?
+ int linesCleared = 0;
+ int TowerHeight = 0;
int board[7][30];
- int stop;
- int speedLevel;
- int pixels;
- int MovesLeft;
- bool timetrial, stageClear, vsMode, puzzleMode;
- int stageClearLimit; //stores number of lines user must clear to win
- int combo;
- int chain;
- int cursorx; //stores cursor position
- int cursory; // -||-
- double speed, baseSpeed; //factor for speed. Lower value = faster gameplay
- int score;
- bool bGameOver;
- bool hasWonTheGame;
- int AI_MoveSpeed; //How often will the computer move? milliseconds
- bool AI_Enabled;
+ int stop = 0;
+ int speedLevel = 0;
+ int pixels = 0;
+ int MovesLeft = 0;
+ bool timetrial = false;
+ bool stageClear = false;
+ bool vsMode = false;
+ bool puzzleMode = false;
+ int stageClearLimit = 0; //stores number of lines user must clear to win
+ int combo = 0;
+ int chain = 0;
+ int cursorx = 0; //stores cursor position
+ int cursory = 0; // -||-
+ double speed = 0.0;
+ double baseSpeed = 0.0; //factor for speed. Lower value = faster gameplay
+ int score = 0;
+ bool bGameOver = false;
+ bool hasWonTheGame = false;
+ int AI_MoveSpeed = 0; //How often will the computer move? milliseconds
+ bool AI_Enabled = false;
bool recordStats = true;
bool vsAI = false; //Set to true for single player vs
- int handicap;
+ int handicap = 0;
std::vector<GarbageStruct> garbageSendQueue;
- int AIlineToClear;
+ int AIlineToClear = 0;
- short AIstatus; //Status flags:
+ short AIstatus = 0; //Status flags:
//0: nothing, 2: clear tower, 3: clear horisontal, 4: clear vertical
//1: make more lines, 5: make 2 lines, 6: make 1 line
diff --git a/source/code/main.cpp b/source/code/main.cpp index 48c3a6e..ad02159 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp
@@ -462,11 +462,11 @@ static ExplosionManager theExplosionManager;
//text pop-up
class TextMessage {
private:
- int x;
- int y;
+ int x = 0;
+ int y = 0;
string textt;
- unsigned long int time;
- unsigned long int placeTime; //Then the text was placed
+ unsigned long int time = 0;
+ unsigned long int placeTime = 0; //Then the text was placed
public:
TextMessage() {