bomberclone can run as a dedicated server

origin
stpohle 21 years ago
parent 790e52c9f6
commit 77fa552c0a

@ -5,7 +5,7 @@ dnl Please disable it in the Anjuta project configuration
AC_INIT(configure.in) AC_INIT(configure.in)
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE(bomberclone, 0.11.6.1) AM_INIT_AUTOMAKE(bomberclone, 0.11.6.2)
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)

@ -1,4 +1,4 @@
/* $Id: basic.h,v 1.30 2005/03/27 01:31:49 stpohle Exp $ */ /* $Id: basic.h,v 1.31 2005/04/09 18:22:40 stpohle Exp $ */
/* basic types which we need everywhere */ /* basic types which we need everywhere */
#ifndef _BC_BASIC_H_ #ifndef _BC_BASIC_H_
@ -80,6 +80,8 @@
#define UDP_TIMEOUT 15000 #define UDP_TIMEOUT 15000
#define BUF_SIZE 1024 #define BUF_SIZE 1024
#define AUTOSTART 20 /* dedicated server autostart */
#define MW_IS_GFX_SELECT(__gfx_nr,__result) for (__result = (MAX_PLAYERS-1); (__result >= 0) && (players[__result].gfx_nr != __gfx_nr); __result--); #define MW_IS_GFX_SELECT(__gfx_nr,__result) for (__result = (MAX_PLAYERS-1); (__result >= 0) && (players[__result].gfx_nr != __gfx_nr); __result--);
#define CUTINT(__x) (__x-floorf(__x)) // cut the integer part off #define CUTINT(__x) (__x-floorf(__x)) // cut the integer part off

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.32 2005/04/08 00:18:28 stpohle Exp $ */ /* $Id: bomberclone.h,v 1.33 2005/04/09 18:22:40 stpohle Exp $ */
/* bomberclone.h */ /* bomberclone.h */
#ifndef _BOMBERCLONE_H_ #ifndef _BOMBERCLONE_H_
@ -85,6 +85,10 @@ struct {
int firewall; int firewall;
int notifygamemaster; int notifygamemaster;
int broadcast; int broadcast;
int dedicated; // if started as dedicated server
int autostart; // time for an autostart of the game
int minplayers; // minimal number of players
int askplayername; // ask player for name at startup int askplayername; // ask player for name at startup
int start_bombs; // start values int start_bombs; // start values

@ -1,4 +1,4 @@
/* $Id: gfx.h,v 1.9 2005/04/06 21:17:48 stpohle Exp $ */ /* $Id: gfx.h,v 1.10 2005/04/09 18:22:40 stpohle Exp $ */
#ifndef _GFX_H_ #ifndef _GFX_H_
#define _GFX_H_ #define _GFX_H_
@ -84,6 +84,7 @@ extern void gfx_unlocksurface (SDL_Surface *surface);
extern void redraw_logo_shaded (int x, int y, int w, int h, int c); extern void redraw_logo_shaded (int x, int y, int w, int h, int c);
extern void gfx_load_players (int sx, int sy); extern void gfx_load_players (int sx, int sy);
extern void gfx_free_players (); extern void gfx_free_players ();
extern int gfx_get_nr_of_playergfx ();
// gfxpixelimage.c // gfxpixelimage.c
extern void getRGBpixel (SDL_Surface *surface, int x, int y, int *R, int *G, int *B); extern void getRGBpixel (SDL_Surface *surface, int x, int y, int *R, int *G, int *B);

@ -1,4 +1,4 @@
/* $Id: bomb.c,v 1.62 2005/02/20 19:11:20 stpohle Exp $ */ /* $Id: bomb.c,v 1.63 2005/04/09 18:22:40 stpohle Exp $ */
/* everything what have to do with the bombs */ /* everything what have to do with the bombs */
#include "bomberclone.h" #include "bomberclone.h"
@ -19,6 +19,9 @@ draw_bomb (_bomb * bomb)
y1, y1,
y2; y2;
if (bman.dedicated)
return;
if (x < 0 || y < 0 || x >= map.size.x || y >= map.size.y) { 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); d_printf ("FATAL: Draw Bomb out of range [%f,%f]\n", x, y);
return; return;

@ -1,4 +1,4 @@
/* $Id: configuration.c,v 1.73 2005/04/08 00:18:29 stpohle Exp $ /* $Id: configuration.c,v 1.74 2005/04/09 18:22:40 stpohle Exp $
* configuration */ * configuration */
#include <SDL.h> #include <SDL.h>
@ -93,6 +93,8 @@ config_init (int argc, char **argv)
resend_cache.fill = -1; resend_cache.fill = -1;
bman.notifygamemaster = 1; bman.notifygamemaster = 1;
bman.broadcast = 1; bman.broadcast = 1;
bman.dedicated = 0;
bman.autostart = AUTOSTART;
bman.askplayername = 0; bman.askplayername = 0;
debug = 0; debug = 0;
gfx.res.x = 640; gfx.res.x = 640;
@ -111,6 +113,7 @@ config_init (int argc, char **argv)
bman.firewall = 0; bman.firewall = 0;
bman.init_timeout = GAME_TIMEOUT; bman.init_timeout = GAME_TIMEOUT;
bman.ai_players = 1; bman.ai_players = 1;
bman.minplayers = 0;
snd.inited = 0; snd.inited = 0;
snd.audio_rate = 22050; snd.audio_rate = 22050;
snd.audio_format = AUDIO_S16; snd.audio_format = AUDIO_S16;
@ -133,36 +136,34 @@ config_init (int argc, char **argv)
bman.bomb_tickingtime = BOMB_TIMEOUT; bman.bomb_tickingtime = BOMB_TIMEOUT;
bman.dropitemsondeath = 0; bman.dropitemsondeath = 0;
d_printf ("\n\n ***** Bomberclone Version %s \n\n", VERSION); d_printf ("\n\n ***** Bomberclone Version %s \n\n", VERSION);
if (config_read ()) { /* error on reading the config file */ config_read ();
ReadPrgArgs (argc, argv);
gfx_init (); ReadPrgArgs (argc, argv);
draw_logo ();
playernamemenu (); gfx_init ();
} draw_logo ();
else { if (bman.askplayername)
ReadPrgArgs (argc, argv); playernamemenu ();
gfx_init ();
draw_logo ();
if (bman.askplayername)
playermenu ();
}
snd_init (); snd_init ();
gfx_blitdraw (); gfx_blitdraw ();
SDL_Flip (gfx.screen);
if (!bman.dedicated)
SDL_Flip (gfx.screen);
sprintf (text,"Bomberclone %s", VERSION); sprintf (text,"Bomberclone %s", VERSION);
sprintf (icon,"%s/pixmaps/bomberclone.png", bman.datapath); sprintf (icon,"%s/pixmaps/bomberclone.png", bman.datapath);
SDL_WM_SetCaption(text , NULL); SDL_WM_SetCaption(text , NULL);
icon_img = IMG_Load(icon); icon_img = IMG_Load(icon);
if (icon_img == NULL) if (icon_img == NULL)
d_printf ("could not load icon. (%s)\n", icon); d_printf ("could not load icon. (%s)\n", icon);
#ifdef _WIN32 #ifdef _WIN32
{ {
SDL_Surface *tmp = icon_img; SDL_Surface *tmp = icon_img;
icon_img = scale_image (tmp, 32, 32); icon_img = scale_image (tmp, 32, 32);
SDL_FreeSurface (tmp); SDL_FreeSurface (tmp);
} }
#endif #endif
SDL_WM_SetIcon (icon_img, NULL); SDL_WM_SetIcon (icon_img, NULL);
@ -173,8 +174,7 @@ config_init (int argc, char **argv)
/* read the configuration file /* read the configuration file
* return -1 if something went wrong and 0 if no problem */ * return -1 if something went wrong and 0 if no problem */
int int
config_read () config_read () {
{
FILE *config; FILE *config;
char buf[1024]; char buf[1024];
char *findit, char *findit,
@ -675,6 +675,8 @@ ReadPrgArgs (int argc, char **argv)
printf (" -join - go into the join menu\n"); printf (" -join - go into the join menu\n");
printf (" -connect ADDRESS - connect to a server\n"); printf (" -connect ADDRESS - connect to a server\n");
printf (" -debug 0/1 - enable/disable debug\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");
exit (0); exit (0);
} }
if (!strcmp (argv[i], "-port")) if (!strcmp (argv[i], "-port"))
@ -693,6 +695,13 @@ ReadPrgArgs (int argc, char **argv)
bman.broadcast = atoi (argv[++i]); bman.broadcast = atoi (argv[++i]);
if (!strcmp (argv[i], "-debug")) if (!strcmp (argv[i], "-debug"))
debug = atoi (argv[++i]); debug = atoi (argv[++i]);
if (!strcmp (argv[i], "-dedicated")) {
if (bman.minplayers <= 1)
bman.minplayers = 2;
bman.dedicated = 1;
}
if (!strcmp (argv[i], "-autostart"))
bman.autostart = atoi (argv[++i]);
} }
}; };
@ -717,6 +726,9 @@ ReadPrgArgs_Jump (int argc, char **argv)
join_multiplayer_game (); join_multiplayer_game ();
} }
} }
if (bman.dedicated > 0)
host_multiplayer_game ();
}; };

@ -1,4 +1,4 @@
/* $Id: font.c,v 1.14 2004/12/26 04:19:20 stpohle Exp $ */ /* $Id: font.c,v 1.15 2005/04/09 18:22:40 stpohle Exp $ */
// Using Fonts in SDL // Using Fonts in SDL
#include <string.h> #include <string.h>
@ -126,17 +126,23 @@ void font_load () {
b = 128; b = 128;
break; break;
} }
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)); if (!bman.dedicated) {
SDL_FillRect (font[i].image[c], NULL, SDL_MapRGB (font[i].image[c]->format, r,g,b)); font[i].image[c] = SDL_DisplayFormat (tmp);
SDL_BlitSurface (raw, NULL, font[i].image[c], NULL); 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].size.x = raw->w / 16; font[i].size.x = tmp->w / 16;
font[i].size.y = raw->h / 16; font[i].size.y = tmp->h / 16;
SDL_FreeSurface (raw); SDL_FreeSurface (raw);
SDL_FreeSurface (tmp); if (!bman.dedicated)
SDL_FreeSurface (tmp);
} }
}; };

@ -1,4 +1,4 @@
/* $Id: game.c,v 1.108 2005/04/06 21:17:48 stpohle Exp $ /* $Id: game.c,v 1.109 2005/04/09 18:22:40 stpohle Exp $
game.c - procedures for the game. */ game.c - procedures for the game. */
#include <string.h> #include <string.h>
@ -220,21 +220,21 @@ game_loop ()
SDL_Event event; SDL_Event event;
int done = 0, eventstate; int done = 0, eventstate;
gfx_blitupdaterectclear ();
draw_logo ();
draw_field ();
if (GT_MP) if (GT_MP)
net_game_fillsockaddr (); net_game_fillsockaddr ();
SDL_Flip (gfx.screen);
menu = NULL; menu = NULL;
bman.updatestatusbar = 1; // force an update bman.updatestatusbar = 1; // force an update
timestamp = SDL_GetTicks (); // needed for time sync. timestamp = SDL_GetTicks (); // needed for time sync.
d_gamedetail ("GAME START"); d_gamedetail ("GAME START");
draw_players ();
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) { if (bman.p_nr >= 0 && bman.p_nr < MAX_PLAYERS) {
players[bman.p_nr].ready = 1; players[bman.p_nr].ready = 1;
@ -248,33 +248,55 @@ game_loop ()
} }
while (!done && (bman.state == GS_running || bman.state == GS_ready)) { 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;
}
/* if (!bman.dedicated) {
* input handling if ((eventstate = SDL_PollEvent (&event)) != 0)
*/ switch (event.type) {
keyb_loop (&event); case (SDL_QUIT):
done = 1;
bman.state = GS_quit;
}
game_keys_loop (); /*
* input handling
*/
keyb_loop (&event);
game_keys_loop ();
if (GT_MP)
chat_loop (&event);
if (GT_MP) if ((!IS_LPLAYER2) && (!chat.active))
chat_loop (&event); chat_setactive (1, 1);
if ((!IS_LPLAYER2) && (!chat.active)) restore_players_screen ();
chat_setactive (1, 1); }
/* 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)
bman.state = GS_running;
else
d_printf ("game_keys_loop: not all players are ready\n");
net_send_servermode ();
}
restore_players_screen ();
player_check (bman.p_nr); player_check (bman.p_nr);
if (IS_LPLAYER2) if (IS_LPLAYER2)
player_check (bman.p2_nr); player_check (bman.p2_nr);
dead_playerani (); if (!bman.dedicated)
dead_playerani ();
special_loop (); special_loop ();
player_move (bman.p_nr); player_move (bman.p_nr);
@ -292,8 +314,11 @@ game_loop ()
bomb_loop (); bomb_loop ();
field_loop (); field_loop ();
flitems_loop (); flitems_loop ();
draw_players ();
game_draw_info (); // will set the var bman.player_nr if (!bman.dedicated) {
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 /* check if there is only one player left and the game is in multiplayer mode
and if there the last dieing animation is done */ and if there the last dieing animation is done */
@ -305,28 +330,34 @@ game_loop ()
done = 1; done = 1;
} }
stonelist_draw (); if (!bman.dedicated) {
stonelist_draw ();
/* if there is any menu displayed do so */ /* if there is any menu displayed do so */
if (menu != NULL) if (menu != NULL)
game_menu_loop (&event, eventstate); game_menu_loop (&event, eventstate);
gfx_blitdraw ();
}
gfx_blitdraw ();
s_calctimesync (); s_calctimesync ();
bman.timeout -= timediff; bman.timeout -= timediff;
} }
if (menu != NULL) if (menu != NULL)
menu_delete (menu); menu_delete (menu);
gfx_blitdraw ();
chat_show (-1, -1, -1, -1); if (!bman.dedicated) {
gfx_blitdraw ();
chat_show (-1, -1, -1, -1);
draw_logo ();
gfx_blitupdaterectclear ();
SDL_Flip (gfx.screen);
}
d_gamedetail ("GAME END"); d_gamedetail ("GAME END");
d_printf ("done = %d\n", done); d_printf ("done = %d\n", done);
draw_logo ();
gfx_blitupdaterectclear ();
SDL_Flip (gfx.screen);
}; };
@ -471,7 +502,7 @@ game_start ()
{ {
int p, i; int p, i;
menu_displaytext ("Loading..", "Please Wait"); if (!bman.dedicated) menu_displaytext ("Loading..", "Please Wait");
bman.players_nr_s = 0; bman.players_nr_s = 0;
@ -527,10 +558,17 @@ game_start ()
flitems_reset (); flitems_reset ();
init_map_tileset (); init_map_tileset ();
tileset_load (map.tileset, -1, -1);
if (!bman.dedicated)
tileset_load (map.tileset, -1, -1);
gfx_load_players (gfx.block.x, gfx.block.y); gfx_load_players (gfx.block.x, gfx.block.y);
snd_load (map.tileset);
snd_music_start (); if (!bman.dedicated) {
snd_load (map.tileset);
snd_music_start ();
}
map.state = MS_normal; map.state = MS_normal;
bman.timeout = bman.init_timeout; bman.timeout = bman.init_timeout;
s_calctimesync (); // to clean up the timesyc s_calctimesync (); // to clean up the timesyc

@ -1,4 +1,4 @@
/* $Id: gfx.c,v 1.39 2005/04/06 21:17:48 stpohle Exp $ */ /* $Id: gfx.c,v 1.40 2005/04/09 18:22:40 stpohle Exp $ */
/* gfx.c */ /* gfx.c */
#include "bomberclone.h" #include "bomberclone.h"
@ -6,14 +6,14 @@
_gfx gfx; _gfx gfx;
static int gfx_get_nr_of_playergfx (); int gfx_get_nr_of_playergfx ();
static void gfx_load_menusmall_players (); static void gfx_load_menusmall_players ();
static void gfx_load_fieldtype_menu (); static void gfx_load_fieldtype_menu ();
/* /*
* count all playergfx * count all playergfx
*/ */
static int gfx_get_nr_of_playergfx () { int gfx_get_nr_of_playergfx () {
int i = 0; int i = 0;
FILE *f = NULL; FILE *f = NULL;
char filename[255]; char filename[255];
@ -65,19 +65,24 @@ gfx_load_players (int sx, int sy)
gfx.players[i].ani.h = sy * 2; gfx.players[i].ani.h = sy * 2;
gfx.players[i].ani.w = (tmpimage->w / 4) * sfkt; gfx.players[i].ani.w = (tmpimage->w / 4) * sfkt;
gfx.players[i].ani.frames = tmpimage->h / GFX_PLAYERIMGSIZE_Y; gfx.players[i].ani.frames = tmpimage->h / GFX_PLAYERIMGSIZE_Y;
tmpimage1 =
scale_image (tmpimage, gfx.players[i].ani.w * 4, if (!bman.dedicated) {
gfx.players[i].ani.frames * gfx.players[i].ani.h); tmpimage1 =
getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); scale_image (tmpimage, gfx.players[i].ani.w * 4,
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b)); gfx.players[i].ani.frames * gfx.players[i].ani.h);
gfx.players[i].ani.image = SDL_DisplayFormat (tmpimage1); getRGBpixel (tmpimage1, 0, 0, &r, &g, &b);
SDL_FreeSurface (tmpimage1); SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b));
gfx.players[i].ani.image = SDL_DisplayFormat (tmpimage1);
/* calculate the numbers of images for the animation */ SDL_FreeSurface (tmpimage1);
gfx.players[i].offset.x = (sx - gfx.players[i].ani.w) / 2;
gfx.players[i].offset.y = -sy; /* calculate the numbers of images for the animation */
gfx.players[i].offset.x = (sx - gfx.players[i].ani.w) / 2;
SDL_FreeSurface (tmpimage); gfx.players[i].offset.y = -sy;
}
else
gfx.players[i].ani.image = NULL;
SDL_FreeSurface (tmpimage);
} }
} }
@ -91,46 +96,48 @@ gfx_load_players (int sx, int sy)
} }
gfx.dead.frames = tmpimage->h / (2* GFX_IMGSIZE); gfx.dead.frames = tmpimage->h / (2* GFX_IMGSIZE);
tmpimage1 = if (!bman.dedicated) {
scale_image (tmpimage, ((2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE)), tmpimage1 =
gfx.dead.frames * (2 * sy)); scale_image (tmpimage, ((2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE)),
getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); gfx.dead.frames * (2 * sy));
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b)); getRGBpixel (tmpimage1, 0, 0, &r, &g, &b);
gfx.dead.image = SDL_DisplayFormat (tmpimage1); SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b));
SDL_FreeSurface (tmpimage1); gfx.dead.image = SDL_DisplayFormat (tmpimage1);
SDL_FreeSurface (tmpimage); SDL_FreeSurface (tmpimage1);
SDL_FreeSurface (tmpimage);
/* load the illnessthing */ /* load the illnessthing */
sprintf (filename, "%s/player/playersick.png", bman.datapath); sprintf (filename, "%s/player/playersick.png", bman.datapath);
tmpimage = IMG_Load (filename); tmpimage = IMG_Load (filename);
if (tmpimage == NULL) { if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ()); printf ("Can't load image: %s\n", SDL_GetError ());
exit (1); exit (1);
} }
gfx.ill.frames = tmpimage->h / (2 * GFX_IMGSIZE); gfx.ill.frames = tmpimage->h / (2 * GFX_IMGSIZE);
tmpimage1 = tmpimage1 =
scale_image (tmpimage, (2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE), scale_image (tmpimage, (2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE),
gfx.ill.frames * (2 * sy)); gfx.ill.frames * (2 * sy));
getRGBpixel (tmpimage1, 0, 0, &r, &g, &b); getRGBpixel (tmpimage1, 0, 0, &r, &g, &b);
SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b)); SDL_SetColorKey (tmpimage1, SDL_SRCCOLORKEY, SDL_MapRGB (tmpimage1->format, r, g, b));
gfx.ill.image = SDL_DisplayFormat (tmpimage1); gfx.ill.image = SDL_DisplayFormat (tmpimage1);
SDL_FreeSurface (tmpimage); SDL_FreeSurface (tmpimage);
SDL_FreeSurface (tmpimage1); SDL_FreeSurface (tmpimage1);
/* load the respawn gfx */
/* load the respawn gfx */ sprintf (filename, "%s/player/respawn.png", bman.datapath);
sprintf (filename, "%s/player/respawn.png", bman.datapath); tmpimage = IMG_Load (filename);
tmpimage = IMG_Load (filename); if (tmpimage == NULL) {
if (tmpimage == NULL) { printf ("Can't load image: %s\n", SDL_GetError ());
printf ("Can't load image: %s\n", SDL_GetError ()); exit (1);
exit (1); }
} gfx.respawn.frames = tmpimage->h / (2 * GFX_IMGSIZE);
gfx.respawn.frames = tmpimage->h / (2 * GFX_IMGSIZE); gfx.respawn.image =
gfx.respawn.image = scale_image (tmpimage, (2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE),
scale_image (tmpimage, (2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE), gfx.respawn.frames * (2 * sy));
gfx.respawn.frames * (2 * sy)); SDL_FreeSurface (tmpimage);
SDL_FreeSurface (tmpimage); }
else
SDL_FreeSurface (tmpimage);
}; };
@ -163,19 +170,22 @@ gfx_init ()
{ {
int i; int i;
if (gfx.fullscreen) if (gfx.fullscreen && !bman.dedicated)
gfx.screen = gfx.screen =
SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp, SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp,
SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL | SDL_FULLSCREEN); SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL | SDL_FULLSCREEN);
else else if (!bman.dedicated)
gfx.screen = gfx.screen =
SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp, SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp,
SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL); SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL);
if (gfx.screen == NULL) { if (!bman.dedicated && gfx.screen == NULL) {
d_printf ("Unable to set video mode: %s\n", SDL_GetError ()); d_printf ("Unable to set video mode: %s\n", SDL_GetError ());
return; return;
} }
else if (bman.dedicated) {
gfx.screen = NULL;
}
SDL_ShowCursor (SDL_DISABLE); SDL_ShowCursor (SDL_DISABLE);
/* delete small gfx und the menu player gfx */ /* delete small gfx und the menu player gfx */
@ -521,6 +531,9 @@ void
draw_logo () draw_logo ()
{ {
SDL_Rect dest; SDL_Rect dest;
if (bman.dedicated) return;
dest.x = dest.y = 0; dest.x = dest.y = 0;
dest.w = gfx.res.x; dest.w = gfx.res.x;
dest.h = gfx.res.y; dest.h = gfx.res.y;

@ -1,4 +1,4 @@
/* $Id: gfxengine.c,v 1.5 2004/09/25 10:57:51 stpohle Exp $ */ /* $Id: gfxengine.c,v 1.6 2005/04/09 18:22:41 stpohle Exp $ */
/* GFX Game Engine */ /* GFX Game Engine */
#include "bomberclone.h" #include "bomberclone.h"
@ -103,7 +103,7 @@ gfx_blitdraw ()
{ {
int i; int i;
if (blitdb_nr < 0) { if (blitdb_nr < 0 || bman.dedicated) {
blitdb_nr = 0; blitdb_nr = 0;
return; return;
} }

@ -1,4 +1,4 @@
/* $Id: gfxpixelimage.c,v 1.12 2004/09/26 02:28:06 stpohle Exp $ */ /* $Id: gfxpixelimage.c,v 1.13 2005/04/09 18:22:41 stpohle Exp $ */
/* gfx pixel manipulation and image manipulation */ /* gfx pixel manipulation and image manipulation */
#include "bomberclone.h" #include "bomberclone.h"
@ -492,6 +492,8 @@ SDL_Surface *gfx_copyfrom (SDL_Surface *img, SDL_Rect *rect) {
SDL_Surface *res; SDL_Surface *res;
SDL_Rect src, dest; SDL_Rect src, dest;
if (img == NULL) return NULL;
if (rect == NULL) { if (rect == NULL) {
src.x = 0; src.x = 0;
src.y = 0; src.y = 0;

@ -1,4 +1,4 @@
/* $Id: main.c,v 1.30 2004/10/18 18:27:20 stpohle Exp $ */ /* $Id: main.c,v 1.31 2005/04/09 18:22:41 stpohle Exp $ */
#include "basic.h" #include "basic.h"
#include "bomberclone.h" #include "bomberclone.h"
@ -41,7 +41,8 @@ main (int argc, char **argv)
SDL_EnableUNICODE(1); SDL_EnableUNICODE(1);
config_init (argc, argv); config_init (argc, argv);
while (menuselect != -1 && bman.state != GS_quit) {
while (menuselect != -1 && bman.state != GS_quit && bman.dedicated == 0) {
menu = menu_new ("Bomberclone", 400, 250); // y=230 menu = menu_new ("Bomberclone", 400, 250); // y=230
menu_create_button (menu, "Single Game", -1, 70, 200, 0); menu_create_button (menu, "Single Game", -1, 70, 200, 0);

@ -1,4 +1,4 @@
/* $Id: multiwait.c,v 1.54 2004/12/26 04:19:20 stpohle Exp $ /* $Id: multiwait.c,v 1.55 2005/04/09 18:22:41 stpohle Exp $
multiwait.c - this manages only the network screen where multiwait.c - this manages only the network screen where
everyone have to select it's players and where even the basic chat is inside everyone have to select it's players and where even the basic chat is inside
*/ */
@ -33,24 +33,30 @@ extern int blitdb_nr;
static void mw_init () static void mw_init ()
{ {
team_update (); team_update ();
gfx_blitdraw (); if (!bman.dedicated) {
draw_logo (); gfx_blitdraw ();
gfx_blitdraw (); draw_logo ();
gfx_blitdraw ();
}
bman.updatestatusbar = 1; bman.updatestatusbar = 1;
d_playerdetail ("mw_init:\n"); d_playerdetail ("mw_init:\n");
SDL_Flip (gfx.screen); if (!bman.dedicated) {
chat_show (10, gfx.res.y / 2, gfx.res.x - 20, gfx.res.y / 2 - 10); SDL_Flip (gfx.screen);
chat_setactive (1, 1); chat_show (10, gfx.res.y / 2, gfx.res.x - 20, gfx.res.y / 2 - 10);
chat_setactive (1, 1);
}
}; };
/* free all graphics */ /* free all graphics */
static void mw_shutdown () { static void mw_shutdown () {
chat_show (-1, -1, -1, -1); if (!bman.dedicated) {
gfx_blitdraw (); chat_show (-1, -1, -1, -1);
draw_logo (); gfx_blitdraw ();
draw_logo ();
SDL_Flip (gfx.screen); SDL_Flip (gfx.screen);
}
}; };
@ -214,6 +220,8 @@ static void mw_draw_all_teams () {
/* the loop itself */ /* the loop itself */
void wait_for_players () { void wait_for_players () {
SDL_Event event; SDL_Event event;
int i, cnt, aipl, humanpl_cnt;
int timeout_timestamp = timestamp + (bman.autostart * 1000);
mw_init (); mw_init ();
@ -233,25 +241,50 @@ void wait_for_players () {
/* /*
* the drawing stuff * the drawing stuff
*/ */
if (mw_check_screenredraw()) { if (!bman.dedicated) {
d_printf ("Draw Status\n"); 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 ();
}
gfx_blitdraw (); gfx_blitdraw ();
draw_logo ();
if (bman.gametype==GT_team) mw_draw_all_teams();
else mw_draw_all_player ();
}
gfx_blitdraw ();
/* /*
* input handling * input handling
*/ */
keyb_loop (&event); keyb_loop (&event);
mw_keys_loop (); mw_keys_loop ();
chat_loop (&event); chat_loop (&event);
chat.active = 1; 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);
}
s_calctimesync (); s_calctimesync ();
if ((bman.autostart > 0) && (timestamp > timeout_timestamp) && bman.dedicated && humanpl_cnt > 0)
bman.state = GS_ready;
} while (bman.state == GS_wait && bman.sock != -1); } while (bman.state == GS_wait && bman.sock != -1);
mw_shutdown (); mw_shutdown ();

@ -1,4 +1,4 @@
/* $Id: network.c,v 1.72 2004/12/26 04:19:20 stpohle Exp $ */ /* $Id: network.c,v 1.73 2005/04/09 18:22:41 stpohle Exp $ */
/* /*
network routines. network routines.
*/ */
@ -469,12 +469,14 @@ net_transmit_gamedata ()
Uint8 *keys; Uint8 *keys;
Uint32 downtimestamp = 0; Uint32 downtimestamp = 0;
draw_logo (); if (!bman.dedicated) {
draw_logo ();
if (GT_MP_PTPM) if (GT_MP_PTPM)
font_draw (100, 0, "Waiting for the Clients", 1, 0); font_draw (100, 0, "Waiting for the Clients", 1, 0);
else else
font_draw (100, 0, "Downloading Data", 1, 0); font_draw (100, 0, "Downloading Data", 1, 0);
}
/* /*
prepare everything for the loop prepare everything for the loop
@ -494,8 +496,11 @@ net_transmit_gamedata ()
else else
net_istep = 3; net_istep = 3;
draw_netupdatestate (1); if (!bman.dedicated) {
SDL_Flip (gfx.screen); draw_netupdatestate (1);
SDL_Flip (gfx.screen);
}
downtimestamp = timestamp; downtimestamp = timestamp;
while (!done && (bman.state == GS_update || (GT_MP_PTPS && net_istep != 0))) { while (!done && (bman.state == GS_update || (GT_MP_PTPS && net_istep != 0))) {
/* the network thing */ /* the network thing */
@ -600,30 +605,32 @@ net_transmit_gamedata ()
} }
/* do the grafik work */ /* do the grafik work */
draw_netupdatestate (0); if (!bman.dedicated) {
draw_netupdatestate (0);
if (SDL_PollEvent (&event) != 0)
switch (event.type) { if (SDL_PollEvent (&event) != 0)
case (SDL_QUIT): switch (event.type) {
bman.state = GS_quit; case (SDL_QUIT):
bman.p_nr = -1; bman.state = GS_quit;
done = 1; bman.p_nr = -1;
} done = 1;
}
keys = SDL_GetKeyState (NULL);
keys = SDL_GetKeyState (NULL);
if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) {
done = 1; if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) {
bman.p_nr = -1; done = 1;
keypressed = 1; bman.p_nr = -1;
bman.state = GS_startup; keypressed = 1;
} bman.state = GS_startup;
}
if (event.type == SDL_KEYUP)
keypressed = 0; if (event.type == SDL_KEYUP)
keypressed = 0;
}
timestamp = SDL_GetTicks (); // needed for time sync. timestamp = SDL_GetTicks (); // needed for time sync.
SDL_Delay (1); // we don't need here anything better SDL_Delay (1); // we don't need here anything better
/* player is only watching so just go after we have got everything /* player is only watching so just go after we have got everything
go to show the field */ go to show the field */

@ -1,4 +1,4 @@
/* $Id: player.c,v 1.99 2005/02/20 21:58:05 stpohle Exp $ /* $Id: player.c,v 1.100 2005/04/09 18:22:41 stpohle Exp $
* player.c - everything what have to do with the player */ * player.c - everything what have to do with the player */
#include <SDL.h> #include <SDL.h>
@ -18,6 +18,9 @@ draw_player (_player * player)
dest; dest;
int i; int i;
if (bman.dedicated)
return;
if ((int)player->pos.x < 0 || (int)player->pos.x >= map.size.x || 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) { (int)player->pos.y < 0 || (int)player->pos.y >= map.size.y) {
d_printf ("FATAL: Draw Player out of range : [%f,%f]\n", player->pos.x, d_printf ("FATAL: Draw Player out of range : [%f,%f]\n", player->pos.x,
@ -578,6 +581,9 @@ void
draw_players () draw_players ()
{ {
int p; int p;
if (bman.dedicated) return;
for (p = 0; p < MAX_PLAYERS; p++) { for (p = 0; p < MAX_PLAYERS; p++) {
if (PS_IS_playing (players[p].state) && players[p].tunnelto <= 0) if (PS_IS_playing (players[p].state) && players[p].tunnelto <= 0)
draw_player (&players[p]); draw_player (&players[p]);

@ -1,4 +1,4 @@
/* $Id: sound.c,v 1.6 2003/12/24 02:38:16 stpohle Exp $ */ /* $Id: sound.c,v 1.7 2005/04/09 18:22:41 stpohle Exp $ */
/* sound */ /* sound */
#include "sound.h" #include "sound.h"
@ -80,6 +80,11 @@ void
snd_init () snd_init ()
{ {
#if HAVE_SDL_MIXER #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) { 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 ()); d_printf ("Couldn't open audio mixer: %s\n", SDL_GetError ());
snd.inited = 0; snd.inited = 0;

Loading…
Cancel
Save