#ifdef CONFIG_MENU
static cvar_t sv_qwmasters [] =
{
- {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "sv_qwmaster1", "", "user-chosen qwmaster server 1"},
- {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "sv_qwmaster2", "", "user-chosen qwmaster server 2"},
- {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "sv_qwmaster3", "", "user-chosen qwmaster server 3"},
- {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "sv_qwmaster4", "", "user-chosen qwmaster server 4"},
- {CF_CLIENT | CF_SERVER, "sv_qwmasterextra1", "master.quakeservers.net:27000", "Global master server. (admin: unknown)"},
- {CF_CLIENT | CF_SERVER, "sv_qwmasterextra2", "asgaard.morphos-team.net:27000", "Global master server. (admin: unknown)"},
- {CF_CLIENT | CF_SERVER, "sv_qwmasterextra3", "qwmaster.ocrana.de:27000", "German master server. (admin: unknown)"},
- {CF_CLIENT | CF_SERVER, "sv_qwmasterextra4", "qwmaster.fodquake.net:27000", "Global master server. (admin: unknown)"},
+ {CF_CLIENT | CF_ARCHIVE, "sv_qwmaster1", "", "user-chosen qwmaster server 1"},
+ {CF_CLIENT | CF_ARCHIVE, "sv_qwmaster2", "", "user-chosen qwmaster server 2"},
+ {CF_CLIENT | CF_ARCHIVE, "sv_qwmaster3", "", "user-chosen qwmaster server 3"},
+ {CF_CLIENT | CF_ARCHIVE, "sv_qwmaster4", "", "user-chosen qwmaster server 4"},
+ {CF_CLIENT, "sv_qwmasterextra1", "master.quakeservers.net:27000", "Global master server. (admin: unknown)"},
+ {CF_CLIENT, "sv_qwmasterextra2", "asgaard.morphos-team.net:27000", "Global master server. (admin: unknown)"},
+ {CF_CLIENT, "sv_qwmasterextra3", "qwmaster.ocrana.de:27000", "German master server. (admin: unknown)"},
+ {CF_CLIENT, "sv_qwmasterextra4", "qwmaster.fodquake.net:27000", "Global master server. (admin: unknown)"},
};
#endif
conn->packetsReceived++;
reliable_message = (sequence >> 31) != 0;
reliable_ack = (sequence_ack >> 31) != 0;
- sequence &= ~(1<<31);
- sequence_ack &= ~(1<<31);
+ sequence &= ~(1u<<31);
+ sequence_ack &= ~(1u<<31);
if (sequence <= conn->qw.incoming_sequence)
{
//Con_DPrint("Got a stale datagram\n");
// update description strings for engine menu and console output
entry->line1_len = dpsnprintf(entry->line1, sizeof(serverlist_cache[n].line1), "^%c%5.0f^7 ^%c%3u^7/%3u %-65.65s",
info->ping >= 300 ? '1' : (info->ping >= 200 ? '3' : '7'),
- info->ping ?: INFINITY, // display inf when a listed server times out and net_slist_pause blocks its removal
+ info->ping ? info->ping : INFINITY, // display inf when a listed server times out and net_slist_pause blocks its removal
((info->numhumans > 0 && info->numhumans < info->maxplayers) ? (info->numhumans >= 4 ? '7' : '3') : '1'),
info->numplayers,
info->maxplayers,
size_t sendlength;
#ifdef CONFIG_MENU
char infostringvalue[MAX_INPUTLINE];
- const char *s;
#endif
// quakeworld ingame packet
string += 15;
// search the cache for this server and update it
// the challenge is (ab)used to return the query time
- s = InfoString_GetValue(string, "challenge", infostringvalue, sizeof(infostringvalue));
- n = NetConn_ClientParsePacket_ServerList_ProcessReply(addressstring2, s);
+ InfoString_GetValue(string, "challenge", infostringvalue, sizeof(infostringvalue));
+ n = NetConn_ClientParsePacket_ServerList_ProcessReply(addressstring2, infostringvalue);
if (n < 0)
return true;
info = &serverlist_cache[n].info;
- info->game[0] = '\0'; info->game_len = 0;
- info->mod[0] = '\0'; info->mod_len = 0;
- info->map[0] = '\0'; info->map_len = 0;
- info->name[0] = '\0'; info->name_len = 0;
- info->qcstatus[0] = '\0'; info->qcstatus_len = 0;
- info->players[0] = '\0'; info->players_len = 0;
- info->protocol = -1;
- info->numplayers = 0;
- info->numbots = -1;
- info->maxplayers = 0;
- info->gameversion = 0;
-
p = strchr(string, '\n');
if(p)
{
*p = 0; // cut off the string there
++p;
+ info->players_len = dp_strlcpy(info->players, p, sizeof(info->players));
}
else
+ {
Con_Printf("statusResponse without players block?\n");
-
- if ((s = InfoString_GetValue(string, "gamename" , infostringvalue, sizeof(infostringvalue))) != NULL) info->game_len = dp_strlcpy(info->game, s, sizeof(info->game));
- if ((s = InfoString_GetValue(string, "modname" , infostringvalue, sizeof(infostringvalue))) != NULL) info->mod_len = dp_strlcpy(info->mod, s, sizeof(info->mod));
- if ((s = InfoString_GetValue(string, "mapname" , infostringvalue, sizeof(infostringvalue))) != NULL) info->map_len = dp_strlcpy(info->map, s, sizeof(info->map));
- if ((s = InfoString_GetValue(string, "hostname" , infostringvalue, sizeof(infostringvalue))) != NULL) info->name_len = dp_strlcpy(info->name, s, sizeof(info->name));
- if ((s = InfoString_GetValue(string, "protocol" , infostringvalue, sizeof(infostringvalue))) != NULL) info->protocol = atoi(s);
- if ((s = InfoString_GetValue(string, "clients" , infostringvalue, sizeof(infostringvalue))) != NULL) info->numplayers = atoi(s);
- if ((s = InfoString_GetValue(string, "bots" , infostringvalue, sizeof(infostringvalue))) != NULL) info->numbots = atoi(s);
- if ((s = InfoString_GetValue(string, "sv_maxclients", infostringvalue, sizeof(infostringvalue))) != NULL) info->maxplayers = atoi(s);
- if ((s = InfoString_GetValue(string, "gameversion" , infostringvalue, sizeof(infostringvalue))) != NULL) info->gameversion = atoi(s);
- if ((s = InfoString_GetValue(string, "qcstatus" , infostringvalue, sizeof(infostringvalue))) != NULL) info->qcstatus_len = dp_strlcpy(info->qcstatus, s, sizeof(info->qcstatus));
- if (p != NULL) info->players_len = dp_strlcpy(info->players, p, sizeof(info->players));
+ info->players_len = info->players[0] = 0;
+ }
+ info->game_len = InfoString_GetValue(string, "gamename", info->game, sizeof(info->game));
+ info->mod_len = InfoString_GetValue(string, "modname", info->mod, sizeof(info->mod));
+ info->map_len = InfoString_GetValue(string, "mapname", info->map, sizeof(info->map));
+ info->name_len = InfoString_GetValue(string, "hostname", info->name, sizeof(info->name));
+ info->qcstatus_len = InfoString_GetValue(string, "qcstatus", info->qcstatus, sizeof(info->qcstatus));
+ info->protocol = InfoString_GetValue(string, "protocol" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : -1;
+ info->numplayers = InfoString_GetValue(string, "clients" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
+ info->numbots = InfoString_GetValue(string, "bots" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : -1;
+ info->maxplayers = InfoString_GetValue(string, "sv_maxclients", infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
+ info->gameversion = InfoString_GetValue(string, "gameversion" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
info->numhumans = info->numplayers - max(0, info->numbots);
info->freeslots = info->maxplayers - info->numplayers;
string += 13;
// search the cache for this server and update it
// the challenge is (ab)used to return the query time
- s = InfoString_GetValue(string, "challenge", infostringvalue, sizeof(infostringvalue));
- n = NetConn_ClientParsePacket_ServerList_ProcessReply(addressstring2, s);
+ InfoString_GetValue(string, "challenge", infostringvalue, sizeof(infostringvalue));
+ n = NetConn_ClientParsePacket_ServerList_ProcessReply(addressstring2, infostringvalue);
if (n < 0)
return true;
info = &serverlist_cache[n].info;
- info->game[0] = '\0'; info->game_len = 0;
- info->mod[0] = '\0'; info->mod_len = 0;
- info->map[0] = '\0'; info->map_len = 0;
- info->name[0] = '\0'; info->name_len = 0;
- info->qcstatus[0] = '\0'; info->qcstatus_len = 0;
- info->players[0] = '\0'; info->players_len = 0;
- info->protocol = -1;
- info->numplayers = 0;
- info->numbots = -1;
- info->maxplayers = 0;
- info->gameversion = 0;
-
- if ((s = InfoString_GetValue(string, "gamename" , infostringvalue, sizeof(infostringvalue))) != NULL) info->game_len = dp_strlcpy(info->game, s, sizeof(info->game));
- if ((s = InfoString_GetValue(string, "modname" , infostringvalue, sizeof(infostringvalue))) != NULL) info->mod_len = dp_strlcpy(info->mod, s, sizeof(info->mod));
- if ((s = InfoString_GetValue(string, "mapname" , infostringvalue, sizeof(infostringvalue))) != NULL) info->map_len = dp_strlcpy(info->map, s, sizeof(info->map));
- if ((s = InfoString_GetValue(string, "hostname" , infostringvalue, sizeof(infostringvalue))) != NULL) info->name_len = dp_strlcpy(info->name, s, sizeof(info->name));
- if ((s = InfoString_GetValue(string, "protocol" , infostringvalue, sizeof(infostringvalue))) != NULL) info->protocol = atoi(s);
- if ((s = InfoString_GetValue(string, "clients" , infostringvalue, sizeof(infostringvalue))) != NULL) info->numplayers = atoi(s);
- if ((s = InfoString_GetValue(string, "bots" , infostringvalue, sizeof(infostringvalue))) != NULL) info->numbots = atoi(s);
- if ((s = InfoString_GetValue(string, "sv_maxclients", infostringvalue, sizeof(infostringvalue))) != NULL) info->maxplayers = atoi(s);
- if ((s = InfoString_GetValue(string, "gameversion" , infostringvalue, sizeof(infostringvalue))) != NULL) info->gameversion = atoi(s);
- if ((s = InfoString_GetValue(string, "qcstatus" , infostringvalue, sizeof(infostringvalue))) != NULL) info->qcstatus_len = dp_strlcpy(info->qcstatus, s, sizeof(info->qcstatus));
+ info->players_len = info->players[0] = 0;
+ info->game_len = InfoString_GetValue(string, "gamename", info->game, sizeof(info->game));
+ info->mod_len = InfoString_GetValue(string, "modname", info->mod, sizeof(info->mod));
+ info->map_len = InfoString_GetValue(string, "mapname", info->map, sizeof(info->map));
+ info->name_len = InfoString_GetValue(string, "hostname", info->name, sizeof(info->name));
+ info->qcstatus_len = InfoString_GetValue(string, "qcstatus", info->qcstatus, sizeof(info->qcstatus));
+ info->protocol = InfoString_GetValue(string, "protocol" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : -1;
+ info->numplayers = InfoString_GetValue(string, "clients" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
+ info->numbots = InfoString_GetValue(string, "bots" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : -1;
+ info->maxplayers = InfoString_GetValue(string, "sv_maxclients", infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
+ info->gameversion = InfoString_GetValue(string, "gameversion" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
info->numhumans = info->numplayers - max(0, info->numbots);
info->freeslots = info->maxplayers - info->numplayers;
#ifdef CONFIG_MENU
serverlist_info_t *info;
int n;
+ const char *s;
// qw server status
if (serverlist_consoleoutput && developer_networking.integer >= 2)
info = &serverlist_cache[n].info;
dp_strlcpy(info->game, "QuakeWorld", sizeof(info->game));
- if ((s = InfoString_GetValue(string, "*gamedir" , infostringvalue, sizeof(infostringvalue))) != NULL) info->mod_len = dp_strlcpy(info->mod, s, sizeof(info->mod));
- else { info->mod[0] = '\0'; info->mod_len = 0; }
- if ((s = InfoString_GetValue(string, "map" , infostringvalue, sizeof(infostringvalue))) != NULL) info->map_len = dp_strlcpy(info->map, s, sizeof(info->map));
- else { info->map[0] = '\0'; info->map_len = 0; }
- if ((s = InfoString_GetValue(string, "hostname" , infostringvalue, sizeof(infostringvalue))) != NULL) info->name_len = dp_strlcpy(info->name, s, sizeof(info->name));
- else { info->name[0] = '\0'; info->name_len = 0; }
+ info->mod_len = InfoString_GetValue(string, "*gamedir", info->mod, sizeof(info->mod));
+ info->map_len = InfoString_GetValue(string, "map" , info->map, sizeof(info->map));
+ info->name_len = InfoString_GetValue(string, "hostname", info->name, sizeof(info->name));
info->protocol = 0;
info->numplayers = 0; // updated below
info->numhumans = 0; // updated below
- if ((s = InfoString_GetValue(string, "maxclients" , infostringvalue, sizeof(infostringvalue))) != NULL) info->maxplayers = atoi(s);else info->maxplayers = 0;
- if ((s = InfoString_GetValue(string, "gameversion" , infostringvalue, sizeof(infostringvalue))) != NULL) info->gameversion = atoi(s);else info->gameversion = 0;
+ info->maxplayers = InfoString_GetValue(string, "maxclients" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
+ info->gameversion = InfoString_GetValue(string, "gameversion", infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
// count active players on server
// (we could gather more info, but we're just after the number)
while((userpass_end = strchr(userpass_start, ' ')))
{
have_usernames = true;
- dp_strlcpy(buf, userpass_start, ((size_t)(userpass_end-userpass_start) >= sizeof(buf)) ? (int)(sizeof(buf)) : (int)(userpass_end-userpass_start+1));
+ dp_ustr2stp(buf, sizeof(buf), userpass_start, userpass_end - userpass_start);
if(buf[0]) // Ignore empty entries due to leading/duplicate space.
if(comparator(peeraddress, buf, password, cs, cslen))
goto allow;
while((userpass_end = strchr(userpass_start, ' ')))
{
have_usernames = true;
- dp_strlcpy(buf, userpass_start, ((size_t)(userpass_end-userpass_start) >= sizeof(buf)) ? (int)(sizeof(buf)) : (int)(userpass_end-userpass_start+1));
+ dp_ustr2stp(buf, sizeof(buf), userpass_start, userpass_end - userpass_start);
if(buf[0]) // Ignore empty entries due to leading/duplicate space.
if(comparator(peeraddress, buf, password, cs, cslen))
goto check;
if(l)
{
client_t *host_client_save = host_client;
- //Cmd_ExecuteString(cmd_local, s, src_local, true); // no variable expansion
- // bones_was_here: prepending allows a loop such as `alias foo "bar; wait; foo"; foo`
- // to be broken with an alias or unalias command
- Cbuf_InsertText(cmd_local, s);
+ Cmd_PreprocessAndExecuteString(cmd_local, s, l, src_local, true);
host_client = host_client_save;
// in case it is a command that changes host_client (like restart)
}
}
else
{
- Con_Printf("server denied rcon access to %s\n", host_client ? host_client->name : addressstring2);
+ if (!host_client || !host_client->netconnection || LHNETADDRESS_GetAddressType(&host_client->netconnection->peeraddress) != LHNETADDRESSTYPE_LOOP)
+ Con_Rcon_Redirect_Init(mysocket, peeraddress, proquakeprotocol);
+ Con_Printf(CON_ERROR "server denied rcon access to %s\n", host_client ? host_client->name : addressstring2);
+ Con_Rcon_Redirect_End();
}
}
}
if (length > 8 && !memcmp(string, "connect\\", 8))
{
- char *s;
client_t *client;
crypto_t *crypto = Crypto_ServerGetInstance(peeraddress);
string += 7;
}
else
{
- if ((s = InfoString_GetValue(string, "challenge", infostringvalue, sizeof(infostringvalue))))
+ if (InfoString_GetValue(string, "challenge", infostringvalue, sizeof(infostringvalue)))
{
// validate the challenge
for (i = 0;i < MAX_CHALLENGES;i++)
if(challenges[i].time > 0)
- if (!LHNETADDRESS_Compare(peeraddress, &challenges[i].address) && !strcmp(challenges[i].string, s))
+ if (!LHNETADDRESS_Compare(peeraddress, &challenges[i].address) && !strcmp(challenges[i].string, infostringvalue))
break;
// if the challenge is not recognized, drop the packet
if (i == MAX_CHALLENGES)
}
}
- if((s = InfoString_GetValue(string, "message", infostringvalue, sizeof(infostringvalue))))
- Con_DPrintf("Connecting client %s sent us the message: %s\n", addressstring2, s);
+ if(InfoString_GetValue(string, "message", infostringvalue, sizeof(infostringvalue)))
+ Con_DPrintf("Connecting client %s sent us the message: %s\n", addressstring2, infostringvalue);
if(!(islocal || sv_public.integer > -2))
{
}
// check engine protocol
- if(!(s = InfoString_GetValue(string, "protocol", infostringvalue, sizeof(infostringvalue))) || strcmp(s, "darkplaces 3"))
+ if(!InfoString_GetValue(string, "protocol", infostringvalue, sizeof(infostringvalue)) || strcmp(infostringvalue, "darkplaces 3"))
{
if (developer_extra.integer)
Con_Printf("Datagram_ParseConnectionless: sending \"reject Wrong game protocol.\" to %s.\n", addressstring2);
LHNETADDRESS_ToString(LHNET_AddressFromSocket(mysocket), myaddressstring, sizeof(myaddressstring), true);
MSG_WriteString(&sv_message, myaddressstring);
MSG_WriteString(&sv_message, hostname.string);
- MSG_WriteString(&sv_message, sv.name);
+ MSG_WriteString(&sv_message, sv.worldbasename);
// How many clients are there?
for (i = 0, numclients = 0;i < svs.maxclients;i++)
if (svs.clients[i].active)
void NetConn_Init(void)
{
int i;
+ unsigned j;
lhnetaddress_t tempaddress;
+
netconn_mempool = Mem_AllocPool("network connections", 0, NULL);
Cmd_AddCommand(CF_SHARED, "net_stats", Net_Stats_f, "print network statistics");
#ifdef CONFIG_MENU
Cvar_RegisterVariable(&sv_public);
Cvar_RegisterVariable(&sv_public_rejectreason);
Cvar_RegisterVariable(&sv_heartbeatperiod);
- for (uint8_t masternum = 0; masternum < DPMASTER_COUNT; ++masternum)
- Cvar_RegisterVariable(&sv_masters[masternum]);
+ for (j = 0; j < DPMASTER_COUNT; ++j)
+ Cvar_RegisterVariable(&sv_masters[j]);
+#ifdef CONFIG_MENU
+ for (j = 0; j < QWMASTER_COUNT; ++j)
+ Cvar_RegisterVariable(&sv_qwmasters[j]);
+#endif
Cvar_RegisterVariable(&gameversion);
Cvar_RegisterVariable(&gameversion_min);
Cvar_RegisterVariable(&gameversion_max);