diff --git a/source/code/BlockGame.cpp b/source/code/BlockGame.cpp index 27bc5e8..f46f406 100644 --- a/source/code/BlockGame.cpp +++ b/source/code/BlockGame.cpp @@ -314,6 +314,9 @@ void BlockGame::NewGame(const BlockGameStartInfo &s) { } putStartBlocks(); } + if (s.startBlocks >= 0) { + putStartBlocks(s.startBlocks); + } } //Instead of creating new object new game is called, to prevent memory leaks diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp index e261f53..7ff730c 100644 --- a/source/code/BlockGame.hpp +++ b/source/code/BlockGame.hpp @@ -69,6 +69,7 @@ struct BlockGameStartInfo { int level = 0; bool AI = false; bool vsMode = false; + int startBlocks = -1; }; struct GarbageStruct { @@ -152,9 +153,8 @@ public: //Constructor BlockGame(); - //Deconstructor, never really used... game used to crash when called, cause of the way sBoard was created //It should work now and can be used if we want to assign more players in network games that we need to free later - ~BlockGame(); + virtual ~BlockGame(); void setGameSpeed(int globalSpeedLevel); void setHandicap(int globalHandicap); @@ -190,7 +190,6 @@ public: void MoveCursorTo(int x, int y); bool GetIsWinner() const; void NewGame(const BlockGameStartInfo &s); - void putStartBlocks(int n); //Creates garbage using a given wide and height bool CreateGarbage(int wide, int height); //Creates garbage using a given wide and height @@ -234,6 +233,7 @@ private: //Anything that the user can't move? In that case Game Over cannot occur bool hasStaticContent() const; void putStartBlocks(); + void putStartBlocks(int n); //decreases hang for all hanging blocks and wait for waiting blocks void ReduceStuff(); //Clears garbage, must take one the lower left corner! diff --git a/source/code/main.cpp b/source/code/main.cpp index 7a4a5ce..29b52d3 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp @@ -1480,8 +1480,8 @@ static void StartSinglePlayerEndless() { //1 player - endless BlockGameStartInfo startInfo; startInfo.ticks = SDL_GetTicks(); + startInfo.startBlocks = startInfo.ticks; player1->NewGame(startInfo); - player1->putStartBlocks(time(0)); twoPlayers =false; player2->SetGameOver(); player1->name = player1name; @@ -1554,6 +1554,7 @@ static void StartTwoPlayerVs() { BlockGameStartInfo startInfo; startInfo.ticks = SDL_GetTicks(); startInfo.vsMode = true; + startInfo.startBlocks = startInfo.ticks; BlockGameStartInfo startInfo2 = startInfo; if (player1AI) { startInfo.AI = true; @@ -1573,9 +1574,6 @@ static void StartTwoPlayerVs() { player2->setGameSpeed(player2Speed); player1->setHandicap(player1handicap); player2->setHandicap(player2handicap); - int theTime = time(0); - player1->putStartBlocks(theTime); - player2->putStartBlocks(theTime); player1->name = player1name; player2->name = player2name; }