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
This commit is contained in:
parent
fcc853ffe8
commit
640aad4541
|
@ -3,6 +3,7 @@ D2X-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, 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
|
||||
--------
|
||||
|
|
1
d2x.ini
1
d2x.ini
|
@ -46,3 +46,4 @@
|
|||
;-ipxnetwork <n> Use IPX network number <n>
|
||||
;-ip_baseport <n> Use <p> as offset from normal port
|
||||
;-ip_relay Relay players with closed port over host (increases traffic and lag)
|
||||
;-ip_hostaddr <n> Use <n> as host ip address
|
||||
|
|
|
@ -78,6 +78,7 @@ typedef struct Arg
|
|||
const char *MplIpxNetwork;
|
||||
int MplIpBasePort;
|
||||
int MplIpRelay;
|
||||
char *MplIpHostAddr;
|
||||
char *EdiAutoLoad;
|
||||
int EdiSaveHoardData;
|
||||
int EdiMacData; // also used for some read routines in non-editor build
|
||||
|
|
|
@ -189,6 +189,7 @@ void print_commandline_help()
|
|||
printf( " -ipxnetwork <n> %s\n", "Use IPX network number <n>");
|
||||
printf( " -ip_baseport <n> %s\n", "Use <n> 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 <n> %s\n", "Use <n> as host ip address");
|
||||
#endif // NETWORK
|
||||
|
||||
#ifdef EDITOR
|
||||
|
|
11
main/menu.c
11
main/menu.c
|
@ -842,6 +842,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;
|
||||
|
|
|
@ -30,9 +30,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)
|
||||
|
@ -394,8 +395,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");
|
||||
|
@ -403,6 +411,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
|
||||
|
@ -417,9 +430,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
|
||||
|
@ -471,7 +486,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;
|
||||
}
|
||||
|
|
|
@ -195,6 +195,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", "");
|
||||
|
||||
#ifdef EDITOR
|
||||
// Editor Options
|
||||
|
|
Loading…
Reference in a new issue