From 473a92c69208127301b151c779833048323bb667 Mon Sep 17 00:00:00 2001 From: stpohle Date: Wed, 6 Jul 2005 13:11:51 +0000 Subject: [PATCH] bugfix with more as 8 different playergraphics. Dedicated server mode removed --- ChangeLog | 11 +- bomberclone.prj | 4 +- include/basic.h | 4 +- include/bomberclone.h | 3 +- src/bomb.c | 4 +- src/configuration.c | 468 ++++++++------- src/font.c | 17 +- src/game.c | 1296 +++++++++++++++++++++-------------------- src/gfx.c | 131 ++--- src/gfxengine.c | 6 +- src/main.c | 4 +- src/multiwait.c | 85 +-- src/network.c | 71 +-- src/player.c | 7 +- src/playermenu.c | 33 +- src/sound.c | 7 +- 16 files changed, 1068 insertions(+), 1083 deletions(-) diff --git a/ChangeLog b/ChangeLog index 90a29ad..b0128ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,13 @@ -$Id: ChangeLog,v 1.103 2005/04/11 22:21:11 stpohle Exp $ +$Id: ChangeLog,v 1.104 2005/07/06 13:11:51 stpohle Exp $ +- Fixed: Bug with more as 8 diffrent player graphics. + The window size hasen't changed if there where more as + 8 different player graphics to choose from. + +- Removed the Dedicated Server Support from the game. + The whole bomberclone game is not desinged for a dedicated + server. The test shown that the whole game would have to + be rewritten. Also that the host can leave the game would + not work no more. Version 0.11.6.2 - Client network player could die two times in a game. diff --git a/bomberclone.prj b/bomberclone.prj index 411cd04..b5d8b74 100644 --- a/bomberclone.prj +++ b/bomberclone.prj @@ -1,4 +1,4 @@ -# Anjuta Version 1.2.2 +# Anjuta Version 1.2.3 Compatibility Level: 1 @@ -39,7 +39,7 @@ echo "T $target H $host B $buid" >cross-target.txt props.file.type=project -anjuta.version=1.2.2 +anjuta.version=1.2.3 anjuta.compatibility.level=1 project.name=bomberclone diff --git a/include/basic.h b/include/basic.h index b384ba6..7c0dd1a 100644 --- a/include/basic.h +++ b/include/basic.h @@ -1,4 +1,4 @@ -/* $Id: basic.h,v 1.32 2005/04/10 00:22:16 stpohle Exp $ */ +/* $Id: basic.h,v 1.33 2005/07/06 13:11:55 stpohle Exp $ */ /* basic types which we need everywhere */ #ifndef _BC_BASIC_H_ @@ -80,7 +80,7 @@ #define UDP_TIMEOUT 15000 #define BUF_SIZE 1024 -#define AUTOSTART 20 /* dedicated server autostart */ +#define AUTOSTART 20 /* server autostart */ #define MW_IS_GFX_SELECT(__gfx_nr,__result) for (__result = (MAX_PLAYERS-1); (__result >= 0) && (players[__result].gfx_nr != __gfx_nr); __result--); diff --git a/include/bomberclone.h b/include/bomberclone.h index 06e17ca..fa35fff 100644 --- a/include/bomberclone.h +++ b/include/bomberclone.h @@ -1,4 +1,4 @@ -/* $Id: bomberclone.h,v 1.33 2005/04/09 18:22:40 stpohle Exp $ */ +/* $Id: bomberclone.h,v 1.34 2005/07/06 13:11:55 stpohle Exp $ */ /* bomberclone.h */ #ifndef _BOMBERCLONE_H_ @@ -85,7 +85,6 @@ struct { int firewall; int notifygamemaster; int broadcast; - int dedicated; // if started as dedicated server int autostart; // time for an autostart of the game int minplayers; // minimal number of players diff --git a/src/bomb.c b/src/bomb.c index 0f5dca2..66ed07f 100644 --- a/src/bomb.c +++ b/src/bomb.c @@ -1,4 +1,4 @@ -/* $Id: bomb.c,v 1.63 2005/04/09 18:22:40 stpohle Exp $ */ +/* $Id: bomb.c,v 1.64 2005/07/06 13:11:55 stpohle Exp $ */ /* everything what have to do with the bombs */ #include "bomberclone.h" @@ -19,8 +19,6 @@ draw_bomb (_bomb * bomb) y1, y2; - if (bman.dedicated) - return; if (x < 0 || y < 0 || x >= map.size.x || y >= map.size.y) { d_printf ("FATAL: Draw Bomb out of range [%f,%f]\n", x, y); diff --git a/src/configuration.c b/src/configuration.c index 0374071..f220bd3 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -1,4 +1,4 @@ -/* $Id: configuration.c,v 1.75 2005/04/10 00:22:17 stpohle Exp $ +/* $Id: configuration.c,v 1.76 2005/07/06 13:11:55 stpohle Exp $ * configuration */ #include @@ -21,29 +21,31 @@ * 2) ./data * 3) ../data */ -void config_get_datapath () { - FILE *f; - char filename[255]; - +void +config_get_datapath () +{ + FILE *f; + char filename[255]; + sprintf (bman.datapath, PACKAGE_DATA_DIR); sprintf (filename, "%s/gfx/logo.png", bman.datapath); - f = fopen (filename, "r"); - - if (!f) { - sprintf (bman.datapath, "data"); + f = fopen (filename, "r"); + + if (!f) { + sprintf (bman.datapath, "data"); sprintf (filename, "%s/gfx/logo.png", bman.datapath); f = fopen (filename, "r"); if (!f) { - sprintf (bman.datapath, "../data"); - sprintf (filename, "%s/gfx/logo.png", bman.datapath); - f = fopen (filename, "r"); - if (!f) { - printf ("Can't find Datafiles.\n"); - exit (1); - } + sprintf (bman.datapath, "../data"); + sprintf (filename, "%s/gfx/logo.png", bman.datapath); + f = fopen (filename, "r"); + if (!f) { + printf ("Can't find Datafiles.\n"); + exit (1); + } } - } - fclose (f); + } + fclose (f); } @@ -53,26 +55,28 @@ void config_get_datapath () { void config_init (int argc, char **argv) { - SDL_Surface *icon_img; - char text[255], icon[255]; - int i, j; + SDL_Surface *icon_img; + char text[255], + icon[255]; + int i, + j; + + config_get_datapath (); - config_get_datapath (); - srand (((int) time (NULL))); // initialize randomgenerator - for (i = 0; i < MAX_TEAMS; i++) { - teams[i].col = i; - sprintf (teams[i].name, "Team %d", i+1); - for (j = 0; j < MAX_PLAYERS; j++) - teams[i].players[j] = NULL; - } - + for (i = 0; i < MAX_TEAMS; i++) { + teams[i].col = i; + sprintf (teams[i].name, "Team %d", i + 1); + for (j = 0; j < MAX_PLAYERS; j++) + teams[i].players[j] = NULL; + } + stonelist_del (); - chat.oldscreen = NULL; - chat.active = 0; + chat.oldscreen = NULL; + chat.active = 0; chat.curline = 0; - keyb_config_reset (); + keyb_config_reset (); keybinput_new (&chat.input, KEYBI_text, 255); for (i = 0; i < CHAT_MAX_LINES; i++) @@ -81,28 +85,27 @@ config_init (int argc, char **argv) bman.maxplayer = MAX_PLAYERS; bman.net_ai_family = PF_INET; bman.sock = -1; - bman.p_nr = -1; - bman.p2_nr = -1; + bman.p_nr = -1; + bman.p2_nr = -1; bman.gamename[0] = 0; - sprintf (bman.playername, "Player1"); - sprintf (bman.player2name, "Player2"); + sprintf (bman.playername, "Player1"); + sprintf (bman.player2name, "Player2"); sprintf (bman.port, "%d", DEFAULT_UDPPORT); sprintf (bman.ogcserver, DEFAULT_GAMECACHE); sprintf (bman.ogc_port, DEFAULT_GAMECACHEPORT); resend_cache.data = NULL; resend_cache.fill = -1; bman.notifygamemaster = 1; - bman.broadcast = 1; - bman.dedicated = 0; - bman.autostart = AUTOSTART; + bman.broadcast = 1; + bman.autostart = AUTOSTART; bman.askplayername = 0; debug = 0; gfx.res.x = 640; gfx.res.y = 480; gfx.bpp = 16; - gfx.players = NULL; - bman.password[0] = 0; - bman.passwordenabled = 0; + gfx.players = NULL; + bman.password[0] = 0; + bman.passwordenabled = 0; map.tileset[0] = 0; map.random_tileset = 1; map.size.x = 25; @@ -113,7 +116,7 @@ config_init (int argc, char **argv) bman.firewall = 0; bman.init_timeout = GAME_TIMEOUT; bman.ai_players = 1; - bman.minplayers = 0; + bman.minplayers = 0; snd.inited = 0; snd.audio_rate = 22050; snd.audio_format = AUDIO_S16; @@ -129,52 +132,52 @@ config_init (int argc, char **argv) map.sp_row = GAME_SPECIAL_ITEMSROW; map.sp_push = GAME_SPECIAL_ITEMSPUSH; map.sp_kick = GAME_SPECIAL_ITEMSKICK; - - bman.start_bombs = START_BOMBS; - bman.start_speed = START_SPEED; - bman.start_range = START_RANGE; - bman.bomb_tickingtime = BOMB_TIMEOUT; - bman.dropitemsondeath = 0; - d_printf ("\n\n ***** Bomberclone Version %s \n\n", VERSION); - config_read (); + + bman.start_bombs = START_BOMBS; + bman.start_speed = START_SPEED; + bman.start_range = START_RANGE; + bman.bomb_tickingtime = BOMB_TIMEOUT; + bman.dropitemsondeath = 0; + d_printf ("\n\n ***** Bomberclone Version %s \n\n", VERSION); + config_read (); ReadPrgArgs (argc, argv); - - gfx_init (); + + gfx_init (); draw_logo (); - if (bman.askplayername) - playernamemenu (); + if (bman.askplayername) + playernamemenu (); snd_init (); - gfx_blitdraw (); - - if (!bman.dedicated) - SDL_Flip (gfx.screen); - - sprintf (text,"Bomberclone %s", VERSION); - sprintf (icon,"%s/pixmaps/bomberclone.png", bman.datapath); - SDL_WM_SetCaption(text , NULL); - icon_img = IMG_Load(icon); - if (icon_img == NULL) - d_printf ("could not load icon. (%s)\n", icon); - + gfx_blitdraw (); + + SDL_Flip (gfx.screen); + + sprintf (text, "Bomberclone %s", VERSION); + sprintf (icon, "%s/pixmaps/bomberclone.png", bman.datapath); + SDL_WM_SetCaption (text, NULL); + icon_img = IMG_Load (icon); + if (icon_img == NULL) + d_printf ("could not load icon. (%s)\n", icon); + #ifdef _WIN32 - { - SDL_Surface *tmp = icon_img; - icon_img = scale_image (tmp, 32, 32); - SDL_FreeSurface (tmp); - } + { + SDL_Surface *tmp = icon_img; + icon_img = scale_image (tmp, 32, 32); + SDL_FreeSurface (tmp); + } #endif - SDL_WM_SetIcon (icon_img, NULL); + SDL_WM_SetIcon (icon_img, NULL); - ReadPrgArgs_Jump (argc, argv); + ReadPrgArgs_Jump (argc, argv); }; /* read the configuration file * return -1 if something went wrong and 0 if no problem */ int -config_read () { +config_read () +{ FILE *config; char buf[1024]; char *findit, @@ -372,61 +375,61 @@ config_read () { if (!strcmp (keyword, "dropitemsondeath")) { bman.dropitemsondeath = atoi (value); } - - for (i = 0; i < MAX_TEAMS; i++) { - char txt[255]; - sprintf (txt,"teamcol%d", i); - if (!strcmp (keyword, txt)) { - teams[i].col = atoi (value); - } - sprintf (txt,"teamname%d", i); - if (!strcmp (keyword, txt)) { - strncpy (teams[i].name,value, LEN_PLAYERNAME); - } - } - - /* - * keyboard config, i will give names to the keys insteed of the numbers, - * this is done to add more keys to the game without destroying the config. - */ - if (!strcmp (keyword, "key_p1_up")) - keyb_gamekeys.keycode[BCPK_up] = atoi (value); - if (!strcmp (keyword, "key_p1_down")) - keyb_gamekeys.keycode[BCPK_down] = atoi (value); - if (!strcmp (keyword, "key_p1_left")) - keyb_gamekeys.keycode[BCPK_left] = atoi (value); - if (!strcmp (keyword, "key_p1_right")) - keyb_gamekeys.keycode[BCPK_right] = atoi (value); - if (!strcmp (keyword, "key_p1_bomb")) - keyb_gamekeys.keycode[BCPK_drop] = atoi (value); - if (!strcmp (keyword, "key_p1_special")) - keyb_gamekeys.keycode[BCPK_special] = atoi (value); - - if (!strcmp (keyword, "key_p2_up")) - keyb_gamekeys.keycode[BCPK_max + BCPK_up] = atoi (value); - if (!strcmp (keyword, "key_p2_down")) - keyb_gamekeys.keycode[BCPK_max + BCPK_down] = atoi (value); - if (!strcmp (keyword, "key_p2_left")) - keyb_gamekeys.keycode[BCPK_max + BCPK_left] = atoi (value); - if (!strcmp (keyword, "key_p2_right")) - keyb_gamekeys.keycode[BCPK_max + BCPK_right] = atoi (value); - if (!strcmp (keyword, "key_p2_bomb")) - keyb_gamekeys.keycode[BCPK_max + BCPK_drop] = atoi (value); - if (!strcmp (keyword, "key_p2_special")) - keyb_gamekeys.keycode[BCPK_max + BCPK_special] = atoi (value); - - if (!strcmp (keyword, "key_help")) - keyb_gamekeys.keycode[BCK_help] = atoi (value); - if (!strcmp (keyword, "key_playermenu")) - keyb_gamekeys.keycode[BCK_playermenu] = atoi (value); - if (!strcmp (keyword, "key_mapmenu")) - keyb_gamekeys.keycode[BCK_mapmenu] = atoi (value); - if (!strcmp (keyword, "key_chat")) - keyb_gamekeys.keycode[BCK_chat] = atoi (value); - if (!strcmp (keyword, "key_pause")) - keyb_gamekeys.keycode[BCK_pause] = atoi (value); - if (!strcmp (keyword, "key_fullscreen")) - keyb_gamekeys.keycode[BCK_fullscreen] = atoi (value); + + for (i = 0; i < MAX_TEAMS; i++) { + char txt[255]; + sprintf (txt, "teamcol%d", i); + if (!strcmp (keyword, txt)) { + teams[i].col = atoi (value); + } + sprintf (txt, "teamname%d", i); + if (!strcmp (keyword, txt)) { + strncpy (teams[i].name, value, LEN_PLAYERNAME); + } + } + + /* + * keyboard config, i will give names to the keys insteed of the numbers, + * this is done to add more keys to the game without destroying the config. + */ + if (!strcmp (keyword, "key_p1_up")) + keyb_gamekeys.keycode[BCPK_up] = atoi (value); + if (!strcmp (keyword, "key_p1_down")) + keyb_gamekeys.keycode[BCPK_down] = atoi (value); + if (!strcmp (keyword, "key_p1_left")) + keyb_gamekeys.keycode[BCPK_left] = atoi (value); + if (!strcmp (keyword, "key_p1_right")) + keyb_gamekeys.keycode[BCPK_right] = atoi (value); + if (!strcmp (keyword, "key_p1_bomb")) + keyb_gamekeys.keycode[BCPK_drop] = atoi (value); + if (!strcmp (keyword, "key_p1_special")) + keyb_gamekeys.keycode[BCPK_special] = atoi (value); + + if (!strcmp (keyword, "key_p2_up")) + keyb_gamekeys.keycode[BCPK_max + BCPK_up] = atoi (value); + if (!strcmp (keyword, "key_p2_down")) + keyb_gamekeys.keycode[BCPK_max + BCPK_down] = atoi (value); + if (!strcmp (keyword, "key_p2_left")) + keyb_gamekeys.keycode[BCPK_max + BCPK_left] = atoi (value); + if (!strcmp (keyword, "key_p2_right")) + keyb_gamekeys.keycode[BCPK_max + BCPK_right] = atoi (value); + if (!strcmp (keyword, "key_p2_bomb")) + keyb_gamekeys.keycode[BCPK_max + BCPK_drop] = atoi (value); + if (!strcmp (keyword, "key_p2_special")) + keyb_gamekeys.keycode[BCPK_max + BCPK_special] = atoi (value); + + if (!strcmp (keyword, "key_help")) + keyb_gamekeys.keycode[BCK_help] = atoi (value); + if (!strcmp (keyword, "key_playermenu")) + keyb_gamekeys.keycode[BCK_playermenu] = atoi (value); + if (!strcmp (keyword, "key_mapmenu")) + keyb_gamekeys.keycode[BCK_mapmenu] = atoi (value); + if (!strcmp (keyword, "key_chat")) + keyb_gamekeys.keycode[BCK_chat] = atoi (value); + if (!strcmp (keyword, "key_pause")) + keyb_gamekeys.keycode[BCK_pause] = atoi (value); + if (!strcmp (keyword, "key_fullscreen")) + keyb_gamekeys.keycode[BCK_fullscreen] = atoi (value); } fclose (config); return 0; @@ -437,9 +440,9 @@ int config_write () { FILE *config; - int i; + int i; char filename[512]; - + #ifdef _WIN32 sprintf (filename, "%sbomberclone.cfg", s_gethomedir ()); #else @@ -466,8 +469,8 @@ config_write () fprintf (config, "gametype=%d\n", bman.gametype); fprintf (config, "maxplayer=%d\n", bman.maxplayer); fprintf (config, "debug=%d\n", debug); - fprintf (config, "password=%s\n", bman.password); - fprintf (config, "passwordenabled=%d\n", bman.passwordenabled); + fprintf (config, "password=%s\n", bman.password); + fprintf (config, "passwordenabled=%d\n", bman.passwordenabled); fprintf (config, "askplayername=%d\n", bman.askplayername); fprintf (config, "playername=%s\n", bman.playername); fprintf (config, "player2name=%s\n", bman.player2name); @@ -479,38 +482,38 @@ config_write () fprintf (config, "sndformat=%d\n", snd.audio_format); fprintf (config, "sndplaymusic=%d\n", snd.playmusic); fprintf (config, "sndplaysound=%d\n", snd.playsound); - fprintf (config, "start_bombs=%d\n", bman.start_bombs); - fprintf (config, "start_range=%d\n", bman.start_range); - fprintf (config, "start_speed=%f\n", bman.start_speed); - fprintf (config, "bomb_ticking=%f\n", bman.bomb_tickingtime); - - for (i = 0; i < MAX_TEAMS; i++) { - fprintf (config, "teamcol%d=%d\n", i, teams[i].col); - fprintf (config, "teamname%d=%s\n", i, teams[i].name); - } + fprintf (config, "start_bombs=%d\n", bman.start_bombs); + fprintf (config, "start_range=%d\n", bman.start_range); + fprintf (config, "start_speed=%f\n", bman.start_speed); + fprintf (config, "bomb_ticking=%f\n", bman.bomb_tickingtime); + + for (i = 0; i < MAX_TEAMS; i++) { + fprintf (config, "teamcol%d=%d\n", i, teams[i].col); + fprintf (config, "teamname%d=%s\n", i, teams[i].name); + } + + /* + * keyboard config + */ + fprintf (config, "key_p1_up=%d\n", keyb_gamekeys.keycode[BCPK_up]); + fprintf (config, "key_p1_down=%d\n", keyb_gamekeys.keycode[BCPK_down]); + fprintf (config, "key_p1_left=%d\n", keyb_gamekeys.keycode[BCPK_left]); + fprintf (config, "key_p1_right=%d\n", keyb_gamekeys.keycode[BCPK_right]); + fprintf (config, "key_p1_bomb=%d\n", keyb_gamekeys.keycode[BCPK_drop]); + fprintf (config, "key_p1_special=%d\n", keyb_gamekeys.keycode[BCPK_special]); + fprintf (config, "key_p2_up=%d\n", keyb_gamekeys.keycode[BCPK_max + BCPK_up]); + fprintf (config, "key_p2_down=%d\n", keyb_gamekeys.keycode[BCPK_max + BCPK_down]); + fprintf (config, "key_p2_left=%d\n", keyb_gamekeys.keycode[BCPK_max + BCPK_left]); + fprintf (config, "key_p2_right=%d\n", keyb_gamekeys.keycode[BCPK_max + BCPK_right]); + fprintf (config, "key_p2_bomb=%d\n", keyb_gamekeys.keycode[BCPK_max + BCPK_drop]); + fprintf (config, "key_p2_special=%d\n", keyb_gamekeys.keycode[BCPK_max + BCPK_special]); + fprintf (config, "key_help=%d\n", keyb_gamekeys.keycode[BCK_help]); + fprintf (config, "key_fullscreen=%d\n", keyb_gamekeys.keycode[BCK_fullscreen]); + fprintf (config, "key_chat=%d\n", keyb_gamekeys.keycode[BCK_chat]); + fprintf (config, "key_mapmenu=%d\n", keyb_gamekeys.keycode[BCK_mapmenu]); + fprintf (config, "key_pause=%d\n", keyb_gamekeys.keycode[BCK_pause]); + fprintf (config, "key_playermenu=%d\n", keyb_gamekeys.keycode[BCK_playermenu]); - /* - * keyboard config - */ - fprintf (config, "key_p1_up=%d\n", keyb_gamekeys.keycode[BCPK_up]); - fprintf (config, "key_p1_down=%d\n", keyb_gamekeys.keycode[BCPK_down]); - fprintf (config, "key_p1_left=%d\n", keyb_gamekeys.keycode[BCPK_left]); - fprintf (config, "key_p1_right=%d\n", keyb_gamekeys.keycode[BCPK_right]); - fprintf (config, "key_p1_bomb=%d\n", keyb_gamekeys.keycode[BCPK_drop]); - fprintf (config, "key_p1_special=%d\n", keyb_gamekeys.keycode[BCPK_special]); - fprintf (config, "key_p2_up=%d\n", keyb_gamekeys.keycode[BCPK_max + BCPK_up]); - fprintf (config, "key_p2_down=%d\n", keyb_gamekeys.keycode[BCPK_max + BCPK_down]); - fprintf (config, "key_p2_left=%d\n", keyb_gamekeys.keycode[BCPK_max + BCPK_left]); - fprintf (config, "key_p2_right=%d\n", keyb_gamekeys.keycode[BCPK_max + BCPK_right]); - fprintf (config, "key_p2_bomb=%d\n", keyb_gamekeys.keycode[BCPK_max + BCPK_drop]); - fprintf (config, "key_p2_special=%d\n", keyb_gamekeys.keycode[BCPK_max + BCPK_special]); - fprintf (config, "key_help=%d\n", keyb_gamekeys.keycode[BCK_help]); - fprintf (config, "key_fullscreen=%d\n", keyb_gamekeys.keycode[BCK_fullscreen]); - fprintf (config, "key_chat=%d\n", keyb_gamekeys.keycode[BCK_chat]); - fprintf (config, "key_mapmenu=%d\n", keyb_gamekeys.keycode[BCK_mapmenu]); - fprintf (config, "key_pause=%d\n", keyb_gamekeys.keycode[BCK_pause]); - fprintf (config, "key_playermenu=%d\n", keyb_gamekeys.keycode[BCK_playermenu]); - fclose (config); return 0; } @@ -540,8 +543,8 @@ config_video () _charlist *selbpp = NULL; char text[100]; - _menu *menu; - + _menu *menu; + /* set all pointers in this array */ charlist_fillarraypointer (screenres, 5); charlist_fillarraypointer (screenbpp, 3); @@ -576,14 +579,14 @@ config_video () gfx.res.y = y; gfx_init (); draw_logo (); - break; + break; case (2): // new color depth gfx_shutdown (); sscanf (selbpp->text, "%d", &x); gfx.bpp = x; gfx_init (); - draw_logo (); - break; + draw_logo (); + break; default: done = 1; break; @@ -602,8 +605,8 @@ void config_menu () { int menuselect = 0; - _menu *menu; - + _menu *menu; + while (menuselect != -1 && bman.state != GS_quit) { menu = menu_new ("Configuration", 400, 300); menu_create_label (menu, "General Option", -1, 50, 1, COLOR_brown); @@ -634,13 +637,13 @@ config_menu () else menuselect = -1; break; - case (1): // player screen - playernamemenu (); - break; - case (2): // keyboard settings - keyb_config (); - break; - case (3): // Screen Options + case (1): // player screen + playernamemenu (); + break; + case (2): // keyboard settings + keyb_config (); + break; + case (3): // Screen Options config_video (); break; } @@ -665,18 +668,17 @@ ReadPrgArgs (int argc, char **argv) printf ("\nProgramm options:\n"); printf (" -name PLAYERNAME - set the Playername\n"); printf (" -name2 PLAYERNAME - set the Playername for the second player\n"); - printf (" -gamename GAMENAME - set the name of the game\n"); + printf (" -gamename GAMENAME - set the name of the game\n"); printf (" -port PORT - set the local BomberClone port\n"); - printf (" (Def.: 11000)\n"); + printf (" (Def.: 11000)\n"); printf (" -ogcport PORT - set the local OGC Port (Def.: 11100)\n"); printf (" -ogc 0/1 - Enable/Disable OGC\n"); - printf (" -broadcast 0/1 - Enable/Disable broadcast requests.\n"); - printf (" -host - start a network game\n"); - printf (" -join - go into the join menu\n"); - printf (" -connect ADDRESS - connect to a server\n"); - printf (" -debug 0/1 - enable/disable debug\n"); - printf (" -dedicated - run as dedicated server\n"); - printf (" -autostart SECONDS - time before a game starts\n"); + printf (" -broadcast 0/1 - Enable/Disable broadcast requests.\n"); + printf (" -host - start a network game\n"); + printf (" -join - go into the join menu\n"); + printf (" -connect ADDRESS - connect to a server\n"); + printf (" -debug 0/1 - enable/disable debug\n"); + printf (" -autostart SECONDS - time before a game starts\n"); exit (0); } if (!strcmp (argv[i], "-port")) @@ -686,24 +688,18 @@ ReadPrgArgs (int argc, char **argv) if (!strcmp (argv[i], "-name")) strncpy (bman.playername, argv[++i], LEN_PLAYERNAME); if (!strcmp (argv[i], "-name2")) - strncpy (bman.player2name, argv[++i], LEN_PLAYERNAME); - if (!strcmp (argv[i], "-gamename")) - strncpy (bman.gamename, argv[++i], LEN_GAMENAME); + strncpy (bman.player2name, argv[++i], LEN_PLAYERNAME); + if (!strcmp (argv[i], "-gamename")) + strncpy (bman.gamename, argv[++i], LEN_GAMENAME); if (!strcmp (argv[i], "-ogc")) bman.notifygamemaster = atoi (argv[++i]); if (!strcmp (argv[i], "-broadcast")) bman.broadcast = atoi (argv[++i]); if (!strcmp (argv[i], "-debug")) debug = atoi (argv[++i]); - if (!strcmp (argv[i], "-dedicated")) { - if (bman.minplayers <= 1) - bman.minplayers = 2; - bman.dedicated = 1; - printf ("\nDedicated Bomberclone Server - Version " VERSION "\n\n"); + if (!strcmp (argv[i], "-autostart")) + bman.autostart = atoi (argv[++i]); } - if (!strcmp (argv[i], "-autostart")) - bman.autostart = atoi (argv[++i]); - } }; @@ -715,43 +711,45 @@ ReadPrgArgs_Jump (int argc, char **argv) int i = 0; while (argv[++i] != NULL) { - /* check for commands which will put us into a certain menu */ - if (!strcmp (argv[i], "-host")) { - host_multiplayer_game (); - } - else if (!strcmp (argv[i], "-join")) { - join_multiplayer_game (); - } - else if (!strcmp (argv[i], "-connect")) { - strncpy (bman.servername, argv[++i], LEN_SERVERNAME + LEN_PORT + 2); - join_multiplayer_game (); - } - } - - if (bman.dedicated > 0) - host_multiplayer_game (); + /* check for commands which will put us into a certain menu */ + if (!strcmp (argv[i], "-host")) { + host_multiplayer_game (); + } + else if (!strcmp (argv[i], "-join")) { + join_multiplayer_game (); + } + else if (!strcmp (argv[i], "-connect")) { + strncpy (bman.servername, argv[++i], LEN_SERVERNAME + LEN_PORT + 2); + join_multiplayer_game (); + } + } }; /* check the version number, return [ 0 =] [-1 <] [ 1 >] */ -int check_version (int ma, int mi, int su, char *ver) { - int v1, v2, v3, res = 0; - - sscanf (ver, "%d.%d.%d", &v1, &v2, &v3); - if (v1 < ma) - res = -1; - else if (v1 > ma) - res = 1; - else if (v2 < mi) - res = -1; - else if (v2 > mi) - res = 1; - else if (v3 < su) - res = -1; - else if (v3 > su) - res = 1; - - // d_printf ("version_check (%d.%d.%d, %s = %d\n" , ma, mi, su, ver, res); - - return res; +int +check_version (int ma, int mi, int su, char *ver) +{ + int v1, + v2, + v3, + res = 0; + + sscanf (ver, "%d.%d.%d", &v1, &v2, &v3); + if (v1 < ma) + res = -1; + else if (v1 > ma) + res = 1; + else if (v2 < mi) + res = -1; + else if (v2 > mi) + res = 1; + else if (v3 < su) + res = -1; + else if (v3 > su) + res = 1; + + // d_printf ("version_check (%d.%d.%d, %s = %d\n" , ma, mi, su, ver, res); + + return res; }; diff --git a/src/font.c b/src/font.c index c008f00..f583ae6 100644 --- a/src/font.c +++ b/src/font.c @@ -1,4 +1,4 @@ -/* $Id: font.c,v 1.15 2005/04/09 18:22:40 stpohle Exp $ */ +/* $Id: font.c,v 1.16 2005/07/06 13:11:55 stpohle Exp $ */ // Using Fonts in SDL #include @@ -127,22 +127,17 @@ void font_load () { break; } - if (!bman.dedicated) { - font[i].image[c] = SDL_DisplayFormat (tmp); - SDL_SetColorKey (font[i].image[c] , SDL_SRCCOLORKEY, SDL_MapRGB (font[i].image[c]->format, 0,0,0)); - SDL_FillRect (font[i].image[c], NULL, SDL_MapRGB (font[i].image[c]->format, r,g,b)); - SDL_BlitSurface (raw, NULL, font[i].image[c], NULL); - } - else - font[i].image[c] = tmp; + font[i].image[c] = SDL_DisplayFormat (tmp); + SDL_SetColorKey (font[i].image[c] , SDL_SRCCOLORKEY, SDL_MapRGB (font[i].image[c]->format, 0,0,0)); + SDL_FillRect (font[i].image[c], NULL, SDL_MapRGB (font[i].image[c]->format, r,g,b)); + SDL_BlitSurface (raw, NULL, font[i].image[c], NULL); } font[i].size.x = tmp->w / 16; font[i].size.y = tmp->h / 16; SDL_FreeSurface (raw); - if (!bman.dedicated) - SDL_FreeSurface (tmp); + SDL_FreeSurface (tmp); } }; diff --git a/src/game.c b/src/game.c index d8e57bf..ecf6341 100644 --- a/src/game.c +++ b/src/game.c @@ -1,4 +1,4 @@ -/* $Id: game.c,v 1.111 2005/04/10 00:22:17 stpohle Exp $ +/* $Id: game.c,v 1.112 2005/07/06 13:11:55 stpohle Exp $ game.c - procedures for the game. */ #include @@ -17,7 +17,8 @@ extern int blitdb_nr, blitrects_nr; -Uint32 game_timediff, game_timediff1; +Uint32 game_timediff, + game_timediff1; static float hurrywarn_to; static int hurrywarn_state; static _menu *menu; @@ -28,21 +29,21 @@ game_draw_info () int i, x, j, - col; + col; char text[255]; char scrtext[255]; SDL_Rect src, dest; - if (GT_MP && (chat.oldscreen == NULL || chat.window.x != 4 || chat.window.y != 4.5*16)) { - chat_show (4, 4.5*16, gfx.res.x - 8, gfx.offset.y - 4.5*16); - chat_setactive (0, 0); - } - + if (GT_MP && (chat.oldscreen == NULL || chat.window.x != 4 || chat.window.y != 4.5 * 16)) { + chat_show (4, 4.5 * 16, gfx.res.x - 8, gfx.offset.y - 4.5 * 16); + chat_setactive (0, 0); + } + if (bman.updatestatusbar) { redraw_logo (0, 0, gfx.res.x, (4.5 * 16)); dest.x = dest.y = 0; - dest.h = 4.5 *16; + dest.h = 4.5 * 16; dest.w = gfx.res.x; gfx_blitupdaterectadd (&dest); @@ -66,15 +67,15 @@ game_draw_info () sprintf (scrtext, "%10s:%2d", players[i].name, players[i].points); if (!PS_IS_alife (players[i].state)) { // Player is dead if ((players[i].state & PSF_used) != PSF_used) - col = 4; + col = 4; else col = 3; } else { // player is alife - if (bman.gametype == GT_team) - col = teams[players[i].team_nr].col; - else - col = 0; + if (bman.gametype == GT_team) + col = teams[players[i].team_nr].col; + else + col = 0; } font_draw (x, j, scrtext, 0, col); @@ -91,15 +92,16 @@ game_draw_info () font_draw (x, 0, text, 0, 0); sprintf (text, "Range: %2d", players[bman.p_nr].range); font_draw (x, 16, text, 0, 0); - sprintf (text, "Speed: %1.1f", players[bman.p_nr].speed*10); + sprintf (text, "Speed: %1.1f", players[bman.p_nr].speed * 10); font_draw (x, 32, text, 0, 0); if (players[bman.p_nr].special.type != 0) { - col = players[bman.p_nr].special.type + FT_sp_trigger - 1; + col = players[bman.p_nr].special.type + FT_sp_trigger - 1; dest.x = x - 32; dest.y = 16; + dest.w = gfx.menu_field[col]->w; dest.h = gfx.menu_field[col]->h; - + SDL_BlitSurface (gfx.menu_field[col], NULL, gfx.screen, &dest); } @@ -107,34 +109,38 @@ game_draw_info () font_gfxdraw (100, 32, "Press F4 to start the game", 0, COLOR_yellow, 0xFFFF); else if (bman.state == GS_ready) font_gfxdraw (100, 32, "Waiting for the Server to Start", 0, COLOR_yellow, 0xFFFF); - + } - /* draw the warning part */ - if (map.state != MS_normal) { - hurrywarn_to -= timediff; - - if (bman.updatestatusbar || hurrywarn_to <= 0.0 || hurrywarn_to > HURRYWARN_TO_BLINKING) { - hurrywarn_to = HURRYWARN_TO_BLINKING; - hurrywarn_state = !hurrywarn_state; - - if (hurrywarn_state) { - font_drawbold ((gfx.res.x - strlen ("HURRY HURRY")*font[1].size.x)/2, 40, "HURRY HURRY", 1, 0, 2); - font_draw ((gfx.res.x - strlen ("HURRY HURRY")*font[1].size.x)/2, 40, "HURRY HURRY", 1, 1); - } - else { - font_drawbold ((gfx.res.x - strlen ("HURRY HURRY")*font[1].size.x)/2, 40, "HURRY HURRY", 1, 1, 2); - font_draw ((gfx.res.x - strlen ("HURRY HURRY")*font[1].size.x)/2, 40, "HURRY HURRY", 1, 0); - } - dest.x = dest.y = 0; - dest.h = 4.5 *16; - dest.w = gfx.res.x; - gfx_blitupdaterectadd (&dest); - } - } - - if (debug) - debug_ingameinfo(); + /* draw the warning part */ + if (map.state != MS_normal) { + hurrywarn_to -= timediff; + + if (bman.updatestatusbar || hurrywarn_to <= 0.0 || hurrywarn_to > HURRYWARN_TO_BLINKING) { + hurrywarn_to = HURRYWARN_TO_BLINKING; + hurrywarn_state = !hurrywarn_state; + + if (hurrywarn_state) { + font_drawbold ((gfx.res.x - strlen ("HURRY HURRY") * font[1].size.x) / 2, 40, + "HURRY HURRY", 1, 0, 2); + font_draw ((gfx.res.x - strlen ("HURRY HURRY") * font[1].size.x) / 2, 40, + "HURRY HURRY", 1, 1); + } + else { + font_drawbold ((gfx.res.x - strlen ("HURRY HURRY") * font[1].size.x) / 2, 40, + "HURRY HURRY", 1, 1, 2); + font_draw ((gfx.res.x - strlen ("HURRY HURRY") * font[1].size.x) / 2, 40, + "HURRY HURRY", 1, 0); + } + dest.x = dest.y = 0; + dest.h = 4.5 * 16; + dest.w = gfx.res.x; + gfx_blitupdaterectadd (&dest); + } + } + + if (debug) + debug_ingameinfo (); bman.updatestatusbar = 0; }; @@ -147,69 +153,73 @@ game_draw_info () * chat mode: the chatmode should only be disabled in the game mode * in the GS_wait mode the chat will always be active. */ -void game_keys_loop () { - - if (menu != NULL) { +void +game_keys_loop () +{ - /* delete all movement keys */ + if (menu != NULL) { + /* delete all movement keys */ - int i; - for (i = 0; i < BCPK_max * 2; i++) - keyb_gamekeys.state[i] = 0; - } - else { - - /* don't go into the game_keys if there is no menu displayed */ - - if (GT_MP_PTPM && bman.state == GS_ready && keyb_gamekeys.state[BCK_pause] && !keyb_gamekeys.old[BCK_pause]) { - /* Server is starting the game - * check in multiplayer if all players are ready for the game - */ - int i, ready = 1; - - for (i = 0; i < MAX_PLAYERS; i++) - if (NET_CANSEND (i) && !players[i].ready) - ready = 0; - - if (ready) - bman.state = GS_running; - else - d_printf ("game_keys_loop: not all players are ready\n"); + int i; + for (i = 0; i < BCPK_max * 2; i++) + keyb_gamekeys.state[i] = 0; + } + else { + + /* don't go into the game_keys if there is no menu displayed */ + + if (GT_MP_PTPM && bman.state == GS_ready && keyb_gamekeys.state[BCK_pause] + && !keyb_gamekeys.old[BCK_pause]) { + /* Server is starting the game + * check in multiplayer if all players are ready for the game + */ + int i, + ready = 1; + + for (i = 0; i < MAX_PLAYERS; i++) + if (NET_CANSEND (i) && !players[i].ready) + ready = 0; + + if (ready) + bman.state = GS_running; + else + d_printf ("game_keys_loop: not all players are ready\n"); net_send_servermode (); bman.updatestatusbar = 1; // force an update - } + } - if (keyb_gamekeys.state[BCK_fullscreen] && !keyb_gamekeys.old[BCK_fullscreen]) { + if (keyb_gamekeys.state[BCK_fullscreen] && !keyb_gamekeys.old[BCK_fullscreen]) { /* Switch Fullscreen */ - SDL_WM_ToggleFullScreen(gfx.screen); - gfx.fullscreen = !gfx.fullscreen; + SDL_WM_ToggleFullScreen (gfx.screen); + gfx.fullscreen = !gfx.fullscreen; bman.updatestatusbar = 1; // force an update - } + } - /* - if (keys[SDLK_F9] && event.type == SDL_KEYDOWN) { - // Switch Debugmode - debug = !debug; - bman.updatestatusbar = 1; // force an update - } - */ - - if (keyb_gamekeys.state[BCK_esc] && !keyb_gamekeys.old[BCK_esc]) { - if (chat.active && (bman.state == GS_ready || bman.state == GS_running) && IS_LPLAYER2) { - chat.active = 0; - d_printf ("Chatmode Disabled\n"); - } - else - game_menu_create (); - } - - if ((GT_MP_PTPM || GT_MP_PTPS) && keyb_gamekeys.state[BCK_chat] && !keyb_gamekeys.old[BCK_chat]) { - chat_setactive (1, 0); - chat.changed = 1; - d_printf ("Chatmode Enabled\n"); - } - } + /* + if (keys[SDLK_F9] && event.type == SDL_KEYDOWN) { + // Switch Debugmode + debug = !debug; + bman.updatestatusbar = 1; // force an update + } + */ + + if (keyb_gamekeys.state[BCK_esc] && !keyb_gamekeys.old[BCK_esc]) { + if (chat.active && (bman.state == GS_ready || bman.state == GS_running) && IS_LPLAYER2) { + chat.active = 0; + d_printf ("Chatmode Disabled\n"); + } + else + game_menu_create (); + } + + if ((GT_MP_PTPM || GT_MP_PTPS) && keyb_gamekeys.state[BCK_chat] + && !keyb_gamekeys.old[BCK_chat]) { + chat_setactive (1, 0); + chat.changed = 1; + d_printf ("Chatmode Enabled\n"); + } + } }; @@ -217,146 +227,119 @@ void game_keys_loop () { void game_loop () { - SDL_Event event; - int done = 0, eventstate; - int ready_timestamp = 0; + SDL_Event event; + int done = 0, + eventstate; - if (GT_MP) - net_game_fillsockaddr (); + if (GT_MP) + net_game_fillsockaddr (); - menu = NULL; + menu = NULL; bman.updatestatusbar = 1; // force an update timestamp = SDL_GetTicks (); // needed for time sync. d_gamedetail ("GAME START"); - if (!bman.dedicated) { - gfx_blitupdaterectclear (); - draw_logo (); - draw_field (); - SDL_Flip (gfx.screen); - draw_players (); - } - - if (bman.p_nr >= 0 && bman.p_nr < MAX_PLAYERS) { - players[bman.p_nr].ready = 1; - if (GT_MP_PTPS) - send_playerdata (&players[bman.p_servnr].net.addr, bman.p_nr, &players[bman.p_nr]); - } - if (bman.p2_nr >= 0 && bman.p2_nr < MAX_PLAYERS) { - players[bman.p2_nr].ready = 1; - if (GT_MP_PTPS) - send_playerdata (&players[bman.p_servnr].net.addr, bman.p2_nr, &players[bman.p2_nr]); - } - + gfx_blitupdaterectclear (); + draw_logo (); + draw_field (); + SDL_Flip (gfx.screen); + draw_players (); + + if (bman.p_nr >= 0 && bman.p_nr < MAX_PLAYERS) { + players[bman.p_nr].ready = 1; + if (GT_MP_PTPS) + send_playerdata (&players[bman.p_servnr].net.addr, bman.p_nr, &players[bman.p_nr]); + } + if (bman.p2_nr >= 0 && bman.p2_nr < MAX_PLAYERS) { + players[bman.p2_nr].ready = 1; + if (GT_MP_PTPS) + send_playerdata (&players[bman.p_servnr].net.addr, bman.p2_nr, &players[bman.p2_nr]); + } + while (!done && (bman.state == GS_running || bman.state == GS_ready)) { + if ((eventstate = SDL_PollEvent (&event)) != 0) + switch (event.type) { + case (SDL_QUIT): + done = 1; + bman.state = GS_quit; + } + + /* + * input handling + */ + keyb_loop (&event); + + game_keys_loop (); + + if (GT_MP) + chat_loop (&event); + + if ((!IS_LPLAYER2) && (!chat.active)) + chat_setactive (1, 1); + + restore_players_screen (); + + player_check (bman.p_nr); + if (IS_LPLAYER2) + player_check (bman.p2_nr); + + dead_playerani (); - if (!bman.dedicated) { - if ((eventstate = SDL_PollEvent (&event)) != 0) - switch (event.type) { - case (SDL_QUIT): - done = 1; - bman.state = GS_quit; - } - - /* - * input handling - */ - keyb_loop (&event); - - game_keys_loop (); - - if (GT_MP) - chat_loop (&event); - - if ((!IS_LPLAYER2) && (!chat.active)) - chat_setactive (1, 1); - - restore_players_screen (); - } - - /* check if we have a dedicated server */ - if (bman.dedicated && bman.state == GS_ready) { - int i, ready = 1; - - for (i = 0; i < MAX_PLAYERS; i++) - if (NET_CANSEND (i) && !players[i].ready) - ready = 0; - - if (ready && ready_timestamp == 0) - ready_timestamp = timestamp; - - if (ready && (timestamp - ready_timestamp) > 2500) { - bman.state = GS_running; - net_send_servermode (); - } - } - - - player_check (bman.p_nr); - if (IS_LPLAYER2) - player_check (bman.p2_nr); - - if (!bman.dedicated) - dead_playerani (); - special_loop (); - player_move (bman.p_nr); - if (IS_LPLAYER2) - player_move (bman.p2_nr); + player_move (bman.p_nr); + if (IS_LPLAYER2) + player_move (bman.p2_nr); if (GT_MP) { player_calcpos (); network_loop (); - } - - if (bman.state == GS_running) - single_loop (); + } + + if (bman.state == GS_running) + single_loop (); bomb_loop (); field_loop (); - flitems_loop (); - - if (!bman.dedicated) { - draw_players (); - game_draw_info (); // will set the var bman.player_nr - } - + flitems_loop (); + + draw_players (); + game_draw_info (); // will set the var bman.player_nr + /* check if there is only one player left and the game is in multiplayer mode and if there the last dieing animation is done */ - if (game_check_endgame () && bman.timeout >= 0.0f) - bman.timeout = 0.0f; - + if (game_check_endgame () && bman.timeout >= 0.0f) + bman.timeout = 0.0f; + if ((GT_SP || GT_MP_PTPM) && bman.timeout < -GAME_OVERTIMEOUT) { d_printf ("GAME: Game Over\n"); done = 1; } - - if (!bman.dedicated) { - stonelist_draw (); - - /* if there is any menu displayed do so */ - if (menu != NULL) - game_menu_loop (&event, eventstate); - - gfx_blitdraw (); - } - - s_calctimesync (); - bman.timeout -= timediff; + + stonelist_draw (); + + /* if there is any menu displayed do so */ + if (menu != NULL) + game_menu_loop (&event, eventstate); + + gfx_blitdraw (); + + s_calctimesync (); + bman.timeout -= timediff; + } - if (menu != NULL) - menu_delete (menu); - - if (!bman.dedicated) { - gfx_blitdraw (); - - chat_show (-1, -1, -1, -1); - draw_logo (); - gfx_blitupdaterectclear (); - SDL_Flip (gfx.screen); + if (menu != NULL) { + menu_delete (menu); + menu = NULL; } + + gfx_blitdraw (); + + chat_show (-1, -1, -1, -1); + draw_logo (); + gfx_blitupdaterectclear (); + SDL_Flip (gfx.screen); d_gamedetail ("GAME END"); d_printf ("done = %d\n", done); @@ -368,65 +351,71 @@ game_loop () * check also if we there is only one team alife */ #define ENDGAME_CHECK_AGAIN 1.0f -int game_check_endgame () { - int res = 0; - static float loop; - - loop -= timediff; - - if (loop > 0.0f && loop < ENDGAME_CHECK_AGAIN) return 0; - loop = ENDGAME_CHECK_AGAIN; - - if (bman.gametype == GT_team) { - /* - * Team Mode Calculation - */ - int t_nr; // teamnumber - int p_nr; // playernumber - int h_team = 0; // how many human teams are alife - int ateam = 0; // teams which are alife - int h_team_last = -1; // last human team which was alife - int team_last = -1; // last teams which was alift - _player *p; - - for (t_nr = 0; t_nr < MAX_TEAMS; t_nr++) for (p_nr = 0; p_nr < MAX_PLAYERS; p_nr++) - if (teams[t_nr].players[p_nr] != NULL) { - p = teams[t_nr].players[p_nr]; - if (PS_IS_used (p->state) && PS_IS_alife (p->state)) { - if (team_last != t_nr) { - team_last = t_nr; - ateam++; - } - if ((!PS_IS_aiplayer (p->state)) && h_team_last != t_nr) { - h_team++; - h_team_last = t_nr; - } - } - } - - if (h_team < 1 || ateam < 2) - res = 1; - } - else if ((bman.gametype == GT_bomberman) || (map.state != MS_normal && bman.gametype == GT_deathmatch)) { - int p_nr; // playernumber - int h_alife = 0; // human players who are alife - int alife = 0; // ai players who are alife - _player *p; - - for (p = &players[0], p_nr = 0; p_nr < MAX_PLAYERS; p_nr++, p++) { - if (PS_IS_used (p->state) && PS_IS_alife (p->state)) { - alife++; - if (!PS_IS_aiplayer (p->state)) - h_alife++; - } - } - - if ((h_alife < 1) || (alife < 2)) - res = 1; - } - - return res; +int +game_check_endgame () +{ + int res = 0; + static float loop; + + loop -= timediff; + + if (loop > 0.0f && loop < ENDGAME_CHECK_AGAIN) + return 0; + loop = ENDGAME_CHECK_AGAIN; + + if (bman.gametype == GT_team) { + /* + * Team Mode Calculation + */ + int t_nr; // teamnumber + int p_nr; // playernumber + int h_team = 0; // how many human teams are alife + int ateam = 0; // teams which are alife + int h_team_last = -1; // last human team which was alife + int team_last = -1; // last teams which was alift + _player *p; + + for (t_nr = 0; t_nr < MAX_TEAMS; t_nr++) + for (p_nr = 0; p_nr < MAX_PLAYERS; p_nr++) + if (teams[t_nr].players[p_nr] != NULL) { + p = teams[t_nr].players[p_nr]; + if (PS_IS_used (p->state) && PS_IS_alife (p->state)) { + if (team_last != t_nr) { + team_last = t_nr; + ateam++; + } + if ((!PS_IS_aiplayer (p->state)) && h_team_last != t_nr) { + h_team++; + h_team_last = t_nr; + } + } + } + + if (h_team < 1 || ateam < 2) + res = 1; + } + else if ((bman.gametype == GT_bomberman) + || (map.state != MS_normal && bman.gametype == GT_deathmatch)) { + int p_nr; // playernumber + int h_alife = 0; // human players who are alife + int alife = 0; // ai players who are alife + _player *p; + + for (p = &players[0], p_nr = 0; p_nr < MAX_PLAYERS; p_nr++, p++) { + if (PS_IS_used (p->state) && PS_IS_alife (p->state)) { + alife++; + if (!PS_IS_aiplayer (p->state)) + h_alife++; + } + } + + if ((h_alife < 1) || (alife < 2)) + res = 1; + } + + return res; }; + #undef ENDGAME_CHECK_AGAIN /* check which player won and free all unnneded data */ @@ -434,63 +423,65 @@ void game_end () { int i; - int cnt_left = 0; - + int cnt_left = 0; + gfx_free_players (); tileset_free (); - snd_music_stop (); + snd_music_stop (); snd_free (); /* count the wins for the player, and if only one player - * left count the points too */ - cnt_left = 0; + * left count the points too */ + cnt_left = 0; for (i = 0; i < MAX_PLAYERS; i++) if (PS_IS_used (players[i].state)) { if (PS_IS_alife (players[i].state)) { bman.lastwinner = i; - cnt_left++; + cnt_left++; players[i].wins++; } } - if (cnt_left == 1) - players[bman.lastwinner].points += bman.players_nr_s; - else bman.lastwinner = -1; - - /* check which team was alife */ - if (bman.gametype == GT_team) { - int t_nr; - - bman.lastwinner = -1; - cnt_left = 0; - - for (t_nr = 0; t_nr < MAX_TEAMS; t_nr++) for (i = 0; i < MAX_PLAYERS; i++) { - if (teams[t_nr].players[i] != NULL) - if (PS_IS_alife(teams[t_nr].players[i]->state)) { - if (bman.lastwinner != t_nr) { - teams[t_nr].wins++; - cnt_left++; - bman.lastwinner = t_nr; - } - } - } - - if (cnt_left == 1) { - /* set the points */ - cnt_left = 0; - for (t_nr = 0; t_nr < MAX_TEAMS; t_nr++) { - for (i = 0; (i < MAX_PLAYERS && teams[t_nr].players[i] != NULL); i++); - if (i < MAX_PLAYERS && teams[t_nr].players[i] != NULL) - cnt_left++; - } - teams[bman.lastwinner].points += cnt_left; - } - else - bman.lastwinner = -1; - } - - if (GT_SP) - game_showresult (); - + if (cnt_left == 1) + players[bman.lastwinner].points += bman.players_nr_s; + else + bman.lastwinner = -1; + + /* check which team was alife */ + if (bman.gametype == GT_team) { + int t_nr; + + bman.lastwinner = -1; + cnt_left = 0; + + for (t_nr = 0; t_nr < MAX_TEAMS; t_nr++) + for (i = 0; i < MAX_PLAYERS; i++) { + if (teams[t_nr].players[i] != NULL) + if (PS_IS_alife (teams[t_nr].players[i]->state)) { + if (bman.lastwinner != t_nr) { + teams[t_nr].wins++; + cnt_left++; + bman.lastwinner = t_nr; + } + } + } + + if (cnt_left == 1) { + /* set the points */ + cnt_left = 0; + for (t_nr = 0; t_nr < MAX_TEAMS; t_nr++) { + for (i = 0; (i < MAX_PLAYERS && teams[t_nr].players[i] != NULL); i++); + if (i < MAX_PLAYERS && teams[t_nr].players[i] != NULL) + cnt_left++; + } + teams[bman.lastwinner].points += cnt_left; + } + else + bman.lastwinner = -1; + } + + if (GT_SP) + game_showresult (); + /* check which player is now free,i.e. disconnected during the game and was playing */ for (i = 0; i < MAX_PLAYERS; i++) if ((players[i].state & PSF_used) == 0) @@ -502,11 +493,12 @@ game_end () void game_start () { - int p, i; - - if (!bman.dedicated) menu_displaytext ("Loading..", "Please Wait"); + int p, + i; + + menu_displaytext ("Loading..", "Please Wait"); - bman.players_nr_s = 0; + bman.players_nr_s = 0; for (p = 0; p < MAX_PLAYERS; p++) { if (PS_IS_used (players[p].state)) { @@ -526,57 +518,54 @@ game_start () players[p].bombs_n = bman.start_bombs; players[p].range = bman.start_range; players[p].speed = bman.start_speed; - players[p].collect_shoes = 0; + players[p].collect_shoes = 0; players[p].special.type = SP_nothing; players[p].m = 0; - players[p].old.x = 0; - players[p].old.y = 0; - bman.updatestatusbar=1; + players[p].old.x = 0; + players[p].old.y = 0; + bman.updatestatusbar = 1; players[p].frame = 0.0f; players[p].d = 0; players[p].pos.x = 0.0; players[p].pos.y = 0.0; - players[p].tunnelto = 0.0f; - players[p].ready = 0; + players[p].tunnelto = 0.0f; + players[p].ready = 0; - /* all types of illnes turn them off */ - for (i = 0; i < PI_max; i++) + /* all types of illnes turn them off */ + for (i = 0; i < PI_max; i++) players[p].ill[i].to = 0.0f; - + // reset bombs for (i = 0; i < MAX_BOMBS; i++) { players[p].bombs[i].state = BS_off; players[p].bombs[i].ex_nr = -1; - players[p].bombs[i].speed = 0; - players[p].bombs[i].dest.x = 0; - players[p].bombs[i].dest.y = 0; - players[p].bombs[i].mode = BM_normal; - players[p].bombs[i].id.p = p; - players[p].bombs[i].id.b = i; - players[p].pos.x = 0; - players[p].pos.x = 0; + players[p].bombs[i].speed = 0; + players[p].bombs[i].dest.x = 0; + players[p].bombs[i].dest.y = 0; + players[p].bombs[i].mode = BM_normal; + players[p].bombs[i].id.p = p; + players[p].bombs[i].id.b = i; + players[p].pos.x = 0; + players[p].pos.x = 0; } } - - flitems_reset (); + + flitems_reset (); init_map_tileset (); - - if (!bman.dedicated) - tileset_load (map.tileset, -1, -1); - + + tileset_load (map.tileset, -1, -1); + gfx_load_players (gfx.block.x, gfx.block.y); - - if (!bman.dedicated) { - snd_load (map.tileset); - snd_music_start (); - } - - map.state = MS_normal; - bman.timeout = bman.init_timeout; - s_calctimesync (); // to clean up the timesyc - s_calctimesync (); // data run this twice - if (GT_MP_PTPM) - net_send_servermode (); + + snd_load (map.tileset); + snd_music_start (); + + map.state = MS_normal; + bman.timeout = bman.init_timeout; + s_calctimesync (); // to clean up the timesyc + s_calctimesync (); // data run this twice + if (GT_MP_PTPM) + net_send_servermode (); }; @@ -588,126 +577,154 @@ game_start () #define SHOWRESULT_TEAMHEAD 24 #define SHOWRESULT_TEAMPLAYER 16 #define SHOWRESULT_TEAMPLAYERWIDTH 150 -void game_showresultteam (int pos_x, int pos_y, int pos_w, int pos_h) { - int i, t_nr, p_nr; // counter for teams and players - struct { - _team *team; // pointer to the team - _player *pl[MAX_PLAYERS]; // players in the team (sorted) - int cnt; - } tdata[MAX_TEAMS]; // hold some team informations (sorted) - int t_count = 0, p_maxcount = 0, p_sumcount = 0; - int sx, sy, p_y, p_x , dx, dy, col, x; - SDL_Rect dest, src; - char text[255]; - - /* sort all teams */ - for (t_nr = 0; t_nr < MAX_TEAMS; t_nr++) { - tdata[t_nr].team = NULL; - tdata[t_nr].cnt = 0; - } - - for (t_nr = 0; t_nr < MAX_TEAMS; t_nr++) { - for (p_nr = 0; (p_nr < MAX_PLAYERS && teams[t_nr].players[p_nr] == NULL); p_nr++); - - if (p_nr < MAX_PLAYERS && teams[t_nr].players[p_nr] != NULL) { - tdata[t_count].team = &teams[t_nr]; - i = t_count; - - while (i > 0 && (tdata[i-1].team->wins < teams[t_nr].wins - || (tdata[i-1].team->wins == teams[t_nr].wins - && tdata[i-1].team->points < teams[t_nr].points))) { - tdata[i].team = tdata[i-1].team; - i--; - tdata[i].team = &teams[t_nr]; - } - t_count++; - } - } - - /* sort all players dependsing on the number of wins they have */ - for (t_nr = 0; t_nr < t_count; t_nr++) for (p_nr = 0, tdata[t_nr].cnt = 0; p_nr < MAX_PLAYERS; p_nr++) { - if (t_nr < t_count) { - if (tdata[t_nr].team->players[p_nr] != NULL && PS_IS_used (tdata[t_nr].team->players[p_nr]->state)) { - tdata[t_nr].pl[tdata[t_nr].cnt] = tdata[t_nr].team->players[p_nr]; - i = tdata[t_nr].cnt; - - while (i > 0 && (tdata[t_nr].pl[i-1]->wins < tdata[t_nr].team->players[p_nr]->wins - || (tdata[t_nr].pl[i-1]->wins == tdata[t_nr].team->players[p_nr]->wins - && tdata[t_nr].pl[i-1]->points < tdata[t_nr].team->players[p_nr]->points))) { - tdata[t_nr].pl[i] = tdata[t_nr].pl[i-1]; - i--; - tdata[t_nr].pl[i] = tdata[t_nr].team->players[p_nr]; - } - tdata[t_nr].cnt++; - } - } - } - - /* check the max number of players in one team and number of all players */ - for (t_nr = 0, p_maxcount = 0; t_nr < t_count; t_nr++) /* t_count + 1 */ - if (p_maxcount < tdata[t_nr].cnt) p_maxcount = tdata[t_nr].cnt; - - for (p_sumcount = 0, p_nr = 0; p_nr < MAX_PLAYERS; p_nr++) - if (PS_IS_used (players[p_nr].state)) p_sumcount++; - - /* calculate the best view */ - p_x = dx = dy = 0; - do { - p_x++; - p_y = 0; // calc. again for this setting - for (t_nr = 0; t_nr < t_count; t_nr++) { - p_y += ceil ((float)(((float) tdata[t_nr].cnt) / ((float)p_x))); - } - if (p_y == 0) p_y = 1; - dy = (pos_h - (SHOWRESULT_TEAMHEAD * t_count)) / p_y; - } while (dy < SHOWRESULT_TEAMPLAYER); - - if (dy > 2*SHOWRESULT_TEAMPLAYER) dy = 2*SHOWRESULT_TEAMPLAYER; - - /* draw everything */ - sy = (pos_h - (SHOWRESULT_TEAMHEAD * t_count + dy * p_y)) / 2; - for (t_nr = 0; t_nr < t_count; t_nr++) { - sprintf (text, "%s Victorys %d (%d)", tdata[t_nr].team->name, tdata[t_nr].team->wins, tdata[t_nr].team->points); - sx = (pos_w - strlen (text) * font[0].size.x) / 2; - font_gfxdrawbold (10+ pos_x + sx, pos_y + sy+3, text, 0, COLOR_brown, 1, 1); - font_gfxdraw (10+ pos_x + sx, pos_y + sy+3, text, 0, COLOR_yellow, 2); - sy += SHOWRESULT_TEAMHEAD; - dx = pos_w / p_x; - sx = (dx - SHOWRESULT_TEAMPLAYERWIDTH)/2; - - for (col = 0, p_nr = 0; p_nr < tdata[t_nr].cnt; p_nr++) { - if (col == 0 || col >= p_x) { - if (col >= p_x) sy += dy; - col = 0; - x = sx; - } - - if (tdata[t_nr].pl[p_nr]->gfx != NULL) { - dest.x = pos_x + x; - dest.y = pos_y + sy; - src.w = dest.w = tdata[t_nr].pl[p_nr]->gfx->small_image->w; - src.h = dest.h = tdata[t_nr].pl[p_nr]->gfx->small_image->h; - src.x = 0; - src.y = 0; - gfx_blit (tdata[t_nr].pl[p_nr]->gfx->small_image, &src, gfx.screen, &dest, 1); - } - else { - dest.x = pos_x + x; - dest.y = pos_y + sy; - src.w = dest.w = gfx.ghost_small->w; - src.h = dest.h = gfx.ghost_small->h; - src.x = 0; - src.y = 0; - gfx_blit (gfx.ghost_small, &src, gfx.screen, &dest, 1); - } - sprintf (text, "%s(%d/%d)", tdata[t_nr].pl[p_nr]->name, tdata[t_nr].pl[p_nr]->wins, tdata[t_nr].pl[p_nr]->points); - font_gfxdraw (10+ pos_x + x + GFX_SMALLPLAYERIMGSIZE_X*2, pos_y + sy + 2, text, 0, 0, 2); - x += dx; - col++; - } - sy += dy; - } +void +game_showresultteam (int pos_x, int pos_y, int pos_w, int pos_h) +{ + int i, + t_nr, + p_nr; // counter for teams and players + struct { + _team *team; // pointer to the team + _player *pl[MAX_PLAYERS]; // players in the team (sorted) + int cnt; + } tdata[MAX_TEAMS]; // hold some team informations (sorted) + int t_count = 0, + p_maxcount = 0, + p_sumcount = 0; + int sx, + sy, + p_y, + p_x, + dx, + dy, + col, + x; + SDL_Rect dest, + src; + char text[255]; + + /* sort all teams */ + for (t_nr = 0; t_nr < MAX_TEAMS; t_nr++) { + tdata[t_nr].team = NULL; + tdata[t_nr].cnt = 0; + } + + for (t_nr = 0; t_nr < MAX_TEAMS; t_nr++) { + for (p_nr = 0; (p_nr < MAX_PLAYERS && teams[t_nr].players[p_nr] == NULL); p_nr++); + + if (p_nr < MAX_PLAYERS && teams[t_nr].players[p_nr] != NULL) { + tdata[t_count].team = &teams[t_nr]; + i = t_count; + + while (i > 0 && (tdata[i - 1].team->wins < teams[t_nr].wins + || (tdata[i - 1].team->wins == teams[t_nr].wins + && tdata[i - 1].team->points < teams[t_nr].points))) { + tdata[i].team = tdata[i - 1].team; + i--; + tdata[i].team = &teams[t_nr]; + } + t_count++; + } + } + + /* sort all players dependsing on the number of wins they have */ + for (t_nr = 0; t_nr < t_count; t_nr++) + for (p_nr = 0, tdata[t_nr].cnt = 0; p_nr < MAX_PLAYERS; p_nr++) { + if (t_nr < t_count) { + if (tdata[t_nr].team->players[p_nr] != NULL + && PS_IS_used (tdata[t_nr].team->players[p_nr]->state)) { + tdata[t_nr].pl[tdata[t_nr].cnt] = tdata[t_nr].team->players[p_nr]; + i = tdata[t_nr].cnt; + + while (i > 0 + && (tdata[t_nr].pl[i - 1]->wins < tdata[t_nr].team->players[p_nr]->wins + || (tdata[t_nr].pl[i - 1]->wins == + tdata[t_nr].team->players[p_nr]->wins + && tdata[t_nr].pl[i - 1]->points < + tdata[t_nr].team->players[p_nr]->points))) { + tdata[t_nr].pl[i] = tdata[t_nr].pl[i - 1]; + i--; + tdata[t_nr].pl[i] = tdata[t_nr].team->players[p_nr]; + } + tdata[t_nr].cnt++; + } + } + } + + /* check the max number of players in one team and number of all players */ + for (t_nr = 0, p_maxcount = 0; t_nr < t_count; t_nr++) /* t_count + 1 */ + if (p_maxcount < tdata[t_nr].cnt) + p_maxcount = tdata[t_nr].cnt; + + for (p_sumcount = 0, p_nr = 0; p_nr < MAX_PLAYERS; p_nr++) + if (PS_IS_used (players[p_nr].state)) + p_sumcount++; + + /* calculate the best view */ + p_x = dx = dy = 0; + do { + p_x++; + p_y = 0; // calc. again for this setting + for (t_nr = 0; t_nr < t_count; t_nr++) { + p_y += ceil ((float) (((float) tdata[t_nr].cnt) / ((float) p_x))); + } + if (p_y == 0) + p_y = 1; + dy = (pos_h - (SHOWRESULT_TEAMHEAD * t_count)) / p_y; + } while (dy < SHOWRESULT_TEAMPLAYER); + + if (dy > 2 * SHOWRESULT_TEAMPLAYER) + dy = 2 * SHOWRESULT_TEAMPLAYER; + + /* draw everything */ + sy = (pos_h - (SHOWRESULT_TEAMHEAD * t_count + dy * p_y)) / 2; + for (t_nr = 0; t_nr < t_count; t_nr++) { + sprintf (text, "%s Victorys %d (%d)", tdata[t_nr].team->name, tdata[t_nr].team->wins, + tdata[t_nr].team->points); + sx = (pos_w - strlen (text) * font[0].size.x) / 2; + font_gfxdrawbold (10 + pos_x + sx, pos_y + sy + 3, text, 0, COLOR_brown, 1, 1); + font_gfxdraw (10 + pos_x + sx, pos_y + sy + 3, text, 0, COLOR_yellow, 2); + sy += SHOWRESULT_TEAMHEAD; + dx = pos_w / p_x; + sx = (dx - SHOWRESULT_TEAMPLAYERWIDTH) / 2; + + for (col = 0, p_nr = 0; p_nr < tdata[t_nr].cnt; p_nr++) { + if (col == 0 || col >= p_x) { + if (col >= p_x) + sy += dy; + col = 0; + x = sx; + } + + if (tdata[t_nr].pl[p_nr]->gfx != NULL) { + dest.x = pos_x + x; + dest.y = pos_y + sy; + src.w = dest.w = tdata[t_nr].pl[p_nr]->gfx->small_image->w; + src.h = dest.h = tdata[t_nr].pl[p_nr]->gfx->small_image->h; + src.x = 0; + src.y = 0; + gfx_blit (tdata[t_nr].pl[p_nr]->gfx->small_image, &src, gfx.screen, &dest, 1); + } + else { + dest.x = pos_x + x; + dest.y = pos_y + sy; + src.w = dest.w = gfx.ghost_small->w; + src.h = dest.h = gfx.ghost_small->h; + src.x = 0; + src.y = 0; + gfx_blit (gfx.ghost_small, &src, gfx.screen, &dest, 1); + } + sprintf (text, "%s(%d/%d)", tdata[t_nr].pl[p_nr]->name, tdata[t_nr].pl[p_nr]->wins, + tdata[t_nr].pl[p_nr]->points); + font_gfxdraw (10 + pos_x + x + GFX_SMALLPLAYERIMGSIZE_X * 2, pos_y + sy + 2, text, 0, 0, + 2); + x += dx; + col++; + } + sy += dy; + } } + #undef SHOWRESULT_TEAMHEAD #undef SHOWRESULT_TEAMPLAYER #undef SHOWRESULT_TEAMPLAYERWIDTH @@ -716,133 +733,154 @@ void game_showresultteam (int pos_x, int pos_y, int pos_w, int pos_h) { /* Bomberman/Deathmatch Version Play */ #define SHOWRESULT_WIDTH 150 #define SHOWRESULT_HEIGHT 60 -void game_showresultnormal (int pos_x, int pos_y, int pos_w, int pos_h) { +void +game_showresultnormal (int pos_x, int pos_y, int pos_w, int pos_h) +{ char text[255]; - int i, p, x, y, pl_cnt = 0, - pl_x, pl_y, // player in a row/col - dx, dy, // distance - sx, sy, px; // start view and position - - SDL_Rect dest, src; - _player *pl[MAX_PLAYERS]; - + int i, + p, + x, + y, + pl_cnt = 0, + pl_x, + pl_y, // player in a row/col + dx, + dy, // distance + sx, + sy, + px; // start view and position + + SDL_Rect dest, + src; + _player *pl[MAX_PLAYERS]; + + + /* Sort the playerlist */ + for (p = 0, pl_cnt = 0; p < MAX_PLAYERS; p++) + if (PS_IS_used (players[p].state)) { + pl[pl_cnt] = &players[p]; + i = pl_cnt; + + while (i > 0 && (pl[i - 1]->wins < players[p].wins + || (pl[i - 1]->wins == players[p].wins + && pl[i - 1]->points < players[p].points))) { + pl[i] = pl[i - 1]; + i--; + pl[i] = &players[p]; + } + pl_cnt++; + } - /* Sort the playerlist */ - for (p = 0, pl_cnt = 0; p < MAX_PLAYERS; p++) - if (PS_IS_used (players[p].state)) { - pl[pl_cnt] = &players[p]; - i = pl_cnt; - - while (i > 0 && (pl[i-1]->wins < players[p].wins - || (pl[i-1]->wins == players[p].wins - && pl[i-1]->points < players[p].points))) { - pl[i] = pl[i-1]; - i--; - pl[i] = &players[p]; - } - pl_cnt++; - } - - if (pl_cnt == 0) { - /* we still haven't joined the game */ - } - - /* calc the best view and start point */ - pl_x = 0; - do { - pl_x++; - pl_y = ceil ((float)(((float) pl_cnt) / ((float)pl_x))); - if (pl_y == 0) pl_y++; - dy = pos_h / pl_y; - } while (dy < SHOWRESULT_HEIGHT); - dx = pos_w / pl_x; - - x = sx = (dx - SHOWRESULT_WIDTH)/2; - y = sy = (dy - SHOWRESULT_HEIGHT)/2; - px = 0; + if (pl_cnt == 0) { + /* we still haven't joined the game */ + } - d_printf ("game_showresultnormal: pl_x:%d, pl_y:%d, dx:%d, dy:%d\n", pl_x, pl_y, dx, dy); - - /* draw the playerlist */ - for (i = 1, p = 0; p < pl_cnt; p++) { - if (PS_IS_used (pl[p]->state)) { - if (PS_IS_alife (pl[p]->state)) { - font_gfxdrawbold (10+ pos_x + x + GFX_MENUPLAYERIMGSIZE_X + 8, pos_y + y - 10, pl[p]->name, 0, COLOR_brown, 1, 1); - font_gfxdraw (10+ pos_x + x + GFX_MENUPLAYERIMGSIZE_X + 8,pos_y + y - 10, pl[p]->name, 0, COLOR_yellow, 1); - } - else - font_gfxdraw (10+ pos_x + x + GFX_MENUPLAYERIMGSIZE_X,pos_y + y - 10, pl[p]->name, 0, COLOR_gray, 1); - - sprintf (text, "%3d (%3d)", pl[p]->wins, pl[p]->points); - font_gfxdraw (10+ pos_x + x + GFX_MENUPLAYERIMGSIZE_X, pos_y + y + 6, text, 0, 0, 1); - - if (pl[p]->gfx != NULL) { - dest.x = pos_x + x; - dest.y = pos_y + y - 16; - src.w = dest.w = pl[p]->gfx->menu_image->w; - src.h = dest.h = pl[p]->gfx->menu_image->h; - src.x = 0; - src.y = 0; - gfx_blit (pl[p]->gfx->menu_image, &src, gfx.screen, &dest, 1); - } - else { - dest.x = pos_x + x; - dest.y = pos_y + y - 16; - src.w = dest.w = gfx.ghost->w; - src.h = dest.h = gfx.ghost->h; - src.x = 0; - src.y = 0; - gfx_blit (gfx.ghost, &src, gfx.screen, &dest, 1); - } - /* setup the new position */ - y += (dy / pl_x); - x += dx; - px++; - if (px >= pl_x) { - px = 0; - x = sx; - } - } - } + /* calc the best view and start point */ + pl_x = 0; + do { + pl_x++; + pl_y = ceil ((float) (((float) pl_cnt) / ((float) pl_x))); + if (pl_y == 0) + pl_y++; + dy = pos_h / pl_y; + } while (dy < SHOWRESULT_HEIGHT); + dx = pos_w / pl_x; + + x = sx = (dx - SHOWRESULT_WIDTH) / 2; + y = sy = (dy - SHOWRESULT_HEIGHT) / 2; + px = 0; + + d_printf ("game_showresultnormal: pl_x:%d, pl_y:%d, dx:%d, dy:%d\n", pl_x, pl_y, dx, dy); + + /* draw the playerlist */ + for (i = 1, p = 0; p < pl_cnt; p++) { + if (PS_IS_used (pl[p]->state)) { + if (PS_IS_alife (pl[p]->state)) { + font_gfxdrawbold (10 + pos_x + x + GFX_MENUPLAYERIMGSIZE_X + 8, pos_y + y - 10, + pl[p]->name, 0, COLOR_brown, 1, 1); + font_gfxdraw (10 + pos_x + x + GFX_MENUPLAYERIMGSIZE_X + 8, pos_y + y - 10, + pl[p]->name, 0, COLOR_yellow, 1); + } + else + font_gfxdraw (10 + pos_x + x + GFX_MENUPLAYERIMGSIZE_X, pos_y + y - 10, pl[p]->name, + 0, COLOR_gray, 1); + + sprintf (text, "%3d (%3d)", pl[p]->wins, pl[p]->points); + font_gfxdraw (10 + pos_x + x + GFX_MENUPLAYERIMGSIZE_X, pos_y + y + 6, text, 0, 0, 1); + + if (pl[p]->gfx != NULL) { + dest.x = pos_x + x; + dest.y = pos_y + y - 16; + src.w = dest.w = pl[p]->gfx->menu_image->w; + src.h = dest.h = pl[p]->gfx->menu_image->h; + src.x = 0; + src.y = 0; + gfx_blit (pl[p]->gfx->menu_image, &src, gfx.screen, &dest, 1); + } + else { + dest.x = pos_x + x; + dest.y = pos_y + y - 16; + src.w = dest.w = gfx.ghost->w; + src.h = dest.h = gfx.ghost->h; + src.x = 0; + src.y = 0; + gfx_blit (gfx.ghost, &src, gfx.screen, &dest, 1); + } + /* setup the new position */ + y += (dy / pl_x); + x += dx; + px++; + if (px >= pl_x) { + px = 0; + x = sx; + } + } + } } + #undef SHOWRESULT_HEIGHT #undef SHOWRESULT_WIDTH -void game_showresult () { +void +game_showresult () +{ char text[255]; SDL_Event event; Uint8 *keys; - int done = 0, keypressed = 0, x, y; - - gfx_blitdraw (); - + int done = 0, + keypressed = 0, + x, + y; + + gfx_blitdraw (); + draw_logo (); - + strcpy (text, "Game Result"); x = (gfx.res.x - (font[2].size.x * strlen (text)) - 64) / 2; y = 0; font_drawbold (x, y, text, 2, 6, 2); font_draw (x, y, text, 2, 5); - y += font[2].size.x; + y += font[2].size.x; - strcpy (text, "[CTRL],[RETURN] or [STRG] for another game"); + strcpy (text, "[CTRL],[RETURN] or [STRG] for another game"); x = (gfx.res.x - (font[1].size.x * strlen (text)) - 64) / 2; - font_drawbold (x, gfx.res.y - (2*font[0].size.y) - 2, text, 0, COLOR_brown, 1); - font_draw (x, gfx.res.y - (2*font[0].size.y) - 2, text, 0, COLOR_yellow); - - strcpy (text, "or [ESC] to leave the game."); + font_drawbold (x, gfx.res.y - (2 * font[0].size.y) - 2, text, 0, COLOR_brown, 1); + font_draw (x, gfx.res.y - (2 * font[0].size.y) - 2, text, 0, COLOR_yellow); + + strcpy (text, "or [ESC] to leave the game."); x = (gfx.res.x - (font[1].size.x * strlen (text)) - 64) / 2; font_drawbold (x, gfx.res.y - font[0].size.y - 2, text, 0, COLOR_brown, 1); font_draw (x, gfx.res.y - font[0].size.y - 2, text, 0, COLOR_yellow); - if (bman.gametype == GT_team) - game_showresultteam (10,50,gfx.res.x-20,gfx.res.y-100); - else - game_showresultnormal (10,50,gfx.res.x-20,gfx.res.y-100); + if (bman.gametype == GT_team) + game_showresultteam (10, 50, gfx.res.x - 20, gfx.res.y - 100); + else + game_showresultnormal (10, 50, gfx.res.x - 20, gfx.res.y - 100); - gfx_blitdraw (); - SDL_Flip (gfx.screen); + gfx_blitdraw (); + SDL_Flip (gfx.screen); while (!done && bman.state != GS_quit) { /* do the keyboard handling */ @@ -852,7 +890,7 @@ void game_showresult () { bman.state = GS_quit; bman.p_nr = -1; done = 1; - } + } keys = SDL_GetKeyState (NULL); @@ -864,47 +902,50 @@ void game_showresult () { bman.state = GS_startup; } - if ((keys[SDLK_RETURN] || keys[SDLK_LCTRL] || keys[SDLK_RCTRL]) && (!keypressed) && (event.type = SDL_KEYDOWN)) { + if ((keys[SDLK_RETURN] || keys[SDLK_LCTRL] || keys[SDLK_RCTRL]) && (!keypressed) + && (event.type = SDL_KEYDOWN)) { done = 1; keypressed = 1; } if (keys[SDLK_F8] && event.type == SDL_KEYDOWN) { /* Switch Fullscreen */ - SDL_WM_ToggleFullScreen(gfx.screen); - gfx.fullscreen = !gfx.fullscreen; + SDL_WM_ToggleFullScreen (gfx.screen); + gfx.fullscreen = !gfx.fullscreen; bman.updatestatusbar = 1; // force an update } if (event.type == SDL_KEYUP) keypressed = 0; - else if (event.type == SDL_KEYDOWN) + else if (event.type == SDL_KEYDOWN) keypressed = 1; s_delay (25); } - - if (bman.state != GS_quit && bman.state != GS_startup) - bman.state = GS_running; + + if (bman.state != GS_quit && bman.state != GS_startup) + bman.state = GS_running; }; /* * create the in game menu */ -void game_menu_create () { - if (menu != NULL) - return; +void +game_menu_create () +{ + if (menu != NULL) + return; - menu = menu_new ("Gamemenu", 300, 150); - - menu_create_button (menu, "Back to the Game", -1, 50, 200, 1); - if (GT_SP || GT_MP_PTPM) - menu_create_button (menu, "End this Round", -1, 80, 200, 2); - menu_create_button (menu, "Quit the Game", -1, 110, 200, 3); - - menu_focus_id (menu, 1); - menu->looprunning = 1; + menu = menu_new ("Gamemenu", 300, 150); + + menu_create_button (menu, "Back to the Game", -1, 50, 200, 1); + if (GT_SP || GT_MP_PTPM) + menu_create_button (menu, "End this Round", -1, 80, 200, 2); + menu_create_button (menu, "Quit the Game", -1, 110, 200, 3); + + menu_focus_id (menu, 1); + menu->looprunning = 1; }; @@ -917,35 +958,38 @@ void game_menu_create () { * * Pressing ESC will bring you back to the game. */ -void game_menu_loop (SDL_Event *event, int eventstate) { - int done; - - if (menu == NULL) - return; - - menu_draw (menu); - - done = menu_event_loop (menu, event, eventstate); - /* - * check if one of the buttons was pressed - */ - - if (done != 0) { - if (menu->focus->id == 2 && (GT_MP_PTPM || GT_SP)) { /* End Round */ - bman.timeout = -GAME_OVERTIMEOUT; - } - - else if (menu->focus->id == 3) { /* End Game */ - /* send network update */ - if (GT_MP) net_game_send_delplayer (bman.p_nr); - bman.state = GS_quit; - } - - else { /* Quit Menu */ - menu_delete (menu); - menu = NULL; - gfx_blitdraw (); - draw_field (); - } - } +void +game_menu_loop (SDL_Event * event, int eventstate) +{ + int done; + + if (menu == NULL) + return; + + menu_draw (menu); + + done = menu_event_loop (menu, event, eventstate); + /* + * check if one of the buttons was pressed + */ + + if (done != 0) { + if (menu->focus->id == 2 && (GT_MP_PTPM || GT_SP)) { /* End Round */ + bman.timeout = -GAME_OVERTIMEOUT; + } + + else if (menu->focus->id == 3) { /* End Game */ + /* send network update */ + if (GT_MP) + net_game_send_delplayer (bman.p_nr); + bman.state = GS_quit; + } + + else { /* Quit Menu */ + menu_delete (menu); + menu = NULL; + gfx_blitdraw (); + draw_field (); + } + } }; diff --git a/src/gfx.c b/src/gfx.c index 3b46585..21f5209 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -1,4 +1,4 @@ -/* $Id: gfx.c,v 1.40 2005/04/09 18:22:40 stpohle Exp $ */ +/* $Id: gfx.c,v 1.41 2005/07/06 13:11:55 stpohle Exp $ */ /* gfx.c */ #include "bomberclone.h" @@ -26,7 +26,7 @@ int gfx_get_nr_of_playergfx () { sprintf (filename, "%s/player/player%d.png", bman.datapath, i); f = fopen (filename, "r"); } while (f); - + return i; } @@ -66,23 +66,16 @@ gfx_load_players (int sx, int sy) gfx.players[i].ani.w = (tmpimage->w / 4) * sfkt; gfx.players[i].ani.frames = tmpimage->h / GFX_PLAYERIMGSIZE_Y; - if (!bman.dedicated) { - tmpimage1 = - scale_image (tmpimage, gfx.players[i].ani.w * 4, - gfx.players[i].ani.frames * gfx.players[i].ani.h); - getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); - SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b)); - gfx.players[i].ani.image = SDL_DisplayFormat (tmpimage1); - SDL_FreeSurface (tmpimage1); - - /* calculate the numbers of images for the animation */ - gfx.players[i].offset.x = (sx - gfx.players[i].ani.w) / 2; - gfx.players[i].offset.y = -sy; - } - else - gfx.players[i].ani.image = NULL; - - SDL_FreeSurface (tmpimage); + tmpimage1 = scale_image (tmpimage, gfx.players[i].ani.w * 4, gfx.players[i].ani.frames * gfx.players[i].ani.h); + getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); + SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b)); + gfx.players[i].ani.image = SDL_DisplayFormat (tmpimage1); + SDL_FreeSurface (tmpimage1); + + /* calculate the numbers of images for the animation */ + gfx.players[i].offset.x = (sx - gfx.players[i].ani.w) / 2; + gfx.players[i].offset.y = -sy; + SDL_FreeSurface (tmpimage); } } @@ -96,48 +89,38 @@ gfx_load_players (int sx, int sy) } gfx.dead.frames = tmpimage->h / (2* GFX_IMGSIZE); - if (!bman.dedicated) { - tmpimage1 = - scale_image (tmpimage, ((2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE)), - gfx.dead.frames * (2 * sy)); - getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); - SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b)); - gfx.dead.image = SDL_DisplayFormat (tmpimage1); - SDL_FreeSurface (tmpimage1); - SDL_FreeSurface (tmpimage); - - /* load the illnessthing */ - sprintf (filename, "%s/player/playersick.png", bman.datapath); - tmpimage = IMG_Load (filename); - if (tmpimage == NULL) { - printf ("Can't load image: %s\n", SDL_GetError ()); - exit (1); - } - gfx.ill.frames = tmpimage->h / (2 * GFX_IMGSIZE); - tmpimage1 = - scale_image (tmpimage, (2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE), - gfx.ill.frames * (2 * sy)); - getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); - SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b)); - gfx.ill.image = SDL_DisplayFormat (tmpimage1); - SDL_FreeSurface (tmpimage); - SDL_FreeSurface (tmpimage1); - - /* load the respawn gfx */ - sprintf (filename, "%s/player/respawn.png", bman.datapath); - tmpimage = IMG_Load (filename); - if (tmpimage == NULL) { - printf ("Can't load image: %s\n", SDL_GetError ()); - exit (1); - } - gfx.respawn.frames = tmpimage->h / (2 * GFX_IMGSIZE); - gfx.respawn.image = - scale_image (tmpimage, (2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE), - gfx.respawn.frames * (2 * sy)); - SDL_FreeSurface (tmpimage); - } - else - SDL_FreeSurface (tmpimage); + tmpimage1 = scale_image (tmpimage, ((2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE)), gfx.dead.frames * (2 * sy)); + getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); + SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b)); + gfx.dead.image = SDL_DisplayFormat (tmpimage1); + SDL_FreeSurface (tmpimage1); + SDL_FreeSurface (tmpimage); + + /* load the illnessthing */ + sprintf (filename, "%s/player/playersick.png", bman.datapath); + tmpimage = IMG_Load (filename); + if (tmpimage == NULL) { + printf ("Can't load image: %s\n", SDL_GetError ()); + exit (1); + } + gfx.ill.frames = tmpimage->h / (2 * GFX_IMGSIZE); + tmpimage1 = scale_image (tmpimage, (2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE), gfx.ill.frames * (2 * sy)); + getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); + SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b)); + gfx.ill.image = SDL_DisplayFormat (tmpimage1); + SDL_FreeSurface (tmpimage); + SDL_FreeSurface (tmpimage1); + + /* load the respawn gfx */ + sprintf (filename, "%s/player/respawn.png", bman.datapath); + tmpimage = IMG_Load (filename); + if (tmpimage == NULL) { + printf ("Can't load image: %s\n", SDL_GetError ()); + exit (1); + } + gfx.respawn.frames = tmpimage->h / (2 * GFX_IMGSIZE); + gfx.respawn.image = scale_image (tmpimage, (2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE), gfx.respawn.frames * (2 * sy)); + SDL_FreeSurface (tmpimage); }; @@ -146,8 +129,8 @@ void gfx_free_players () { int i; - - d_printf ("gfx_free_players\n"); + + d_printf ("gfx_free_players\n"); for (i = 0; i < gfx.player_gfx_count; i++) { if (gfx.players[i].ani.image != NULL) @@ -170,22 +153,15 @@ gfx_init () { int i; - if (gfx.fullscreen && !bman.dedicated) - gfx.screen = - SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp, - SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL | SDL_FULLSCREEN); + if (gfx.fullscreen) + gfx.screen = SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp, SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL | SDL_FULLSCREEN); - else if (!bman.dedicated) - gfx.screen = - SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp, - SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL); - if (!bman.dedicated && gfx.screen == NULL) { + else + gfx.screen = SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp, SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL); + if (gfx.screen == NULL) { d_printf ("Unable to set video mode: %s\n", SDL_GetError ()); return; } - else if (bman.dedicated) { - gfx.screen = NULL; - } SDL_ShowCursor (SDL_DISABLE); /* delete small gfx und the menu player gfx */ @@ -532,14 +508,13 @@ draw_logo () { SDL_Rect dest; - if (bman.dedicated) return; dest.x = dest.y = 0; dest.w = gfx.res.x; dest.h = gfx.res.y; - SDL_BlitSurface (gfx.logo, NULL, gfx.screen, NULL); - gfx_blitupdaterectadd (&dest); + SDL_BlitSurface (gfx.logo, NULL, gfx.screen, NULL); + gfx_blitupdaterectadd (&dest); }; diff --git a/src/gfxengine.c b/src/gfxengine.c index dc093af..e087d0f 100644 --- a/src/gfxengine.c +++ b/src/gfxengine.c @@ -1,4 +1,4 @@ -/* $Id: gfxengine.c,v 1.6 2005/04/09 18:22:41 stpohle Exp $ */ +/* $Id: gfxengine.c,v 1.7 2005/07/06 13:11:55 stpohle Exp $ */ /* GFX Game Engine */ #include "bomberclone.h" @@ -103,7 +103,7 @@ gfx_blitdraw () { int i; - if (blitdb_nr < 0 || bman.dedicated) { + if (blitdb_nr < 0) { blitdb_nr = 0; return; } @@ -111,7 +111,7 @@ gfx_blitdraw () gfx_blitsort (); for (i = 0; i < MAX_BLITRECTS && sortblitdb[i] != NULL; i++) { - SDL_BlitSurface (sortblitdb[i]->srci, &sortblitdb[i]->srcr, sortblitdb[i]->desti, &sortblitdb[i]->destr); + SDL_BlitSurface (sortblitdb[i]->srci, &sortblitdb[i]->srcr, sortblitdb[i]->desti, &sortblitdb[i]->destr); gfx_blitupdaterectadd (&sortblitdb[i]->destr); } diff --git a/src/main.c b/src/main.c index dfa90aa..dab0b63 100644 --- a/src/main.c +++ b/src/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.31 2005/04/09 18:22:41 stpohle Exp $ */ +/* $Id: main.c,v 1.32 2005/07/06 13:11:55 stpohle Exp $ */ #include "basic.h" #include "bomberclone.h" @@ -42,7 +42,7 @@ main (int argc, char **argv) config_init (argc, argv); - while (menuselect != -1 && bman.state != GS_quit && bman.dedicated == 0) { + while (menuselect != -1 && bman.state != GS_quit) { menu = menu_new ("Bomberclone", 400, 250); // y=230 menu_create_button (menu, "Single Game", -1, 70, 200, 0); diff --git a/src/multiwait.c b/src/multiwait.c index d2a7645..a8039b8 100644 --- a/src/multiwait.c +++ b/src/multiwait.c @@ -1,4 +1,4 @@ -/* $Id: multiwait.c,v 1.55 2005/04/09 18:22:41 stpohle Exp $ +/* $Id: multiwait.c,v 1.56 2005/07/06 13:11:55 stpohle Exp $ multiwait.c - this manages only the network screen where everyone have to select it's players and where even the basic chat is inside */ @@ -33,30 +33,24 @@ extern int blitdb_nr; static void mw_init () { team_update (); - if (!bman.dedicated) { - gfx_blitdraw (); - draw_logo (); - gfx_blitdraw (); - } - bman.updatestatusbar = 1; + gfx_blitdraw (); + draw_logo (); + gfx_blitdraw (); + bman.updatestatusbar = 1; d_playerdetail ("mw_init:\n"); - if (!bman.dedicated) { - SDL_Flip (gfx.screen); - chat_show (10, gfx.res.y / 2, gfx.res.x - 20, gfx.res.y / 2 - 10); - chat_setactive (1, 1); - } + SDL_Flip (gfx.screen); + chat_show (10, gfx.res.y / 2, gfx.res.x - 20, gfx.res.y / 2 - 10); + chat_setactive (1, 1); }; /* free all graphics */ static void mw_shutdown () { - if (!bman.dedicated) { - chat_show (-1, -1, -1, -1); - gfx_blitdraw (); - draw_logo (); + chat_show (-1, -1, -1, -1); + gfx_blitdraw (); + draw_logo (); - SDL_Flip (gfx.screen); - } + SDL_Flip (gfx.screen); }; @@ -241,50 +235,25 @@ void wait_for_players () { /* * the drawing stuff */ - if (!bman.dedicated) { - if (mw_check_screenredraw()) { - d_printf ("Draw Status\n"); - gfx_blitdraw (); - draw_logo (); - if (bman.gametype==GT_team) mw_draw_all_teams(); - else mw_draw_all_player (); - } + if (mw_check_screenredraw()) { + d_printf ("Draw Status\n"); gfx_blitdraw (); - - /* - * input handling - */ - keyb_loop (&event); - mw_keys_loop (); - - chat_loop (&event); - chat.active = 1; - } - else { - /* check for the minimum of players */ - - for (humanpl_cnt = 0, i = 0, cnt = 0, aipl = -1; i < MAX_PLAYERS; i++) { - if (PS_IS_used (players[i].state)) { - cnt++; - if (PS_IS_aiplayer (players[i].state)) - aipl = i; - else if (players[i].gfx_nr >= 0) - humanpl_cnt++; - } - } - - if (cnt < (bman.minplayers+1)) - single_create_ai (1); - - if (cnt > (bman.minplayers+1) && aipl >= 0) - player_delete (aipl); + draw_logo (); + if (bman.gametype==GT_team) mw_draw_all_teams(); + else mw_draw_all_player (); } + gfx_blitdraw (); - s_calctimesync (); - - if ((bman.autostart > 0) && (timestamp > timeout_timestamp) && bman.dedicated && humanpl_cnt > 0) - bman.state = GS_ready; + /* + * input handling + */ + keyb_loop (&event); + mw_keys_loop (); + + chat_loop (&event); + chat.active = 1; + s_calctimesync (); } while (bman.state == GS_wait && bman.sock != -1); mw_shutdown (); diff --git a/src/network.c b/src/network.c index c688471..2863556 100644 --- a/src/network.c +++ b/src/network.c @@ -1,4 +1,4 @@ -/* $Id: network.c,v 1.74 2005/04/10 00:22:17 stpohle Exp $ */ +/* $Id: network.c,v 1.75 2005/07/06 13:11:56 stpohle Exp $ */ /* network routines. */ @@ -477,14 +477,12 @@ net_transmit_gamedata () Uint8 *keys; Uint32 downtimestamp = 0; - if (!bman.dedicated) { - draw_logo (); + draw_logo (); - if (GT_MP_PTPM) - font_draw (100, 0, "Waiting for the Clients", 1, 0); - else - font_draw (100, 0, "Downloading Data", 1, 0); - } + if (GT_MP_PTPM) + font_draw (100, 0, "Waiting for the Clients", 1, 0); + else + font_draw (100, 0, "Downloading Data", 1, 0); /* prepare everything for the loop @@ -505,10 +503,8 @@ net_transmit_gamedata () else net_istep = 3; - if (!bman.dedicated) { - draw_netupdatestate (1); - SDL_Flip (gfx.screen); - } + draw_netupdatestate (1); + SDL_Flip (gfx.screen); downtimestamp = timestamp; while (!done && (bman.state == GS_update || (GT_MP_PTPS && net_istep != 0))) { @@ -617,40 +613,37 @@ net_transmit_gamedata () } /* do the grafik work */ - if (!bman.dedicated) { - draw_netupdatestate (0); - - if (SDL_PollEvent (&event) != 0) - switch (event.type) { - case (SDL_QUIT): - bman.state = GS_quit; - bman.p_nr = -1; - done = 1; - } + draw_netupdatestate (0); - keys = SDL_GetKeyState (NULL); - - if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) { - done = 1; + if (SDL_PollEvent (&event) != 0) + switch (event.type) { + case (SDL_QUIT): + bman.state = GS_quit; bman.p_nr = -1; - keypressed = 1; - bman.state = GS_startup; + done = 1; } - if (event.type == SDL_KEYUP) - keypressed = 0; - } - - timestamp = SDL_GetTicks (); // needed for time sync. - SDL_Delay (1); // we don't need here anything better + keys = SDL_GetKeyState (NULL); - /* player is only watching so just go after we have got everything - go to show the field */ - if (GT_MP_PTPS && bman.state == GS_update && net_istep == 0 - && players[bman.p_nr].gfx_nr == -1) { + if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) { done = 1; - bman.state = GS_running; + bman.p_nr = -1; + keypressed = 1; + bman.state = GS_startup; } + + if (event.type == SDL_KEYUP) + keypressed = 0; + } + + timestamp = SDL_GetTicks (); // needed for time sync. + SDL_Delay (1); // we don't need here anything better + + /* player is only watching so just go after we have got everything + go to show the field */ + if (GT_MP_PTPS && bman.state == GS_update && net_istep == 0 && players[bman.p_nr].gfx_nr == -1) { + done = 1; + bman.state = GS_running; } }; diff --git a/src/player.c b/src/player.c index 2983b86..92fcca3 100644 --- a/src/player.c +++ b/src/player.c @@ -1,4 +1,4 @@ -/* $Id: player.c,v 1.101 2005/04/11 22:21:14 stpohle Exp $ +/* $Id: player.c,v 1.102 2005/07/06 13:11:56 stpohle Exp $ * player.c - everything what have to do with the player */ #include @@ -17,9 +17,6 @@ draw_player (_player * player) SDL_Rect src, dest; int i; - - if (bman.dedicated) - return; if ((int)player->pos.x < 0 || (int)player->pos.x >= map.size.x || (int)player->pos.y < 0 || (int)player->pos.y >= map.size.y) { @@ -582,8 +579,6 @@ draw_players () { int p; - if (bman.dedicated) return; - for (p = 0; p < MAX_PLAYERS; p++) { if (PS_IS_playing (players[p].state) && players[p].tunnelto <= 0) draw_player (&players[p]); diff --git a/src/playermenu.c b/src/playermenu.c index 362f466..53b1442 100644 --- a/src/playermenu.c +++ b/src/playermenu.c @@ -1,4 +1,4 @@ -/* $Id: playermenu.c,v 1.16 2004/12/26 04:19:20 stpohle Exp $ +/* $Id: playermenu.c,v 1.17 2005/07/06 13:11:56 stpohle Exp $ */ #include "bomberclone.h" @@ -28,7 +28,9 @@ static void playermenu_selgfx_drawplayer (int selgfx, _menu *menu) { static int changed = 0; SDL_Rect rect, srcrect; int i; - + int i_start; + int i_end; + /* * delete old state, to force an update of all playergfx */ @@ -50,26 +52,36 @@ static void playermenu_selgfx_drawplayer (int selgfx, _menu *menu) { rect.h = 4 * GFX_IMGSIZE; menu_draw_background (menu, &rect); - for (i = 0; i < gfx.player_gfx_count; i++) { - srcrect.h = rect.h = gfx.players[i].menu_image->h; - srcrect.w = rect.w = gfx.players[i].menu_image->w; + /* calculate the first element on the screen */ + if (gfx.player_gfx_count < 12 || selgfx < 4) i_start = 0; + else { + i_start = (((selgfx / 4)-1) * 4); + if (i_start < 0) i_start = 0; + } + + if ((i_end = i_start + 12) > gfx.player_gfx_count) + i_end = gfx.player_gfx_count; + + for (i = 0; i < i_end - i_start; i++) { + srcrect.h = rect.h = gfx.players[i + i_start].menu_image->h; + srcrect.w = rect.w = gfx.players[i + i_start].menu_image->w; rect.x = (2 * GFX_MENUPLAYERIMGSIZE_X) * (i % 4) + ((menu->oldscreenpos.w - 2 * menuimages[0]->w) - (8 * GFX_MENUPLAYERIMGSIZE_X)) / 2; rect.y = (GFX_MENUPLAYERIMGSIZE_X * 2) * (i / 4) + PLAYERMENU_GFXSEL_Y; srcrect.x = 0; srcrect.y = 0; rect.x += menu->oldscreenpos.x + menuimages[0]->w; rect.y += menu->oldscreenpos.y + menuimages[0]->h; - gfx_blit (gfx.players[i].menu_image, &srcrect, gfx.screen, &rect, 10002); + gfx_blit (gfx.players[i + i_start].menu_image, &srcrect, gfx.screen, &rect, 10002); /* draw the select border */ - if (i == selgfx) { + if ((i + i_start) == selgfx) { srcrect.x = 0; srcrect.y = 0; srcrect.h = rect.h = GFX_IMGSIZE; srcrect.w = rect.w = GFX_IMGSIZE; rect.x = GFX_IMGSIZE * (i % 4) + ((menu->oldscreenpos.w - 2 * menuimages[0]->w) -(4 * GFX_IMGSIZE)) / 2; rect.y = GFX_IMGSIZE * (i / 4) + PLAYERMENU_GFXSEL_Y; - rect.x += (gfx.players[i].menu_image->w - gfx.menuselect.image->w) / 2; // center the playergfx + rect.x += (gfx.players[i + i_start].menu_image->w - gfx.menuselect.image->w) / 2; // center the playergfx rect.x += menu->oldscreenpos.x + menuimages[0]->w; rect.y += menu->oldscreenpos.y + menuimages[0]->h; gfx_blit (gfx.menuselect.image, &srcrect, gfx.screen, &rect, 10001); @@ -98,7 +110,10 @@ int playermenu_selgfx (int pl_nr) { playermenu_selgfx_drawplayer (-1, NULL); player_set_gfx (&players[pl_nr], -1); - menu = menu_new ("Player Selection", 400, 270); + if (gfx.player_gfx_count > 8) + menu = menu_new ("Player Selection", 400, 330); + else + menu = menu_new ("Player Selection", 400, 270); menu_create_text (menu, "playergfxsel", -1, 50, 40, 5, COLOR_yellow, "%s, please select your Player and press ENTER/RETURN or press ESCAPE for no player (that means you will only watch the next game).", players[pl_nr].name); menu->looprunning = 1; diff --git a/src/sound.c b/src/sound.c index 8eb6cb3..9848490 100644 --- a/src/sound.c +++ b/src/sound.c @@ -1,4 +1,4 @@ -/* $Id: sound.c,v 1.7 2005/04/09 18:22:41 stpohle Exp $ */ +/* $Id: sound.c,v 1.8 2005/07/06 13:11:56 stpohle Exp $ */ /* sound */ #include "sound.h" @@ -80,11 +80,6 @@ void snd_init () { #if HAVE_SDL_MIXER - if (bman.dedicated) { - snd.inited = 0; - return; - } - if (Mix_OpenAudio (snd.audio_rate, snd.audio_format, snd.audio_channels, 1024) < 0) { d_printf ("Couldn't open audio mixer: %s\n", SDL_GetError ()); snd.inited = 0;