commit 52d3ef2e
Eliminated the garbageTarget struct. The games in VS are no longer directly connected
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 7d4a8a3..f11fbef 100644
--- a/source/code/BlockGame.cpp
+++ b/source/code/BlockGame.cpp
@@ -83,7 +83,6 @@ BlockGame::BlockGame() {
srand((int)time(nullptr));
nrFellDown = 0;
nrPushedPixel = 0;
- garbageTarget = this;
nrStops=0;
//topx = tx;
//topy = ty;
@@ -388,7 +387,7 @@ void BlockGame::setPlayerWon() {
Stats::getInstance()->addOne("totalWins");
if (vsAI) {
//We have defeated an AI
- Stats::getInstance()->addOne("defeatedAI"+itoa(garbageTarget->getAIlevel()));
+ Stats::getInstance()->addOne("defeatedAI"+itoa(getAIlevel()));
}
}
if (AI_Enabled && vsAI) {
@@ -1861,14 +1860,6 @@ int BlockGame::getLevel() const {
return Level;
}
-void BlockGame::setGarbageTarget(BlockGame* garbageTarget) {
- this->garbageTarget = garbageTarget;
-}
-
-BlockGame* BlockGame::getGarbageTarget() const {
- return garbageTarget;
-}
-
void BlockGame::PopSendGarbage(std::vector<GarbageStruct>& poppedData) {
for (const GarbageStruct& g : this->garbageSendQueue) {
poppedData.push_back(g);
diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp
index 18bafd4..9cc4efd 100644
--- a/source/code/BlockGame.hpp
+++ b/source/code/BlockGame.hpp
@@ -117,7 +117,6 @@ protected:
unsigned int gameEndedAfter; //How long did the game last?
int linesCleared;
int TowerHeight;
- BlockGame *garbageTarget;
int board[7][30];
int stop;
int speedLevel;
@@ -210,8 +209,6 @@ public:
void setPlayerWon();
//Prints "draw" and ends the game
void setDraw();
- void setGarbageTarget(BlockGame* garbageTarget);
- BlockGame* getGarbageTarget() const;
private:
void NewGame(unsigned int ticks);
//Test if LineNr is an empty line, returns false otherwise.
@@ -275,9 +272,8 @@ private:
void AI_ClearVertical();
bool firstLineCreated;
void AI_Move();
-//////////////////////////////////////////////////////////////////////////
-///////////////////////////// AI ends here! //////////////////////////////
-////////
+//////////////////////////////////////////////////////////////////
+///////////////////////////// AI ends here! //////////////////////
//////////////////////////////////////////////////////////////////
//Set the move speed of the AI based on the aiLevel parameter
void setAIlevel(int aiLevel);
diff --git a/source/code/main.cpp b/source/code/main.cpp
index 0e9b811..46619ae 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -1456,9 +1456,7 @@ static void StartTwoPlayerVs() {
startInfo.handicap = player1handicap;
startInfo2.handicap = player2handicap;
player1->NewGame(startInfo);
- player1->setGarbageTarget(player2);
player2->NewGame(startInfo2);
- player2->setGarbageTarget(player1);
//vsMode = true;
twoPlayers = true;
player1->name = player1name;
@@ -1901,10 +1899,8 @@ int runGame(int gametype, int level) {
startInfo.vsAI = true;
startInfo.level = theAIlevel;
theGame.NewGame(startInfo);
- theGame.setGarbageTarget(&theGame2);
startInfo.AI = true;
theGame2.NewGame(startInfo);
- theGame2.setGarbageTarget(&theGame);
DrawIMG(backgroundImage, screen, 0, 0);
twoPlayers = true; //Single player, but AI plays
theGame.name = player1name;