From 21ca92c4930ce8d9c9ea0591894e1ec40af920f0 Mon Sep 17 00:00:00 2001 From: stpohle Date: Sun, 26 Dec 2004 04:19:20 +0000 Subject: [PATCH] Major Network Bugs fixed. --- include/basic.h | 14 ++++- include/font.h | 2 + include/network.h | 5 +- include/packets.h | 16 +++++- src/configuration.c | 22 +++++++- src/font.c | 6 +- src/game.c | 4 +- src/help.c | 15 +---- src/multiwait.c | 53 +++++++++++++++++- src/network.c | 35 +++++++++--- src/packets.c | 134 ++++++++++++++++++++++++++++++++++---------- src/player.c | 7 +-- src/playermenu.c | 17 ++++-- src/single.c | 12 +--- 14 files changed, 258 insertions(+), 84 deletions(-) diff --git a/include/basic.h b/include/basic.h index 7dfca28..5740915 100644 --- a/include/basic.h +++ b/include/basic.h @@ -1,4 +1,4 @@ -/* $Id: basic.h,v 1.28 2004/10/18 18:27:02 stpohle Exp $ */ +/* $Id: basic.h,v 1.29 2004/12/26 04:19:21 stpohle Exp $ */ /* basic types which we need everywhere */ #ifndef _BC_BASIC_H_ @@ -173,6 +173,18 @@ enum _mstatus { MS_max }; +enum _help_page { + HP_howto0 = 0, + HP_powerup0, + HP_powerup1, + HP_powerup2, + HP_keyboard0, + HP_credit0, + HP_credit1, + HP_max +}; + + struct { Sint16 x; Sint16 y; diff --git a/include/font.h b/include/font.h index 1890064..f812514 100644 --- a/include/font.h +++ b/include/font.h @@ -17,6 +17,7 @@ enum _color { COLOR_max }; + struct __font { SDL_Surface *image[COLOR_max]; _point size; @@ -30,6 +31,7 @@ struct _key_codes { extern _point font_lastsize; extern _font font[3]; +extern char *color_map[COLOR_max]; extern void font_draw (int x, int y, char *text, int size, int color); extern void font_drawbold (int x, int y, char *text, int size, int color, int bold); diff --git a/include/network.h b/include/network.h index d441351..2823f67 100644 --- a/include/network.h +++ b/include/network.h @@ -1,4 +1,4 @@ -/* $Id: network.h,v 1.22 2004/12/13 21:29:30 stpohle Exp $ +/* $Id: network.h,v 1.23 2004/12/26 04:19:21 stpohle Exp $ * network.h file... for everything what have to do with the network stuff */ @@ -23,7 +23,7 @@ #define GT_MP_PTPM (bman.p_nr == bman.p_servnr && bman.sock >= 0) #define GT_MP_PTPS (bman.p_nr != bman.p_servnr && bman.sock >= 0) -#define GT_MP (bman.sock >= 0) +#define GT_MP (bman.sock > 0) #define GT_SP (bman.sock <= 0) #define GS_WAITRUNNING (bman.state == GS_wait || bman.state == GS_ready || bman.state == GS_running) @@ -117,6 +117,7 @@ extern void net_game_send_delplayer (int pl_nr); extern void draw_netupdatestate (char st); extern void net_send_servermode (); extern void net_send_players (); +extern void net_send_teamdata (int team_nr); extern int net_check_timeout (int pl_nr); extern void net_dyn_pkgoption (); extern void net_send_chat (char *text, signed char notigamesrv); diff --git a/include/packets.h b/include/packets.h index cee2613..7f1261f 100644 --- a/include/packets.h +++ b/include/packets.h @@ -1,4 +1,4 @@ -/* $Id: packets.h,v 1.30 2004/12/24 03:13:49 stpohle Exp $ +/* $Id: packets.h,v 1.31 2004/12/26 04:19:21 stpohle Exp $ * network packets.. */ #ifndef _PACKETS_H_ @@ -23,6 +23,7 @@ enum _network_data { PKG_pingack, PKG_getfield, PKG_getplayerdata, + PKG_teamdata, PKG_fieldline, PKG_pkgack, PKG_mapinfo, @@ -95,6 +96,15 @@ struct pkg_contest { }; +struct pkg_teamdata { + struct pkgheader h; + signed char team_nr; + signed char col; + signed char wins; + char name[LEN_PLAYERNAME]; +}; + + struct pkgdropitemelemt { signed char x; signed char y; @@ -372,7 +382,8 @@ extern void do_tunneldata (struct pkg_tunneldata *tun_pkg, _net_addr *addr); extern void do_dropitems (struct pkg_dropitem *di_pkg, _net_addr *addr); extern void do_respawn (struct pkg_respawn *r_pkg, _net_addr *addr); extern void do_contest (struct pkg_contest *ct_pkg, _net_addr *addr); - +extern void do_teamdata (struct pkg_teamdata *td, _net_addr * addr); + extern void send_pkg (struct pkg *packet, _net_addr *addr); extern void send_playerid (_net_addr *addr, char *name, char *pladdr, char *plport, int p_nr, int gfx_nr, int team_nr, signed char netflags); extern void send_servermode (_net_addr *addr, int pl_nr); @@ -398,6 +409,7 @@ extern void send_tunneldata (_net_addr *addr, int tunnelnr, int x, int y); extern void send_dropitems (_net_addr *addr, int pl_nr, _flyingitem **fitems, int cnt); extern void send_respawn (_net_addr * addr, int plnr); extern void send_contest (_net_addr * addr, int from, int to, int ackreq); +extern void send_teamdata (_net_addr * addr, int team_nr); extern void fwd_pkg (struct pkg *packet, _net_addr *addr); diff --git a/src/configuration.c b/src/configuration.c index 7017553..9077b2f 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -1,4 +1,4 @@ -/* $Id: configuration.c,v 1.68 2004/11/30 14:30:36 stpohle Exp $ +/* $Id: configuration.c,v 1.69 2004/12/26 04:19:20 stpohle Exp $ * configuration */ #include @@ -369,6 +369,18 @@ config_read () 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. @@ -421,7 +433,9 @@ int config_write () { FILE *config; + int i; char filename[512]; + #ifdef _WIN32 sprintf (filename, "%sbomberclone.cfg", s_gethomedir ()); #else @@ -464,7 +478,11 @@ config_write () 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); - fprintf (config, "dropitemsondeath=%d\n", bman.dropitemsondeath); + + 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 diff --git a/src/font.c b/src/font.c index aefabd7..1ee6cee 100644 --- a/src/font.c +++ b/src/font.c @@ -1,14 +1,18 @@ -/* $Id: font.c,v 1.13 2004/02/05 22:59:02 stpohle Exp $ */ +/* $Id: font.c,v 1.14 2004/12/26 04:19:20 stpohle Exp $ */ // Using Fonts in SDL #include #include #include "bomberclone.h" +#include "font.h" _point font_lastsize; // so we can get the last size of the drawn font _font font[3]; +char *color_map[COLOR_max] = { "white", "red", "green", "blue", + "yellow", "brown", "gray", "black"}; + void font_draw (int x, int y, char *text, int size, int color) { diff --git a/src/game.c b/src/game.c index 6ba0d68..36276e2 100644 --- a/src/game.c +++ b/src/game.c @@ -1,4 +1,4 @@ -/* $Id: game.c,v 1.105 2004/12/13 21:29:30 stpohle Exp $ +/* $Id: game.c,v 1.106 2004/12/26 04:19:20 stpohle Exp $ game.c - procedures for the game. */ #include @@ -877,7 +877,7 @@ void game_menu_loop (SDL_Event *event, int eventstate) { else if (menu->focus->id == 3) { /* End Game */ /* send network update */ - net_game_send_delplayer (bman.p_nr); + if (GT_MP) net_game_send_delplayer (bman.p_nr); bman.state = GS_quit; } diff --git a/src/help.c b/src/help.c index 08ae184..80fc74a 100644 --- a/src/help.c +++ b/src/help.c @@ -1,4 +1,4 @@ -/* $Id: help.c,v 1.13 2004/09/26 02:28:06 stpohle Exp $ +/* $Id: help.c,v 1.14 2004/12/26 04:19:20 stpohle Exp $ * Display complex help text and information screen about the game */ @@ -6,18 +6,6 @@ #include "menu.h" #include "player.h" -enum _help_page { - HP_howto0 = 0, - HP_powerup0, - HP_powerup1, - HP_powerup2, - HP_keyboard0, - HP_credit0, - HP_credit1, - HP_max -}; - - /* * show the manual pages */ @@ -188,7 +176,6 @@ void help (int showpage) { "F3 - Map and Game Settings\n" "F4 - Start the Game if at last 2 Players\n" " are selected. (only Server)\n" - "F5 - Chatmode (Exit whit ESC)\n" "ESC - Exit Game\n"); } else if (page == HP_credit0) { diff --git a/src/multiwait.c b/src/multiwait.c index e48e6c6..9a0954e 100644 --- a/src/multiwait.c +++ b/src/multiwait.c @@ -1,4 +1,4 @@ -/* $Id: multiwait.c,v 1.53 2004/12/13 21:29:31 stpohle Exp $ +/* $Id: multiwait.c,v 1.54 2004/12/26 04:19:20 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 */ @@ -17,6 +17,7 @@ static void mw_init (); static void mw_shutdown (); static void mw_keys_loop (); +static void mw_draw_top (); static void mw_draw_all_player (); static void mw_draw_all_teams (); @@ -120,6 +121,14 @@ static void mw_keys_loop () { keyb_loop (NULL); // to reload the current keys } + if (keyb_gamekeys.state[BCK_help] && !keyb_gamekeys.old[BCK_help]) { + /* playermenu */ + help (HP_keyboard0); + bman.updatestatusbar = 1; + keyb_loop (NULL); // to reload the current keys + } + + if (keyb_gamekeys.state[BCK_playermenu] && !keyb_gamekeys.old[BCK_playermenu]) { /* playermenu */ playermenu (); @@ -145,11 +154,48 @@ static int mw_check_screenredraw () { } +/* + * draw the top of the screen, the keys you can press and so + */ +static void mw_draw_top () { + int step = gfx.res.x / 4; + int x = 0; + + font_gfxdraw (x,0,"F1", 0, COLOR_brown, 0x1000); + font_gfxdraw (x+1,1,"F1", 0, COLOR_yellow, 0x1001); + font_gfxdraw (x+32,0,"Help", 0, COLOR_brown, 0x1000); + + x += step; + + font_gfxdraw (x,0,"F2", 0, COLOR_brown, 0x1000); + font_gfxdraw (x+1,0,"F2", 0, COLOR_yellow, 0x1001); + font_gfxdraw (x+32,0,"Playermenu", 0, COLOR_brown, 0x1000); + + x += step; + if (GT_MP_PTPM) { + font_gfxdraw (x,0,"F3", 0, COLOR_brown, 0x1000); + font_gfxdraw (x+1,0,"F3", 0, COLOR_yellow, 0x1001); + font_gfxdraw (x+32,0,"Mapmenu", 0, COLOR_brown, 0x1000); + + x += step; + + font_gfxdraw (x,0,"F4", 0, COLOR_brown, 0x1000); + font_gfxdraw (x+1,0,"F4", 0, COLOR_yellow, 0x1001); + font_gfxdraw (x+32,0,"Start", 0, COLOR_brown, 0x1000); + } + else { + x += step/2; + font_gfxdraw (x+32,0,"Wait for the Server", 0, COLOR_brown, 0x1000); + } +}; + + /* * draw all player informations */ static void mw_draw_all_player () { - game_showresultnormal (20, 30, gfx.res.x-40, (gfx.res.y / 2) - 60); + mw_draw_top (); + game_showresultnormal (20, 50, gfx.res.x-40, (gfx.res.y / 2) - 60); chat_draw (); }; @@ -158,7 +204,8 @@ static void mw_draw_all_player () { * draw all team informations */ static void mw_draw_all_teams () { - game_showresultteam (20, 30, gfx.res.x-40, (gfx.res.y / 2) - 60); + mw_draw_top (); + game_showresultteam (20, 50, gfx.res.x-40, (gfx.res.y / 2) - 60); chat_draw (); }; diff --git a/src/network.c b/src/network.c index 156f81c..f30e94f 100644 --- a/src/network.c +++ b/src/network.c @@ -1,4 +1,4 @@ -/* $Id: network.c,v 1.71 2004/12/13 21:29:31 stpohle Exp $ */ +/* $Id: network.c,v 1.72 2004/12/26 04:19:20 stpohle Exp $ */ /* network routines. */ @@ -638,7 +638,7 @@ net_transmit_gamedata () /* * send informations about a player too all connected players - * last_change: the player will not be send if (send_to_p_nr == p_nr) + * last_change: the player will not be send if (send_to_p_nr == bman.p_nr) */ void net_game_send_player (int p_nr) @@ -736,19 +736,24 @@ net_game_send_delplayer (int pl_nr) { } for (i = 0; i < MAX_PLAYERS; i++) - if (NET_CANSEND(i)) + if (NET_CANSEND(i) && i != bman.p_nr) send_quit (&players[i].net.addr, pl_nr, new_server); bman.updatestatusbar=1; } - /* we have to send that one of our own players quit */ + /* we have to send that one if our own players quit */ else if (pl_nr == bman.p_nr || pl_nr == bman.p2_nr) { send_quit (&players[bman.p_servnr].net.addr, pl_nr, -1); } - if (GT_MP_PTPM && bman.notifygamemaster) - send_ogc_update (); - inpkg_delplayer (pl_nr); + + if (GT_MP_PTPM) { + if (bman.notifygamemaster) + send_ogc_update (); + + if (new_server >= 0 && new_server < MAX_PLAYERS) + bman.p_servnr = new_server; + } }; @@ -798,6 +803,22 @@ net_send_players () +/* sends to everyone the teamdata */ +void +net_send_teamdata (int team_nr) +{ + int j; + + if (GT_MP_PTPS) + return; + + for (j = 0; j < MAX_PLAYERS; j++) + if (NET_CANSEND (j)) + send_teamdata (&players[j].net.addr, team_nr); +}; + + + void net_send_chat (char *text, signed char notigamesrv) { diff --git a/src/packets.c b/src/packets.c index c6c6ed7..ad6d951 100644 --- a/src/packets.c +++ b/src/packets.c @@ -227,6 +227,7 @@ send_joingame (_net_addr * addr, char *name, int secondplayer) strncpy (p_jg.name, name, LEN_PLAYERNAME); strncpy (p_jg.password, bman.password, LEN_PASSWORD); + bman.firewall = 1; send_pkg ((struct pkg *) &p_jg, addr); }; @@ -261,19 +262,21 @@ void do_contest (struct pkg_contest *ct_pkg, _net_addr *addr) { /* if a client get this packet we send a packet * to the server that we have got this packet. */ - else + else { send_contest (&players[bman.p_servnr].net.addr, ct_pkg->from, bman.p_nr, 1); + bman.firewall = 0; + } } void send_contest (_net_addr * addr, int from, int to, int ackreq) { struct pkg_contest ct_pkg; - d_printf ("send_contest addr->id%d, from:%d, to:%d\n", addr->pl_nr, from, to); + d_printf ("send_contest addr->id:%d, from:%d, to:%d\n", addr->pl_nr, from, to); ct_pkg.h.typ = PKG_contest; - if (ackreq) ct_pkg.h.flags = PKGF_ackreq; - else ct_pkg.h.flags = 0; + if (ackreq) ct_pkg.h.flags = PKGF_ackreq; + else ct_pkg.h.flags = 0; ct_pkg.h.len = HTON16 (sizeof (struct pkg_contest)); ct_pkg.from = from; @@ -304,8 +307,9 @@ do_playerid (struct pkg_playerid *p_id, _net_addr * addr) /* * check if we have to send the whole playerlist to a client */ - if (GT_MP_PTPM && p_id->pl_nr == -1) { + if (GT_MP_PTPM && p_id->pl_nr == -1 && addr->pl_nr >= 0 && addr->pl_nr < MAX_PLAYERS) { /* Send all connected players the new PlayerID, except to the new player */ + pl = &players[addr->pl_nr]; for (i = 0; i < MAX_PLAYERS; i++) if (NET_CANSEND(i) && addr->pl_nr != i) send_playerid (&players[i].net.addr, pl->name, pl->net.addr.host, @@ -438,6 +442,66 @@ send_playerid (_net_addr * addr, char *name, char *pladdr, char *plport, }; + +/*** + *** Packettype: teamdata + *** Server Side: + *** Send all teamdata to the client. + *** Client Side: + *** Get all Teamdata + ***/ +void do_teamdata (struct pkg_teamdata *td, _net_addr * addr) { + int i; + + if (addr->pl_nr == -1) + return; + + d_printf ("do_teamdata (addr->pl_nr: %d): team:%d col:%d wins:%d\n", addr->pl_nr, td->team_nr, td->col, td->wins); + + if (addr->pl_nr == bman.p_servnr) { /* packet comes from the server */ + if (td->team_nr >= 0 && td->team_nr < MAX_TEAMS) { + strncpy (teams[td->team_nr].name, td->name, LEN_PLAYERNAME); + teams[td->team_nr].col = td->col; + teams[td->team_nr].wins = td->wins; + bman.updatestatusbar = 1; + } + } + else { + if (td->team_nr < 0 || td->team_nr >= MAX_TEAMS) { + for (i = 0; i < MAX_TEAMS; i++) + send_teamdata (addr, i); + } + else { + send_teamdata (addr, td->team_nr); + } + } +} + + +void send_teamdata (_net_addr * addr, int team_nr) { + struct pkg_teamdata td; + + d_printf ("send_teamdata (%s:%s) team:%d\n", addr->host, addr->port, team_nr); + + td.h.typ = PKG_teamdata; + td.h.flags = PKGF_ackreq; + td.h.len = HTON16 (sizeof (struct pkg_teamdata)); + + td.team_nr = team_nr; + if (team_nr >= 0 && team_nr < MAX_PLAYERS) { + strncpy (td.name, teams[team_nr].name, LEN_PLAYERNAME); + td.wins = teams[team_nr].wins; + td.col = teams[team_nr].col; + } + else { + td.name[0] = 0; + td.wins = 0; + td.col = 0; + } + send_pkg ((struct pkg *) &td, addr); +} + + /*** *** Packettype: servermode ***/ @@ -469,8 +533,10 @@ do_servermode (struct pkg_servermode *s_mod, _net_addr * addr) players[bman.p_nr].state &= (0xFF - PSF_net); strncpy (players[s_mod->p_nr].name, bman.playername, LEN_PLAYERNAME); - /* send playerid with p_nr -1 so we get the whole playerlist */ + /* send playerid with p_nr -1 so we get the whole playerlist + * do the same with the teamdata */ send_playerid (addr, NULL, NULL, NULL, -1, -1, -1, 0); + send_teamdata (addr, -1); } else if (s_mod->p_nr >= 0 && s_mod->p_nr < MAX_PLAYERS && bman.p2_nr == -1 && s_mod->lplayer2 == 1) { bman.p2_nr = s_mod->p_nr; @@ -481,7 +547,7 @@ do_servermode (struct pkg_servermode *s_mod, _net_addr * addr) } /* do the normal update */ - if (GT_MP_PTPS) { + if (GT_MP_PTPS && addr->pl_nr == bman.p_servnr) { bman.state = s_mod->state; bman.gametype = s_mod->gametype; bman.dropitemsondeath = s_mod->dropitemsondeath; @@ -505,6 +571,29 @@ send_servermode (_net_addr * addr, int pl_nr) { struct pkg_servermode s_mod; + switch (bman.state) { + case (GS_startup): + d_printf ("Send ServerMode : startup\n"); + break; + case (GS_ready): + d_printf ("Send ServerMode : ready\n"); + break; + case (GS_running): + d_printf ("Send ServerMode : running\n"); + break; + case (GS_quit): + d_printf ("Send ServerMode : quit\n"); + break; + case (GS_wait): + d_printf ("Send ServerMode : wait\n"); + break; + case (GS_update): + d_printf ("Send ServerMode : update\n"); + break; + default: + d_printf ("Send ServerMode : mode %d\n", s_mod.state); + } + s_mod.h.typ = PKG_servermode; s_mod.h.len = HTON16 (sizeof (struct pkg_servermode)); s_mod.h.flags = PKGF_ackreq; @@ -527,26 +616,6 @@ send_servermode (_net_addr * addr, int pl_nr) s_mod.fieldsize_x = map.size.x; s_mod.fieldsize_y = map.size.y; strncpy (s_mod.tileset, map.tileset, LEN_TILESETNAME); - switch (s_mod.state) { - case (GS_startup): - d_printf ("Send ServerMode : startup\n"); - break; - case (GS_ready): - d_printf ("Send ServerMode : ready\n"); - break; - case (GS_running): - d_printf ("Send ServerMode : running\n"); - break; - case (GS_quit): - d_printf ("Send ServerMode : quit\n"); - break; - case (GS_wait): - d_printf ("Send ServerMode : wait\n"); - break; - case (GS_update): - d_printf ("Send ServerMode : wait\n"); - break; - } send_pkg ((struct pkg *) &s_mod, addr); }; @@ -1039,11 +1108,14 @@ send_quit (_net_addr * addr, int pl_nr, int new_server) void do_quit (struct pkg_quit *q_dat, _net_addr * addr) { - d_printf ("do_quit (%s:%s) pl_nr = %d\n", addr->host, addr->port, q_dat->pl_nr); + d_printf ("do_quit (%s:%s) pl_nr=%d new_server=%d\n", addr->host, addr->port, q_dat->pl_nr, q_dat->new_server); if (addr->pl_nr == -1) return; + bman.updatestatusbar=1; + player_delete (q_dat->pl_nr); + /* the player who send this quit */ if (q_dat->pl_nr == bman.p_servnr && q_dat->new_server != bman.p_servnr) { d_printf ("do_quit: new server is set to: %d\n", q_dat->new_server); @@ -1063,9 +1135,6 @@ do_quit (struct pkg_quit *q_dat, _net_addr * addr) else if (q_dat->pl_nr == bman.p_servnr && q_dat->new_server == bman.p_servnr) menu_displaymessage ("Server Quit", "The game closed because you are the only one who is left." " Or the server could not find any other possible new server."); - - bman.updatestatusbar=1; - player_delete (q_dat->pl_nr); }; @@ -1786,6 +1855,9 @@ do_pkg (struct pkg *packet, _net_addr * addr) case (PKG_updateinfo): do_updateinfo ((struct pkg_updateinfo *) packet, addr); break; + case (PKG_teamdata): + do_teamdata ((struct pkg_teamdata *) packet, addr); + break; default: send_error (addr, "BomberClone: unknown data packet"); break; diff --git a/src/player.c b/src/player.c index 00bfbd6..92588e9 100644 --- a/src/player.c +++ b/src/player.c @@ -1,4 +1,4 @@ -/* $Id: player.c,v 1.96 2004/12/13 21:29:31 stpohle Exp $ +/* $Id: player.c,v 1.97 2004/12/26 04:19:20 stpohle Exp $ * player.c - everything what have to do with the player */ #include @@ -993,9 +993,6 @@ player_delete (int pl_nr) { net_game_send_delplayer (pl_nr); } - if (GT_MP_PTPS && pl_nr == bman.p_servnr) /* server quit */ - bman.state = GS_startup; - if (GT_MP_PTPM && bman.notifygamemaster) send_ogc_update (); @@ -1095,7 +1092,7 @@ void team_choose (_player *pl) { if (pl->team_nr >= 0 && pl->team_nr < MAX_TEAMS) return; - printf ("team_choose need to fix\n"); + d_printf ("team_choose need to rewrite this part\n"); if (PS_IS_aiplayer (pl->state)) pl->team_nr = 1; else pl->team_nr = 0; diff --git a/src/playermenu.c b/src/playermenu.c index e412475..362f466 100644 --- a/src/playermenu.c +++ b/src/playermenu.c @@ -1,4 +1,4 @@ -/* $Id: playermenu.c,v 1.15 2004/12/13 21:29:31 stpohle Exp $ +/* $Id: playermenu.c,v 1.16 2004/12/26 04:19:20 stpohle Exp $ */ #include "bomberclone.h" @@ -413,18 +413,18 @@ void teammenu () { _charlist *collistsel; } tdata[MAX_TEAMS]; - menu = menu_new ("Teamsettings", 360, 100 + (MAX_TEAMS * 30)); + menu = menu_new ("Teamsettings", 420, 100 + (MAX_TEAMS * 30)); y = 60; for (i = 0; i < MAX_TEAMS; i++) { for (col = 0; col < COLOR_max; col++) - sprintf (tdata[i].collist[col].text, "%d", col); + strncpy (tdata[i].collist[col].text, color_map[col], LEN_CHARENTRY); charlist_fillarraypointer (tdata[i].collist, COLOR_max); - tdata[i].collistsel = tdata[i].collist + i; + tdata[i].collistsel = &tdata[i].collist[teams[i].col]; menu_create_entry (menu, "Name :", 25, y, 200, teams[i].name, LEN_PLAYERNAME, MENU_entrytext, 2*i + 1); menu_create_label (menu, "Color:", 250, y, 0, COLOR_yellow); - menu_create_list (menu, "Liste", 320, y, 30, 20, tdata[i].collist, &tdata[i].collistsel, 2*i + 2); + menu_create_list (menu, "Liste", 320, y, 90, 20, tdata[i].collist, &tdata[i].collistsel, 2*i + 2); y += 30; } @@ -432,6 +432,13 @@ void teammenu () { menu_create_button (menu, "Close", -1, y + 10, 150, 2*i+1); menu_loop (menu); + + for (i = 0; i < MAX_TEAMS; i++) { + teams[i].col = tdata[i].collistsel - &tdata[i].collist[0]; + if (GT_MP_PTPM) + net_send_teamdata (i); + } + menu_delete (menu); return; diff --git a/src/single.c b/src/single.c index 9e682e4..0195890 100644 --- a/src/single.c +++ b/src/single.c @@ -1,4 +1,4 @@ -/* $Id: single.c,v 1.81 2004/12/13 21:29:31 stpohle Exp $ */ +/* $Id: single.c,v 1.82 2004/12/26 04:19:20 stpohle Exp $ */ /* single player */ #include "basic.h" @@ -697,7 +697,7 @@ void single_menu () { int i, - p, + p, eventstate = 0, done = 0, second_player = 0; @@ -708,11 +708,7 @@ single_menu () SDL_Event event; /* fill in the nrplayerlist */ - if (debug) - p = 0; - else - p = 1; - for (i = 0; p < MAX_PLAYERS + 1; i++) { + for (p = 0, i = 0; p < MAX_PLAYERS + 1; i++) { sprintf (nrplayerlist[i].text, "%d", p); if (p < MAX_PLAYERS - 1) nrplayerlist[i].next = &nrplayerlist[i + 1]; @@ -767,8 +763,6 @@ single_menu () } while (!done); bman.ai_players = selnrplayer - &nrplayerlist[0]; - if (!debug) - bman.ai_players++; if (menu->focus->id == 2) single_playergame (second_player, bman.ai_players);