]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
forcing teams by player ID (usign cvars g_forced_team_*)
authorRudolf Polzer <divVerent@xonotic.org>
Thu, 11 Nov 2010 13:12:01 +0000 (14:12 +0100)
committerRudolf Polzer <divVerent@xonotic.org>
Thu, 11 Nov 2010 13:13:21 +0000 (14:13 +0100)
defaultXonotic.cfg
qcsrc/server/cl_client.qc
qcsrc/server/defs.qh
qcsrc/server/g_world.qc
qcsrc/server/teamplay.qc

index 19d728abe3199de275004d1c0e5355f138592652..12e66aa76452938119b32358c03396147c830cf1 100644 (file)
@@ -2012,6 +2012,14 @@ mod_q3shader_default_polygonfactor 0
 // allow fullbright
 set sv_allow_fullbright 0 "when set, clients may use r_fullbright on this server without getting a night vision effect overlay"
 
+// auto-teams (team selection by player ID)
+// any player not listed is forced to spectate
+set g_forced_team_red "" "list of player IDs for red team"
+set g_forced_team_blue "" "list of player IDs for blue team"
+set g_forced_team_yellow "" "list of player IDs for yellow team"
+set g_forced_team_pink "" "list of player IDs for pink team"
+set g_forced_team_otherwise "default" "action if a non listed player joins (can be default for default action, spectate for forcing to spectate, or red, blue, yellow, pink)"
+
 // other config files
 exec balanceXonotic.cfg
 exec ctfscoring-ai.cfg
index 1438d317c76947d9fd04cec4477a49f1d5b15e15..750590a84210a76597f1a42f5b5308b87fcc8eeb 100644 (file)
@@ -1408,6 +1408,27 @@ void FixClientCvars(entity e)
         */
 }
 
+float PlayerInIDList(entity p, string idlist)
+{
+       float n, i;
+       string s;
+
+       // NOTE: we do NOT check crypto_keyfp here, an unsigned ID is fine too for this
+       if not(p.crypto_idfp)
+               return 0;
+
+       // this function allows abbreviated player IDs too!
+       n = tokenize_console(idlist);
+       for(i = 0; i < n; ++i)
+       {
+               s = argv(i);
+               if(s == substring(p.crypto_idfp, 0, strlen(s)))
+                       return 1;
+       }
+
+       return 0;
+}
+
 /*
 =============
 ClientConnect
@@ -1463,9 +1484,37 @@ void ClientConnect (void)
        //if(g_domination)
        //      dom_player_join_team(self);
 
+       // identify the right forced team
+       if(PlayerInIDList(self, cvar_string("g_forced_team_red")))
+               self.team_forced = COLOR_TEAM1;
+       else if(PlayerInIDList(self, cvar_string("g_forced_team_blue")))
+               self.team_forced = COLOR_TEAM2;
+       else if(PlayerInIDList(self, cvar_string("g_forced_team_yellow")))
+               self.team_forced = COLOR_TEAM3;
+       else if(PlayerInIDList(self, cvar_string("g_forced_team_pink")))
+               self.team_forced = COLOR_TEAM4;
+       else if(cvar_string("g_forced_team_otherwise") == "red")
+               self.team_forced = COLOR_TEAM1;
+       else if(cvar_string("g_forced_team_otherwise") == "blue")
+               self.team_forced = COLOR_TEAM2;
+       else if(cvar_string("g_forced_team_otherwise") == "yellow")
+               self.team_forced = COLOR_TEAM3;
+       else if(cvar_string("g_forced_team_otherwise") == "pink")
+               self.team_forced = COLOR_TEAM4;
+       else if(cvar_string("g_forced_team_otherwise") == "spectate")
+               self.team_forced = -1;
+       else if(cvar_string("g_forced_team_otherwise") == "spectator")
+               self.team_forced = -1;
+       else
+               self.team_forced = 0;
+
+       if(!teams_matter)
+               if(self.team_forced > 0)
+                       self.team_forced = 0;
+
        JoinBestTeam(self, FALSE, FALSE); // if the team number is valid, keep it
 
-       if((cvar("sv_spectate") == 1 && !g_lms) || cvar("g_campaign")) {
+       if((cvar("sv_spectate") == 1 && !g_lms) || cvar("g_campaign") || self.team_forced < 0) {
                self.classname = "observer";
        } else {
                if(teams_matter)
@@ -2379,6 +2428,9 @@ void LeaveSpectatorMode()
  * @return bool TRUE if the player is allowed to join, false otherwise
  */
 float isJoinAllowed() {
+       if(self.team_forced < 0)
+               return FALSE; // forced spectators can never join
+
        if (!cvar("g_maxplayers"))
                return TRUE;
 
index 74797441c38a10965614bc19763352330d3bbd9b..4e5a6bfced33d959f054d8ef724c853c7379f8d5 100644 (file)
@@ -662,3 +662,5 @@ string deathmessage;
 float allowed_to_spawn; // boolean variable used by the clan arena code to determine if a player can spawn (after the round has ended)
 
 float serverflags;
+
+.float team_forced; // can be a team number to force a team, or 0 for default action, or -1 for forced spectator
index c5abb52f592ed30d817fa21574035e64b9f7a207..9e911be07d038ccc0786957458379c5a5bfe9f3d 100644 (file)
@@ -301,6 +301,12 @@ void cvar_changes_init()
                BADCVAR("developer");
                BADPREFIX("developer_");
 
+               // these can contain player IDs, so better hide
+               BADCVAR("g_forced_team_red");
+               BADCVAR("g_forced_team_blue");
+               BADCVAR("g_forced_team_yellow");
+               BADCVAR("g_forced_team_pink");
+
                // mapinfo
                BADCVAR("timelimit");
                BADCVAR("fraglimit");
@@ -437,6 +443,12 @@ void cvar_changes_init()
                BADCVAR("sv_vote_master_password");
                BADCVAR("sv_vote_simple_majority_factor");
                BADCVAR("timelimit_override");
+
+               if(cvar("g_minstagib"))
+               {
+                       BADCVAR("g_grappling_hook");
+                       BADCVAR("g_jetpack");
+               }
 #undef BADPREFIX
 #undef BADCVAR
 
index 1232e3c8eb9262f180e8bb97279fdaf761f29181..d9d71bc0985c38c4cd42624d83cd6552387cea22 100644 (file)
@@ -711,6 +711,16 @@ void CheckAllowedTeams (entity for_whom)
                                c1 = -1;
                }
        }
+
+       // if player has a forced team, ONLY allow that one
+       if(self.team_forced == COLOR_TEAM1 && c1 >= 0)
+               c2 = c3 = c4 = -1;
+       else if(self.team_forced == COLOR_TEAM2 && c2 >= 0)
+               c1 = c3 = c4 = -1;
+       else if(self.team_forced == COLOR_TEAM3 && c3 >= 0)
+               c1 = c2 = c4 = -1;
+       else if(self.team_forced == COLOR_TEAM4 && c4 >= 0)
+               c1 = c2 = c3 = -1;
 }
 
 float PlayerValue(entity p)