diff --git a/source/code/BlockGame.cpp b/source/code/BlockGame.cpp index f3674e4..97803bb 100644 --- a/source/code/BlockGame.cpp +++ b/source/code/BlockGame.cpp @@ -36,15 +36,17 @@ http://blockattack.net #include "stageclearhandler.hpp" #include +using namespace std; -static stringstream ss; //Used for internal formatting + +static std::stringstream ss; //Used for internal formatting //////////////////////////////////////////////////////////////////////////////// //The BloackGame class represents a board, score, time etc. for a single player/ //////////////////////////////////////////////////////////////////////////////// -Uint16 BlockGame::rand2() { +int BlockGame::rand2() { nextRandomNumber = nextRandomNumber*1103515245 + 12345; - return ((Uint16)(nextRandomNumber/65536)) % 32768; + return ((int)(nextRandomNumber/65536)) % 32768; } int BlockGame::firstUnusedChain() { @@ -115,7 +117,7 @@ BlockGame::BlockGame() { BlockGame::~BlockGame() { } -void BlockGame::setGameSpeed(Uint8 globalSpeedLevel) { +void BlockGame::setGameSpeed(int globalSpeedLevel) { boost::format f("%1%"); f % globalSpeedLevel; switch (globalSpeedLevel) { @@ -140,20 +142,20 @@ void BlockGame::setGameSpeed(Uint8 globalSpeedLevel) { }; } -void BlockGame::setHandicap(Uint8 globalHandicap) { +void BlockGame::setHandicap(int globalHandicap) { boost::format f("%1%"); f % globalHandicap; - handicap=1000*((Uint32)globalHandicap); + handicap=1000*((int)globalHandicap); } //Set the move speed of the AI based on the aiLevel parameter //Also enables AI -void BlockGame::setAIlevel(Uint8 aiLevel) { +void BlockGame::setAIlevel(int aiLevel) { AI_Enabled = true; AI_MoveSpeed=120-(20*(aiLevel-3)); }; -Uint8 BlockGame::getAIlevel() const { +int BlockGame::getAIlevel() const { return (120-AI_MoveSpeed)/20+3; } @@ -169,11 +171,11 @@ bool BlockGame::isGameOver() const { return bGameOver; } -Sint32 BlockGame::GetGameStartedAt() const { +int BlockGame::GetGameStartedAt() const { return gameStartedAt; } -Sint32 BlockGame::GetGameEndedAt() const { +int BlockGame::GetGameEndedAt() const { return gameEndedAfter; } @@ -451,13 +453,13 @@ bool BlockGame::hasStaticContent() const { /* * Generates some blocks so the user don't see a board without blocks */ -//void putStartBlocks(Uint32); +//void putStartBlocks(int); void BlockGame::putStartBlocks() { putStartBlocks(time(0)); } -void BlockGame::putStartBlocks(Uint32 n) { +void BlockGame::putStartBlocks(int n) { for (int i=0; i<7; i++) { for (int j=0; j<30; j++) { board[i][j] = -1; @@ -578,7 +580,7 @@ void BlockGame::putStartBlocks(Uint32 n) { //decreases hang for all hanging blocks and wait for waiting blocks void BlockGame::ReduceStuff() { - Sint32 howMuchHang = (ticks - FRAMELENGTH*hangTicks)/FRAMELENGTH; + int howMuchHang = (ticks - FRAMELENGTH*hangTicks)/FRAMELENGTH; if (howMuchHang>0) { for (int i=0; i<7; i++) for (int j=0; j<30; j++) { @@ -797,7 +799,7 @@ void BlockGame::ClearBlocks() { for (int i=0; i<6; i++) for (int j=0; j<30; j++) { //Clears blocks marked for clearing - Sint32 temp=board[i][j]; + int temp=board[i][j]; if (1==((temp/BLOCKWAIT)%10)) if (((temp/10)%100)==0) { if (chainSize[chain]nrStops*40+gameStartedAt) { //Increase stops, till we reach nowTime + while ( nowTime> nrStops*40+gameStartedAt) { //Increase stops, till we reach nowTime if (stop>0) { stop = stop-20; if (stop<=0) { @@ -1853,7 +1855,7 @@ void BlockGame::PerformAction(unsigned int tick, int action, string param) { ss.clear(); ss << param; int p1,p2; - Uint32 p3; + int p3; switch (action) { case ACTION_UPDATE: UpdateInternal(tick); diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp index 0c66e48..fe28bd0 100644 --- a/source/code/BlockGame.hpp +++ b/source/code/BlockGame.hpp @@ -58,27 +58,28 @@ private: int prevTowerHeight; bool bGarbageFallLeft; - Uint32 nextGarbageNumber; - Uint32 pushedPixelAt; - Uint32 nrPushedPixel, nrFellDown, nrStops; + int nextGarbageNumber; + int pushedPixelAt; + int nrPushedPixel, nrFellDown; + unsigned int nrStops; bool garbageToBeCleared[7][30]; - Uint32 lastAImove; + unsigned int lastAImove; - Sint16 AI_LineOffset; //how many lines have changed since command - Uint32 hangTicks; //How many times have hang been decreased? + int AI_LineOffset; //how many lines have changed since command + int hangTicks; //How many times have hang been decreased? //int the two following index 0 may NOT be used (what the fuck did I meen?) - Uint8 chainSize[NUMBEROFCHAINS]; //Contains the chains + int chainSize[NUMBEROFCHAINS]; //Contains the chains bool chainUsed[NUMBEROFCHAINS]; //True if the chain is used - Uint32 nextRandomNumber; + unsigned int nextRandomNumber; - Uint16 rand2(); + int rand2(); int firstUnusedChain(); //public: protected: int lastCounter; - string strHolder; + std::string strHolder; bool bDraw; unsigned int ticks; unsigned int gameStartedAt; @@ -86,7 +87,7 @@ protected: int linesCleared; int TowerHeight; BlockGame *garbageTarget; - Sint32 board[7][30]; + int board[7][30]; int stop; int speedLevel; int pixels; @@ -99,13 +100,13 @@ protected: int cursorx; //stores cursor position int cursory; // -||- double speed, baseSpeed; //factor for speed. Lower value = faster gameplay - Uint32 score; + int score; bool bGameOver; bool hasWonTheGame; int AI_MoveSpeed; //How often will the computer move? milliseconds bool AI_Enabled; - Uint32 handicap; + int handicap; int AIlineToClear; @@ -126,12 +127,12 @@ public: //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(); - void setGameSpeed(Uint8 globalSpeedLevel); - void setHandicap(Uint8 globalHandicap); + void setGameSpeed(int globalSpeedLevel); + void setHandicap(int globalHandicap); //Set the move speed of the AI based on the aiLevel parameter //Also enables AI - void setAIlevel(Uint8 aiLevel); - Uint8 getAIlevel() const; + void setAIlevel(int aiLevel); + int 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 {} @@ -146,8 +147,8 @@ public: int GetScore() const; int GetHandicap() const; bool isGameOver() const; - Sint32 GetGameStartedAt() const; - Sint32 GetGameEndedAt() const; + int GetGameStartedAt() const; + int GetGameEndedAt() const; bool isTimeTrial() const; bool isStageClear() const; bool isVsMode() const; @@ -176,7 +177,7 @@ public: void NewVsGame(BlockGame *target,unsigned int ticks); //Starts new Vs Game (two Player) void NewVsGame(BlockGame *target, bool AI,unsigned int ticks); - void putStartBlocks(Uint32 n); + 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 @@ -192,7 +193,7 @@ public: //Generates a new line and moves the field one block up (restart puzzle mode) void PushLine(); void Update(unsigned int newtick); - void PerformAction(unsigned int tick, int action, string param); + void PerformAction(unsigned int tick, int action, std::string param); /** * * @param tick Tick of the action @@ -200,7 +201,7 @@ public: * @param param Params. * @return 1 if an action was selected */ - int GotAction(unsigned int &tick,int &action,string ¶m); + int GotAction(unsigned int &tick, int &action, std::string ¶m); //Prints "winner" and ends game void setPlayerWon(); //void SetGameOver();