diff --git a/source/code/BlockGame.cpp b/source/code/BlockGame.cpp index ef2b239..2e54008 100644 --- a/source/code/BlockGame.cpp +++ b/source/code/BlockGame.cpp @@ -264,7 +264,7 @@ void BlockGame::MoveCursorTo(int x, int y) { format f("%1% %2%"); f % x % y; - ActionPerformed(ACTION_MOVECURSORTO,f.str()); + ActionPerformed(ACTION_MOVECURSORTO, f.str()); cursorx = x; cursory = y; } @@ -469,10 +469,12 @@ void BlockGame::NewVsGame(int tx, int ty, BlockGame *target, bool AI,unsigned in NewGame(tx, ty,ticks); vsMode = true; AI_Enabled = AI; - if(!AI) + if(!AI) { Stats::getInstance()->addOne("VSgamesStarted"); - else - strcpy(name,"CPU\0"); + } + else { + name = "CPU"; + } putStartBlocks(); garbageTarget = target; } @@ -2147,7 +2149,7 @@ void BlockGame::ActionPerformed(int action, string param) { if(bGameOver || bReplaying) return; - theReplay.addAction(ticks-gameStartedAt,action,param); + theReplay.addAction(ticks-gameStartedAt, action, param); } int BlockGame::GotAction(unsigned int &tick,int &action,string ¶m) diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp index 089af67..725f539 100644 --- a/source/code/BlockGame.hpp +++ b/source/code/BlockGame.hpp @@ -136,7 +136,7 @@ protected: public: - char name[30]; + std::string name; Replay theReplay; //Stores the replay public: diff --git a/source/code/NetworkThing.hpp b/source/code/NetworkThing.hpp index a91f778..282e147 100644 --- a/source/code/NetworkThing.hpp +++ b/source/code/NetworkThing.hpp @@ -73,7 +73,7 @@ public: { if(!bgHome || !bgAway) return; - strcpy(bgAway->name,player2name); + bgAway->name = player2name; if (weAreConnected || weAreAClient || weAreAServer) { if (weAreAClient) @@ -303,8 +303,9 @@ public: /* Store any relevant client information here. */ //event.peer -> data = "Client"; { - - ENetPacket * namePacket = enet_packet_create(bgHome->name,sizeof(char[30]),ENET_PACKET_FLAG_RELIABLE); + char buffer[30]; + snprintf(buffer, sizeof(buffer), "%s", bgHome->name.c_str()); + ENetPacket * namePacket = enet_packet_create(buffer,sizeof(buffer),ENET_PACKET_FLAG_RELIABLE); //if(weAreAServer) enet_host_broadcast (server, 3, namePacket); ENetPacket * answerPacket = enet_packet_create("version4",sizeof("version4"),ENET_PACKET_FLAG_RELIABLE); @@ -370,12 +371,14 @@ public: { if (event.packet->dataLength==sizeof(char[30])) //We have reveived a name { - strcpy(bgAway->name,(const char*)event.packet->data); + bgAway->name = (const char*)event.packet->data; if(verboseLevel) cout << "The enemy name is: " << bgAway->name << " Length: " << sizeof(char[30])<< endl; if (weAreAClient) //We have just recieved the servers name and must send our own { - ENetPacket * answerPacket = enet_packet_create(bgHome->name,sizeof(char[30]),ENET_PACKET_FLAG_RELIABLE); + char buffer[30]; + snprintf(buffer, sizeof(buffer), "%s", bgHome->name.c_str()); + ENetPacket * answerPacket = enet_packet_create(buffer, sizeof(buffer), ENET_PACKET_FLAG_RELIABLE); enet_peer_send (peer, 3, answerPacket); } } diff --git a/source/code/highscore.cpp b/source/code/highscore.cpp index 152cc84..4bd00d3 100644 --- a/source/code/highscore.cpp +++ b/source/code/highscore.cpp @@ -143,7 +143,7 @@ bool Highscore::isHighScore(int newScore) return false; } -void Highscore::addScore(char newName[], int newScore) +void Highscore::addScore(const string& newName, int newScore) { int ranking = top-1; while ((tabel[ranking-1].scoreSetGameOver(); showGame = true; - strcpy(player1->name, player1name); - strcpy(player2->name, player2name); + player1->name = player1name; + player2->name = player2name; } static void StartSinglePlayerTimeTrial() @@ -3061,8 +3061,8 @@ static void StartSinglePlayerTimeTrial() player2->SetGameOver(); showGame = true; //vsMode = false; - strcpy(player1->name, player1name); - strcpy(player2->name, player2name); + player1->name = player1name; + player2->name = player2name; } static int StartSinglePlayerPuzzle(int level) @@ -3078,8 +3078,8 @@ static int StartSinglePlayerPuzzle(int level) player2->SetGameOver(); showGame = true; //vsMode = true; - strcpy(player1->name, player1name); - strcpy(player2->name, player2name); + player1->name = player1name; + player2->name = player2name; return 0; } @@ -3101,8 +3101,8 @@ static void StarTwoPlayerTimeTrial() player1->setAIlevel(player1AIlevel); if(player2AI) player2->setAIlevel(player2AIlevel); - strcpy(player1->name, player1name); - strcpy(player2->name, player2name); + player1->name = player1name; + player2->name = player2name; } static void StartTwoPlayerVs() @@ -3125,8 +3125,8 @@ static void StartTwoPlayerVs() int theTime = time(0); player1->putStartBlocks(theTime); player2->putStartBlocks(theTime); - strcpy(player1->name, player1name); - strcpy(player2->name, player2name); + player1->name = player1name; + player2->name = player2name; } static void StartReplay(string filename) @@ -3523,8 +3523,8 @@ int main(int argc, char *argv[]) //Takes names from file instead - strcpy(theGame.name, player1name); - strcpy(theGame2.name, player2name); + theGame.name = player1name; + theGame2.name = player2name; #if NETWORK //NetworkThing nt = NetworkThing(); @@ -3658,8 +3658,8 @@ int runGame(int gametype, int level) theGame2.SetGameOver(); //Takes names from file instead - strcpy(theGame.name, player1name); - strcpy(theGame2.name, player2name); + theGame.name = player1name; + theGame2.name = player2name; Joypad joypad1 = Joypad(); //Creates a joypad Joypad joypad2 = Joypad(); //Creates a joypad @@ -3712,8 +3712,8 @@ int runGame(int gametype, int level) twoPlayers =false; theGame2.SetGameOver(); showGame = true; - strcpy(theGame.name, player1name); - strcpy(theGame2.name, player2name); + theGame.name = player1name; + theGame2.name = player2name; } break; case 3: @@ -3736,8 +3736,8 @@ int runGame(int gametype, int level) int theTime = time(0); theGame.putStartBlocks(theTime); theGame2.putStartBlocks(theTime); - strcpy(theGame.name, player1name); - strcpy(theGame2.name, player2name); + theGame.name = player1name; + theGame2.name = player2name; } break; case 10: diff --git a/source/code/ttfont.cpp b/source/code/ttfont.cpp index 46fe677..b81c758 100644 --- a/source/code/ttfont.cpp +++ b/source/code/ttfont.cpp @@ -73,31 +73,7 @@ TTFont::TTFont(const TTFont &t) if(t.font == NULL || t.actualInstance) { font = NULL; - ac/* -Block Attack - Rise of the Blocks, SDL game, besed on Nintendo's Tetris Attack -Copyright (C) 2008 Poul Sander - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Poul Sander - R�vehjvej 36, V. 1111 - 2800 Kgs. Lyngby - DENMARK - blockattack@poulsander.com - http://blockattack.sf.net -*/tualInstance = false; + actualInstance = false; } else {