diff --git a/ChangeLog b/ChangeLog index d8dbb20..714f0fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -$Id: ChangeLog,v 1.67 2004/02/02 23:26:50 patty21 Exp $ +$Id: ChangeLog,v 1.68 2004/02/04 22:56:47 patty21 Exp $ - Fixed: forgot to put the Message F4 to start the game into the playerselection screen. I put this only into the @@ -16,10 +16,16 @@ $Id: ChangeLog,v 1.67 2004/02/02 23:26:50 patty21 Exp $ - Fixed: Logo is now shown after change of resolution. -- Fixed: Bombtickingtime could not be readen from the config +- Fixed: Bombtickingtime could not be read from the config file. -* Changed: Download-Screen shows now a progress bar. +- Fixed: If you select "Host a Netgame" nothing happened if firewall was + enabled. Now a error message is displayed. + +- Fixed: Chat input in multiplayer wait menu is now smoother. + +- Changed: Download-Screen shows now a progress bar. Additionally, every + player can now see the download progress of all other players. Version 0.11.1 diff --git a/include/network.h b/include/network.h index 05c6356..1c54289 100644 --- a/include/network.h +++ b/include/network.h @@ -1,4 +1,4 @@ -/* $Id: network.h,v 1.15 2004/02/02 23:30:34 patty21 Exp $ +/* $Id: network.h,v 1.16 2004/02/04 22:56:55 patty21 Exp $ * network.h file... for everything what have to do with the network stuff */ @@ -19,6 +19,7 @@ #define DYN_PKG_MIN_MISSING 1 #define PKG_SENDSETOPT 2 #define MAX_SRVLIST 512 +#define TIME_UPDATEINFO 1000 #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) @@ -118,6 +119,7 @@ extern int net_check_timeout (int pl_nr); extern void net_dyn_pkgoption (); extern void net_send_chat (char *text, signed char notigamesrv); extern void net_send_mapinfo (); +extern void net_send_updateinfo (); extern void send_ogc_update (); // multiwait.c diff --git a/include/packets.h b/include/packets.h index fb3f9b9..7676c7e 100644 --- a/include/packets.h +++ b/include/packets.h @@ -25,7 +25,8 @@ enum _network_data { PKG_special, // forward PKG_dropitem, // forward PKG_respawn, // forward - PKG_quit // always the last known type + PKG_updateinfo, // forward + PKG_quit // always the last known type }; @@ -235,6 +236,12 @@ struct pkg_ill { Sint32 to[PI_max]; }; +struct pkg_updateinfo { + struct pkgheader h; + signed char pl_nr; + unsigned char step[MAX_PLAYERS]; + unsigned char status[MAX_PLAYERS]; +}; struct pkg_respawn { struct pkgheader h; @@ -318,6 +325,7 @@ extern void do_joingame (struct pkg_joingame *p_jg, _net_addr * addr); extern void do_field (struct pkg_field *f_dat, _net_addr *addr); extern void do_ping (struct pkg_ping *p_dat, _net_addr *addr); extern void do_playerdata (struct pkg_playerdata *p_dat, _net_addr *addr); +extern void do_updateinfo(struct pkg_updateinfo *stat, _net_addr *addr); extern void do_playermove (struct pkg_playermove *p_dat, _net_addr *addr); extern void do_bombdata (struct pkg_bombdata *b_dat, _net_addr *addr); extern void do_quit (struct pkg_quit *q_dat, _net_addr *addr); @@ -356,6 +364,7 @@ extern void send_chat (_net_addr *addr, char *text); extern void send_ill (_net_addr *addr, int p_nr, _player *pl); extern void send_special (_net_addr *addr, int p_nr, int typ, int ex_nr); extern void send_mapinfo (_net_addr *addr); +extern void send_updateinfo(_net_addr *addr); 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); diff --git a/src/chat.c b/src/chat.c index 2a15470..4319978 100644 --- a/src/chat.c +++ b/src/chat.c @@ -158,7 +158,8 @@ chat_clearscreen (signed char all) src.y = 2; src.w = chat.window.w - 4; src.h = chat.window.h - 4; - } + gfx_blitupdaterectadd (&chat.window); + } else { /* redraw only the textline of out input box */ dest.x = chat.window.x + 2; @@ -168,7 +169,8 @@ chat_clearscreen (signed char all) src.x = 2; src.y = chat.window.h - 18; - } + gfx_blitupdaterectadd (&dest); + } SDL_BlitSurface (chat.oldscreen, &src, gfx.screen, &dest); if (all == 1) { @@ -182,8 +184,6 @@ chat_clearscreen (signed char all) src.w = src.x + chat.window.w - 4; src.h = src.y + font[0].size.y; draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_DARK >> 1); - - gfx_blitupdaterectadd (&chat.window); }; diff --git a/src/multiwait.c b/src/multiwait.c index cd94d61..ed5856b 100644 --- a/src/multiwait.c +++ b/src/multiwait.c @@ -249,8 +249,8 @@ wait_for_players () ready = 0, keypressed = 0, i, - selgfx = 0; - + selgfx = 0, + drawgfx=1; mw_init (); draw_logo (); SDL_Flip (gfx.screen); @@ -286,8 +286,11 @@ wait_for_players () mw_draw_status (); bman.updatestatusbar = 0; } - mw_draw_gfxselect (selgfx); - mw_draw_chat (); + if (!--drawgfx) { + mw_draw_gfxselect (selgfx); + mw_draw_chat (); + drawgfx=5; + } } gfx_blitdraw (); @@ -406,7 +409,7 @@ wait_for_players () else if (event.type == SDL_KEYDOWN && event.key.keysym.sym != SDLK_RSHIFT && event.key.keysym.sym != SDLK_LSHIFT) keypressed = 1; - s_delay (25); + s_delay (5); } gfx_blitdraw (); // to clean the gfx blit data diff --git a/src/netmenu.c b/src/netmenu.c index d3ae0e0..a1ee82d 100644 --- a/src/netmenu.c +++ b/src/netmenu.c @@ -123,15 +123,24 @@ multiplayer_firstrun () bman.players_nr_s = 1; }; +void host_multiplayer_errormessage() +{ + menu_new ("Error", 400, 150); + menu_create_label ("You cannot host a game", 60, 54, 0); + + menu_create_label ("with Firewall option enabled.", 60, 84, 0); + menu_loop (); + menu_delete (); +} /* * We will host a network game */ void host_multiplayer_game () { if (bman.firewall) { + host_multiplayer_errormessage(); return; } - multiplayer_firstrun (); if (network_init () < 0) { @@ -192,6 +201,8 @@ void multiplayer_game () { }; + + /* We will join a network game */ void join_multiplayer_game () diff --git a/src/network.c b/src/network.c index d1c02aa..650e5aa 100644 --- a/src/network.c +++ b/src/network.c @@ -1,4 +1,4 @@ -/* $Id: network.c,v 1.60 2004/02/02 23:30:35 patty21 Exp $ */ +/* $Id: network.c,v 1.61 2004/02/04 22:56:55 patty21 Exp $ */ /* network routines. */ @@ -284,18 +284,22 @@ void draw_netupdatestate (char st) { char text[255]; + unsigned char b; int y = 0, + b1, z, + zx=200, i, - j; + j, + s=map.size.y+MAX_PLAYERS+GAME_MAX_TUNNELS; SDL_Rect src, dest; - z=gfx.res.x-110; - for (i = 0; i < MAX_PLAYERS; i++) + z=gfx.res.x-zx-30-8; + for (i = 0; i < MAX_PLAYERS; i++) if (PS_IS_used (players[i].state)) { - y += 48; + y += 50; if (st) { - redraw_logo (0, y, gfx.res.x, y + 48); + redraw_logo (0, y, gfx.res.x, y + 50); if (players[i].gfx_nr != -1) { dest.w = src.w = players[i].gfx->smal_size.x; @@ -310,56 +314,89 @@ draw_netupdatestate (char st) gfx_blitupdaterectadd (&dest); } - dest.x = 70; - dest.y = y+20; + dest.x = zx; + dest.y = y; dest.w = menu.listimages[1][0]->w; dest.h = menu.listimages[1][0]->h; gfx_blit (menu.listimages[1][0], NULL, gfx.screen, &dest, 10000); - dest.x = z+70+6; + dest.x = z+zx+4; gfx_blit (menu.listimages[1][2], NULL, gfx.screen, &dest, 10000); // draw the bottom left and right of the list - dest.y = y+36; + dest.y = y+29; gfx_blit (menu.listimages[1][8], NULL, gfx.screen, &dest, 10000); - dest.x = 70; + dest.x = zx; gfx_blit (menu.listimages[1][6], NULL, gfx.screen, &dest, 10000); //top & bottom - for (j=4;j0) { + b1=b*z/255; + dest.x = zx+4; + dest.y = y+4; + dest.w = menu.buttonimages[2][0]->w; + dest.h = menu.buttonimages[2][0]->h; + gfx_blit (menu.buttonimages[2][0], NULL, gfx.screen, &dest, 10000); + dest.x = zx+4+b1-menu.buttonimages[1][2]->w; + if (dest.xw; + dest.h = menu.buttonimages[2][2]->h; + gfx_blit (menu.buttonimages[2][2], NULL, gfx.screen, &dest, 10000); + if (b1>menu.buttonimages[2][0]->w+menu.buttonimages[2][2]->w) { + dest.w = menu.buttonimages[2][1]->w; + dest.h = menu.buttonimages[2][1]->h; + for(j=menu.buttonimages[2][0]->w;jw; + j+=menu.buttonimages[2][1]->w) { + dest.x=j+zx+4; + gfx_blit (menu.buttonimages[2][1], NULL, gfx.screen, &dest, 10000); + } + } + } + // draw old status in case of debug + if (!players[i].net.net_istep) + font_draw (80, y + 20, text, 0, 4); + else + if (debug) { + redraw_logo (80, y+35, gfx.res.x-80, 15); + font_draw (80, y + 35, text, 0, 4); + } + } gfx_blitdraw (); return; } @@ -422,15 +459,13 @@ net_transmit_gamedata () else font_draw (100, 0, "Downloading Data", 1, 0); - SDL_Flip (gfx.screen); - /* prepare everything for the loop */ for (x = 0; x < MAX_PLAYERS; x++) { players[x].net.timestamp = 0; players[x].net.net_status = -1; - if (PS_IS_aiplayer (players[x].state)) + if ((PS_IS_aiplayer (players[x].state)) || (x==bman.p_servnr)) players[x].net.net_istep = 0; else players[x].net.net_istep = 3; @@ -442,8 +477,9 @@ net_transmit_gamedata () else net_istep = 3; - draw_netupdatestate (1); - SDL_Flip (gfx.screen); + draw_netupdatestate (1); + SDL_Flip (gfx.screen); + downtimestamp = timestamp; while (!done && (bman.state == GS_update || (GT_MP_PTPS && net_istep != 0))) { /* the network thing */ @@ -451,6 +487,10 @@ net_transmit_gamedata () /* if PTPM check if all players are ready */ if (GT_MP_PTPM) { + if (timestamp - downtimestamp > TIME_UPDATEINFO) { + downtimestamp = timestamp; + net_send_updateinfo(); + } for (p = 1, i = 1; p < MAX_PLAYERS; p++) if (PS_IS_playing (players[p].state) && players[p].net.net_istep != 0) i = 0; @@ -539,11 +579,10 @@ net_transmit_gamedata () downtimestamp = timestamp; send_playerstatus (&players[bman.p_servnr].net.addr, bman.p_nr, 0, 0); } - } + } /* do the grafik work */ draw_netupdatestate (0); - SDL_Flip (gfx.screen); if (SDL_PollEvent (&event) != 0) switch (event.type) { @@ -829,6 +868,23 @@ net_game_send_special (int pl_nr, int ex_nr) }; +/* Send update informations to all clients */ +void +net_send_updateinfo () +{ + int i; + + if (GT_MP_PTPS) + return; + + d_printf ("Send Updateinfo\n"); + + for (i = 0; i < MAX_PLAYERS; i++) + if (!PS_IS_aiplayer (players[i].state) && PS_IS_netplayer (players[i].state) && i != bman.p_nr && NET_CANSEND(i)) + send_updateinfo (&players[i].net.addr); +}; + + /* Send mapinformations to all clients */ void net_send_mapinfo () diff --git a/src/packets.c b/src/packets.c index 8b2dacf..f08b6a0 100644 --- a/src/packets.c +++ b/src/packets.c @@ -1059,8 +1059,6 @@ do_getplayerdata (struct pkg_getplayerdata *gp_dat, _net_addr * addr) void do_playerstatus (struct pkg_playerstatus *stat, _net_addr * addr) { - int i; - d_printf ("do_playerstatus (%s,%s)\n", addr->host, addr->port); if (addr->pl_nr != bman.p_servnr && !(GT_MP_PTPM)) { @@ -1076,11 +1074,13 @@ do_playerstatus (struct pkg_playerstatus *stat, _net_addr * addr) players[addr->pl_nr].net.net_status = stat->status; players[addr->pl_nr].net.net_istep = stat->net_istep; + /* if (GT_MP_PTPM) for (i = 0; i < MAX_PLAYERS; i++) if (players[i].net.addr.host[0] != 0) - send_playerstatus (&players[i].net.addr, stat->pl_nr, + send_playerstatus (addr, stat->pl_nr, stat->net_istep, stat->status); + */ }; void @@ -1101,6 +1101,43 @@ send_playerstatus (_net_addr * addr, int pl_nr, int net_istep, int status) send_pkg ((struct pkg *) &stat, addr); }; +/*** + *** Packettype: updateinfo + ***/ +void +do_updateinfo (struct pkg_updateinfo *stat, _net_addr * addr) +{ + int i; + + d_printf ("do_updateinfo (%s,%s)\n", addr->host, addr->port); + + if (addr->pl_nr != bman.p_servnr && !(GT_MP_PTPM)) { + /* the data we have got are not from the server */ + d_printf ("do_updateinfo: the data we have got are not from the server\n"); + return; + } + for (i=0;istatus[i]; + players[i].net.net_istep = stat->step[i]; + } +}; + +void +send_updateinfo (_net_addr * addr) +{ + struct pkg_updateinfo stat; + int i; + stat.h.typ = PKG_updateinfo; + stat.h.flags = 0; + stat.h.len = HTON16 (sizeof (struct pkg_updateinfo)); + for (i=0;i