bugfix with more as 8 different playergraphics. Dedicated server mode removed

origin
stpohle 21 years ago
parent a98791b800
commit 473a92c692

@ -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 Version 0.11.6.2
- Client network player could die two times in a game. - Client network player could die two times in a game.

@ -1,4 +1,4 @@
# Anjuta Version 1.2.2 # Anjuta Version 1.2.3
Compatibility Level: 1 Compatibility Level: 1
<PROJECT_DESCRIPTION_START> <PROJECT_DESCRIPTION_START>
@ -39,7 +39,7 @@ echo "T $target H $host B $buid" >cross-target.txt
props.file.type=project props.file.type=project
anjuta.version=1.2.2 anjuta.version=1.2.3
anjuta.compatibility.level=1 anjuta.compatibility.level=1
project.name=bomberclone project.name=bomberclone

@ -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 */ /* basic types which we need everywhere */
#ifndef _BC_BASIC_H_ #ifndef _BC_BASIC_H_
@ -80,7 +80,7 @@
#define UDP_TIMEOUT 15000 #define UDP_TIMEOUT 15000
#define BUF_SIZE 1024 #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--); #define MW_IS_GFX_SELECT(__gfx_nr,__result) for (__result = (MAX_PLAYERS-1); (__result >= 0) && (players[__result].gfx_nr != __gfx_nr); __result--);

@ -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 */ /* bomberclone.h */
#ifndef _BOMBERCLONE_H_ #ifndef _BOMBERCLONE_H_
@ -85,7 +85,6 @@ 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 autostart; // time for an autostart of the game
int minplayers; // minimal number of players int minplayers; // minimal number of players

@ -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 */ /* everything what have to do with the bombs */
#include "bomberclone.h" #include "bomberclone.h"
@ -19,8 +19,6 @@ 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);

@ -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 */ * configuration */
#include <SDL.h> #include <SDL.h>
@ -21,7 +21,9 @@
* 2) ./data * 2) ./data
* 3) ../data * 3) ../data
*/ */
void config_get_datapath () { void
config_get_datapath ()
{
FILE *f; FILE *f;
char filename[255]; char filename[255];
@ -54,8 +56,10 @@ void
config_init (int argc, char **argv) config_init (int argc, char **argv)
{ {
SDL_Surface *icon_img; SDL_Surface *icon_img;
char text[255], icon[255]; char text[255],
int i, j; icon[255];
int i,
j;
config_get_datapath (); config_get_datapath ();
@ -93,7 +97,6 @@ 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.autostart = AUTOSTART;
bman.askplayername = 0; bman.askplayername = 0;
debug = 0; debug = 0;
@ -148,7 +151,6 @@ config_init (int argc, char **argv)
snd_init (); snd_init ();
gfx_blitdraw (); gfx_blitdraw ();
if (!bman.dedicated)
SDL_Flip (gfx.screen); SDL_Flip (gfx.screen);
sprintf (text, "Bomberclone %s", VERSION); sprintf (text, "Bomberclone %s", VERSION);
@ -174,7 +176,8 @@ 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,7 +678,6 @@ 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"); printf (" -autostart SECONDS - time before a game starts\n");
exit (0); exit (0);
} }
@ -695,12 +697,6 @@ 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;
printf ("\nDedicated Bomberclone Server - Version " VERSION "\n\n");
}
if (!strcmp (argv[i], "-autostart")) if (!strcmp (argv[i], "-autostart"))
bman.autostart = atoi (argv[++i]); bman.autostart = atoi (argv[++i]);
} }
@ -727,15 +723,17 @@ ReadPrgArgs_Jump (int argc, char **argv)
join_multiplayer_game (); join_multiplayer_game ();
} }
} }
if (bman.dedicated > 0)
host_multiplayer_game ();
}; };
/* check the version number, return [ 0 =] [-1 <] [ 1 >] */ /* check the version number, return [ 0 =] [-1 <] [ 1 >] */
int check_version (int ma, int mi, int su, char *ver) { int
int v1, v2, v3, res = 0; check_version (int ma, int mi, int su, char *ver)
{
int v1,
v2,
v3,
res = 0;
sscanf (ver, "%d.%d.%d", &v1, &v2, &v3); sscanf (ver, "%d.%d.%d", &v1, &v2, &v3);
if (v1 < ma) if (v1 < ma)

@ -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 // Using Fonts in SDL
#include <string.h> #include <string.h>
@ -127,21 +127,16 @@ void font_load () {
break; break;
} }
if (!bman.dedicated) {
font[i].image[c] = SDL_DisplayFormat (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_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_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); SDL_BlitSurface (raw, NULL, font[i].image[c], NULL);
} }
else
font[i].image[c] = tmp;
}
font[i].size.x = tmp->w / 16; font[i].size.x = tmp->w / 16;
font[i].size.y = tmp->h / 16; font[i].size.y = tmp->h / 16;
SDL_FreeSurface (raw); SDL_FreeSurface (raw);
if (!bman.dedicated)
SDL_FreeSurface (tmp); SDL_FreeSurface (tmp);
} }
}; };

@ -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. */ game.c - procedures for the game. */
#include <string.h> #include <string.h>
@ -17,7 +17,8 @@
extern int blitdb_nr, extern int blitdb_nr,
blitrects_nr; blitrects_nr;
Uint32 game_timediff, game_timediff1; Uint32 game_timediff,
game_timediff1;
static float hurrywarn_to; static float hurrywarn_to;
static int hurrywarn_state; static int hurrywarn_state;
static _menu *menu; static _menu *menu;
@ -97,6 +98,7 @@ game_draw_info ()
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.x = x - 32;
dest.y = 16; dest.y = 16;
dest.w = gfx.menu_field[col]->w; dest.w = gfx.menu_field[col]->w;
dest.h = gfx.menu_field[col]->h; dest.h = gfx.menu_field[col]->h;
@ -119,12 +121,16 @@ game_draw_info ()
hurrywarn_state = !hurrywarn_state; hurrywarn_state = !hurrywarn_state;
if (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_drawbold ((gfx.res.x - strlen ("HURRY HURRY") * font[1].size.x) / 2, 40,
font_draw ((gfx.res.x - strlen ("HURRY HURRY")*font[1].size.x)/2, 40, "HURRY HURRY", 1, 1); "HURRY HURRY", 1, 0, 2);
font_draw ((gfx.res.x - strlen ("HURRY HURRY") * font[1].size.x) / 2, 40,
"HURRY HURRY", 1, 1);
} }
else { else {
font_drawbold ((gfx.res.x - strlen ("HURRY HURRY")*font[1].size.x)/2, 40, "HURRY HURRY", 1, 1, 2); font_drawbold ((gfx.res.x - strlen ("HURRY HURRY") * font[1].size.x) / 2, 40,
font_draw ((gfx.res.x - strlen ("HURRY HURRY")*font[1].size.x)/2, 40, "HURRY HURRY", 1, 0); "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.x = dest.y = 0;
dest.h = 4.5 * 16; dest.h = 4.5 * 16;
@ -147,10 +153,11 @@ game_draw_info ()
* chat mode: the chatmode should only be disabled in the game mode * chat mode: the chatmode should only be disabled in the game mode
* in the GS_wait mode the chat will always be active. * in the GS_wait mode the chat will always be active.
*/ */
void game_keys_loop () { void
game_keys_loop ()
{
if (menu != NULL) { if (menu != NULL) {
/* delete all movement keys */ /* delete all movement keys */
int i; int i;
@ -161,11 +168,13 @@ void game_keys_loop () {
/* don't go into the game_keys if there is no menu displayed */ /* 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]) { if (GT_MP_PTPM && bman.state == GS_ready && keyb_gamekeys.state[BCK_pause]
&& !keyb_gamekeys.old[BCK_pause]) {
/* Server is starting the game /* Server is starting the game
* check in multiplayer if all players are ready for the game * check in multiplayer if all players are ready for the game
*/ */
int i, ready = 1; int i,
ready = 1;
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if (NET_CANSEND (i) && !players[i].ready) if (NET_CANSEND (i) && !players[i].ready)
@ -204,7 +213,8 @@ void game_keys_loop () {
game_menu_create (); game_menu_create ();
} }
if ((GT_MP_PTPM || GT_MP_PTPS) && keyb_gamekeys.state[BCK_chat] && !keyb_gamekeys.old[BCK_chat]) { if ((GT_MP_PTPM || GT_MP_PTPS) && keyb_gamekeys.state[BCK_chat]
&& !keyb_gamekeys.old[BCK_chat]) {
chat_setactive (1, 0); chat_setactive (1, 0);
chat.changed = 1; chat.changed = 1;
d_printf ("Chatmode Enabled\n"); d_printf ("Chatmode Enabled\n");
@ -218,8 +228,8 @@ void
game_loop () game_loop ()
{ {
SDL_Event event; SDL_Event event;
int done = 0, eventstate; int done = 0,
int ready_timestamp = 0; eventstate;
if (GT_MP) if (GT_MP)
net_game_fillsockaddr (); net_game_fillsockaddr ();
@ -229,13 +239,11 @@ game_loop ()
timestamp = SDL_GetTicks (); // needed for time sync. timestamp = SDL_GetTicks (); // needed for time sync.
d_gamedetail ("GAME START"); d_gamedetail ("GAME START");
if (!bman.dedicated) {
gfx_blitupdaterectclear (); gfx_blitupdaterectclear ();
draw_logo (); draw_logo ();
draw_field (); draw_field ();
SDL_Flip (gfx.screen); SDL_Flip (gfx.screen);
draw_players (); 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;
@ -249,8 +257,6 @@ game_loop ()
} }
while (!done && (bman.state == GS_running || bman.state == GS_ready)) { while (!done && (bman.state == GS_running || bman.state == GS_ready)) {
if (!bman.dedicated) {
if ((eventstate = SDL_PollEvent (&event)) != 0) if ((eventstate = SDL_PollEvent (&event)) != 0)
switch (event.type) { switch (event.type) {
case (SDL_QUIT): case (SDL_QUIT):
@ -272,31 +278,11 @@ game_loop ()
chat_setactive (1, 1); chat_setactive (1, 1);
restore_players_screen (); 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); player_check (bman.p_nr);
if (IS_LPLAYER2) if (IS_LPLAYER2)
player_check (bman.p2_nr); player_check (bman.p2_nr);
if (!bman.dedicated)
dead_playerani (); dead_playerani ();
special_loop (); special_loop ();
@ -317,10 +303,8 @@ game_loop ()
field_loop (); field_loop ();
flitems_loop (); flitems_loop ();
if (!bman.dedicated) {
draw_players (); draw_players ();
game_draw_info (); // will set the var bman.player_nr 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 */
@ -332,7 +316,6 @@ game_loop ()
done = 1; done = 1;
} }
if (!bman.dedicated) {
stonelist_draw (); stonelist_draw ();
/* if there is any menu displayed do so */ /* if there is any menu displayed do so */
@ -340,23 +323,23 @@ game_loop ()
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);
menu = NULL;
}
if (!bman.dedicated) {
gfx_blitdraw (); gfx_blitdraw ();
chat_show (-1, -1, -1, -1); chat_show (-1, -1, -1, -1);
draw_logo (); draw_logo ();
gfx_blitupdaterectclear (); gfx_blitupdaterectclear ();
SDL_Flip (gfx.screen); SDL_Flip (gfx.screen);
}
d_gamedetail ("GAME END"); d_gamedetail ("GAME END");
d_printf ("done = %d\n", done); d_printf ("done = %d\n", done);
@ -368,13 +351,16 @@ game_loop ()
* check also if we there is only one team alife * check also if we there is only one team alife
*/ */
#define ENDGAME_CHECK_AGAIN 1.0f #define ENDGAME_CHECK_AGAIN 1.0f
int game_check_endgame () { int
game_check_endgame ()
{
int res = 0; int res = 0;
static float loop; static float loop;
loop -= timediff; loop -= timediff;
if (loop > 0.0f && loop < ENDGAME_CHECK_AGAIN) return 0; if (loop > 0.0f && loop < ENDGAME_CHECK_AGAIN)
return 0;
loop = ENDGAME_CHECK_AGAIN; loop = ENDGAME_CHECK_AGAIN;
if (bman.gametype == GT_team) { if (bman.gametype == GT_team) {
@ -389,7 +375,8 @@ int game_check_endgame () {
int team_last = -1; // last teams which was alift int team_last = -1; // last teams which was alift
_player *p; _player *p;
for (t_nr = 0; t_nr < MAX_TEAMS; t_nr++) for (p_nr = 0; p_nr < MAX_PLAYERS; p_nr++) 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) { if (teams[t_nr].players[p_nr] != NULL) {
p = teams[t_nr].players[p_nr]; p = teams[t_nr].players[p_nr];
if (PS_IS_used (p->state) && PS_IS_alife (p->state)) { if (PS_IS_used (p->state) && PS_IS_alife (p->state)) {
@ -407,7 +394,8 @@ int game_check_endgame () {
if (h_team < 1 || ateam < 2) if (h_team < 1 || ateam < 2)
res = 1; res = 1;
} }
else if ((bman.gametype == GT_bomberman) || (map.state != MS_normal && bman.gametype == GT_deathmatch)) { else if ((bman.gametype == GT_bomberman)
|| (map.state != MS_normal && bman.gametype == GT_deathmatch)) {
int p_nr; // playernumber int p_nr; // playernumber
int h_alife = 0; // human players who are alife int h_alife = 0; // human players who are alife
int alife = 0; // ai players who are alife int alife = 0; // ai players who are alife
@ -427,6 +415,7 @@ int game_check_endgame () {
return res; return res;
}; };
#undef ENDGAME_CHECK_AGAIN #undef ENDGAME_CHECK_AGAIN
/* check which player won and free all unnneded data */ /* check which player won and free all unnneded data */
@ -454,7 +443,8 @@ game_end ()
} }
if (cnt_left == 1) if (cnt_left == 1)
players[bman.lastwinner].points += bman.players_nr_s; players[bman.lastwinner].points += bman.players_nr_s;
else bman.lastwinner = -1; else
bman.lastwinner = -1;
/* check which team was alife */ /* check which team was alife */
if (bman.gametype == GT_team) { if (bman.gametype == GT_team) {
@ -463,7 +453,8 @@ game_end ()
bman.lastwinner = -1; bman.lastwinner = -1;
cnt_left = 0; cnt_left = 0;
for (t_nr = 0; t_nr < MAX_TEAMS; t_nr++) for (i = 0; i < MAX_PLAYERS; i++) { 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 (teams[t_nr].players[i] != NULL)
if (PS_IS_alife (teams[t_nr].players[i]->state)) { if (PS_IS_alife (teams[t_nr].players[i]->state)) {
if (bman.lastwinner != t_nr) { if (bman.lastwinner != t_nr) {
@ -502,9 +493,10 @@ game_end ()
void void
game_start () game_start ()
{ {
int p, i; int p,
i;
if (!bman.dedicated) menu_displaytext ("Loading..", "Please Wait"); menu_displaytext ("Loading..", "Please Wait");
bman.players_nr_s = 0; bman.players_nr_s = 0;
@ -561,15 +553,12 @@ game_start ()
flitems_reset (); flitems_reset ();
init_map_tileset (); 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); gfx_load_players (gfx.block.x, gfx.block.y);
if (!bman.dedicated) {
snd_load (map.tileset); snd_load (map.tileset);
snd_music_start (); snd_music_start ();
}
map.state = MS_normal; map.state = MS_normal;
bman.timeout = bman.init_timeout; bman.timeout = bman.init_timeout;
@ -588,16 +577,30 @@ game_start ()
#define SHOWRESULT_TEAMHEAD 24 #define SHOWRESULT_TEAMHEAD 24
#define SHOWRESULT_TEAMPLAYER 16 #define SHOWRESULT_TEAMPLAYER 16
#define SHOWRESULT_TEAMPLAYERWIDTH 150 #define SHOWRESULT_TEAMPLAYERWIDTH 150
void game_showresultteam (int pos_x, int pos_y, int pos_w, int pos_h) { void
int i, t_nr, p_nr; // counter for teams and players 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 { struct {
_team *team; // pointer to the team _team *team; // pointer to the team
_player *pl[MAX_PLAYERS]; // players in the team (sorted) _player *pl[MAX_PLAYERS]; // players in the team (sorted)
int cnt; int cnt;
} tdata[MAX_TEAMS]; // hold some team informations (sorted) } tdata[MAX_TEAMS]; // hold some team informations (sorted)
int t_count = 0, p_maxcount = 0, p_sumcount = 0; int t_count = 0,
int sx, sy, p_y, p_x , dx, dy, col, x; p_maxcount = 0,
SDL_Rect dest, src; p_sumcount = 0;
int sx,
sy,
p_y,
p_x,
dx,
dy,
col,
x;
SDL_Rect dest,
src;
char text[255]; char text[255];
/* sort all teams */ /* sort all teams */
@ -625,15 +628,20 @@ void game_showresultteam (int pos_x, int pos_y, int pos_w, int pos_h) {
} }
/* sort all players dependsing on the number of wins they have */ /* 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++) { 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 (t_nr < t_count) {
if (tdata[t_nr].team->players[p_nr] != NULL && PS_IS_used (tdata[t_nr].team->players[p_nr]->state)) { 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]; tdata[t_nr].pl[tdata[t_nr].cnt] = tdata[t_nr].team->players[p_nr];
i = tdata[t_nr].cnt; i = tdata[t_nr].cnt;
while (i > 0 && (tdata[t_nr].pl[i-1]->wins < tdata[t_nr].team->players[p_nr]->wins 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 - 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]; tdata[t_nr].pl[i] = tdata[t_nr].pl[i - 1];
i--; i--;
tdata[t_nr].pl[i] = tdata[t_nr].team->players[p_nr]; tdata[t_nr].pl[i] = tdata[t_nr].team->players[p_nr];
@ -645,10 +653,12 @@ void game_showresultteam (int pos_x, int pos_y, int pos_w, int pos_h) {
/* check the max number of players in one team and number of all players */ /* 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 */ 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; 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++) for (p_sumcount = 0, p_nr = 0; p_nr < MAX_PLAYERS; p_nr++)
if (PS_IS_used (players[p_nr].state)) p_sumcount++; if (PS_IS_used (players[p_nr].state))
p_sumcount++;
/* calculate the best view */ /* calculate the best view */
p_x = dx = dy = 0; p_x = dx = dy = 0;
@ -658,16 +668,19 @@ void game_showresultteam (int pos_x, int pos_y, int pos_w, int pos_h) {
for (t_nr = 0; t_nr < t_count; t_nr++) { for (t_nr = 0; t_nr < t_count; t_nr++) {
p_y += ceil ((float) (((float) tdata[t_nr].cnt) / ((float) p_x))); p_y += ceil ((float) (((float) tdata[t_nr].cnt) / ((float) p_x)));
} }
if (p_y == 0) p_y = 1; if (p_y == 0)
p_y = 1;
dy = (pos_h - (SHOWRESULT_TEAMHEAD * t_count)) / p_y; dy = (pos_h - (SHOWRESULT_TEAMHEAD * t_count)) / p_y;
} while (dy < SHOWRESULT_TEAMPLAYER); } while (dy < SHOWRESULT_TEAMPLAYER);
if (dy > 2*SHOWRESULT_TEAMPLAYER) dy = 2*SHOWRESULT_TEAMPLAYER; if (dy > 2 * SHOWRESULT_TEAMPLAYER)
dy = 2 * SHOWRESULT_TEAMPLAYER;
/* draw everything */ /* draw everything */
sy = (pos_h - (SHOWRESULT_TEAMHEAD * t_count + dy * p_y)) / 2; sy = (pos_h - (SHOWRESULT_TEAMHEAD * t_count + dy * p_y)) / 2;
for (t_nr = 0; t_nr < t_count; t_nr++) { 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); 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; 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_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); font_gfxdraw (10 + pos_x + sx, pos_y + sy + 3, text, 0, COLOR_yellow, 2);
@ -677,7 +690,8 @@ void game_showresultteam (int pos_x, int pos_y, int pos_w, int pos_h) {
for (col = 0, p_nr = 0; p_nr < tdata[t_nr].cnt; p_nr++) { for (col = 0, p_nr = 0; p_nr < tdata[t_nr].cnt; p_nr++) {
if (col == 0 || col >= p_x) { if (col == 0 || col >= p_x) {
if (col >= p_x) sy += dy; if (col >= p_x)
sy += dy;
col = 0; col = 0;
x = sx; x = sx;
} }
@ -700,14 +714,17 @@ void game_showresultteam (int pos_x, int pos_y, int pos_w, int pos_h) {
src.y = 0; src.y = 0;
gfx_blit (gfx.ghost_small, &src, gfx.screen, &dest, 1); 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); sprintf (text, "%s(%d/%d)", tdata[t_nr].pl[p_nr]->name, tdata[t_nr].pl[p_nr]->wins,
font_gfxdraw (10+ pos_x + x + GFX_SMALLPLAYERIMGSIZE_X*2, pos_y + sy + 2, text, 0, 0, 2); 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; x += dx;
col++; col++;
} }
sy += dy; sy += dy;
} }
} }
#undef SHOWRESULT_TEAMHEAD #undef SHOWRESULT_TEAMHEAD
#undef SHOWRESULT_TEAMPLAYER #undef SHOWRESULT_TEAMPLAYER
#undef SHOWRESULT_TEAMPLAYERWIDTH #undef SHOWRESULT_TEAMPLAYERWIDTH
@ -716,14 +733,25 @@ void game_showresultteam (int pos_x, int pos_y, int pos_w, int pos_h) {
/* Bomberman/Deathmatch Version Play */ /* Bomberman/Deathmatch Version Play */
#define SHOWRESULT_WIDTH 150 #define SHOWRESULT_WIDTH 150
#define SHOWRESULT_HEIGHT 60 #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]; char text[255];
int i, p, x, y, pl_cnt = 0, int i,
pl_x, pl_y, // player in a row/col p,
dx, dy, // distance x,
sx, sy, px; // start view and position y,
pl_cnt = 0,
SDL_Rect dest, src; 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]; _player *pl[MAX_PLAYERS];
@ -752,7 +780,8 @@ void game_showresultnormal (int pos_x, int pos_y, int pos_w, int pos_h) {
do { do {
pl_x++; pl_x++;
pl_y = ceil ((float) (((float) pl_cnt) / ((float) pl_x))); pl_y = ceil ((float) (((float) pl_cnt) / ((float) pl_x)));
if (pl_y == 0) pl_y++; if (pl_y == 0)
pl_y++;
dy = pos_h / pl_y; dy = pos_h / pl_y;
} while (dy < SHOWRESULT_HEIGHT); } while (dy < SHOWRESULT_HEIGHT);
dx = pos_w / pl_x; dx = pos_w / pl_x;
@ -767,11 +796,14 @@ void game_showresultnormal (int pos_x, int pos_y, int pos_w, int pos_h) {
for (i = 1, p = 0; p < pl_cnt; p++) { for (i = 1, p = 0; p < pl_cnt; p++) {
if (PS_IS_used (pl[p]->state)) { if (PS_IS_used (pl[p]->state)) {
if (PS_IS_alife (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_gfxdrawbold (10 + pos_x + x + GFX_MENUPLAYERIMGSIZE_X + 8, pos_y + y - 10,
font_gfxdraw (10+ pos_x + x + GFX_MENUPLAYERIMGSIZE_X + 8,pos_y + y - 10, pl[p]->name, 0, COLOR_yellow, 1); 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 else
font_gfxdraw (10+ pos_x + x + GFX_MENUPLAYERIMGSIZE_X,pos_y + y - 10, pl[p]->name, 0, COLOR_gray, 1); 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); 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); font_gfxdraw (10 + pos_x + x + GFX_MENUPLAYERIMGSIZE_X, pos_y + y + 6, text, 0, 0, 1);
@ -805,15 +837,21 @@ void game_showresultnormal (int pos_x, int pos_y, int pos_w, int pos_h) {
} }
} }
} }
#undef SHOWRESULT_HEIGHT #undef SHOWRESULT_HEIGHT
#undef SHOWRESULT_WIDTH #undef SHOWRESULT_WIDTH
void game_showresult () { void
game_showresult ()
{
char text[255]; char text[255];
SDL_Event event; SDL_Event event;
Uint8 *keys; Uint8 *keys;
int done = 0, keypressed = 0, x, y; int done = 0,
keypressed = 0,
x,
y;
gfx_blitdraw (); gfx_blitdraw ();
@ -864,7 +902,8 @@ void game_showresult () {
bman.state = GS_startup; 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; done = 1;
keypressed = 1; keypressed = 1;
} }
@ -892,7 +931,9 @@ void game_showresult () {
/* /*
* create the in game menu * create the in game menu
*/ */
void game_menu_create () { void
game_menu_create ()
{
if (menu != NULL) if (menu != NULL)
return; return;
@ -917,7 +958,9 @@ void game_menu_create () {
* *
* Pressing ESC will bring you back to the game. * Pressing ESC will bring you back to the game.
*/ */
void game_menu_loop (SDL_Event *event, int eventstate) { void
game_menu_loop (SDL_Event * event, int eventstate)
{
int done; int done;
if (menu == NULL) if (menu == NULL)
@ -937,7 +980,8 @@ void game_menu_loop (SDL_Event *event, int eventstate) {
else if (menu->focus->id == 3) { /* End Game */ else if (menu->focus->id == 3) { /* End Game */
/* send network update */ /* send network update */
if (GT_MP) net_game_send_delplayer (bman.p_nr); if (GT_MP)
net_game_send_delplayer (bman.p_nr);
bman.state = GS_quit; bman.state = GS_quit;
} }

@ -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 */ /* gfx.c */
#include "bomberclone.h" #include "bomberclone.h"
@ -66,10 +66,7 @@ gfx_load_players (int sx, int sy)
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;
if (!bman.dedicated) { tmpimage1 = scale_image (tmpimage, gfx.players[i].ani.w * 4, gfx.players[i].ani.frames * gfx.players[i].ani.h);
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); 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.players[i].ani.image = SDL_DisplayFormat (tmpimage1); gfx.players[i].ani.image = SDL_DisplayFormat (tmpimage1);
@ -78,10 +75,6 @@ gfx_load_players (int sx, int sy)
/* calculate the numbers of images for the animation */ /* calculate the numbers of images for the animation */
gfx.players[i].offset.x = (sx - gfx.players[i].ani.w) / 2; gfx.players[i].offset.x = (sx - gfx.players[i].ani.w) / 2;
gfx.players[i].offset.y = -sy; gfx.players[i].offset.y = -sy;
}
else
gfx.players[i].ani.image = NULL;
SDL_FreeSurface (tmpimage); SDL_FreeSurface (tmpimage);
} }
} }
@ -96,10 +89,7 @@ gfx_load_players (int sx, int sy)
} }
gfx.dead.frames = tmpimage->h / (2* GFX_IMGSIZE); 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));
tmpimage1 =
scale_image (tmpimage, ((2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE)),
gfx.dead.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.dead.image = SDL_DisplayFormat (tmpimage1); gfx.dead.image = SDL_DisplayFormat (tmpimage1);
@ -114,9 +104,7 @@ gfx_load_players (int sx, int sy)
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), gfx.ill.frames * (2 * sy));
scale_image (tmpimage, (2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE),
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);
@ -131,12 +119,7 @@ gfx_load_players (int sx, int sy)
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), gfx.respawn.frames * (2 * sy));
scale_image (tmpimage, (2 * sx * tmpimage->w) / (2 * GFX_IMGSIZE),
gfx.respawn.frames * (2 * sy));
SDL_FreeSurface (tmpimage);
}
else
SDL_FreeSurface (tmpimage); SDL_FreeSurface (tmpimage);
}; };
@ -170,22 +153,15 @@ gfx_init ()
{ {
int i; int i;
if (gfx.fullscreen && !bman.dedicated) if (gfx.fullscreen)
gfx.screen = gfx.screen = SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp, SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL | SDL_FULLSCREEN);
SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp,
SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL | SDL_FULLSCREEN);
else if (!bman.dedicated) else
gfx.screen = gfx.screen = SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp, SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL);
SDL_SetVideoMode (gfx.res.x, gfx.res.y, gfx.bpp, if (gfx.screen == NULL) {
SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL);
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 */
@ -532,7 +508,6 @@ 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;

@ -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 */ /* GFX Game Engine */
#include "bomberclone.h" #include "bomberclone.h"
@ -103,7 +103,7 @@ gfx_blitdraw ()
{ {
int i; int i;
if (blitdb_nr < 0 || bman.dedicated) { if (blitdb_nr < 0) {
blitdb_nr = 0; blitdb_nr = 0;
return; return;
} }

@ -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 "basic.h"
#include "bomberclone.h" #include "bomberclone.h"
@ -42,7 +42,7 @@ main (int argc, char **argv)
config_init (argc, 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 = 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.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 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,30 +33,24 @@ extern int blitdb_nr;
static void mw_init () static void mw_init ()
{ {
team_update (); team_update ();
if (!bman.dedicated) {
gfx_blitdraw (); gfx_blitdraw ();
draw_logo (); draw_logo ();
gfx_blitdraw (); gfx_blitdraw ();
}
bman.updatestatusbar = 1; bman.updatestatusbar = 1;
d_playerdetail ("mw_init:\n"); d_playerdetail ("mw_init:\n");
if (!bman.dedicated) {
SDL_Flip (gfx.screen); SDL_Flip (gfx.screen);
chat_show (10, gfx.res.y / 2, gfx.res.x - 20, gfx.res.y / 2 - 10); chat_show (10, gfx.res.y / 2, gfx.res.x - 20, gfx.res.y / 2 - 10);
chat_setactive (1, 1); chat_setactive (1, 1);
}
}; };
/* free all graphics */ /* free all graphics */
static void mw_shutdown () { static void mw_shutdown () {
if (!bman.dedicated) {
chat_show (-1, -1, -1, -1); chat_show (-1, -1, -1, -1);
gfx_blitdraw (); gfx_blitdraw ();
draw_logo (); draw_logo ();
SDL_Flip (gfx.screen); SDL_Flip (gfx.screen);
}
}; };
@ -241,7 +235,6 @@ void wait_for_players () {
/* /*
* the drawing stuff * the drawing stuff
*/ */
if (!bman.dedicated) {
if (mw_check_screenredraw()) { if (mw_check_screenredraw()) {
d_printf ("Draw Status\n"); d_printf ("Draw Status\n");
gfx_blitdraw (); gfx_blitdraw ();
@ -259,32 +252,8 @@ void wait_for_players () {
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.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. network routines.
*/ */
@ -477,14 +477,12 @@ net_transmit_gamedata ()
Uint8 *keys; Uint8 *keys;
Uint32 downtimestamp = 0; Uint32 downtimestamp = 0;
if (!bman.dedicated) {
draw_logo (); 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
@ -505,10 +503,8 @@ net_transmit_gamedata ()
else else
net_istep = 3; net_istep = 3;
if (!bman.dedicated) {
draw_netupdatestate (1); draw_netupdatestate (1);
SDL_Flip (gfx.screen); 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))) {
@ -617,7 +613,6 @@ net_transmit_gamedata ()
} }
/* do the grafik work */ /* do the grafik work */
if (!bman.dedicated) {
draw_netupdatestate (0); draw_netupdatestate (0);
if (SDL_PollEvent (&event) != 0) if (SDL_PollEvent (&event) != 0)
@ -646,12 +641,10 @@ net_transmit_gamedata ()
/* 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 */
if (GT_MP_PTPS && bman.state == GS_update && net_istep == 0 if (GT_MP_PTPS && bman.state == GS_update && net_istep == 0 && players[bman.p_nr].gfx_nr == -1) {
&& players[bman.p_nr].gfx_nr == -1) {
done = 1; done = 1;
bman.state = GS_running; bman.state = GS_running;
} }
}
}; };

@ -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 */ * player.c - everything what have to do with the player */
#include <SDL.h> #include <SDL.h>
@ -18,9 +18,6 @@ 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,
@ -582,8 +579,6 @@ 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: 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" #include "bomberclone.h"
@ -28,6 +28,8 @@ static void playermenu_selgfx_drawplayer (int selgfx, _menu *menu) {
static int changed = 0; static int changed = 0;
SDL_Rect rect, srcrect; SDL_Rect rect, srcrect;
int i; int i;
int i_start;
int i_end;
/* /*
* delete old state, to force an update of all playergfx * 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; rect.h = 4 * GFX_IMGSIZE;
menu_draw_background (menu, &rect); menu_draw_background (menu, &rect);
for (i = 0; i < gfx.player_gfx_count; i++) { /* calculate the first element on the screen */
srcrect.h = rect.h = gfx.players[i].menu_image->h; if (gfx.player_gfx_count < 12 || selgfx < 4) i_start = 0;
srcrect.w = rect.w = gfx.players[i].menu_image->w; 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.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; rect.y = (GFX_MENUPLAYERIMGSIZE_X * 2) * (i / 4) + PLAYERMENU_GFXSEL_Y;
srcrect.x = 0; srcrect.x = 0;
srcrect.y = 0; srcrect.y = 0;
rect.x += menu->oldscreenpos.x + menuimages[0]->w; rect.x += menu->oldscreenpos.x + menuimages[0]->w;
rect.y += menu->oldscreenpos.y + menuimages[0]->h; 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 */ /* draw the select border */
if (i == selgfx) { if ((i + i_start) == selgfx) {
srcrect.x = 0; srcrect.x = 0;
srcrect.y = 0; srcrect.y = 0;
srcrect.h = rect.h = GFX_IMGSIZE; srcrect.h = rect.h = GFX_IMGSIZE;
srcrect.w = rect.w = 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.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.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.x += menu->oldscreenpos.x + menuimages[0]->w;
rect.y += menu->oldscreenpos.y + menuimages[0]->h; rect.y += menu->oldscreenpos.y + menuimages[0]->h;
gfx_blit (gfx.menuselect.image, &srcrect, gfx.screen, &rect, 10001); gfx_blit (gfx.menuselect.image, &srcrect, gfx.screen, &rect, 10001);
@ -98,6 +110,9 @@ int playermenu_selgfx (int pl_nr) {
playermenu_selgfx_drawplayer (-1, NULL); playermenu_selgfx_drawplayer (-1, NULL);
player_set_gfx (&players[pl_nr], -1); player_set_gfx (&players[pl_nr], -1);
if (gfx.player_gfx_count > 8)
menu = menu_new ("Player Selection", 400, 330);
else
menu = menu_new ("Player Selection", 400, 270); 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_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);

@ -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 */ /* sound */
#include "sound.h" #include "sound.h"
@ -80,11 +80,6 @@ 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