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:
Spoike 2018-04-07 12:33:06 +00:00
parent a4942abf52
commit 3c4b5fabb6
9 changed files with 91 additions and 53 deletions

View file

@ -69,7 +69,19 @@ cvar_t *hud_tracking_show;
cvar_t *hud_miniscores_show; cvar_t *hud_miniscores_show;
extern cvar_t net_compress; 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."); 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) if (!to)
{ {
to = &addr; 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); Con_TPrintf ("CL_SendConnectPacket: Bad server address \"%s\"\n", cls.servername);
connectinfo.trying = false; connectinfo.trying = false;
@ -2453,7 +2465,7 @@ void CL_Packet_f (void)
return; 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)); Con_Printf ("Bad address: %s\n", Cmd_Argv(1));
return; return;
@ -2814,7 +2826,7 @@ void CL_ConnectionlessPacket (void)
netadr_t adr; netadr_t adr;
char *data = MSG_ReadStringLine(); char *data = MSG_ReadStringLine();
Con_TPrintf ("redirect to %s\n", data); 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"; 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." "Use a scheme of tcp:// or tls:// to connect via non-udp protocols."
#endif #endif
#if defined(NQPROT) || defined(Q2CLIENT) || defined(Q3CLIENT) #if defined(NQPROT) || defined(Q2CLIENT) || defined(Q3CLIENT)
"\nDefault port is port "STRINGIFY(PORT_QWSERVER)"." "\nDefault port is port "STRINGIFY(PORT_DEFAULTSERVER)"."
#ifdef NQPROT #ifndef GAME_DEFAULTPORT
" NQ:"STRINGIFY(PORT_NQSERVER)"." #ifdef NQPROT
#endif " NQ:"STRINGIFY(PORT_NQSERVER)"."
" QW:"STRINGIFY(PORT_QWSERVER)"." #endif
#ifdef Q2CLIENT " QW:"STRINGIFY(PORT_QWSERVER)"."
" Q2:"STRINGIFY(PORT_Q2SERVER)"." #ifdef Q2CLIENT
#endif " Q2:"STRINGIFY(PORT_Q2SERVER)"."
#ifdef Q3CLIENT #endif
" Q3:"STRINGIFY(PORT_Q3SERVER)"." #ifdef Q3CLIENT
#endif " 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."); Cmd_AddCommandD ("cl_transfer", CL_Transfer_f, "Connect to a different server, disconnecting from the current server only when the new server replies.");

View file

@ -2636,8 +2636,9 @@ void MasterInfo_Refresh(void)
Master_LoadMasterList("servers.txt", false, MT_MASTERUDP, MP_QUAKEWORLD, 1); 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 #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("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)"); Master_AddMasterHTTP("https://www.quakeservers.net/lists/servers/global.txt",MT_MASTERHTTP, MP_QUAKEWORLD, "QuakeServers.net (http)");
#endif #endif

View file

@ -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. //#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 //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_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_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_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_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 //#define GAME_DEFAULTCMDS NULL //a string containing the things you want to exec in order to override default.cfg

View file

@ -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. //#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 //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_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_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_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_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 //#define GAME_DEFAULTCMDS NULL //a string containing the things you want to exec in order to override default.cfg

View file

@ -16,6 +16,7 @@
//#define GAME_FULLNAME FULLENGINENAME //full name of the game we're playing //#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_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_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_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_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 //#define GAME_DEFAULTCMDS NULL //a string containing the things you want to exec in order to override default.cfg

View file

@ -15,6 +15,7 @@
#define GAME_FULLNAME FULLENGINENAME //full name of the game we're playing #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_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-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_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_DOWNLOADSURL NULL //url for the package manger to update from
//#define GAME_DEFAULTCMDS NULL //a string containing the things you want to //#define GAME_DEFAULTCMDS NULL //a string containing the things you want to

View file

@ -3076,9 +3076,11 @@ ftenet_generic_connection_t *FTENET_Datagram_EstablishConnection(qboolean isserv
int family; int family;
int port; int port;
int bindtries; int bindtries;
const int bindmaxtries = 100;
int bufsz; int bufsz;
qboolean hybrid = false; qboolean hybrid = false;
int protocol; int protocol;
char addrstr[128];
switch(adr.type) switch(adr.type)
{ {
@ -3101,7 +3103,7 @@ ftenet_generic_connection_t *FTENET_Datagram_EstablishConnection(qboolean isserv
if (adr.type == NA_INVALID) 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 return NULL; //couldn't resolve the name
} }
temp = NetadrToSockadr(&adr, &qs); temp = NetadrToSockadr(&adr, &qs);
@ -3167,24 +3169,34 @@ ftenet_generic_connection_t *FTENET_Datagram_EstablishConnection(qboolean isserv
//try and find an unused port. //try and find an unused port.
port = ntohs(((struct sockaddr_in*)&qs)->sin_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 ((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; continue;
} }
break; break;
} }
if (!bindtries) if (bindtries == bindmaxtries)
{ {
SockadrToNetadr(&qs, &adr); SockadrToNetadr(&qs, &adr);
//mneh, reuse qs. NET_AdrToString(addrstr, sizeof(addrstr), &adr);
NET_AdrToString((char*)&qs, sizeof(qs), &adr); Con_Printf(CON_ERROR "Unable to listen at %s\n", addrstr);
Con_Printf("Unable to listen at %s\n", (char*)&qs);
closesocket(newsocket); closesocket(newsocket);
return NULL; 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) if (ioctlsocket (newsocket, FIONBIO, &_true) == -1)
Sys_Error ("UDP_OpenSocket: ioctl FIONBIO: %s", strerror(neterrno())); Sys_Error ("UDP_OpenSocket: ioctl FIONBIO: %s", strerror(neterrno()));
@ -7260,7 +7272,7 @@ void SVNET_AddPort_f(void)
{ {
svs.sockets = FTENET_CreateCollection(true); svs.sockets = FTENET_CreateCollection(true);
#ifndef SERVERONLY #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 #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); 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 #endif
#ifdef IPPROTO_IPV6 #ifdef IPPROTO_IPV6
void QDECL SV_PortIPv6_Callback(struct cvar_s *var, char *oldvalue) void QDECL SV_PortIPv6_Callback(struct cvar_s *var, char *oldvalue)
@ -7553,7 +7565,7 @@ void NET_InitServer(void)
{ {
svs.sockets = FTENET_CreateCollection(true); svs.sockets = FTENET_CreateCollection(true);
#ifndef SERVERONLY #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 #endif
} }
@ -7591,7 +7603,7 @@ void NET_InitServer(void)
#ifndef SERVERONLY #ifndef SERVERONLY
svs.sockets = FTENET_CreateCollection(true); 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 #endif
} }
} }

View file

@ -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_NQSERVER 26000
#define PORT_DPMASTER PORT_Q3MASTER #define PORT_DPMASTER PORT_Q3MASTER
#define PORT_QWCLIENT 27001 #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_Q3MASTER 27950
#define PORT_Q3SERVER 27960 #define PORT_Q3SERVER 27960
#ifdef GAME_DEFAULTPORT
#define PORT_DEFAULTSERVER GAME_DEFAULTPORT
#else
#define PORT_DEFAULTSERVER PORT_QWSERVER
#endif
//hexen2: 26900 //hexen2: 26900
//========================================= //=========================================

View file

@ -2235,26 +2235,26 @@ static int bi_lua_qtrue (lua_State *L)
break; break;
default: default:
// case LUA_TUSERDATA: // case LUA_TUSERDATA:
// case LUA_TTHREAD: // case LUA_TTHREAD:
// case LUA_TLIGHTUSERDATA: // case LUA_TLIGHTUSERDATA:
// case LUA_TNONE: // case LUA_TNONE:
// case LUA_TNIL: // case LUA_TNIL:
lua_pushboolean(L, false); lua_pushboolean(L, false);
break; break;
case LUA_TBOOLEAN: case LUA_TBOOLEAN:
lua_pushvalue(L, 1); lua_pushvalue(L, 1);
break; break;
case LUA_TNUMBER: case LUA_TNUMBER:
lua_pushboolean(L, lua_tonumber(L, 1) != 0); lua_pushboolean(L, lua_tonumber(L, 1) != 0);
break; break;
case LUA_TFUNCTION: //functions are always considered true. otherwise they're nil and not functions. case LUA_TFUNCTION: //functions are always considered true. otherwise they're nil and not functions.
lua_pushboolean(L, true); lua_pushboolean(L, true);
break; break;
case LUA_TTABLE: case LUA_TTABLE:
//might be a vector or an entity. //might be a vector or an entity.
lua_getfield(L, 1, "entnum"); lua_getfield(L, 1, "entnum");
if (!lua_isnil(L, -1)) if (!lua_isnil(L, -1))
{ //okay, so its a table with a valid entnum field. must be an entity. { //okay, so its a table with a valid entnum field. must be an entity.
@ -2264,10 +2264,10 @@ static int bi_lua_qtrue (lua_State *L)
{ //assume that its a vector. { //assume that its a vector.
//note that this means that any table without x|y|z fields will be considered false. //note that this means that any table without x|y|z fields will be considered false.
vec3_t v; vec3_t v;
lua_readvector(L, 1, v); lua_readvector(L, 1, v);
lua_pushboolean(L, v[0] || v[1] || v[2]); lua_pushboolean(L, v[0] || v[1] || v[2]);
} }
break; break;
} }
return 1; return 1;
} }