commit 027b5cfd
Added some const
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 564aca9..0d1f3ed 100644
--- a/source/code/BlockGame.cpp
+++ b/source/code/BlockGame.cpp
@@ -169,92 +169,92 @@ void BlockGame::setAIlevel(Uint8 aiLevel)
AI_MoveSpeed=120-(20*(aiLevel-3));
};
-Uint8 BlockGame::getAIlevel()
+Uint8 BlockGame::getAIlevel() const
{
return (120-AI_MoveSpeed)/20+3;
}
-int BlockGame::GetScore()
+int BlockGame::GetScore() const
{
return score;
}
-int BlockGame::GetHandicap()
+int BlockGame::GetHandicap() const
{
return handicap;
}
-bool BlockGame::isGameOver()
+bool BlockGame::isGameOver() const
{
return bGameOver;
}
-Sint32 BlockGame::GetGameStartedAt()
+Sint32 BlockGame::GetGameStartedAt() const
{
return gameStartedAt;
}
-Sint32 BlockGame::GetGameEndedAt()
+Sint32 BlockGame::GetGameEndedAt() const
{
return gameEndedAfter;
}
-bool BlockGame::isTimeTrial()
+bool BlockGame::isTimeTrial() const
{
return timetrial;
}
-bool BlockGame::isStageClear()
+bool BlockGame::isStageClear() const
{
return stageClear;
}
-bool BlockGame::isVsMode()
+bool BlockGame::isVsMode() const
{
return vsMode;
}
-bool BlockGame::isPuzzleMode()
+bool BlockGame::isPuzzleMode() const
{
return puzzleMode;
}
-int BlockGame::GetLinesCleared()
+int BlockGame::GetLinesCleared() const
{
return linesCleared;
}
-int BlockGame::GetStageClearLimit()
+int BlockGame::GetStageClearLimit() const
{
return stageClearLimit;
}
-int BlockGame::GetChains()
+int BlockGame::GetChains() const
{
return chain;
}
-int BlockGame::GetPixels()
+int BlockGame::GetPixels() const
{
return pixels;
}
-int BlockGame::GetSpeedLevel()
+int BlockGame::GetSpeedLevel() const
{
return speedLevel;
}
-int BlockGame::GetTowerHeight()
+int BlockGame::GetTowerHeight() const
{
return TowerHeight;
}
-int BlockGame::GetCursorX()
+int BlockGame::GetCursorX() const
{
return cursorx;
}
-int BlockGame::GetCursorY()
+int BlockGame::GetCursorY() const
{
return cursory;
}
@@ -268,7 +268,7 @@ void BlockGame::MoveCursorTo(int x, int y)
cursory = y;
}
-bool BlockGame::GetIsWinner()
+bool BlockGame::GetIsWinner() const
{
return hasWonTheGame;
}
@@ -566,9 +566,10 @@ void BlockGame::setDraw()
}
hasWonTheGame = false;
bDraw = true;
- Mix_HaltChannel(1);
- if(!AI_Enabled && !bReplaying)
+ DrawEvent();
+ if (!AI_Enabled && !bReplaying) {
Stats::getInstance()->addOne("totalDraws");
+ }
}
diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp
index 6c7f484..eb7d5fa 100644
--- a/source/code/BlockGame.hpp
+++ b/source/code/BlockGame.hpp
@@ -140,36 +140,37 @@ public:
//Set the move speed of the AI based on the aiLevel parameter
//Also enables AI
void setAIlevel(Uint8 aiLevel);
- Uint8 getAIlevel();
+ Uint8 getAIlevel() const;
virtual void AddText(int x, int y, const std::string& text, int time) const {}
virtual void AddBall(int x, int y, bool right, int color) const {}
virtual void AddExplosion(int x, int y) const {}
virtual void PlayerWonEvent() const {}
+ virtual void DrawEvent() const {}
virtual void BlockPopEvent() const {}
virtual void LongChainDoneEvent() const {}
virtual void TimeTrialEndEvent() const {}
virtual void EndlessHighscoreEvent() const {}
- int GetScore();
- int GetHandicap();
- bool isGameOver();
- Sint32 GetGameStartedAt();
- Sint32 GetGameEndedAt();
- bool isTimeTrial();
- bool isStageClear();
- bool isVsMode();
- bool isPuzzleMode();
- int GetLinesCleared();
- int GetStageClearLimit();
- int GetChains();
- int GetPixels();
- int GetSpeedLevel();
- int GetTowerHeight();
- int GetCursorX();
- int GetCursorY();
+ int GetScore() const;
+ int GetHandicap() const;
+ bool isGameOver() const;
+ Sint32 GetGameStartedAt() const;
+ Sint32 GetGameEndedAt() const;
+ bool isTimeTrial() const;
+ bool isStageClear() const;
+ bool isVsMode() const;
+ bool isPuzzleMode() const;
+ int GetLinesCleared() const;
+ int GetStageClearLimit() const;
+ int GetChains() const;
+ int GetPixels() const;
+ int GetSpeedLevel() const;
+ int GetTowerHeight() const;
+ int GetCursorX() const;
+ int GetCursorY() const;
void MoveCursorTo(int x, int y);
- bool GetIsWinner();
+ bool GetIsWinner() const;
//Instead of creating new object new game is called, to prevent memory leaks
void NewGame(unsigned int ticks);
void NewTimeTrialGame(unsigned int ticks);
diff --git a/source/code/main.cpp b/source/code/main.cpp
index eb7b6aa..dd1ac38 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -1259,6 +1259,10 @@ public:
Mix_PlayChannel(1, applause, 0);
}
+ void DrawEvent() const override {
+ Mix_HaltChannel(1);
+ }
+
void BlockPopEvent() const override {
if (!SoundEnabled) {return;}
Mix_PlayChannel(0, boing, 0);