case SLIF_NUMHUMANS:
result = A->info.numhumans - B->info.numhumans;
break;
+ case SLIF_FREESLOTS:
+ result = A->info.freeslots - B->info.freeslots;
+ break;
case SLIF_PROTOCOL:
result = A->info.protocol - B->info.protocol;
break;
return false;
if( !_ServerList_CompareInt( info->numhumans, mask->tests[SLIF_NUMHUMANS], mask->info.numhumans ) )
return false;
+ if( !_ServerList_CompareInt( info->freeslots, mask->tests[SLIF_FREESLOTS], mask->info.freeslots ) )
+ return false;
if( !_ServerList_CompareInt( info->protocol, mask->tests[SLIF_PROTOCOL], mask->info.protocol ))
return false;
if( *mask->info.cname
return 0;
}
+qboolean NetConn_HaveClientPorts(void)
+{
+ return !!cl_numsockets;
+}
+
+qboolean NetConn_HaveServerPorts(void)
+{
+ return !!sv_numsockets;
+}
+
void NetConn_CloseClientPorts(void)
{
for (;cl_numsockets > 0;cl_numsockets--)
if ((s = SearchInfostring(string, "sv_maxclients")) != NULL) info->maxplayers = atoi(s);
if ((s = SearchInfostring(string, "gameversion" )) != NULL) info->gameversion = atoi(s);
info->numhumans = info->numplayers - max(0, info->numbots);
+ info->freeslots = info->maxplayers - info->numplayers;
NetConn_ClientParsePacket_ServerList_UpdateCache(n);
while (cl_sockets[i] && (length = NetConn_Read(cl_sockets[i], readbuffer, sizeof(readbuffer), &peeraddress)) > 0)
NetConn_ClientParsePacket(cl_sockets[i], readbuffer, length, &peeraddress);
NetConn_QueryQueueFrame();
- if (cls.netcon && realtime > cls.netcon->timeout)
+ if (cls.netcon && realtime > cls.netcon->timeout && !sv.active)
{
Con_Print("Connection timed out\n");
CL_Disconnect();
{
int i;
char *s = string + 5;
+ char *endpos = string + length + 1; // one behind the NUL, so adding strlen+1 will eventually reach it
char password[64];
for (i = 0;*s > ' ';s++)
if (i < (int)sizeof(password) - 1)
password[i++] = *s;
+ if(*s <= ' ' && s != endpos) // skip leading ugly space
+ ++s;
password[i] = 0;
if (password[0] > ' ' && !strcmp(rcon_password.string, password))
{
// looks like a legitimate rcon command with the correct password
- Con_Printf("server received rcon command from %s:\n%s\n", host_client ? host_client->name : addressstring2, s);
+ char *s_ptr = s;
+ Con_Printf("server received rcon command from %s:\n", host_client ? host_client->name : addressstring2);
+ while(s_ptr != endpos)
+ {
+ size_t l = strlen(s_ptr);
+ if(l)
+ Con_Printf(" %s;", s_ptr);
+ s_ptr += l + 1;
+ }
+ Con_Printf("\n");
rcon_redirect = true;
rcon_redirect_bufferpos = 0;
- Cmd_ExecuteString(s, src_command);
+ while(s != endpos)
+ {
+ size_t l = strlen(s);
+ if(l)
+ Cmd_ExecuteString(s, src_command);
+ s += l + 1;
+ }
rcon_redirect_buffer[rcon_redirect_bufferpos] = 0;
rcon_redirect = false;
// print resulting text to client
// protocol
// (this protects more modern protocols against being used for
// Quake packet flood Denial Of Service attacks)
- if (length >= 5 && (i = BigLong(*((int *)data))) && (i & (~NETFLAG_LENGTH_MASK)) == (int)NETFLAG_CTL && (i & NETFLAG_LENGTH_MASK) == length && (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE || sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3))
+ if (length >= 5 && (i = BigLong(*((int *)data))) && (i & (~NETFLAG_LENGTH_MASK)) == (int)NETFLAG_CTL && (i & NETFLAG_LENGTH_MASK) == length && (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE || sv.protocol == PROTOCOL_NEHAHRABJP || sv.protocol == PROTOCOL_NEHAHRABJP2 || sv.protocol == PROTOCOL_NEHAHRABJP3 || sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3))
{
int c;
int protocolnumber;