mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-10 14:42:13 +00:00
Make the default port re-brandable to reduce confusion with TCs.
Make sure TCs send server query broadcasts. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5235 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
a4942abf52
commit
3c4b5fabb6
9 changed files with 91 additions and 53 deletions
|
@ -69,7 +69,19 @@ cvar_t *hud_tracking_show;
|
|||
cvar_t *hud_miniscores_show;
|
||||
extern cvar_t net_compress;
|
||||
|
||||
cvar_t cl_defaultport = CVARAFD("cl_defaultport", STRINGIFY(PORT_QWSERVER), "port", 0, "The default port to connect to servers.\nQW: "STRINGIFY(PORT_QWSERVER)", NQ: "STRINGIFY(PORT_NQSERVER)", Q2: "STRINGIFY(PORT_Q2SERVER)".");
|
||||
cvar_t cl_defaultport =
|
||||
#ifdef GAME_DEFAULTPORT //remove the confusing port alias if we're running as a TC, as well as info about irrelevant games.
|
||||
CVARFD("cl_defaultport", STRINGIFY(PORT_DEFAULTSERVER), 0, "The default port used to connect to servers.")
|
||||
#else
|
||||
CVARAFD("cl_defaultport", STRINGIFY(PORT_DEFAULTSERVER), "port", 0, "The default port used to connect to servers."
|
||||
"\nQW: "STRINGIFY(PORT_QWSERVER)
|
||||
", NQ: "STRINGIFY(PORT_NQSERVER)
|
||||
", Q2: "STRINGIFY(PORT_Q2SERVER)
|
||||
", Q3: "STRINGIFY(PORT_Q3SERVER)
|
||||
"."
|
||||
)
|
||||
#endif
|
||||
;
|
||||
|
||||
cvar_t cfg_save_name = CVARFD("cfg_save_name", "fte", CVAR_ARCHIVE|CVAR_NOTFROMSERVER, "This is the config name that is saved by default when no argument is specified.");
|
||||
|
||||
|
@ -586,7 +598,7 @@ void CL_SendConnectPacket (netadr_t *to, int mtu,
|
|||
if (!to)
|
||||
{
|
||||
to = &addr;
|
||||
if (!NET_StringToAdr (cls.servername, PORT_QWSERVER, to))
|
||||
if (!NET_StringToAdr (cls.servername, PORT_DEFAULTSERVER, to))
|
||||
{
|
||||
Con_TPrintf ("CL_SendConnectPacket: Bad server address \"%s\"\n", cls.servername);
|
||||
connectinfo.trying = false;
|
||||
|
@ -2453,7 +2465,7 @@ void CL_Packet_f (void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!NET_StringToAdr (Cmd_Argv(1), PORT_QWSERVER, &adr))
|
||||
if (!NET_StringToAdr (Cmd_Argv(1), PORT_DEFAULTSERVER, &adr))
|
||||
{
|
||||
Con_Printf ("Bad address: %s\n", Cmd_Argv(1));
|
||||
return;
|
||||
|
@ -2814,7 +2826,7 @@ void CL_ConnectionlessPacket (void)
|
|||
netadr_t adr;
|
||||
char *data = MSG_ReadStringLine();
|
||||
Con_TPrintf ("redirect to %s\n", data);
|
||||
if (NET_StringToAdr(data, PORT_QWSERVER, &adr))
|
||||
if (NET_StringToAdr(data, PORT_DEFAULTSERVER, &adr))
|
||||
{
|
||||
data = "\xff\xff\xff\xffgetchallenge\n";
|
||||
|
||||
|
@ -4354,17 +4366,19 @@ void CL_Init (void)
|
|||
"Use a scheme of tcp:// or tls:// to connect via non-udp protocols."
|
||||
#endif
|
||||
#if defined(NQPROT) || defined(Q2CLIENT) || defined(Q3CLIENT)
|
||||
"\nDefault port is port "STRINGIFY(PORT_QWSERVER)"."
|
||||
#ifdef NQPROT
|
||||
"\nDefault port is port "STRINGIFY(PORT_DEFAULTSERVER)"."
|
||||
#ifndef GAME_DEFAULTPORT
|
||||
#ifdef NQPROT
|
||||
" NQ:"STRINGIFY(PORT_NQSERVER)"."
|
||||
#endif
|
||||
#endif
|
||||
" QW:"STRINGIFY(PORT_QWSERVER)"."
|
||||
#ifdef Q2CLIENT
|
||||
#ifdef Q2CLIENT
|
||||
" Q2:"STRINGIFY(PORT_Q2SERVER)"."
|
||||
#endif
|
||||
#ifdef Q3CLIENT
|
||||
#endif
|
||||
#ifdef Q3CLIENT
|
||||
" Q3:"STRINGIFY(PORT_Q3SERVER)"."
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
);
|
||||
Cmd_AddCommandD ("cl_transfer", CL_Transfer_f, "Connect to a different server, disconnecting from the current server only when the new server replies.");
|
||||
|
|
|
@ -2636,8 +2636,9 @@ void MasterInfo_Refresh(void)
|
|||
|
||||
Master_LoadMasterList("servers.txt", false, MT_MASTERUDP, MP_QUAKEWORLD, 1);
|
||||
|
||||
Master_AddMaster("255.255.255.255:"STRINGIFY(PORT_QWSERVER), MT_BCAST, MP_QUAKEWORLD, "Nearby QuakeWorld UDP servers.");
|
||||
Master_AddMaster("255.255.255.255:"STRINGIFY(PORT_DEFAULTSERVER), MT_BCAST, MP_DPMASTER, "Nearby Game Servers.");
|
||||
#ifndef QUAKETC
|
||||
Master_AddMaster("255.255.255.255:"STRINGIFY(PORT_QWSERVER), MT_BCAST, MP_QUAKEWORLD, "Nearby QuakeWorld UDP servers.");
|
||||
Master_AddMasterHTTP("http://www.gameaholic.com/servers/qspy-quakeworld", MT_MASTERHTTP, MP_QUAKEWORLD, "gameaholic's QW master");
|
||||
Master_AddMasterHTTP("https://www.quakeservers.net/lists/servers/global.txt",MT_MASTERHTTP, MP_QUAKEWORLD, "QuakeServers.net (http)");
|
||||
#endif
|
||||
|
|
|
@ -12,10 +12,11 @@
|
|||
//#define BRANDING_ICON "fte_eukara.ico" //The file to use in windows' resource files - for linux your game should include an icon.[png|ico] file in the game's data.
|
||||
|
||||
//filesystem rebranding
|
||||
//#define GAME_SHORTNAME "wastes" //short alphanumeric description
|
||||
//#define GAME_SHORTNAME "quake" //short alphanumeric description
|
||||
//#define GAME_FULLNAME FULLENGINENAME //full name of the game we're playing
|
||||
//#define GAME_BASEGAMES GAME_SHORTNAME //comma-separate list of basegame strings to use
|
||||
//#define GAME_PROTOCOL "FTE-Wastes" //so other games won't show up in the server browser
|
||||
//#define GAME_PROTOCOL "FTE-Quake" //so other games won't show up in the server browser
|
||||
//#define GAME_DEFAULTPORT 27500 //slightly reduces the chance of people connecting to the wrong type of server
|
||||
//#define GAME_IDENTIFYINGFILES NULL //with multiple games, this string-list gives verification that the basedir is actually valid. if null, will just be assumed correct.
|
||||
//#define GAME_DOWNLOADSURL NULL //url for the package manger to update from
|
||||
//#define GAME_DEFAULTCMDS NULL //a string containing the things you want to exec in order to override default.cfg
|
||||
|
|
|
@ -14,10 +14,11 @@
|
|||
//#define BRANDING_ICON "fte_eukara.ico" //The file to use in windows' resource files - for linux your game should include an icon.[png|ico] file in the game's data.
|
||||
|
||||
//filesystem rebranding
|
||||
//#define GAME_SHORTNAME "wastes" //short alphanumeric description
|
||||
//#define GAME_SHORTNAME "quake" //short alphanumeric description
|
||||
//#define GAME_FULLNAME FULLENGINENAME //full name of the game we're playing
|
||||
//#define GAME_BASEGAMES GAME_SHORTNAME //comma-separate list of basegame strings to use
|
||||
//#define GAME_PROTOCOL "FTE-Wastes" //so other games won't show up in the server browser
|
||||
//#define GAME_PROTOCOL "FTE-Quake" //so other games won't show up in the server browser
|
||||
//#define GAME_DEFAULTPORT 27500 //slightly reduces the chance of people connecting to the wrong type of server
|
||||
//#define GAME_IDENTIFYINGFILES NULL //with multiple games, this string-list gives verification that the basedir is actually valid. if null, will just be assumed correct.
|
||||
//#define GAME_DOWNLOADSURL NULL //url for the package manger to update from
|
||||
//#define GAME_DEFAULTCMDS NULL //a string containing the things you want to exec in order to override default.cfg
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
//#define GAME_FULLNAME FULLENGINENAME //full name of the game we're playing
|
||||
//#define GAME_BASEGAMES GAME_SHORTNAME //comma-separate list of basegame strings to use
|
||||
//#define GAME_PROTOCOL "FTE-Generic" //so other games won't show up in the server browser
|
||||
//#define GAME_DEFAULTPORT 27500 //slightly reduces the chance of people connecting to the wrong type of server
|
||||
//#define GAME_IDENTIFYINGFILES NULL //with multiple games, this string-list gives verification that the basedir is actually valid. if null, will just be assumed correct.
|
||||
//#define GAME_DOWNLOADSURL NULL //url for the package manger to update from
|
||||
//#define GAME_DEFAULTCMDS NULL //a string containing the things you want to exec in order to override default.cfg
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#define GAME_FULLNAME FULLENGINENAME //full name of the game we're playing
|
||||
#define GAME_BASEGAMES GAME_SHORTNAME //comma-separate list of basegame strings to use
|
||||
#define GAME_PROTOCOL "FTE-Wastes" //so other games won't show up in the server browser
|
||||
#define GAME_DEFAULTPORT 27500 //FIXME: change me!
|
||||
//#define GAME_IDENTIFYINGFILES NULL //with multiple games, this string-list gives verification that the basedir is actually valid. if null, will just be assumed correct.
|
||||
//#define GAME_DOWNLOADSURL NULL //url for the package manger to update from
|
||||
//#define GAME_DEFAULTCMDS NULL //a string containing the things you want to
|
||||
|
|
|
@ -3076,9 +3076,11 @@ ftenet_generic_connection_t *FTENET_Datagram_EstablishConnection(qboolean isserv
|
|||
int family;
|
||||
int port;
|
||||
int bindtries;
|
||||
const int bindmaxtries = 100;
|
||||
int bufsz;
|
||||
qboolean hybrid = false;
|
||||
int protocol;
|
||||
char addrstr[128];
|
||||
|
||||
switch(adr.type)
|
||||
{
|
||||
|
@ -3101,7 +3103,7 @@ ftenet_generic_connection_t *FTENET_Datagram_EstablishConnection(qboolean isserv
|
|||
|
||||
if (adr.type == NA_INVALID)
|
||||
{
|
||||
Con_Printf("unable to resolve local address %s\n", address);
|
||||
Con_Printf(CON_ERROR "unable to resolve local address %s\n", address);
|
||||
return NULL; //couldn't resolve the name
|
||||
}
|
||||
temp = NetadrToSockadr(&adr, &qs);
|
||||
|
@ -3167,24 +3169,34 @@ ftenet_generic_connection_t *FTENET_Datagram_EstablishConnection(qboolean isserv
|
|||
|
||||
//try and find an unused port.
|
||||
port = ntohs(((struct sockaddr_in*)&qs)->sin_port);
|
||||
for (bindtries = 100; bindtries > 0; bindtries--)
|
||||
for (bindtries = 0; bindtries < bindmaxtries; bindtries++)
|
||||
{
|
||||
((struct sockaddr_in*)&qs)->sin_port = htons((unsigned short)(port+100-bindtries));
|
||||
((struct sockaddr_in*)&qs)->sin_port = htons((unsigned short)(port+bindtries));
|
||||
if ((bind(newsocket, (struct sockaddr *)&qs, temp) == INVALID_SOCKET))
|
||||
{
|
||||
if (port == 0)
|
||||
{ //if binding to an ephemerial port failed, binding to the admin-only ports won't work any better...
|
||||
bindtries = bindmaxtries;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!bindtries)
|
||||
if (bindtries == bindmaxtries)
|
||||
{
|
||||
SockadrToNetadr(&qs, &adr);
|
||||
//mneh, reuse qs.
|
||||
NET_AdrToString((char*)&qs, sizeof(qs), &adr);
|
||||
Con_Printf("Unable to listen at %s\n", (char*)&qs);
|
||||
NET_AdrToString(addrstr, sizeof(addrstr), &adr);
|
||||
Con_Printf(CON_ERROR "Unable to listen at %s\n", addrstr);
|
||||
closesocket(newsocket);
|
||||
return NULL;
|
||||
}
|
||||
else if (bindtries && isserver)
|
||||
{
|
||||
SockadrToNetadr(&qs, &adr);
|
||||
NET_AdrToString(addrstr, sizeof(addrstr), &adr);
|
||||
Con_Printf(CON_ERROR "Unable to bind to port %i, bound to %s instead\n", port, addrstr);
|
||||
}
|
||||
|
||||
if (ioctlsocket (newsocket, FIONBIO, &_true) == -1)
|
||||
Sys_Error ("UDP_OpenSocket: ioctl FIONBIO: %s", strerror(neterrno()));
|
||||
|
@ -7260,7 +7272,7 @@ void SVNET_AddPort_f(void)
|
|||
{
|
||||
svs.sockets = FTENET_CreateCollection(true);
|
||||
#ifndef SERVERONLY
|
||||
FTENET_AddToCollection(svs.sockets, "SVLoopback", STRINGIFY(PORT_QWSERVER), NA_LOOPBACK, NP_DGRAM);
|
||||
FTENET_AddToCollection(svs.sockets, "SVLoopback", STRINGIFY(PORT_DEFAULTSERVER), NA_LOOPBACK, NP_DGRAM);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -7449,7 +7461,7 @@ void QDECL SV_Port_Callback(struct cvar_s *var, char *oldvalue)
|
|||
{
|
||||
FTENET_AddToCollection(svs.sockets, var->name, var->string, NA_IP, NP_DGRAM);
|
||||
}
|
||||
cvar_t sv_port_ipv4 = CVARC("sv_port", STRINGIFY(PORT_QWSERVER), SV_Port_Callback);
|
||||
cvar_t sv_port_ipv4 = CVARC("sv_port", STRINGIFY(PORT_DEFAULTSERVER), SV_Port_Callback);
|
||||
#endif
|
||||
#ifdef IPPROTO_IPV6
|
||||
void QDECL SV_PortIPv6_Callback(struct cvar_s *var, char *oldvalue)
|
||||
|
@ -7553,7 +7565,7 @@ void NET_InitServer(void)
|
|||
{
|
||||
svs.sockets = FTENET_CreateCollection(true);
|
||||
#ifndef SERVERONLY
|
||||
FTENET_AddToCollection(svs.sockets, "SVLoopback", STRINGIFY(PORT_QWSERVER), NA_LOOPBACK, NP_DGRAM);
|
||||
FTENET_AddToCollection(svs.sockets, "SVLoopback", STRINGIFY(PORT_DEFAULTSERVER), NA_LOOPBACK, NP_DGRAM);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -7591,7 +7603,7 @@ void NET_InitServer(void)
|
|||
|
||||
#ifndef SERVERONLY
|
||||
svs.sockets = FTENET_CreateCollection(true);
|
||||
FTENET_AddToCollection(svs.sockets, "SVLoopback", STRINGIFY(PORT_QWSERVER), NA_LOOPBACK, NP_DGRAM);
|
||||
FTENET_AddToCollection(svs.sockets, "SVLoopback", STRINGIFY(PORT_DEFAULTSERVER), NA_LOOPBACK, NP_DGRAM);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
//=========================================
|
||||
|
||||
//#define GAME_DEFAULTPORT XXXXX //rebranding allows selection of a different default port, which slightly reduces protocol conflicts.
|
||||
#define PORT_NQSERVER 26000
|
||||
#define PORT_DPMASTER PORT_Q3MASTER
|
||||
#define PORT_QWCLIENT 27001
|
||||
|
@ -133,6 +134,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define PORT_Q3MASTER 27950
|
||||
#define PORT_Q3SERVER 27960
|
||||
|
||||
#ifdef GAME_DEFAULTPORT
|
||||
#define PORT_DEFAULTSERVER GAME_DEFAULTPORT
|
||||
#else
|
||||
#define PORT_DEFAULTSERVER PORT_QWSERVER
|
||||
#endif
|
||||
|
||||
//hexen2: 26900
|
||||
|
||||
//=========================================
|
||||
|
|
Loading…
Reference in a new issue