diff --git a/code/network/multi.cpp b/code/network/multi.cpp index d20e5e76292..f0dc860abdd 100644 --- a/code/network/multi.cpp +++ b/code/network/multi.cpp @@ -49,6 +49,7 @@ #include "fs2netd/fs2netd_client.h" #include "pilotfile/pilotfile.h" #include "debugconsole/console.h" +#include "network/psnet2.h" @@ -337,9 +338,11 @@ void multi_check_listen() } // the connection was accepted in check_for_listen. Find the netplayer whose address we connected - // with and assign the socket descriptor + // with and assign the socket descriptor. + // Updated to utilize psnet_same() for address comparison so the port is also taken into account. + // This allows multiple players using NAT to access a remote server simultneously. for (i = 0; i < MAX_PLAYERS; i++ ) { - if ( (Net_players[i].flags & NETINFO_FLAG_CONNECTED) && (!memcmp(&(addr.addr), &(Net_players[i].p_info.addr.addr), 6)) ) { + if ( (Net_players[i].flags & NETINFO_FLAG_CONNECTED) && (psnet_same(&addr, &(Net_players[i].p_info.addr))) ) { // mark this flag so we know he's "fully" connected Net_players[i].flags |= NETINFO_FLAG_RELIABLE_CONNECTED; Net_players[i].reliable_socket = sock; diff --git a/code/network/psnet2.cpp b/code/network/psnet2.cpp index 86c38bad9cc..d98a3ebfad4 100644 --- a/code/network/psnet2.cpp +++ b/code/network/psnet2.cpp @@ -905,7 +905,7 @@ void psnet_string_to_addr( net_addr * address, char * text ) */ int psnet_same( net_addr * a1, net_addr * a2 ) { - return !memcmp(a1->addr, a2->addr, 6); + return !memcmp(a1->addr, a2->addr, 6) && a1->port == a2->port; } /**