diff options
| -rw-r--r-- | README.sk | 96 | ||||
| -rw-r--r-- | config.h | 4 | ||||
| -rw-r--r-- | include/idManager.h | 3 | ||||
| -rw-r--r-- | include/item.h | 1 | ||||
| -rwxr-xr-x | include/layer.h | 1 | ||||
| -rw-r--r-- | include/pipe.h | 50 | ||||
| -rw-r--r-- | include/shot.h | 1 | ||||
| -rw-r--r-- | include/teleport.h | 45 | ||||
| -rw-r--r-- | include/tux.h | 3 | ||||
| -rw-r--r-- | include/wall.h | 49 | ||||
| -rwxr-xr-x | modules/modPipe.c | 30 | ||||
| -rwxr-xr-x | modules/modTeleport.c | 29 | ||||
| -rwxr-xr-x | modules/modWall.c | 16 | ||||
| -rwxr-xr-x | src/Makefile | 6 | ||||
| -rwxr-xr-x | src/Makefile-publicServer | 13 | ||||
| -rw-r--r-- | src/arena.c | 3 | ||||
| -rw-r--r-- | src/arenaFile.c | 3 | ||||
| -rw-r--r-- | src/dynamicInt.c | 13 | ||||
| -rw-r--r-- | src/gun.c | 1 | ||||
| -rwxr-xr-x | src/interface.c | 9 | ||||
| -rw-r--r-- | src/item.c | 2 | ||||
| -rw-r--r-- | src/pipe.c | 223 | ||||
| -rw-r--r-- | src/proto.c | 13 | ||||
| -rw-r--r-- | src/publicServer.c | 10 | ||||
| -rw-r--r-- | src/screen.c | 1 | ||||
| -rw-r--r-- | src/screen_world.c | 4 | ||||
| -rw-r--r-- | src/shot.c | 2 | ||||
| -rw-r--r-- | src/teleport.c | 242 | ||||
| -rw-r--r-- | src/tux.c | 4 | ||||
| -rw-r--r-- | src/wall.c | 142 |
30 files changed, 181 insertions, 838 deletions
diff --git a/README.sk b/README.sk new file mode 100644 index 0000000..40e1877 --- /dev/null +++ b/README.sk @@ -0,0 +1,96 @@ + + *** + + Navod ako skompilovat zdrojove kody + + *** + + Projekt sa da kompilovat ako hra ( client ) s GUI, alebo ako herny server + + ************************************************ + + kompilacia hry s GUI + + Pri kompilacii, hry ako grafickeho klienta sa potrebuju kniznice : + (g)libc, SDL, SDL_Image, SDL_Mixer, SDL_ttf, SDL_Net + v ratatne hlavickovych suborov a konfiguracnych striptov ( sdl-config ) + + ldd -u `which tuxanci` + Unused direct dependencies: + /usr/lib/libSDL_image-1.2.so.0 + /usr/lib/libSDL_mixer-1.2.so.0 + /usr/lib/libSDL_ttf-2.0.so.0 + /usr/lib/libSDL_net-1.2.so.0 + /usr/lib/libSDL-1.2.so.0 + + make clean + ---------- + + pre istotu vymazame subory z predchadzajucej kompilacie + + v subore config.h do makra DESTDIR ulozime nas prefix-path, + ktory sa natvrdo skompiluje do programu + #define DESTDIR "/usr/local/" + + Ak toto maro nebude existovat, program bude pouzivat svoje podaresare :) + ( vhodne pri vyvoji, ked sa casto menia subory ) + + make mod + -------- + + skompilujeme moduly hry + + su + -- + + prepneme sa na roota + + make install DESTDIR=/usr/local + nainstalujeme subory, DESTDIR urcuje kam sa budu subory kopirovat. + bolo by dobre, keby sa rovnala hodnoty makru DESTDIR, ale nie je to podmienka. + Ak bude hodnota makra DESTDIR a premennej DESTDIR v Makefile rozdielna, program + si nenajde svoje subory. + + tuxanci-ng + ---------- + Program spustime tymto prikazom. + Hra si vytvara domovsky adresar v domovskom adresari uzivatela ~/.tuxanci-ng + + make uninstall DESTDIR=/usr/local + --------------------------------- + + Program sa odinstaluje + + ************************************************ + + kompilacia herneho servera + + Pri kompilacii, herneho servera musi existovat makro PUBLIC_SERVER v config.h + Je automaticky zakomentovane, tak ho pls. odkomentujte + + Makro DESTDIR, nehra pri kompilacii herneho server ziadnu rolu. Server pouziva + svoje podadresare a ani sa neinstaluje + + make clean + ---------- + + pre istotu vymazame subory z predchadzajucej kompilacie. + + make server + ----------- + + kompilujeme server + + ./build-server/publicserver + -------------- + + Spustame server + + konfiguracia servera je v server.conf, dufam, ze je jasna + + ************************************************ + + Dušan Ďurech + email: Dusan.D@Centrum.Sk + jabber IM: Oroborus@Jabbim.sk + //fakt narychlo napisane @@ -6,8 +6,8 @@ #define DEBUG_CLIENT_RECV */ -#define TUXANCI_NG_VERSION "svn52" +#define TUXANCI_NG_VERSION "svn54" -//#define DESTDIR "/usr/local/" +#define DESTDIR "/usr/local/" #define SUPPORT_NET_SDL_UDP //#define PUBLIC_SERVER diff --git a/include/idManager.h b/include/idManager.h index a525a56..1684186 100644 --- a/include/idManager.h +++ b/include/idManager.h @@ -4,7 +4,8 @@ #define ID_MANAGER_H -#define MAX_ID 1000 +#define MAX_ID 1000 +#define ID_UNKNOWN -1 #include "list.h" diff --git a/include/item.h b/include/item.h index 3413452..7c1043a 100644 --- a/include/item.h +++ b/include/item.h @@ -62,6 +62,7 @@ extern bool_t isItemInicialized(); extern void initItem(); extern item_t* newItem(int x, int y, int type, int author_id); extern item_t* getItemID(list_t *listItem, int id); +extern void replaceItemID(item_t *item, int id); extern void addNewItem(list_t *listItem, int author_id); #ifndef PUBLIC_SERVER extern void drawItem(item_t *p); diff --git a/include/layer.h b/include/layer.h index 1aded63..04a4617 100755 --- a/include/layer.h +++ b/include/layer.h @@ -47,6 +47,7 @@ extern void addLayer(SDL_Surface *img, */ extern void drawLayer(); extern void drawLayerCenter(int x, int y); +extern void flushLayer(); extern void quitLayer(); #endif diff --git a/include/pipe.h b/include/pipe.h deleted file mode 100644 index af8e180..0000000 --- a/include/pipe.h +++ /dev/null @@ -1,50 +0,0 @@ - -#ifndef PIPE_H - -#define PIPE_H - -#include "main.h" -#ifndef PUBLIC_SERVER -#include "interface.h" -#endif -#include "list.h" - -typedef struct pipe_struct -{ - int x; // poloha steny - int y; - - int w; // rozmery steny - int h; - - int id; - int id_out; - int position; - - int layer; // vrstva - -#ifndef PUBLIC_SERVER - SDL_Surface *img; //obrazok -#endif -} pipe_t; - -#ifndef PUBLIC_SERVER -extern pipe_t* newPipe(int x, int y, int w, int h, int layer, - int id, int id_out, int position, SDL_Surface *img); -#endif - -#ifdef PUBLIC_SERVER -extern pipe_t* newPipe(int x, int y, int w, int h, int layer, - int id, int id_out, int position); -#endif - -#ifndef PUBLIC_SERVER -extern void drawPipe(pipe_t *p); -extern void drawListPipe(list_t *listPipe); -#endif -extern pipe_t* isConflictWithListPipe(list_t *listPipe, int x, int y, int w, int h); -extern void eventConflictShotWithPipe(list_t *listPipe, list_t *listShot); -extern void destroyPipe(pipe_t *p); - -#endif - diff --git a/include/shot.h b/include/shot.h index 156a736..526727b 100644 --- a/include/shot.h +++ b/include/shot.h @@ -38,6 +38,7 @@ extern bool_t isShotInicialized(); extern void initShot(); extern shot_t* newShot(int x,int y, int px, int py, int gun, int author_id); extern shot_t* getShotID(list_t *listShot, int id); +extern void replaceShotID(shot_t *shot, int id); #ifndef PUBLIC_SERVER extern void drawShot(shot_t *p); extern void drawListShot(list_t *listShot); diff --git a/include/teleport.h b/include/teleport.h deleted file mode 100644 index 1101a57..0000000 --- a/include/teleport.h +++ /dev/null @@ -1,45 +0,0 @@ - -#ifndef TELEPORT_H - -#define TELEPORT_H - -#ifndef PUBLIC_SERVER -#include "interface.h" -#endif -#include "main.h" -#include "list.h" - -typedef struct teleport_struct -{ - int x; // poloha steny - int y; - - int w; // rozmery steny - int h; - - int layer; // vrstva - -#ifndef PUBLIC_SERVER - SDL_Surface *img; //obrazok -#endif -} teleport_t; - -#ifndef PUBLIC_SERVER -extern teleport_t* newTeleport(int x, int y, int w, int h, int layer, SDL_Surface *img); -#endif - -#ifdef PUBLIC_SERVER -extern teleport_t* newTeleport(int x, int y, int w, int h, int layer); -#endif - -#ifndef PUBLIC_SERVER -extern void drawTeleport(teleport_t *p); -extern void drawListTeleport(list_t *listTeleport); -#endif -extern teleport_t* isConflictWithListTeleport(list_t *listTeleport, int x, int y, int w, int h); -extern void eventConflictShotWithTeleport(list_t *listTeleport, list_t *listShot); -extern void eventTeleportTux(list_t *listTeleport, teleport_t *teleport, tux_t *tux); -extern void destroyTeleport(teleport_t *p); - -#endif - diff --git a/include/tux.h b/include/tux.h index 05c0c8c..1343274 100644 --- a/include/tux.h +++ b/include/tux.h @@ -6,8 +6,6 @@ #include "main.h" #include "list.h" -#define ID_UNKNOWN -1 - #define TUX_STEP 6 #define TUX_LAYER 0 @@ -123,6 +121,7 @@ extern void actionTux(tux_t *tux, int action); extern void eventListTux(list_t *listTux); extern tux_t* getTuxID(list_t *listTux, int id); extern void getTuxProportion(tux_t *tux, int *x,int *y, int *w, int *h); +extern void replaceTuxID(tux_t *tux, int id); extern void setTuxProportion(tux_t *tux, int x, int y); extern void destroyTux(tux_t *tux); extern void quitTux(); diff --git a/include/wall.h b/include/wall.h deleted file mode 100644 index 1389539..0000000 --- a/include/wall.h +++ /dev/null @@ -1,49 +0,0 @@ - -#ifndef WALL_H - -#define WALL_H - -#include "main.h" - -#ifndef PUBLIC_SERVER -#include "interface.h" -#endif - -#include "list.h" - -typedef struct wall_struct -{ - int x; // poloha steny - int y; - - int w; // rozmery steny - int h; - - int img_x; // poloha obrazka - int img_y; - - int layer; // vrstva - -#ifndef PUBLIC_SERVER - SDL_Surface *img; //obrazok -#endif -} wall_t; - -#ifndef PUBLIC_SERVER -extern wall_t* newWall(int x, int y, int w, int h, - int img_x, int img_y, int layer, SDL_Surface *img); -#endif - -#ifdef PUBLIC_SERVER -extern wall_t* newWall(int x, int y, int w, int h, - int img_x, int img_y, int layer); -#endif - -extern void drawWall(wall_t *p); -extern void drawListWall(list_t *listWall); -extern int isConflictWithListWall(list_t *listWall, int x, int y, int w, int h); -extern void eventConflictShotWithWall(list_t *listWall, list_t *listShot); -extern void destroyWall(wall_t *p); - -#endif - diff --git a/modules/modPipe.c b/modules/modPipe.c index fa5f99e..6f000d8 100755 --- a/modules/modPipe.c +++ b/modules/modPipe.c @@ -83,16 +83,16 @@ static void drawPipe(pipe_t *p) #endif -static pipe_t* isConflictWithListPipe(list_t *listPipe, int x, int y, int w, int h) +static pipe_t* isConflictWithListPipe(list_t *list, int x, int y, int w, int h) { pipe_t *thisPipe; int i; - assert( listPipe != NULL ); + assert( list != NULL ); - for( i = 0 ; i < listPipe->count ; i++ ) + for( i = 0 ; i < list->count ; i++ ) { - thisPipe = (pipe_t *)listPipe->list[i]; + thisPipe = (pipe_t *)list->list[i]; assert( thisPipe != NULL ); if( export_fce->fce_conflictSpace(x, y, w, h, @@ -248,15 +248,15 @@ static void moveShot(shot_t *shot, int position, int src_x, int src_y, } -static pipe_t* getPipeId(list_t *listPipe, int id) +static pipe_t* getPipeId(list_t *list, int id) { int i; - for( i = 0 ; i < listPipe->count ; i++ ) + for( i = 0 ; i < list->count ; i++ ) { pipe_t *thisPipe; - thisPipe = (pipe_t *) listPipe->list[i]; + thisPipe = (pipe_t *) list->list[i]; if( thisPipe->id == id ) { @@ -267,11 +267,11 @@ static pipe_t* getPipeId(list_t *listPipe, int id) return NULL; } -static void moveShotFromPipe(shot_t *shot, pipe_t *pipe, list_t *listPipe) +static void moveShotFromPipe(shot_t *shot, pipe_t *pipe, list_t *list) { pipe_t *distPipe; - distPipe = getPipeId(listPipe, pipe->id_out); + distPipe = getPipeId(list, pipe->id_out); if( distPipe == NULL ) { @@ -339,7 +339,12 @@ int event() pipe_t *thisPipe; arena_t *arena; int i; - +/* + if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT ) + { + return; + } +*/ arena = export_fce->fce_getCurrentArena(); for( i = 0 ; i < arena->listShot->count ; i++ ) @@ -365,6 +370,8 @@ int event() if( negPosition( thisShot->position ) == thisPipe->position ) { + //moveShotFromPipe(thisShot, thisPipe, listPipe); + if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT ) { if( thisShot->gun != GUN_BOMBBALL ) @@ -377,11 +384,12 @@ int event() { moveShotFromPipe(thisShot, thisPipe, listPipe); } + } else { if( thisShot->gun == GUN_BOMBBALL && - export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT ) + export_fce->fce_getNetTypeGame() != NET_GAME_TYPE_CLIENT ) { export_fce->fce_boundBombBall(thisShot); continue; diff --git a/modules/modTeleport.c b/modules/modTeleport.c index fb59470..0f0d41b 100755 --- a/modules/modTeleport.c +++ b/modules/modTeleport.c @@ -62,7 +62,6 @@ teleport_t* newTeleport(int x, int y, int w, int h, int layer) new->img = img; #endif - printf("new teleport\n"); return new; } @@ -77,16 +76,16 @@ static void drawTeleport(teleport_t *p) #endif -static teleport_t* isConflictWithListTeleport(list_t *listTeleport, int x, int y, int w, int h) +static teleport_t* isConflictWithListTeleport(list_t *list, int x, int y, int w, int h) { teleport_t *thisTeleport; int i; - assert( listTeleport != NULL ); + assert( list != NULL ); - for( i = 0 ; i < listTeleport->count ; i++ ) + for( i = 0 ; i < list->count ; i++ ) { - thisTeleport = (teleport_t *)listTeleport->list[i]; + thisTeleport = (teleport_t *)list->list[i]; assert( thisTeleport != NULL ); if( export_fce->fce_conflictSpace(x, y, w, h, @@ -138,15 +137,15 @@ static void cmd_teleport(char *line) addList(listTeleport, new); } -static teleport_t* getRandomTeleportBut(list_t *listTeleport, teleport_t *teleport) +static teleport_t* getRandomTeleportBut(list_t *list, teleport_t *teleport) { int x; do{ - x = random() % listTeleport->count; - }while( listTeleport->list[x] == teleport ); + x = random() % list->count; + }while( list->list[x] == teleport ); - return (teleport_t *) listTeleport->list[x]; + return (teleport_t *) list->list[x]; } static int getRandomPosition() @@ -353,11 +352,11 @@ static void moveShot(shot_t *shot, int position, int src_x, int src_y, } -static void moveShotFromTeleport(shot_t *shot, teleport_t *teleport, list_t *listTeleport) +static void moveShotFromTeleport(shot_t *shot, teleport_t *teleport, list_t *list) { teleport_t *distTeleport; - distTeleport = getRandomTeleportBut(listTeleport, teleport); + distTeleport = getRandomTeleportBut(list, teleport); moveShot(shot, getRandomPosition(), teleport->x, teleport->y, distTeleport->x, distTeleport->y, distTeleport->w, distTeleport->h); @@ -397,6 +396,11 @@ int event() arena_t *arena; int i; + if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT ) + { + return 0; + } + arena = export_fce->fce_getCurrentArena(); for( i = 0 ; i < arena->listTux->count ; i++ ) @@ -439,6 +443,8 @@ int event() continue; } + moveShotFromTeleport(thisShot, thisTeleport, listTeleport); +/* if( export_fce->fce_getNetTypeGame() == NET_GAME_TYPE_CLIENT ) { delListItem(arena->listShot, i, export_fce->fce_destroyShot); @@ -448,6 +454,7 @@ int event() { moveShotFromTeleport(thisShot, thisTeleport, listTeleport); } +*/ } } diff --git a/modules/modWall.c b/modules/modWall.c index 50756e8..d435613 100755 --- a/modules/modWall.c +++ b/modules/modWall.c @@ -80,16 +80,16 @@ void drawWall(wall_t *p) export_fce->fce_addLayer(p->img, p->img_x, p->img_y, 0, 0, p->img->w, p->img->h, p->layer); } -void drawListWall(list_t *listWall) +void drawListWall(list_t *list) { wall_t *thisWall; int i; - assert( listWall != NULL ); + assert( list != NULL ); - for( i = 0 ; i < listWall->count ; i++ ) + for( i = 0 ; i < list->count ; i++ ) { - thisWall = (wall_t *)listWall->list[i]; + thisWall = (wall_t *)list->list[i]; assert( thisWall != NULL ); drawWall(thisWall); } @@ -97,16 +97,16 @@ void drawListWall(list_t *listWall) #endif -wall_t* isConflictWithListWall(list_t *listWall, int x, int y, int w, int h) +wall_t* isConflictWithListWall(list_t *list, int x, int y, int w, int h) { wall_t *thisWall; int i; - assert( listWall != NULL ); + assert( list != NULL ); - for( i = 0 ; i < listWall->count ; i++ ) + for( i = 0 ; i < list->count ; i++ ) { - thisWall = (wall_t *)listWall->list[i]; + thisWall = (wall_t *)list->list[i]; assert( thisWall != NULL ); if( export_fce->fce_conflictSpace(x, y, w, h, diff --git a/src/Makefile b/src/Makefile index 25db7f8..cfc9478 100755 --- a/src/Makefile +++ b/src/Makefile @@ -9,7 +9,7 @@ CFLAGS = -g -O0 -std=c99 -I../include -Wall `sdl-config --cflags` BUILD_DIR = . LIBS = `sdl-config --libs` -lSDL_image -lSDL_ttf -lSDL_mixer -lSDL_net -FILES = interface.o idManager.o checkFront.o font.o list.o modules.o image.o layer.o director.o\ +FILES = interface.o idManager.o font.o list.o modules.o image.o layer.o director.o\ configFile.o tux.o main.o \ screen.o screen_world.o shot.o myTimer.o panel.o net_multiplayer.o \ buffer.o arena.o arenaFile.o textFile.o audio.o sound.o music.o gun.o \ @@ -33,8 +33,8 @@ modules.o: modules.c ../include/modules.h idManager.o: idManager.c ../include/idManager.h $(CC) $(CFLAGS) -o $(BUILD_DIR)/idManager.o -c idManager.c -checkFront.o: checkFront.c ../include/checkFront.h - $(CC) $(CFLAGS) -o $(BUILD_DIR)/checkFront.o -c checkFront.c +#checkFront.o: checkFront.c ../include/checkFront.h +# $(CC) $(CFLAGS) -o $(BUILD_DIR)/checkFront.o -c checkFront.c font.o: font.c ../include/font.h $(CC) $(CFLAGS) -o $(BUILD_DIR)/font.o -c font.c diff --git a/src/Makefile-publicServer b/src/Makefile-publicServer index d6956bf..69edffd 100755 --- a/src/Makefile-publicServer +++ b/src/Makefile-publicServer @@ -10,8 +10,8 @@ CFLAGS = -g -O0 -I../include -Wall BUILD_DIR = ../build-server LIBS = -ldl -FILES = list.o modules.o director.o configFile.o tux.o wall.o shot.o myTimer.o \ - buffer.o dynamicInt.o arena.o arenaFile.o textFile.o gun.o item.o\ +FILES = list.o modules.o director.o configFile.o tux.o shot.o myTimer.o \ + buffer.o arena.o arenaFile.o textFile.o gun.o item.o idManager.o\ udp.o proto.o server.o publicServer.o net_multiplayer.o serverConfigFile.o main.o $(BUILD_DIR)/publicserver: mkdir_build $(FILES) @@ -23,6 +23,9 @@ mkdir_build: main.o: main.c $(CC) $(CFLAGS) -o $(BUILD_DIR)/main.o -c main.c +idManager.o: idManager.c ../include/idManager.h + $(CC) $(CFLAGS) -o $(BUILD_DIR)/idManager.o -c idManager.c + modules.o: modules.c $(CC) $(CFLAGS) -o $(BUILD_DIR)/modules.o -c modules.c @@ -41,9 +44,6 @@ configFile.o: configFile.c ../include/configFile.h tux.o: tux.c ../include/tux.h $(CC) $(CFLAGS) -o $(BUILD_DIR)/tux.o -c tux.c -wall.o: wall.c ../include/wall.h - $(CC) $(CFLAGS) -o $(BUILD_DIR)/wall.o -c wall.c - shot.o: shot.c ../include/shot.h $(CC) $(CFLAGS) -o $(BUILD_DIR)/shot.o -c shot.c @@ -68,9 +68,6 @@ server.o: server.c ../include/server.h net_multiplayer.o: net_multiplayer.c ../include/net_multiplayer.h $(CC) $(CFLAGS) -o $(BUILD_DIR)/net_multiplayer.o -c net_multiplayer.c -dynamicInt.o: dynamicInt.c ../include/dynamicInt.h - $(CC) $(CFLAGS) -o $(BUILD_DIR)/dynamicInt.o -c dynamicInt.c - arena.o: arena.c ../include/arena.h $(CC) $(CFLAGS) -o $(BUILD_DIR)/arena.o -c arena.c diff --git a/src/arena.c b/src/arena.c index 3e14066..1980a95 100644 --- a/src/arena.c +++ b/src/arena.c @@ -8,10 +8,7 @@ #include "list.h" #include "tux.h" #include "shot.h" -#include "wall.h" #include "item.h" -#include "teleport.h" -#include "pipe.h" #include "myTimer.h" #include "modules.h" diff --git a/src/arenaFile.c b/src/arenaFile.c index dc705fd..53b6138 100644 --- a/src/arenaFile.c +++ b/src/arenaFile.c @@ -12,9 +12,6 @@ #include "arena.h" #include "tux.h" #include "shot.h" -#include "wall.h" -#include "pipe.h" -#include "teleport.h" #include "item.h" #include "director.h" #include "path.h" diff --git a/src/dynamicInt.c b/src/dynamicInt.c deleted file mode 100644 index 0b53762..0000000 --- a/src/dynamicInt.c +++ /dev/null @@ -1,13 +0,0 @@ - -#include <stdlib.h> -#include "main.h" -#include "dynamicInt.h" - - -int* newInt(int x) -{ - int *new; - new = malloc( sizeof(int) ); - *new = x; - return new; -} @@ -7,7 +7,6 @@ #include "arena.h" #include "tux.h" #include "shot.h" -#include "dynamicInt.h" #include "myTimer.h" #include "item.h" #include "gun.h" diff --git a/src/interface.c b/src/interface.c index 4fdf2ba..675c4d2 100755 --- a/src/interface.c +++ b/src/interface.c @@ -9,7 +9,7 @@ //povrch okna static SDL_Surface *screen; -static SDL_Surface *fake_screen; +//static SDL_Surface *my_surface; //casovac static SDL_TimerID timer; @@ -53,11 +53,14 @@ int initSDL() //screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, 0, g_win_flags); screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, 0, g_win_flags); - fake_screen = SDL_CreateRGBSurface(screen->flags, WINDOW_SIZE_X, WINDOW_SIZE_Y, +/* + my_surface = SDL_CreateRGBSurface(screen->flags, WINDOW_SIZE_X, WINDOW_SIZE_Y, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask); + memset(my_surface->pixels, 128, 200); +*/ if (screen == NULL ) { fprintf(stderr, "%s\n", SDL_GetError()); @@ -86,6 +89,8 @@ void interfaceRefresh() { //SDL_BlitSurface(fake_screen, NULL, screen, NULL); //SDL_UpdateRect(screen, 0, 0, screen->w, screen->h); + + //drawImage(my_surface, 200, 100, 0, 0, 200, 200); SDL_Flip(screen); } @@ -215,8 +215,6 @@ void addNewItem(list_t *listItem, int author_id) (getNetTypeGame() == NET_GAME_TYPE_NONE && type == BONUS_HIDDEN) ); #endif - type = GUN_MINE; - item = newItem(new_x, new_y, type, author_id); addList(listItem, item); diff --git a/src/pipe.c b/src/pipe.c deleted file mode 100644 index 9225be5..0000000 --- a/src/pipe.c +++ /dev/null @@ -1,223 +0,0 @@ - -#include <stdlib.h> -#include <stdio.h> -#include <assert.h> - -#include "main.h" -#include "pipe.h" -#include "shot.h" -#include "net_multiplayer.h" - -#ifndef PUBLIC_SERVER -#include "screen_world.h" -#include "layer.h" -#endif - -#ifdef PUBLIC_SERVER -#include "publicServer.h" -#endif - -#ifndef PUBLIC_SERVER -pipe_t* newPipe(int x, int y, int w, int h, int layer, int id, int id_out, int position, SDL_Surface *img) -#endif - -#ifdef PUBLIC_SERVER -pipe_t* newPipe(int x, int y, int w, int h, int layer, int id, int id_out, int position) -#endif - -{ - pipe_t *new; - -#ifndef PUBLIC_SERVER - assert( img != NULL ); -#endif - - new = malloc( sizeof(pipe_t) ); - assert( new != NULL ); - - new->x = x; - new->y = y; - new->w = w; - new->h = h; - new->layer = layer; - new->id = id; - new->id_out = id_out; - new->position = position; -#ifndef PUBLIC_SERVER - new->img = img; -#endif - return new; -} - -#ifndef PUBLIC_SERVER - -void drawPipe(pipe_t *p) -{ - assert( p != NULL ); - - addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, p->layer); -} - -void drawListPipe(list_t *listPipe) -{ - pipe_t *thisPipe; - int i; - - assert( listPipe != NULL ); - - for( i = 0 ; i < listPipe->count ; i++ ) - { - thisPipe = (pipe_t *)listPipe->list[i]; - assert( thisPipe != NULL ); - drawPipe(thisPipe); - } -} - -#endif - -pipe_t* isConflictWithListPipe(list_t *listPipe, int x, int y, int w, int h) -{ - pipe_t *thisPipe; - int i; - - assert( listPipe != NULL ); - - for( i = 0 ; i < listPipe->count ; i++ ) - { - thisPipe = (pipe_t *)listPipe->list[i]; - assert( thisPipe != NULL ); - - if( conflictSpace(x, y, w, h, - thisPipe->x, thisPipe->y, thisPipe->w, thisPipe->h) ) - { - return thisPipe; - } - } - - return NULL; -} - -static int negPosition(int n) -{ - switch( n ) - { - case TUX_UP : - return TUX_DOWN; - - case TUX_LEFT : - return TUX_RIGHT; - - case TUX_RIGHT : - return TUX_LEFT; - - case TUX_DOWN : - return TUX_UP; - - default : - assert( ! "premenna n ma zlu hodnotu !" ); - break; - } -} - -static pipe_t* getPipeId(list_t *listPipe, int id) -{ - int i; - - for( i = 0 ; i < listPipe->count ; i++ ) - { - pipe_t *thisPipe; - - thisPipe = (pipe_t *) listPipe->list[i]; - - if( thisPipe->id == id ) - { - return thisPipe; - } - } - - return NULL; -} - -static void moveShotFromPipe(shot_t *shot, pipe_t *pipe, list_t *listPipe) -{ - pipe_t *distPipe; - - distPipe = getPipeId(listPipe, pipe->id_out); - - if( distPipe == NULL ) - { - fprintf(stderr, "Pipe %d ID not found\n", pipe->id); - return; - } -/* - moveShot(shot, distPipe->position, pipe->x, pipe->y, - distPipe->x, distPipe->y, distPipe->w, distPipe->h); -*/ -} - -void eventConflictShotWithPipe(list_t *listPipe, list_t *listShot) -{ - shot_t *thisShot; - pipe_t *thisPipe; - int i; - - assert( listPipe != NULL ); - assert( listShot != NULL ); - - for( i = 0 ; i < listShot->count ; i++ ) - { - thisShot = (shot_t *)listShot->list[i]; - assert( thisShot != NULL ); - - if( ( thisPipe = isConflictWithListPipe(listPipe, thisShot->x, thisShot->y, - thisShot->w, thisShot->h) ) != NULL ) - { - tux_t *author; - - author = getTuxID(getCurrentArena()->listTux, thisShot->author_id); - - if( author != NULL && - author->bonus == BONUS_GHOST && - author->bonus_time > 0 ) - { - continue; - } - - if( negPosition( thisShot->position ) == thisPipe->position ) - { - if( getNetTypeGame() == NET_GAME_TYPE_CLIENT ) - { - if( thisShot->gun != GUN_BOMBBALL ) - { - delListItem(listShot, i, destroyShot); - i--; - } - } - else - { - moveShotFromPipe(thisShot, thisPipe, listPipe); - } - } - else - { - if( thisShot->gun == GUN_BOMBBALL && getNetTypeGame() != NET_GAME_TYPE_CLIENT ) - { - boundBombBall(thisShot); - continue; - } - else - { - delListItem(listShot, i, destroyShot); - i--; - } - } - } - } -} - -void destroyPipe(pipe_t *p) -{ - assert( p != NULL ); - free(p); -} - diff --git a/src/proto.c b/src/proto.c index 45abf8c..4174f09 100644 --- a/src/proto.c +++ b/src/proto.c @@ -577,7 +577,7 @@ void proto_send_shot_server(int type, client_t *client, shot_t *p) char msg[STR_PROTO_SIZE]; assert( p != NULL ); - + sprintf(msg, "shot %d %d %d %d %d %d %d %d %d\n", p->id, p->x, p->y, p->px, p->py, p->position, p->gun, p->author_id, p->isCanKillAuthor); @@ -597,12 +597,15 @@ void proto_recv_shot_client(char *msg) sscanf(msg, "%s %d %d %d %d %d %d %d %d %d", cmd, &shot_id, &x, &y, &px, &py, &position, &gun, &author_id, &isCanKillAuthor); -/* - if( getShotID(getCurrentArena()->listShot, shot_id) != NULL ) + + if( ( shot = getShotID(getCurrentArena()->listShot, shot_id) ) != NULL ) { - return; + delListItem(getCurrentArena()->listShot, + searchListItem(getCurrentArena()->listShot, shot), destroyShot); + + //return; } -*/ + shot = newShot(x, y, px, py, gun, author_id); replaceShotID(shot, shot_id); diff --git a/src/publicServer.c b/src/publicServer.c index 66d530f..6ac64c9 100644 --- a/src/publicServer.c +++ b/src/publicServer.c @@ -9,9 +9,7 @@ #include "main.h" #include "list.h" #include "tux.h" -#include "wall.h" -#include "teleport.h" -#include "pipe.h" +#include "idManager.h" #include "myTimer.h" #include "arena.h" #include "item.h" @@ -111,8 +109,14 @@ void my_handler_quit(int n) void quitPublicServer() { printf("quit public server\n"); + quitNetMultiplayer(); destroyArena(arena); + + quitTux(); + quitItem(); + quitShot(); + quitArenaFile(); quitServerConfigFile(); quitModule(); diff --git a/src/screen.c b/src/screen.c index 0fc0d69..07a30a2 100644 --- a/src/screen.c +++ b/src/screen.c @@ -6,6 +6,7 @@ #include "interface.h" #include "screen.h" #include "list.h" +#include "layer.h" static screen_t *currentScreen; static list_t *listScreen; diff --git a/src/screen_world.c b/src/screen_world.c index fde1d4a..c90b419 100644 --- a/src/screen_world.c +++ b/src/screen_world.c @@ -21,9 +21,6 @@ #include "sound.h" #include "fake_audio.h" #include "tux.h" -#include "wall.h" -#include "teleport.h" -#include "pipe.h" #include "item.h" #include "shot.h" #include "gun.h" @@ -37,6 +34,7 @@ #include "font.h" #include "music.h" #include "modules.h" +#include "idManager.h" static arena_t *arena; static int count; @@ -6,8 +6,6 @@ #include "main.h" #include "shot.h" #include "gun.h" -#include "wall.h" -#include "pipe.h" #include "net_multiplayer.h" #include "proto.h" #include "idManager.h" diff --git a/src/teleport.c b/src/teleport.c deleted file mode 100644 index d8557e3..0000000 --- a/src/teleport.c +++ /dev/null @@ -1,242 +0,0 @@ - -#include <stdlib.h> -#include <assert.h> - -#include "main.h" -#include "tux.h" -#include "teleport.h" -#include "shot.h" -#include "net_multiplayer.h" -#include "proto.h" -#include "arena.h" - -#ifndef PUBLIC_SERVER -#include "layer.h" -#include "screen_world.h" -#include "sound.h" -#include "fake_audio.h" -#endif - -#ifdef PUBLIC_SERVER -#include "publicServer.h" -#endif - -#ifndef PUBLIC_SERVER -teleport_t* newTeleport(int x, int y, int w, int h, int layer, SDL_Surface *img) -#endif - -#ifdef PUBLIC_SERVER -teleport_t* newTeleport(int x, int y, int w, int h, int layer) -#endif -{ - teleport_t *new; - -#ifndef PUBLIC_SERVER - assert( img != NULL ); -#endif - - new = malloc( sizeof(teleport_t) ); - assert( new != NULL ); - - new->x = x; - new->y = y; - new->w = w; - new->h = h; - new->layer = layer; -#ifndef PUBLIC_SERVER - new->img = img; -#endif - return new; -} - -#ifndef PUBLIC_SERVER - -void drawTeleport(teleport_t *p) -{ - assert( p != NULL ); - - addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, p->layer); -} - -void drawListTeleport(list_t *listTeleport) -{ - teleport_t *thisTeleport; - int i; - - assert( listTeleport != NULL ); - - for( i = 0 ; i < listTeleport->count ; i++ ) - { - thisTeleport = (teleport_t *)listTeleport->list[i]; - assert( thisTeleport != NULL ); - drawTeleport(thisTeleport); - } -} - -#endif - -teleport_t* isConflictWithListTeleport(list_t *listTeleport, int x, int y, int w, int h) -{ - teleport_t *thisTeleport; - int i; - - assert( listTeleport != NULL ); - - for( i = 0 ; i < listTeleport->count ; i++ ) - { - thisTeleport = (teleport_t *)listTeleport->list[i]; - assert( thisTeleport != NULL ); - - if( conflictSpace(x, y, w, h, - thisTeleport->x, thisTeleport->y, thisTeleport->w, thisTeleport->h) ) - { - return thisTeleport; - } - } - - return NULL; -} - -static teleport_t* getRandomTeleportBut(list_t *listTeleport, teleport_t *teleport) -{ - int x; - - do{ - x = random() % listTeleport->count; - }while( listTeleport->list[x] == teleport ); - - return (teleport_t *) listTeleport->list[x]; -} - -static int getRandomPosition() -{ - switch( random() % 4 ) - { - case 0 : - return TUX_UP; - - case 1 : - return TUX_LEFT; - - case 2 : - return TUX_RIGHT; - - case 3 : - return TUX_DOWN; - } - - assert( ! "Stupid error ! " ); -} - -static void moveShotFromTeleport(shot_t *shot, teleport_t *teleport, list_t *listTeleport) -{ - teleport_t *distTeleport; - - distTeleport = getRandomTeleportBut(listTeleport, teleport); - - moveShot(shot, getRandomPosition(), teleport->x, teleport->y, - distTeleport->x, distTeleport->y, distTeleport->w, distTeleport->h); -} - -void eventConflictShotWithTeleport(list_t *listTeleport, list_t *listShot) -{ - shot_t *thisShot; - teleport_t *thisTeleport; - int i; - - assert( listTeleport != NULL ); - assert( listShot != NULL ); - - for( i = 0 ; i < listShot->count ; i++ ) - { - thisShot = (shot_t *)listShot->list[i]; - assert( thisShot != NULL ); - - if( ( thisTeleport = isConflictWithListTeleport(listTeleport, thisShot->x, thisShot->y, thisShot->w, thisShot->h) ) != NULL ) - { - tux_t *author; - - author = getTuxID(getCurrentArena()->listTux, thisShot->author_id); - - if( author != NULL && - author->bonus == BONUS_GHOST && - author->bonus_time > 0 ) - { - continue; - } - - if( getNetTypeGame() == NET_GAME_TYPE_CLIENT ) - { - delListItem(listShot, i, destroyShot); - i--; - } - else - { - moveShotFromTeleport(thisShot, thisTeleport, listTeleport); - } - } - } -} - -void eventTeleportTux(list_t *listTeleport, teleport_t *teleport, tux_t *tux) -{ - teleport_t *distTeleport; - int current_x, current_y; - int dist_x, dist_y; - - if( tux->bonus == BONUS_GHOST || - getNetTypeGame() == NET_GAME_TYPE_CLIENT ) - { - return; - } - - distTeleport = getRandomTeleportBut(listTeleport, teleport); - - getTuxProportion(tux, ¤t_x, ¤t_y, NULL, NULL); - - switch( tux->position ) - { - case TUX_UP : - dist_x = distTeleport->x + distTeleport->w/2; - dist_y = distTeleport->y - ( TUX_HEIGHT + 10 ); - break; - - case TUX_LEFT : - dist_y = distTeleport->y + distTeleport->h/2; - dist_x = distTeleport->x - ( TUX_WIDTH + 10 ); - break; - - case TUX_RIGHT : - dist_y = distTeleport->y + distTeleport->h/2; - dist_x = distTeleport->x + distTeleport->w + 10; - break; - - case TUX_DOWN : - dist_x = distTeleport->x + distTeleport->w/2; - dist_y = distTeleport->y + distTeleport->h + 10; - break; - - default : - assert( ! "premenna p->control ma zlu hodnotu !" ); - break; - } - - if( isFreeSpace(getCurrentArena(), dist_x, dist_y, TUX_WIDTH, TUX_HEIGHT) ) - { - setTuxProportion(tux, dist_x, dist_y); -#ifndef PUBLIC_SERVER - playSound("teleport", SOUND_GROUP_BASE); -#endif - if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) - { - proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux); - } - } -} - -void destroyTeleport(teleport_t *p) -{ - assert( p != NULL ); - free(p); -} - @@ -9,14 +9,10 @@ #include "arena.h" #include "shot.h" #include "gun.h" -#include "wall.h" -#include "teleport.h" -#include "pipe.h" #include "item.h" #include "arena.h" #include "myTimer.h" #include "net_multiplayer.h" -#include "dynamicInt.h" #include "proto.h" #include "modules.h" #include "idManager.h" diff --git a/src/wall.c b/src/wall.c deleted file mode 100644 index c91f58d..0000000 --- a/src/wall.c +++ /dev/null @@ -1,142 +0,0 @@ - -#include <stdlib.h> -#include <assert.h> - -#include "main.h" -#include "wall.h" -#include "shot.h" -#include "net_multiplayer.h" -#include "proto.h" - -#ifndef PUBLIC_SERVER -#include "layer.h" -#include "screen_world.h" -#endif - -#ifdef PUBLIC_SERVER -#include "publicServer.h" -#endif - -#ifndef PUBLIC_SERVER -wall_t* newWall(int x, int y, int w, int h, - int img_x, int img_y, int layer, SDL_Surface *img) -#endif - -#ifdef PUBLIC_SERVER -wall_t* newWall(int x, int y, int w, int h, - int img_x, int img_y, int layer) -#endif -{ - wall_t *new; - -#ifndef PUBLIC_SERVER - assert( img != NULL ); -#endif - new = malloc( sizeof(wall_t) ); - assert( new != NULL ); - - new->x = x; - new->y = y; - new->w = w; - new->h = h; - new->img_x = img_x; - new->img_y = img_y; - new->layer = layer; -#ifndef PUBLIC_SERVER - new->img = img; -#endif - - return new; -} - -#ifndef PUBLIC_SERVER - -void drawWall(wall_t *p) -{ - assert( p != NULL ); - - addLayer(p->img, p->img_x, p->img_y, 0, 0, p->img->w, p->img->h, p->layer); -} - -void drawListWall(list_t *listWall) -{ - wall_t *thisWall; - int i; - - assert( listWall != NULL ); - - for( i = 0 ; i < listWall->count ; i++ ) - { - thisWall = (wall_t *)listWall->list[i]; - assert( thisWall != NULL ); - drawWall(thisWall); - } -} - -#endif - -int isConflictWithListWall(list_t *listWall, int x, int y, int w, int h) -{ - wall_t *thisWall; - int i; - - assert( listWall != NULL ); - - for( i = 0 ; i < listWall->count ; i++ ) - { - thisWall = (wall_t *)listWall->list[i]; - assert( thisWall != NULL ); - - if( conflictSpace(x, y, w, h, - thisWall->x, thisWall->y, thisWall->w, thisWall->h) ) - { - return 1; - } - } - - return 0; -} - -void eventConflictShotWithWall(list_t *listWall, list_t *listShot) -{ - shot_t *thisShot; - tux_t *author; - int i; - - assert( listWall != NULL ); - assert( listShot != NULL ); - - for( i = 0 ; i < listShot->count ; i++ ) - { - thisShot = (shot_t *)listShot->list[i]; - assert( thisShot != NULL ); - - if( isConflictWithListWall(listWall, thisShot->x, thisShot->y, thisShot->w, thisShot->h) ) - { - author = getTuxID( getCurrentArena()->listShot, thisShot->author_id ); - - if( author != NULL && - author->bonus == BONUS_GHOST && - author->bonus_time > 0 ) - { - continue; - } - - if( thisShot->gun == GUN_BOMBBALL && getNetTypeGame() != NET_GAME_TYPE_CLIENT ) - { - boundBombBall(thisShot); - continue; - } - - delListItem(listShot, i, destroyShot); - i--; - } - } -} - -void destroyWall(wall_t *p) -{ - assert( p != NULL ); - free(p); -} - |