git repos / blockattack-game

commit 2f30c381

sago007 · 2008-09-14 13:08
2f30c381ca5a37ee7eb9cc3110bcc7519731d9ec patch · browse files
parent 91886cae76524b1d92d3b5585a6d0a6a1e4c8049

Trying to make some of the things optional and easier to choose at 
compile time. Not working perfectly yet...


git-svn-id: https://blockattack.svn.sourceforge.net/svnroot/blockattack/trunk@41 9d7177f8-192b-0410-8f35-a16a89829b06

Changed files

M Makefile before
M source/code/BlockGame.hpp before
M source/code/NetworkThing.hpp before
M source/code/block.make before
M source/code/main.cpp before
M source/code/mainVars.hpp before
diff --git a/Makefile b/Makefile index 041f5de..7b0c95b 100644 --- a/Makefile +++ b/Makefile
@@ -1,7 +1,7 @@
#the things that tells about the system
-PREF=/usr/local
-EXECUTEPATH=/usr/local/bin
-INST=/games/blockattack
+#PREF=/usr/local
+#EXECUTEPATH=/usr/local/bin
+#INST=/games/blockattack
standard:
@echo "Removing old files (if they exists)"
diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp index 5a8f208..2e6ce45 100644 --- a/source/code/BlockGame.hpp +++ b/source/code/BlockGame.hpp
@@ -33,8 +33,10 @@ private:
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
Uint32 nextGarbageNumber;
Uint32 pushedPixelAt;
Uint32 nrPushedPixel, nrFellDown, nrStops;
@@ -118,8 +120,10 @@ public:
bGameOver = false;
bDraw = false;
bReplaying=false; //No replay by default
+ #if NETWORK
bDisconnected=false;
bNetworkPlayer = false;
+ #endif
timetrial = false;
stageClear = false;
vsMode = false;
@@ -235,8 +239,10 @@ public:
void NewGame(int tx, int ty) {
stageButtonStatus = SBdontShow;
bReplaying = false;
+ #if NETWORK
bNetworkPlayer=false;
bDisconnected =false;
+ #endif
nrFellDown = 0;
lastNrOfPlayers = 1; //At least one player :-)
nrPushedPixel = 0;
@@ -378,7 +384,9 @@ public:
NewGame(tx, ty);
gameStartedAt = SDL_GetTicks();
bReplaying = true; //We are playing, no calculations
+ #if NETWORK
bNetworkPlayer = false; //Take input from replay file
+ #endif
}
#if NETWORK
@@ -405,12 +413,14 @@ public:
//void SetGameOver();
+ #if NETWORK
//Sets disconnected:
void setDisconnect() {
bDisconnected = true;
SetGameOver();
}
-
+ #endif
+
//Prints "draw" and ends the game
void setDraw() {
bGameOver = true;
@@ -1966,7 +1976,11 @@ public:
//Draws everything
void DoPaintJob() {
DrawIMG(backBoard, sBoard, 0, 0);
+ #if NETWORK
if ((!bReplaying)&&(!bNetworkPlayer))
+ #else
+ if (!bReplaying)
+ #endif
PaintBricks();
else
SimplePaintBricks();
@@ -2063,7 +2077,11 @@ public:
break;
};
}
+ #if NETWORK
if ((!bReplaying)&&(!bNetworkPlayer)) {
+ #else
+ if (!bReplaying) {
+ #endif
FindTowerHeight();
if ((linesCleared-TowerHeight>stageClearLimit) && (stageClear) && (!bGameOver)) {
stageCleared[Level] = true;
diff --git a/source/code/NetworkThing.hpp b/source/code/NetworkThing.hpp index 8070fd5..88e8f30 100644 --- a/source/code/NetworkThing.hpp +++ b/source/code/NetworkThing.hpp
@@ -23,6 +23,8 @@ Copyright (C) 2007 Poul Sander
blockattack@poulsander.com
*/
+#if NETWORK
+
//The network interface
class NetworkThing
{
@@ -388,3 +390,5 @@ public:
}
}; //NetworkThing
+
+#endif
diff --git a/source/code/block.make b/source/code/block.make index ddcc331..dc1296b 100644 --- a/source/code/block.make +++ b/source/code/block.make
@@ -1,38 +1,64 @@
-../../Game/blockattack: main.o highscore.o SFont.o ReadKeyboard.o joypad.o listFiles.o replay.o common.o stats.o uploadReplay.o
- g++ -O -o ../../Game/blockattack main.o highscore.o SFont.o ReadKeyboard.o joypad.o listFiles.o replay.o common.o stats.o `sdl-config --cflags --libs` -lSDL_image -lSDL_mixer -lenet
+GAMEDIR=../../Game/
+BINARY=$(GAMEDIR)blockattack
+CC=gcc
+CPP=g++
+BASE_CFLAGS=-c $(shell sdl-config --cflags)
+BASE_LIBS=$(shell sdl-config --libs) -lSDL_image -lSDL_mixer
+
+ifndef DEBUG
+DEBUG=1
+endif
+
+ifndef NETWORK
+NETWORK=1
+endif
+
+ifeq ($(DEBUG),1)
+BASE_CFLAGS += -g -DDEBUG=1
+endif
+
+ifeq ($(NETWORK),1)
+BASE_CFLAGS += -DNETWORK=1
+BASE_LIBS += -lenet
+else
+BASE_CFLAGS += -DNETWORK=0
+endif
+
+$(BINARY): main.o highscore.o SFont.o ReadKeyboard.o joypad.o listFiles.o replay.o common.o stats.o uploadReplay.o
+ $(CPP) -O -o $(BINARY) main.o highscore.o SFont.o ReadKeyboard.o joypad.o listFiles.o replay.o common.o stats.o $(BASE_LIBS)
#-lphysfs
main.o: main.cpp BlockGame.hpp mainVars.hpp common.h
- g++ -g -c main.cpp `sdl-config --cflags`
+ $(CPP) $(BASE_CFLAGS) main.cpp
highscore.o: highscore.h highscore.cpp
- g++ -g -c highscore.cpp
+ $(CPP) $(BASE_CFLAGS) highscore.cpp
SFont.o: SFont.h SFont.c
- gcc -g -c SFont.c `sdl-config --cflags`
+ $(CC) $(BASE_CFLAGS) SFont.c
ReadKeyboard.o: ReadKeyboard.h ReadKeyboard.cpp
- g++ -g -c ReadKeyboard.cpp `sdl-config --cflags`
+ $(CPP) $(BASE_CFLAGS) ReadKeyboard.cpp
joypad.o: joypad.h joypad.cpp
- g++ -g -c joypad.cpp `sdl-config --cflags`
+ $(CPP) $(BASE_CFLAGS) joypad.cpp
listFiles.o: listFiles.h listFiles.cpp
- g++ -g -c listFiles.cpp
+ $(CPP) $(BASE_CFLAGS) listFiles.cpp
replay.o: replay.h replay.cpp
- g++ -g -c replay.cpp `sdl-config --cflags`
+ $(CPP) $(BASE_CFLAGS) replay.cpp
stats.o: stats.h stats.cc
- g++ -g -c stats.cc
+ $(CPP) $(BASE_CFLAGS) stats.cc
common.o: common.h common.cc
- g++ -g -c common.cc
+ $(CPP) $(BASE_CFLAGS) common.cc
uploadReplay.o: uploadReplay.cc uploadReplay.h
- g++ -g -c uploadReplay.cc `sdl-config --cflags`
+ $(CPP) $(BASE_CFLAGS) uploadReplay.cc
-run: ../../Game/blockattack
+run: $(BINARY)
clean:
rm *o
diff --git a/source/code/main.cpp b/source/code/main.cpp index d1bbccd..4deb7ce 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp
@@ -33,7 +33,7 @@ Copyright (C) 2008 Poul Sander
//If DEBUG is defined: AI info and FPS will be written to screen
#ifndef DEBUG
- #define DEBUG 1
+ #define DEBUG 0
#endif
//If NETWORK id defined: enet will be used
@@ -2267,7 +2267,11 @@ void DrawEverything(int xsize, int ysize,BlockGame &theGame, BlockGame &theGame2
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
DrawIMG(bNewGame, screen, 0, 0);
@@ -3540,7 +3544,11 @@ int main(int argc, char *argv[])
}
if ( event.key.keysym.sym == SDLK_F2 ) {
+ #if NETWORK
if ((!showHighscores)&&(!showOptions)&&(!networkActive)){
+ #else
+ if ((!showHighscores)&&(!showOptions)){
+ #endif
theGame.NewGame(50,100);
theGame.timetrial = false;
theGame.putStartBlocks();
@@ -3551,7 +3559,11 @@ int main(int argc, char *argv[])
vsMode = false;
}}
if ( event.key.keysym.sym == SDLK_F3 ) {
+ #if NETWORK
if ((!showHighscores)&&(!showOptions)&&(!networkActive)){
+ #else
+ if ((!showHighscores)&&(!showOptions)){
+ #endif
theGame.NewGame(50,100);
theGame.timetrial = true;
theGame.putStartBlocks();
@@ -3563,7 +3575,11 @@ int main(int argc, char *argv[])
}}
if ( event.key.keysym.sym == SDLK_F5 )
{
+ #if NETWORK
if ((!showHighscores)&&(!showOptions)&&(!networkActive))
+ #else
+ if ((!showHighscores)&&(!showOptions))
+ #endif
{
int myLevel = StageLevelSelect();
theGame.NewStageGame(myLevel,50,100);
@@ -3578,7 +3594,11 @@ int main(int argc, char *argv[])
}
if ( event.key.keysym.sym == SDLK_F6 )
{
+ #if NETWORK
if ((!showHighscores)&&(!showOptions)&&(!networkActive))
+ #else
+ if ((!showHighscores)&&(!showOptions))
+ #endif
{
theGame.NewVsGame(50,100,&theGame2);
theGame2.NewVsGame(xsize-500,100,&theGame);
@@ -3600,7 +3620,11 @@ int main(int argc, char *argv[])
}
if ( event.key.keysym.sym == SDLK_F4 )
{
+ #if NETWORK
if ((!showHighscores)&&(!showOptions)&&(!networkActive))
+ #else
+ if ((!showHighscores)&&(!showOptions))
+ #endif
{
theGame.NewGame(50,100);
theGame2.NewGame(xsize-500,100);
@@ -3623,7 +3647,11 @@ int main(int argc, char *argv[])
}
if ( event.key.keysym.sym == SDLK_F7 )
{
+ #if NETWORK
if ((!showHighscores)&&(!showOptions)&&(!networkActive))
+ #else
+ if ((!showHighscores)&&(!showOptions))
+ #endif
{
int myLevel = PuzzleLevelSelect();
theGame.NewPuzzleGame(myLevel,50,100);
@@ -3638,7 +3666,11 @@ int main(int argc, char *argv[])
}
if ( event.key.keysym.sym == SDLK_F8 )
{
+ #if NETWORK
if ((!showGame)&&(!showOptions)&&(!networkActive))
+ #else
+ if ((!showGame)&&(!showOptions))
+ #endif
if (!showHighscores)
{
closeAllMenus();
@@ -3986,6 +4018,11 @@ int main(int argc, char *argv[])
{
bMouseUp = false;
DrawIMG(background, screen, 0, 0);
+ #if NETWORK
+ //Nothing
+ #else
+ bool networkActive=false;
+ #endif
if ((0<mousex) && (mousex<120) && (0<mousey) && (mousey<40) &&(!networkActive) )
{
//New game clicked
@@ -4488,7 +4525,9 @@ int main(int argc, char *argv[])
theGame2.Update();
//see if anyone has won (two players only)
+ #if NETWORK
if (!networkPlay)
+ #endif
if (twoPlayers)
{
lastNrOfPlayers = 2;
diff --git a/source/code/mainVars.hpp b/source/code/mainVars.hpp index 03fbc19..3376b04 100644 --- a/source/code/mainVars.hpp +++ b/source/code/mainVars.hpp
@@ -74,7 +74,7 @@ SDL_Surface *iChainBack;
SDL_Surface *bReplay;
SDL_Surface *bSave;
SDL_Surface *bLoad;
-#ifdef NETWORK
+#if NETWORK
SDL_Surface *bNetwork;
SDL_Surface *bConnect;
SDL_Surface *bHost;
@@ -190,7 +190,7 @@ bool bOptionsOpen; //Show OptionsMenu (Configure and Select Puzzle)
bool b1playerOpen; //show submenu
bool b2playersOpen; //show submenu
bool bReplayOpen; //Show replay menu
-#ifdef NETWORK
+#if NETWORK
bool bNetworkOpen; //Show the network menu
#endif
bool showHighscores; //true if highscores is displayed
@@ -216,6 +216,7 @@ bool editorModeTest = false;
//end new 1.3.2
//Things for network play:
+#if NETWORK
bool networkPlay;
bool networkActive;
Uint8 nrOfNetworkPlayers; //Up to 4 players (inkl. self)
@@ -224,7 +225,7 @@ bool playerAlive[4];
#define SERVERPORT 41780
#define CLIENTPORT 41781
-#ifdef NETWORK
+
char serverAddress[30];
#endif