From 790e52c9f6bf87c5f4a93ece366af8233ab6504f Mon Sep 17 00:00:00 2001 From: stpohle Date: Fri, 8 Apr 2005 00:18:24 +0000 Subject: [PATCH] added broadcast menuswitch to the programm parameters and also into the config file --- ChangeLog | 8 +++++++- include/bomberclone.h | 3 ++- src/broadcast.c | 7 ++++--- src/configuration.c | 10 +++++++++- src/netmenu.c | 13 +++++++------ src/sysfunc.c | 4 ++-- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index f773ac5..089dcfa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,17 @@ -$Id: ChangeLog,v 1.101 2005/04/06 21:45:46 stpohle Exp $ +$Id: ChangeLog,v 1.102 2005/04/08 00:18:24 stpohle Exp $ Version 0.11.6.1 ================ +- Display the number of players for each listed network game. + - Ghost Player added. + - Playername will not overlapped by the player gfx anymore. +- Added menuswitch to enable/disable broadcast requests. + + Version 0.11.6 ============== diff --git a/include/bomberclone.h b/include/bomberclone.h index e465e8a..0d284a0 100644 --- a/include/bomberclone.h +++ b/include/bomberclone.h @@ -1,4 +1,4 @@ -/* $Id: bomberclone.h,v 1.31 2005/03/28 16:38:29 stpohle Exp $ */ +/* $Id: bomberclone.h,v 1.32 2005/04/08 00:18:28 stpohle Exp $ */ /* bomberclone.h */ #ifndef _BOMBERCLONE_H_ @@ -84,6 +84,7 @@ struct { char ogc_port[LEN_PORT]; int firewall; int notifygamemaster; + int broadcast; int askplayername; // ask player for name at startup int start_bombs; // start values diff --git a/src/broadcast.c b/src/broadcast.c index f5f76dc..04a629e 100644 --- a/src/broadcast.c +++ b/src/broadcast.c @@ -1,4 +1,4 @@ -/* $Id: broadcast.c,v 1.4 2005/03/28 21:06:41 stpohle Exp $ +/* $Id: broadcast.c,v 1.5 2005/04/08 00:18:29 stpohle Exp $ * find broadcasted games and also hold in this list * all games which the ogc reports us */ @@ -101,7 +101,8 @@ void broadcast_init () { for (i = 0; i < BC_MAXENTRYS; i++) broadcast_list[i].host[0] = 0; - broadcast_send (NULL, NULL); + if (bman.broadcast) + broadcast_send (NULL, NULL); bc_lastrequest = timestamp; }; @@ -134,7 +135,7 @@ void broadcast_loop () { struct pkg_gameinfo *pgi; _net_addr addr; - if ((timestamp - bc_lastrequest) > BC_REQUESTTIME) { + if (bman.broadcast && (timestamp - bc_lastrequest) > BC_REQUESTTIME) { broadcast_send (NULL, NULL); bc_lastrequest = timestamp; } diff --git a/src/configuration.c b/src/configuration.c index fd837a2..f3d4ba7 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -1,4 +1,4 @@ -/* $Id: configuration.c,v 1.72 2005/03/28 16:38:34 stpohle Exp $ +/* $Id: configuration.c,v 1.73 2005/04/08 00:18:29 stpohle Exp $ * configuration */ #include @@ -92,6 +92,7 @@ config_init (int argc, char **argv) resend_cache.data = NULL; resend_cache.fill = -1; bman.notifygamemaster = 1; + bman.broadcast = 1; bman.askplayername = 0; debug = 0; gfx.res.x = 640; @@ -317,6 +318,9 @@ config_read () if (!strcmp (keyword, "notify")) { bman.notifygamemaster = atoi (value); } + if (!strcmp (keyword, "broadcast")) { + bman.broadcast = atoi (value); + } if (!strcmp (keyword, "ogcserver")) { strcpy (bman.ogcserver, value); } @@ -453,6 +457,7 @@ config_write () fprintf (config, "fieldsizex=%d\n", map.size.x); fprintf (config, "fieldsizey=%d\n", map.size.y); fprintf (config, "notify=%d\n", bman.notifygamemaster); + fprintf (config, "broadcast=%d\n", bman.broadcast); fprintf (config, "ai_family=%d\n", bman.net_ai_family); fprintf (config, "ogcserver=%s\n", bman.ogcserver); fprintf (config, "ogc_port=%s\n", bman.ogc_port); @@ -665,6 +670,7 @@ ReadPrgArgs (int argc, char **argv) printf (" (Def.: 11000)\n"); printf (" -ogcport PORT - set the local OGC Port (Def.: 11100)\n"); printf (" -ogc 0/1 - Enable/Disable OGC\n"); + printf (" -broadcast 0/1 - Enable/Disable broadcast requests.\n"); printf (" -host - start a network game\n"); printf (" -join - go into the join menu\n"); printf (" -connect ADDRESS - connect to a server\n"); @@ -683,6 +689,8 @@ ReadPrgArgs (int argc, char **argv) strncpy (bman.gamename, argv[++i], LEN_GAMENAME); if (!strcmp (argv[i], "-ogc")) bman.notifygamemaster = atoi (argv[++i]); + if (!strcmp (argv[i], "-broadcast")) + bman.broadcast = atoi (argv[++i]); if (!strcmp (argv[i], "-debug")) debug = atoi (argv[++i]); } diff --git a/src/netmenu.c b/src/netmenu.c index 9241788..89c989f 100644 --- a/src/netmenu.c +++ b/src/netmenu.c @@ -66,17 +66,18 @@ network_options () menu = menu_new ("Network Options", 400, 380); menu_create_label (menu, "Max Players", 30, 75, 0, COLOR_brown); menu_create_list (menu, "Players", 150, 55, 55, 70, nrplayerlist, &selnrplayer, 1); - menu_create_entry (menu, "Gamename", -1, 150, 300, &bman.gamename, LEN_GAMENAME, MENU_entrytext, 2); - menu_create_entry (menu, "UDP Port:", -1, 180, 200, &bman.port, LEN_PORT, MENU_entrytext,3); + menu_create_entry (menu, "Gamename", -1, 150, 300, &bman.gamename, LEN_GAMENAME, MENU_entrytext, 3); + menu_create_entry (menu, "UDP Port:", -1, 180, 200, &bman.port, LEN_PORT, MENU_entrytext,4); #ifndef _WIN32 - menu_create_bool (menu, "IPV6", 260, 60, 100, &net_ai_typ, 4); + menu_create_bool (menu, "IPV6", 260, 60, 100, &net_ai_typ, 2); #endif menu_create_bool (menu, "Private Game", 20, 220, 150, &bman.passwordenabled, 6); menu_create_entry (menu, "Password:", 190, 220, 210, &bman.password, LEN_PASSWORD, MENU_entrytext, 7); - menu_create_bool (menu, "Use OpenGameCache", -1, 250, 350, &bman.notifygamemaster, 8); - menu_create_entry (menu, "OpenGameCache:", -1, 280, 350, &bman.ogcserver, LEN_SERVERNAME, MENU_entrytext, 9); - menu_create_entry (menu, "Local OGC Port", -1, 310, 350, &bman.ogc_port, LEN_PORT, MENU_entrytext, 10); + menu_create_bool (menu, "Use OGC", 70, 250, 120, &bman.notifygamemaster, 8); + menu_create_bool (menu, "Broadcast", 250, 250, 120, &bman.broadcast, 9); + menu_create_entry (menu, "OpenGameCache:", -1, 280, 350, &bman.ogcserver, LEN_SERVERNAME, MENU_entrytext, 10); + menu_create_entry (menu, "Local OGC Port", -1, 310, 350, &bman.ogc_port, LEN_PORT, MENU_entrytext, 11); menu_create_button (menu, "Ok", -1, 350, 150, 0); menuselect = menu_loop (menu); bman.maxplayer = (selnrplayer - &nrplayerlist[0]) + 1; diff --git a/src/sysfunc.c b/src/sysfunc.c index 1921597..ffd00b5 100644 --- a/src/sysfunc.c +++ b/src/sysfunc.c @@ -1,4 +1,4 @@ -/* $Id: sysfunc.c,v 1.23 2004/01/07 23:04:32 patty21 Exp $ +/* $Id: sysfunc.c,v 1.24 2005/04/08 00:18:29 stpohle Exp $ sysfunc.c - this file hold some routines for the system functions.. like d_delay */ @@ -242,7 +242,7 @@ inline void s_calctimesync () { timeloop1 = SDL_GetTicks (); game_timediff = timeloop1 - timestamp; // only for debugging needed - while (timeloop1 - timestamp >= 0 && timeloop1 - timestamp < 20) { + while (timeloop1 - timestamp >= 3 && timeloop1 - timestamp < 20) { s_delay (20 - (timeloop1 - timestamp) - 1); timeloop1 = SDL_GetTicks (); }