diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a73909264..b47875af7 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ D1X-Rebirth Changelog 20081020 -------- main/menu.c: resolution 1440x960 to 1440x900 - typo +d1x.ini, include/args.h, main/inferno.c, main/menu.c, main/netdrv_udp.c, main/network.c, misc/args.c: Readded -ip_hostaddr optional to the value stored in descent.cfg for automated program starts or whatever; Fix by Locate: Correctly close UDP sockets on Win32; Fix by Locate: Ability to select Secret levels on Multiplayer in D1X again which was broken in r619 20081019 -------- diff --git a/d1x.ini b/d1x.ini index 30c142739..3e263d119 100644 --- a/d1x.ini +++ b/d1x.ini @@ -41,3 +41,4 @@ ;-ipxnetwork Use IPX network number ;-ip_baseport Use

as offset from normal port ;-ip_relay Relay players with closed port over host (increases traffic and lag) +;-ip_hostaddr Use as host ip address diff --git a/include/args.h b/include/args.h index c41d84141..829f30968 100644 --- a/include/args.h +++ b/include/args.h @@ -72,6 +72,7 @@ typedef struct Arg const char *MplIpxNetwork; int MplIpBasePort; int MplIpRelay; + char *MplIpHostAddr; int DbgVerbose; int DbgNoRun; int DbgRenderStats; diff --git a/main/inferno.c b/main/inferno.c index 301318c87..a372a824c 100644 --- a/main/inferno.c +++ b/main/inferno.c @@ -178,6 +178,7 @@ void show_commandline_help() printf( " -ipxnetwork %s\n", "Use IPX network number "); printf( " -ip_baseport %s\n", "Use as offset from normal port (allows multiple instances of d1x to be run on a single computer)"); printf( " -ip_relay %s\n", "Relay players with closed port over host (increases traffic and lag)"); + printf( " -ip_hostaddr %s\n", "Use as host ip address"); #endif // NETWORK #ifdef EDITOR diff --git a/main/menu.c b/main/menu.c index 9bb4b2088..9ff563c28 100644 --- a/main/menu.c +++ b/main/menu.c @@ -844,6 +844,17 @@ void do_ip_manual_join_menu() } } + if (*GameArg.MplIpHostAddr) { + sprintf(buf,"%s",GameArg.MplIpHostAddr); + + for (j=0; buf[j] != '\0'; j++) { + switch (buf[j]) { + case ' ': + buf[j] = '\0'; + } + } + } + do { old_game_mode = Game_mode; num_options = 0; diff --git a/main/netdrv_udp.c b/main/netdrv_udp.c index 3f8da0f14..430c3ffeb 100755 --- a/main/netdrv_udp.c +++ b/main/netdrv_udp.c @@ -29,9 +29,10 @@ #include "key.h" #include "text.h" -int UDP_sock; +int UDP_sock = -1; unsigned int myid=0; // My personal ID which I will get from host and will be used for IPX-Node struct peer_list UDPPeers[MAX_CONNECTIONS]; // The Peer list. +void UDPCloseSocket(socket_t *unused); // Receive Configuration: Exchanging Peers, doing Handshakes, etc. void UDPReceiveCFG(char *text, struct _sockaddr *sAddr) @@ -392,8 +393,15 @@ int UDPOpenSocket(socket_t *unused, int port) { int i; + // close stale socket + if( UDP_sock != -1 ) + UDPCloseSocket(NULL); + #ifdef _WIN32 struct _sockaddr sAddr; // my address information + int reuse_on = -1; + + memset( &sAddr, '\0', sizeof( sAddr ) ); if ((UDP_sock = socket (_af, SOCK_DGRAM, 0)) == -1) { con_printf(CON_URGENT,"UDPOpenSocket: socket creation failed\n"); @@ -401,6 +409,11 @@ int UDPOpenSocket(socket_t *unused, int port) return -1; } + // this is pretty annoying in win32. Not doing that will lead to + // "Could not bind name to socket" errors. It may be suitable for other + // socket implementations, too + (void)setsockopt( UDP_sock, SOL_SOCKET, SO_REUSEADDR, (const char *) &reuse_on, sizeof( reuse_on )); + #ifdef IPv6 sAddr.sin6_family = _pf; // host byte order sAddr.sin6_port = htons (GameArg.MplIpBasePort+UDP_BASEPORT);; // short, network byte order @@ -415,9 +428,11 @@ int UDPOpenSocket(socket_t *unused, int port) memset (&(sAddr.sin_zero), '\0', 8); // zero the rest of the struct - if (bind (UDP_sock, (struct sockaddr *) &sAddr, sizeof (struct sockaddr)) == -1) { + if (bind (UDP_sock, (struct sockaddr *) &sAddr, sizeof (struct sockaddr)) == -1) + { con_printf(CON_URGENT,"UDPOpenSocket: bind name to socket failed\n"); nm_messagebox(TXT_ERROR,1,TXT_OK,"Could not bind name to socket"); + UDPCloseSocket(NULL); return -1; } #else @@ -469,7 +484,7 @@ int UDPOpenSocket(socket_t *unused, int port) { con_printf(CON_URGENT,"UDPOpenSocket: bind name to socket failed\n"); nm_messagebox(TXT_ERROR,1,TXT_OK,"Could not bind name to socket"); - close (UDP_sock); + UDPCloseSocket(NULL); freeaddrinfo (res); return -1; } diff --git a/main/network.c b/main/network.c index b409a7bae..444beb192 100644 --- a/main/network.c +++ b/main/network.c @@ -2057,12 +2057,18 @@ menu: Netgame.levelnum = atoi(slevel); - if ((Netgame.levelnum < 1) || (Netgame.levelnum > Last_level)) + if (!strnicmp(slevel, "s", 1)) + Netgame.levelnum = -atoi(slevel+1); + else + Netgame.levelnum = atoi(slevel); + + if ((Netgame.levelnum < Last_secret_level) || (Netgame.levelnum > Last_level) || (Netgame.levelnum == 0)) { nm_messagebox(TXT_ERROR, 1, TXT_OK, TXT_LEVEL_OUT_RANGE ); sprintf(slevel, "1"); goto menu; } + if ( m[opt_mode].value ) Netgame.gamemode = NETGAME_ANARCHY; @@ -3746,7 +3752,14 @@ int show_game_stats(int choice) else info+=sprintf(info,Active_games[choice].mission_title); - info+=sprintf (info," - Lvl %i",Active_games[choice].levelnum); + if( Active_games[choice].levelnum >= 0 ) + { + info+=sprintf (info," - Lvl %i",Active_games[choice].levelnum); + } + else + { + info+=sprintf (info," - Lvl S%i",(Active_games[choice].levelnum*-1)); + } #endif info+=sprintf (info,"\n\nDifficulty: %s",MENU_DIFFICULTY_TEXT(Active_games[choice].difficulty)); info+=sprintf (info,"\nGame Mode: %s",NetworkModeNames[Active_games[choice].gamemode]); diff --git a/misc/args.c b/misc/args.c index c20f16429..3927523aa 100644 --- a/misc/args.c +++ b/misc/args.c @@ -184,6 +184,7 @@ void ReadCmdArgs(void) GameArg.MplIpxNetwork = get_str_arg("-ipxnetwork", NULL); GameArg.MplIpBasePort = get_int_arg("-ip_baseport", 0); GameArg.MplIpRelay = FindArg("-ip_relay"); + GameArg.MplIpHostAddr = get_str_arg("-ip_hostaddr", ""); // Editor Options