Index: sv_main.c =================================================================== RCS file: /cvsroot/paintball2/paintball2/server/sv_main.c,v retrieving revision 1.47 diff -u -r1.47 sv_main.c --- sv_main.c 29 Sep 2009 17:36:47 -0000 1.47 +++ sv_main.c 11 Dec 2009 16:15:57 -0000 @@ -61,6 +61,9 @@ cvar_t *sv_locked; // T3RR0R15T: Locked server. Prevent new players from connecting. (from R1Q2) +cvar_t *sv_reserved_slots; // T3RR0R15T: Reserved slots (from R1Q2) +cvar_t *sv_reserved_password; // T3RR0R15T: Reserved slots (from R1Q2) + cvar_t *sv_certificated; // T3RR0R15T: certificated server info void Master_Shutdown (void); @@ -149,6 +152,7 @@ */ char *SV_StatusString (void) { + char *serverinfo; // T3RR0R15T char player[1024]; static char status[MAX_MSGLEN - 16]; int i; @@ -156,7 +160,12 @@ int statusLength; int playerLength; - strcpy(status, Cvar_Serverinfo()); + serverinfo = Cvar_Serverinfo(); + + // T3RR0R15T: hide reserved slots + Info_SetValueForKey (serverinfo, "maxclients", va("%d", (int)maxclients->value - (int)sv_reserved_slots->value)); + + strcpy(status, serverinfo); strcat(status, "\n"); statusLength = strlen(status); @@ -247,7 +256,7 @@ if (svs.clients[i].state >= cs_connected) count++; - Com_sprintf(string, sizeof(string), "%16s %8s %2i/%2i\n", hostname->string, sv.name, count, (int)maxclients->value); + Com_sprintf(string, sizeof(string), "%16s %8s %2i/%2i\n", hostname->string, sv.name, count, (int)maxclients->value - (int)sv_reserved_slots->value); // T3RR0R15T: hide reserved slots } Netchan_OutOfBandPrint(NS_SERVER, net_from, "info\n%s", string); @@ -330,6 +339,8 @@ int version; int qport; int challenge; + char *pass; // T3RR0R15T: Reserved slots (from R1Q2) + int reserved; // T3RR0R15T: Reserved slots (from R1Q2) adr = net_from; Com_DPrintf("SVC_DirectConnect ()\n"); @@ -391,6 +402,22 @@ return; } + // T3RR0R15T: Reserved slots (from R1Q2) + pass = Info_ValueForKey (userinfo, "password"); + + if (sv_reserved_password->string[0] && !strcmp (pass, sv_reserved_password->string)) + { + reserved = 0; + //r1: this prevents mod/admin dll from also checking password as some mods incorrectly + //refuse if password cvar exists and no password is set on the server. by definition a + //server with reserved slots should be public anyway. + Info_RemoveKey (userinfo, "password"); + } + else + { + reserved = (int)sv_reserved_slots->value; + } + newcl = &temp; memset(newcl, 0, sizeof(client_t)); @@ -418,7 +445,7 @@ // find a client slot newcl = NULL; - for (i = 0, cl = svs.clients; i < maxclients->value; i++, cl++) + for (i = 0, cl = svs.clients; i < ((int)maxclients->value - reserved); i++, cl++) { if (cl->state == cs_free) { @@ -427,10 +454,19 @@ } } + // T3RR0R15T: Added reserved slots (from R1Q2) if (!newcl) { - Netchan_OutOfBandPrint(NS_SERVER, adr, "print\nServer is full.\n"); - Com_DPrintf("Rejected a connection.\n"); + if ((int)sv_reserved_slots->value && !reserved) + { + Netchan_OutOfBandPrint (NS_SERVER, adr, "print\nServer and reserved slots are full.\n"); + Com_DPrintf ("Reserved slots full\n"); + } + else + { + Netchan_OutOfBandPrint (NS_SERVER, adr, "print\nServer is full.\n"); + Com_DPrintf ("Server full\n"); + } return; } @@ -1429,6 +1465,8 @@ sv_cullentities= Cvar_Get("sv_cullentities", "0", 0); sv_noextascii = Cvar_Get("sv_noextascii", "1", 0); // jit sv_locked = Cvar_Get("sv_locked", "0", 0); // T3RR0R15T: Locked server. Prevent new players from connecting. (from R1Q2) + sv_reserved_slots = Cvar_Get("sv_reserved_slots", "0", CVAR_LATCH); // T3RR0R15T: Number of reserved player slots. (from R1Q2) + sv_reserved_password = Cvar_Get("sv_reserved_password", "", 0); // T3RR0R15T: Password required to access a reserved player slot. Clients should set their 'password' cvar to this. (from R1Q2) allow_download = Cvar_Get("allow_download", "1", CVAR_ARCHIVE); allow_download_players = Cvar_Get("allow_download_players", "1", CVAR_ARCHIVE); // jit, default to 1 allow_download_models = Cvar_Get("allow_download_models", "1", CVAR_ARCHIVE);