git repos / blockattack-game

commit 6787b808

sago007 · 2015-08-23 14:57
6787b808bf64d364c0b63323105f575b59460c64 patch · browse files
parent 027b5cfd2d6d604124b9be2646ba0ea6f24c4c5b

Removed all network functionality for the moment

Changed files

M source/code/BlockGame.cpp before
M source/code/BlockGame.hpp before
D source/code/NetworkThing.hpp before
M source/code/main.cpp before
M source/code/menudef.cpp before
diff --git a/source/code/BlockGame.cpp b/source/code/BlockGame.cpp index 0d1f3ed..8c05f60 100644 --- a/source/code/BlockGame.cpp +++ b/source/code/BlockGame.cpp
@@ -79,10 +79,6 @@ BlockGame::BlockGame()
bGameOver = false;
bDraw = false;
bReplaying=false; //No replay by default
-#if NETWORK
- bDisconnected=false;
- bNetworkPlayer = false;
-#endif
timetrial = false;
stageClear = false;
vsMode = false;
@@ -273,52 +269,12 @@ bool BlockGame::GetIsWinner() const
return hasWonTheGame;
}
-#if NETWORK
-#define garbageStackSize 10
-
-void BlockGame::emptyGarbageStack()
-{
- for (int i=0; i<10; i++)
- for (int j=0; j<3; j++)
- garbageStack[i][j] = 0;
- garbageStackUsed = 0;
-}
-
-bool BlockGame::pushGarbage(Uint8 width, Uint8 height, Uint8 type)
-{
- if (garbageStackUsed>=garbageStackSize)
- return false;
- garbageStack[garbageStackUsed][0]=width;
- garbageStack[garbageStackUsed][1]=height;
- garbageStack[garbageStackUsed][2]=type;
- garbageStackUsed++;
- return true;
-}
-
-bool BlockGame::popGarbage(Uint8 *width, Uint8 *height, Uint8 *type)
-{
- if (garbageStackUsed<1)
- return false;
- garbageStackUsed--;
- *width=garbageStack[garbageStackUsed][0];
- *height=garbageStack[garbageStackUsed][1];
- *type=garbageStack[garbageStackUsed][2];
- return true;
-}
-
-#endif
-
-
//Instead of creating new object new game is called, to prevent memory leaks
void BlockGame::NewGame( unsigned int ticks)
{
this->ticks = ticks;
stageButtonStatus = SBdontShow;
bReplaying = false;
-#if NETWORK
- bNetworkPlayer=false;
- bDisconnected =false;
-#endif
nrFellDown = 0;
nrPushedPixel = 0;
nrStops = 0;
@@ -494,24 +450,7 @@ void BlockGame::playReplay( unsigned int ticks, const Replay& r)
replayIndex = 0;
bReplaying = true; //We are playing, no calculations
theReplay = r;
-#if NETWORK
- bNetworkPlayer = false; //Take input from replay file
-#endif
-}
-
-
-#if NETWORK
-
-//network play
-void BlockGame::playNetwork(unsigned int ticks)
-{
- NewGame(ticks);
- gameStartedAt = ticks;
- bReplaying = false; //We are playing, no calculations
- bNetworkPlayer = true; //Don't Take input from replay file
- emptyGarbageStack();
}
-#endif
//Prints "winner" and ends game
void BlockGame::setPlayerWon()
@@ -544,17 +483,6 @@ void BlockGame::setPlayerWon()
hasWonTheGame = true;
}
-//void SetGameOver();
-
-#if NETWORK
-//Sets disconnected:
-void BlockGame::setDisconnect()
-{
- bDisconnected = true;
- SetGameOver();
-}
-#endif
-
//Prints "draw" and ends the game
void BlockGame::setDraw()
{
@@ -788,13 +716,6 @@ bool BlockGame::CreateGarbage(int wide, int height)
format f("%1% %2%");
f % wide % height;
ActionPerformed(ACTION_CREATEGARBAGE,f.str());
-#if NETWORK
- if (bNetworkPlayer)
- {
- pushGarbage(wide, height, 0);
- }
- else
-#endif
{
if (wide>6) wide = 6;
if (height>12) height = 12;
@@ -833,13 +754,6 @@ bool BlockGame::CreateGarbage(int wide, int height)
bool BlockGame::CreateGreyGarbage()
{
ActionPerformed(ACTION_CREATEGRAYGARBAGE,"");
-#if NETWORK
- if (bNetworkPlayer)
- {
- pushGarbage(6, 1, 1);
- }
- else
-#endif
{
int startPosition = 12;
while ((!(LineEmpty(startPosition))) || (startPosition == 29))
@@ -2101,8 +2015,6 @@ void BlockGame::UpdateInternal(unsigned int newtick)
void BlockGame::Update(unsigned int newtick)
{
- if(bNetworkPlayer)
- return;
if(bReplaying)
{
/*cout << "Testing " << replayIndex << "<" << theReplay.getActions().size()
diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp index eb7d5fa..1222907 100644 --- a/source/code/BlockGame.hpp +++ b/source/code/BlockGame.hpp
@@ -82,10 +82,6 @@ protected:
string strHolder;
bool bDraw;
bool bReplaying; //true if we are watching a replay
-#if NETWORK
- bool bNetworkPlayer; //must recieve packages from the net
- bool bDisconnected; //The player has disconnected
-#endif
unsigned int ticks;
unsigned int gameStartedAt;
unsigned int gameEndedAfter; //How long did the game last?
@@ -212,33 +208,12 @@ public:
* @return 1 if an action was selected
*/
int GotAction(unsigned int &tick,int &action,string &param);
-#if NETWORK
- //network play
- void playNetwork(unsigned int ticks);
-#endif
//Prints "winner" and ends game
void setPlayerWon();
//void SetGameOver();
-
-#if NETWORK
- //Sets disconnected:
- void setDisconnect();
-#endif
//Prints "draw" and ends the game
void setDraw();
private:
-#if NETWORK
-#define garbageStackSize 10
- Uint8 garbageStack[garbageStackSize][3]; //A garbage stack with space for 10 garbage blocks. 0=x,1=y,2=type
- int garbageStackUsed;
-
- void emptyGarbageStack();
- bool pushGarbage(Uint8 width, Uint8 height, Uint8 type);
-public:
- bool popGarbage(Uint8 *width, Uint8 *height, Uint8 *type);
-private:
-
-#endif
//Go in Demonstration mode, no movement
void Demonstration(bool toggle);
//Test if LineNr is an empty line, returns false otherwise.
diff --git a/source/code/NetworkThing.hpp b/source/code/NetworkThing.hpp deleted file mode 100644 index 034d252..0000000 --- a/source/code/NetworkThing.hpp +++ /dev/null
@@ -1,439 +0,0 @@
-/*
-===========================================================================
-blockattack - Block Attack - Rise of the Blocks
-Copyright (C) 2005-2012 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, see http://www.gnu.org/licenses/
-
-Source information and contacts persons can be found at
-http://blockattack.sf.net
-===========================================================================
-*/
-
-#include "BlockGame.hpp"
-
-
-#if NETWORK
-
-//The network interface
-class NetworkThing
-{
-private:
- ENetAddress address;
- ENetHost * server;
- ENetHost * client;
- ENetPeer *peer;
-
- BlockGame *bgHome, *bgAway; //Pointers to the two games, so we can call the procedures
- bool weAreAServer, weAreAClient;
- bool weAreConnected;
- bool enemyIsReady;
- bool enemyHasStarted; //If we should have a ready button
- bool gameHasStarted; //If the player is GameOver it might just be because the game hasn't started yet... not if this is true!
-
-public:
-
- Uint32 theSeed;
-
- NetworkThing()
- {
- weAreAServer = false;
- weAreAClient = false;
- weAreConnected = false;
- enemyIsReady = false;
- enemyHasStarted = false;
- gameHasStarted = false;
- bgAway = NULL;
- bgHome = NULL;
- if (enet_initialize () != 0)
- {
- fprintf (stderr, "An error occurred while initializing ENet.\n");
- }
- else
- {
- if(verboseLevel)
- cout << "Network is working!" << endl;
- }
- //atexit (enet_deinitialize); in deconstructor
- }
-
- //This function couses us to remove the connection to the other peer, plus destroying servers
- void ntDisconnect()
- {
- if(!bgHome || !bgAway)
- return;
- bgAway->name = player2name;
- if (weAreConnected || weAreAClient || weAreAServer)
- {
- if (weAreAClient)
- {
- enet_peer_disconnect (peer,0);
- SDL_Delay(20);
- enet_host_destroy(client);
- weAreAClient = false;
- weAreConnected = false;
- enemyHasStarted = false;
- }
- if (weAreAServer)
- {
- enet_host_destroy(server);
- weAreAServer = false;
- weAreConnected = false;
- enemyHasStarted = false;
- }
- //If the game is running then we disconnect, we are considered the looser!
- if ((!bgHome->isGameOver())&&(!bgAway->isGameOver()))
- {
- bgAway->setPlayerWon();
- bgHome->SetGameOver();
- }
- gameHasStarted = false;
- }
- };
-
- //Lets disconnect before we close...
- ~NetworkThing()
- {
- if(verboseLevel)
- cout << "Network system is going down" << endl;
- ntDisconnect();
- enet_deinitialize();
- if(verboseLevel)
- cout << "Network system went down" << endl;
- }
-
- void theGameHasStarted()
- {
- gameHasStarted = true;
- }
-
- //The NetworkThing needs to be able to call the models... here the pointers are set
- void setBGpointers(BlockGame *bg1, BlockGame *bg2)
- {
- bgHome = bg1;
- bgAway = bg2;
- }
-
- //Starts a server instance
- void startServer()
- {
- if (!weAreAServer)
- {
- ntDisconnect();
-
- /* Bind the server to the default localhost. */
- /* A specific host address can be specified by */
- /* enet_address_set_host (& address, "x.x.x.x"); */
-
- address.host = ENET_HOST_ANY;
- /* Bind the server to port SERVERPORT. */
- address.port = Config::getInstance()->getInt("portv4");
-
- server = enet_host_create (& address /* the address to bind the server host to */,
- 1 /* allow up to 1 clients and/or outgoing connections */,
- 4 /* allow 4 channels to be used */,
- 0 /* assume any amount of incoming bandwidth */,
- 0 /* assume any amount of outgoing bandwidth */);
- if (server == NULL)
- {
- fprintf (stderr,
- "An error occurred while trying to create an ENet server host.\n");
-
- }
- else
- {
- weAreAServer = true;
- enemyIsReady = false;
- gameHasStarted = false;
- if(verboseLevel)
- cout << "Server is listening on port " << SERVERPORT << endl;
- }
- }
- }
-
- void connectToServer(string server)
- {
- ENetAddress address;
- ENetEvent event;
-
- enet_address_set_host (& address, server.c_str());
- address.port = Config::getInstance()->getInt("portv4");
-
- ntDisconnect();
- client = enet_host_create (NULL /* create a client host */,
- 1 /* only allow 1 outgoing connection */,
- 4 /* allow 4 channels to be used */,
- 0 /* Unlimited downstream bandwidth */,
- 0 /* Unlimted upstream bandwidth */);
-
- if (client == NULL)
- {
- cerr << "Error: An error occurred while trying to create an ENet client host." << endl;
- }
- else
- {
- /* Initiate the connection, allocating the four channels 0 and 1 and 2 and 3. */
- peer = enet_host_connect (client, & address, 4,0);
-
- if (peer == NULL)
- {
- cerr << "Error: No available peers for initiating an ENet connection." << endl;
- }
- else if (enet_host_service (client, & event, 2000) > 0 &&
- event.type == ENET_EVENT_TYPE_CONNECT)
- {
- if(verboseLevel)
- cout << "We are connected!" << endl;
- enemyIsReady = false;
- weAreAClient = true;
- weAreConnected = true;
- gameHasStarted = false;
- }
- else
- {
- cout << "Server " << server.c_str() << ":" << address.port << " didn't answer in time" << endl;
- }
- }
- }
-
- bool isConnected()
- {
- return (weAreConnected||weAreAServer);
- }
-
- bool isConnectedToPeer()
- {
- return weAreConnected;
- }
-
- //This function must be called in the game loop:
- void updateNetwork()
- {
- //Now we must send our own board:
- if (weAreConnected)
- {
- //cout << "Creating package" << endl;
- Uint32 tick;
- Sint32 action;
- Sint32 paramsize;
- string param;
- while(bgHome->GotAction(tick,action,param))
- {
- if(action == ACTION_NEW || action == ACTION_NEWTT || action == ACTION_NEWVS)
- continue; //Do not send start messages
- paramsize = param.length();
- char *tmpPacket = (char*)malloc(sizeof(Sint32)*3+param.length()+1);
- if(!tmpPacket)
- {
- cerr << "Failed to alloc memoroy" << endl;
- exit(-3);
- }
- memcpy(tmpPacket,&tick,sizeof(Sint32));
- memcpy(tmpPacket+sizeof(Sint32),&action,sizeof(Sint32));
- memcpy(tmpPacket+sizeof(Sint32)*2,&paramsize,sizeof(Sint32));
- memcpy(tmpPacket+sizeof(Sint32)*3,param.c_str(),paramsize+1);
- ENetPacket * packet = enet_packet_create (tmpPacket,
- sizeof(Sint32)*3+param.length()+1,
- ENET_PACKET_FLAG_RELIABLE);
- //Now lets send the package
- if (weAreAServer)
- enet_host_broadcast (server, 0, packet);
- else if (weAreAClient)
- enet_peer_send (peer, 0, packet);
- //cout << "Package sent" << endl;
- free(tmpPacket);
- }
-
- //See if we are game over and in that case notify the other player
- if ((gameHasStarted)&&(bgHome->isGameOver()))
- {
- ENetPacket * packet = enet_packet_create("G",2,ENET_PACKET_FLAG_RELIABLE);
- if (weAreAServer)
- enet_host_broadcast (server, 1, packet);
- else if (weAreAClient)
- enet_peer_send (peer, 1, packet);
- gameHasStarted=false;
- }
-
- //Now lets see if we have something to throw at the opponent.
- Uint8 x,y,type;
-
- if (gameHasStarted)
- while (bgAway->popGarbage(&x,&y,&type))
- {
- //if there are garbage to drop
- if (type==1)
- {
- x=255;
- y=255;
- }
- Uint16 g = ((Uint16)x)*256+(Uint16)y; //A 16-bit int containing everything
- ENetPacket * packet = enet_packet_create(&g,2,ENET_PACKET_FLAG_RELIABLE);
- if (weAreAServer)
- enet_host_broadcast (server, 2, packet);
- else if (weAreAClient)
- enet_peer_send (peer, 2, packet);
- if(verboseLevel)
- cout << "We send a garbage block: " << (int)x << "," << (int)y << "==" << g << endl;
- }
- }
- ENetEvent event;
-
- /* Wait up to 0 milliseconds for an event. */
- while (((weAreAClient)&&(enet_host_service (client, & event, 0) > 0))||((weAreAServer)&&(enet_host_service (server, & event, 0) > 0)))
- {
- switch (event.type)
- {
- case ENET_EVENT_TYPE_CONNECT:
- printf ("A new client connected from %x:%u.\n",
- event.peer -> address.host,
- event.peer -> address.port);
- weAreConnected = true;
- /* Store any relevant client information here. */
- //event.peer -> data = "Client";
- {
- 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);
- enet_host_broadcast (server, 3, answerPacket);
- theSeed = time(0)/4;
- bgHome->NewVsGame(bgAway, SDL_GetTicks());
- bgAway->NewVsGame(bgHome, SDL_GetTicks());
- bgHome->putStartBlocks(theSeed);
- ENetPacket * timePacket = enet_packet_create(&theSeed,sizeof(theSeed),ENET_PACKET_FLAG_RELIABLE);
- enet_host_broadcast (server, 3, timePacket);
- if(verboseLevel)
- cout << "We send the seed: " << theSeed << endl;
- }
- break;
-
- case ENET_EVENT_TYPE_RECEIVE:
- /*printf ("A packet of length %u containing %s was received from %s on channel %u.\n",
- event.packet -> dataLength,
- event.packet -> data,
- event.peer -> data,
- event.channelID);*/
- //cout << "Package recieved" << endl;
- if (event.channelID==0) //Unreliable (only boardPacks)
- {
- Sint32 tick;
- Sint32 action;
- string param;
- memcpy(&tick,event.packet->data,sizeof(Sint32));
- memcpy(&action,event.packet->data+sizeof(Sint32),sizeof(Sint32));
- param = (const char*) (event.packet->data+sizeof(Sint32)*3);
- bgAway->PerformAction(tick,action,param);
- }
- if (event.channelID==1) //reliable (used for GameOver notifications only!)
- {
- if ((bgHome->isGameOver())&&(!bgHome->GetIsWinner())&&(gameHasStarted))
- {
- bgHome->setDraw();
- bgAway->setDraw();
- }
- else
- {
- bgHome->setPlayerWon();
- bgAway->SetGameOver();
- }
- gameHasStarted=false;
- }
-
- if (event.channelID==2) //reliable (used for Garbage only!)
- {
- Uint16 g;
- memcpy(&g,event.packet->data,sizeof(Uint16));
- Uint8 x = (g/256);
- Uint8 y = (g%256);
- if(verboseLevel)
- cout << "Recieved Garbage: " << (int)x << "," << (int)y << endl;
- if ((x==255)&&(y==255))
- bgHome->CreateGreyGarbage();
- else
- bgHome->CreateGarbage(x,y);
- }
-
- if (event.channelID==3) //We have reacieved a name or a version number
- {
- if (event.packet->dataLength==sizeof(char[30])) //We have reveived a name
- {
- 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
- {
- 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);
- }
- }
- else if (event.packet->dataLength==sizeof("version4")) //We have recieved aversion number
- {
- if (0!=strcmp((const char*)event.packet->data,"version4"))
- {
- cerr << "Error: Incompatible version: " << event.packet->data << "!=" << "version4" << endl;
- ntDisconnect();
- }
- if (weAreAClient) //We will send our version number
- {
- ENetPacket * answerPacket = enet_packet_create("version4",sizeof("version4"),ENET_PACKET_FLAG_RELIABLE);
- enet_peer_send (peer, 3, answerPacket);
- }
- }
- else if (event.packet->dataLength==sizeof(Uint32)) //We have recieved a seed
- {
- memcpy(&theSeed,event.packet->data,sizeof(Uint32));
- bgHome->putStartBlocks(theSeed);
- if(verboseLevel)
- cout << "We recieved a seed: " << theSeed << endl;
- }
- }
-
- /* Clean up the packet now that we're done using it. */
- enet_packet_destroy (event.packet);
-
- break;
-
- case ENET_EVENT_TYPE_DISCONNECT:
- //printf ("%s disconected.\n", event.peer -> data);
- if(verboseLevel)
- cout << event.peer -> data << " disconnected." << endl;
-
- /* Reset the peer's client information. */
-
- event.peer -> data = NULL;
- //weAreConnected = false;
- if ((!bgHome->isGameOver())&&(!bgAway->isGameOver()))
- {
- bgHome->setPlayerWon();
- bgAway->SetGameOver();
- }
-
- ntDisconnect(); //When we will disconnect!
- break;
-
- case ENET_EVENT_TYPE_NONE:
- break;
- }
- }
-
-
- }
-}; //NetworkThing
-
-#endif
diff --git a/source/code/main.cpp b/source/code/main.cpp index dd1ac38..c4a6328 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp
@@ -36,11 +36,6 @@ http://blockattack.sf.net
#define DEBUG 0
#endif
-//If NETWORK id defined: enet will be used
-#ifndef NETWORK
-#define NETWORK 1
-#endif
-
//Build-in level editor is still experimental!
#ifndef LEVELEDITOR
#define LEVELEDITOR 0
@@ -86,13 +81,6 @@ http://blockattack.sf.net
#define PACKAGE "blockattack_roftb"
#endif
-//enet things
-#if NETWORK
-#include "enet/enet.h"
-#endif
-//enet things end
-
-//#include "SFont.h" //Used to write on screen
#include "highscore.h" //Stores highscores
#include "ReadKeyboard.h" //Reads text from keyboard
#include "joypad.h" //Used for joypads
@@ -396,29 +384,12 @@ static int InitImages()
{
if (!((backgroundImage = IMG_Load2("gfx/background.png"))
&& (background = IMG_Load2("gfx/blackBackGround.png"))
-// && (b1player = IMG_Load2("gfx/bOnePlayer.png"))
-// && (b2players = IMG_Load2("gfx/bTwoPlayers.png"))
-// && (bVsMode = IMG_Load2("gfx/bVsGame.png"))
-// && (bVsModeConfig = IMG_Load2("gfx/bVsGameConfig.png"))
-// && (bPuzzle = IMG_Load2("gfx/bPuzzle.png"))
-// && (bStageClear = IMG_Load2("gfx/bStageClear.png"))
-// && (bTimeTrial = IMG_Load2("gfx/bTimeTrial.png"))
- //&& (bEndless = IMG_Load2("gfx/bEndless.png"))
&& (bOptions = IMG_Load2("gfx/bOptions.png"))
&& (bConfigure = IMG_Load2("gfx/bConfigure.png"))
&& (bSelectPuzzle = IMG_Load2("gfx/bSelectPuzzle.png"))
&& (bHighScore = IMG_Load2("gfx/bHighScore.png"))
-// && (bExit = IMG_Load2("gfx/bExit.png"))
&& (bBack = IMG_Load2("gfx/bBlank.png"))
&& (bForward = IMG_Load2("gfx/bForward.png"))
-// && (bReplay = IMG_Load2("gfx/bReplays.png"))
-// && (bSave = IMG_Load2("gfx/bSave.png"))
-// && (bLoad = IMG_Load2("gfx/bLoad.png"))
- /*#if NETWORK
- && (bNetwork = IMG_Load2("gfx/bNetwork.png"))
- && (bHost = IMG_Load2("gfx/bHost.png"))
- && (bConnect = IMG_Load2("gfx/bConnect.png"))
- #endif*/
&& (blackLine = IMG_Load2("gfx/blackLine.png"))
&& (stageBobble = IMG_Load2("gfx/iStageClearLimit.png"))
&& (bricks[0] = IMG_Load2("gfx/bricks/blue.png"))
@@ -533,28 +504,12 @@ static int InitImages()
//Prepare for fast blittering!
CONVERT(background);
CONVERT(backgroundImage);
-// CONVERT(b1player);
-// CONVERT(b2players);
-// CONVERT(bVsMode);
-// CONVERT(bVsModeConfig);
-// CONVERT(bPuzzle);
-// CONVERT(bStageClear);
-// CONVERT(bTimeTrial);
- //CONVERT(bEndless);
CONVERT(bOptions);
CONVERTA(bConfigure);
CONVERTA(bSelectPuzzle);
-// CONVERTA(bReplay);
-// CONVERTA(bSave);
-// CONVERTA(bLoad);
CONVERTA(bSkip);
CONVERTA(bRetry);
CONVERTA(bNext);
- /*#if NETWORK
- CONVERTA(bNetwork);
- CONVERTA(bHost);
- CONVERTA(bConnect);
- #endif*/
CONVERT(bHighScore);
CONVERTA(boardBackBack);
CONVERT(backBoard);
@@ -565,11 +520,8 @@ static int InitImages()
CONVERTA(counter[0]);
CONVERTA(counter[1]);
CONVERTA(counter[2]);
-// CONVERTA(optionsBack);
-// CONVERT(bExit);
CONVERT(bOn);
CONVERT(bOff);
-// CONVERT(bChange);
CONVERT(b1024);
CONVERTA(dialogBox);
// CONVERTA(fileDialogBox);
@@ -708,28 +660,10 @@ void UnloadImages()
//Chrashes no more. Caused by an undocumented double free
SDL_FreeSurface(backgroundImage);
SDL_FreeSurface(background);
- //SDL_FreeSurface(bNewGame);
-// SDL_FreeSurface(b1player);
-// SDL_FreeSurface(b2players);
-// SDL_FreeSurface(bVsMode);
-// SDL_FreeSurface(bVsModeConfig);
-// SDL_FreeSurface(bPuzzle);
-// SDL_FreeSurface(bStageClear);
-// SDL_FreeSurface(bTimeTrial);
- //SDL_FreeSurface(bEndless);
SDL_FreeSurface(bOptions);
SDL_FreeSurface(bConfigure);
SDL_FreeSurface(bSelectPuzzle);
SDL_FreeSurface(bHighScore);
-// SDL_FreeSurface(bReplay);
-// SDL_FreeSurface(bSave);
-// SDL_FreeSurface(bLoad);
- /* #if NETWORK
- SDL_FreeSurface(bNetwork);
- SDL_FreeSurface(bHost);
- SDL_FreeSurface(bConnect);
- #endif
- SDL_FreeSurface(bExit);*/
SDL_FreeSurface(blackLine);
SDL_FreeSurface(stageBobble);
SDL_FreeSurface(bricks[0]);
@@ -755,10 +689,8 @@ void UnloadImages()
SDL_FreeSurface(iDraw);
SDL_FreeSurface(iLoser);
SDL_FreeSurface(iChainBack);
-// SDL_FreeSurface(optionsBack);
SDL_FreeSurface(bOn);
SDL_FreeSurface(bOff);
-// SDL_FreeSurface(bChange);
SDL_FreeSurface(b1024);
SDL_FreeSurface(dialogBox);
//SDL_FreeSurface(fileDialogBox);
@@ -2404,30 +2336,10 @@ void DrawEverything(int xsize, int ysize,BlockGameSdl *theGame, BlockGameSdl *th
DrawIMG(background,screen,50,60,300,50,50,60);
DrawIMG(background,screen,510,60,300,50,510,60);
- }
- else
+ }
+ else {
DrawIMG(background,screen,0,0);
- //draw bottons (should be moves and drawn directly to background once)
- /*if (!editorMode)
- #if NETWORK
- if (!networkActive) //We don't show the menu while running server or connected to a server
- #else
- if(true)
- #endif
- {
- //Here we draw the menu
- bNewGame.PaintTo(screen,0,0);
- DrawIMG(bOptions, screen, buttonXsize,0);
- DrawIMG(bHighScore, screen, 2*buttonXsize,0);
- DrawIMG(bReplay,screen,3*buttonXsize,0);
- }
- else
- { //If network is active
- DrawIMG(bBack, screen, 0, 0); //Display a disconnect button
- }
- if (!editorMode)
- DrawIMG(bExit, screen, xsize-120,ysize-120);*/
- //DrawIMG(boardBackBack,screen,theGame->GetTopX()-60,theGame->GetTopY()-68);
+ }
DrawIMG(theGame->sBoard,screen,theGame->GetTopX(),theGame->GetTopY());
string strHolder;
strHolder = itoa(theGame->GetScore()+theGame->GetHandicap());
@@ -3025,12 +2937,6 @@ void changePuzzleLevels()
}
-#if NETWORK
-#include "NetworkThing.hpp"
-//#include "MenuSystem.h"
-NetworkThing nt;
-#endif
-
static BlockGameSdl *player1;
static BlockGameSdl *player2;
@@ -3123,22 +3029,6 @@ static void StartReplay(string filename)
player2->playReplay(SDL_GetTicks(),r2);
}
-static void StartHostServer()
-{
- player1->SetGameOver();
- player2->SetGameOver();
- nt.startServer();
-}
-
-static void StartJoinServer()
-{
- player1->SetGameOver();
- player2->SetGameOver();
- string server = Config::getInstance()->getString("address0");
- nt.connectToServer(server.substr(0,server.find(" ")));
-}
-
-
//The main function, quite big... too big
int main(int argc, char *argv[])
{
@@ -3507,11 +3397,6 @@ int main(int argc, char *argv[])
theGame.name = player1name;
theGame2.name = player2name;
-#if NETWORK
- //NetworkThing nt = NetworkThing();
- nt.setBGpointers(&theGame,&theGame2);
-#endif
-
if (singlePuzzle) {
LoadPuzzleStages();
theGame.NewPuzzleGame(singlePuzzleNr, SDL_GetTicks());
@@ -3639,11 +3524,6 @@ int runGame(int gametype, int level)
Joypad joypad1 = Joypad(); //Creates a joypad
Joypad joypad2 = Joypad(); //Creates a joypad
-#if NETWORK
- //NetworkThing nt = NetworkThing();
- nt.setBGpointers(&theGame,&theGame2);
-#endif
-
if (singlePuzzle)
{
LoadPuzzleStages();
@@ -3715,12 +3595,6 @@ int runGame(int gametype, int level)
case 11:
StartTwoPlayerVs();
break;
- case 12:
- StartHostServer();
- break;
- case 13:
- StartJoinServer();
- break;
case 0:
default:
StartSinglePlayerEndless();
@@ -3752,36 +3626,6 @@ int runGame(int gametype, int level)
theExplosionManeger.update();
theTextManeger.update();
-#if NETWORK
- if (nt.isConnected())
- {
- nt.updateNetwork();
- networkActive = true;
- if (!nt.isConnectedToPeer())
- DrawIMG(background, screen, 0, 0);
- }
- else
- networkActive = false;
- if (nt.isConnectedToPeer())
- {
- networkPlay=true;
- if (!weWhereConnected) //We have just connected
- {
- theGame.NewVsGame(&theGame2,SDL_GetTicks());
- theGame.putStartBlocks(nt.theSeed);
- theGame2.playNetwork(SDL_GetTicks());
- nt.theGameHasStarted();
- DrawIMG(background, screen, 0, 0);
- }
- weWhereConnected = true;
- }
- else
- {
- networkPlay=false;
- weWhereConnected = false;
- }
-#endif
-
if (!bScreenLocked)
{
SDL_Event event;
diff --git a/source/code/menudef.cpp b/source/code/menudef.cpp index ad33144..2235e14 100644 --- a/source/code/menudef.cpp +++ b/source/code/menudef.cpp
@@ -314,30 +314,6 @@ static void SinglePlayerVsMenu(Button *b)
spvs.run();
}
-static void NetworkMenu(Button *b)
-{
- Menu nm(&screen,_("Network"),true);
- Button bPort, bIp, bHost, bJoin;
- bHost.setLabel(_("Host game"));
- bHost.setAction(runHostGame);
- bJoin.setLabel(_("Join game"));
- bJoin.setAction(runJoinGame);
- format fi(_("Address: %1%") );
- fi % Config::getInstance()->getString("address0");
- bIp.setLabel(fi.str());
- bIp.setAction(buttonActionIpChange);
- format fp(_("Port: %1%") );
- fp % Config::getInstance()->getString("portv4");
- bPort.setLabel(fp.str());
- bPort.setAction(buttonActionPortChange);
- nm.addButton(&bHost);
- nm.addButton(&bJoin);
- nm.addButton(&bIp);
- nm.addButton(&bPort);
- nm.run();
-
-}
-
static void MultiplayerMenu(Button *b)
{
Menu mm(&screen,_("Multiplayer"),true);
@@ -346,13 +322,8 @@ static void MultiplayerMenu(Button *b)
bTT.setAction(runTwoPlayerTimeTrial);
bVs.setLabel(_("Two player - vs"));
bVs.setAction(runTwoPlayerVs);
- bNet.setLabel(_("Network/Internet game"));
- bNet.setAction(NetworkMenu);
mm.addButton(&bTT);
mm.addButton(&bVs);
-#if NETWORK
- mm.addButton(&bNet);
-#endif
mm.run();
}