]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote branch 'origin/samual/samualbalance'
authorRudolf Polzer <divverent@alientrap.org>
Sun, 14 Nov 2010 16:46:59 +0000 (17:46 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Sun, 14 Nov 2010 16:46:59 +0000 (17:46 +0100)
defaultXonotic.cfg
qcsrc/server/cl_client.qc
qcsrc/server/clientcommands.qc
qcsrc/server/defs.qh
qcsrc/server/g_world.qc
qcsrc/server/gamecommand.qc
qcsrc/server/teamplay.qc

index ec539074d86e6b6ac7c0f0fe1dba5dcb82be9d3f..e1670b137608947ec0e11a042b37f59968d9964a 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 8151aa5f128caf2e16ff6acff4a8f34109da729d..97bffaacc43b9dc22f706b11ce019f1d73bbd76d 100644 (file)
@@ -1414,6 +1414,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
@@ -1469,9 +1490,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)
@@ -2339,7 +2388,7 @@ void ShowRespawnCountdown()
 void LeaveSpectatorMode()
 {
        if(isJoinAllowed()) {
-               if(!teams_matter || cvar("g_campaign") || cvar("g_balance_teams") || (self.wasplayer && cvar("g_changeteam_banned"))) {
+               if(!teams_matter || cvar("g_campaign") || cvar("g_balance_teams") || (self.wasplayer && cvar("g_changeteam_banned")) || self.team_forced > 0) {
                        self.classname = "player";
 
                        if(cvar("g_campaign") || cvar("g_balance_teams") || cvar("g_balance_teams_force"))
@@ -2380,6 +2429,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 df19ab592f4779beb94a38881992e37150a43ae0..0cbe3017eae1ef889844324e8649a1c6cf036d8b 100644 (file)
@@ -171,7 +171,7 @@ void SV_ParseClientCommand(string s) {
                        PutClientInServer();
                } else if(cvar("g_campaign") || cvar("g_balance_teams") || cvar("g_balance_teams_force")) {
                        //JoinBestTeam(self, FALSE, TRUE);
-               } else if(teams_matter && !cvar("sv_spectate")) {
+               } else if(teams_matter && !cvar("sv_spectate") && !(self.team_forced > 0)) {
                        self.classname = "observer";
                        stuffcmd(self,"menu_showteamselect\n");
                }
@@ -249,9 +249,11 @@ void SV_ParseClientCommand(string s) {
                if not(self.flags & FL_CLIENT)
                        return;
                if( !teams_matter ) {
-                       sprint( self, "selecteam can only be used in teamgames\n");
+                       sprint( self, "selectteam can only be used in teamgames\n");
                } else if(cvar("g_campaign")) {
                        //JoinBestTeam(self, 0);
+               } else if(self.team_forced > 0) {
+                       sprint( self, "selectteam can not be used as your team is forced\n");
                } else if(lockteams) {
                        sprint( self, "^7The game has already begun, you must wait until the next map to be able to join a team.\n");
                } else if( argv(1) == "red" ) {
index 5302aef503b1b851ff1a17437aa7135bec98d2d8..d369298a56cd5b679a7113934831a7878d2476ba 100644 (file)
@@ -659,3 +659,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 688b5e416f881b55b7507d7d62a892bd1adda9a7..f381612c3f7843a427fa43724cc16e7919b0edec 100644 (file)
@@ -272,7 +272,21 @@ void cvar_changes_init()
                BADCVAR("bgmvolume");
 
                // private
+               BADCVAR("developer");
+               BADCVAR("g_banned_list");
+               BADCVAR("log_dest_udp");
+               BADCVAR("log_file");
+               BADCVAR("net_address");
+               BADCVAR("net_address_ipv6");
+               BADCVAR("port");
+               BADCVAR("savedgamecfg");
                BADCVAR("serverconfig");
+               BADCVAR("sv_heartbeatperiod");
+               BADCVAR("sv_vote_master_password");
+               BADCVAR("sys_colortranslation");
+               BADCVAR("sys_specialcharactertranslation");
+               BADCVAR("timestamps");
+               BADPREFIX("developer_");
                BADPREFIX("g_ban_");
                BADPREFIX("g_chat_flood_");
                BADPREFIX("g_voice_flood_");
@@ -284,22 +298,13 @@ void cvar_changes_init()
                BADPREFIX("sv_eventlog");
                BADPREFIX("sv_logscores_");
                BADPREFIX("sv_master");
-               BADCVAR("g_banned_list");
-               BADCVAR("log_dest_udp");
-               BADCVAR("log_file");
-               BADCVAR("net_address");
-               BADCVAR("port");
-               BADCVAR("savedgamecfg");
-               BADCVAR("sv_heartbeatperiod");
-               BADCVAR("sv_vote_master_password");
-               BADCVAR("sys_colortranslation");
-               BADCVAR("sys_specialcharactertranslation");
-               BADCVAR("timestamps");
-               BADCVAR("net_address");
-               BADCVAR("net_address_ipv6");
                BADPREFIX("sv_weaponstats_");
-               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");
@@ -363,6 +368,7 @@ void cvar_changes_init()
                BADCVAR("sv_checkforpacketsduringsleep");
                BADPREFIX("crypto_");
                BADPREFIX("g_chat_");
+               BADPREFIX("net_");
                BADPREFIX("prvm_");
                BADPREFIX("sv_fragmessage_");
                BADPREFIX("sv_vote_");
@@ -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 90b06a5a3d92a5950fa42d3213263c4f337db8e3..8e63beecc33793b7c3611434f609953b76988a98 100644 (file)
@@ -801,16 +801,15 @@ void GameCommand(string command)
                        bprint("That command can only be used in a team-based gamemode.\n");
                return;
        }
-       if(argv(0) == "movetoteam")
-       if(argc == 3 || argc == 4) {
-//     sv_cmd movetoteam  player_id  team_colour
-//     sv_cmd movetoteam  player_id  team_colour  type_of_move
+       if(argv(0) == "movetoteam") if(argc == 3 || argc == 4) {
+               //      sv_cmd movetoteam  player_id  team_colour
+               //      sv_cmd movetoteam  player_id  team_colour  type_of_move
 
-//     type of move
-//     0 (00) automove centerprint, admin message
-//     1 (01) automove centerprint, no admin message
-//     2 (10) no centerprint, admin message
-//     3 (11) no centerprint, no admin message
+               //      type of move
+               //      0 (00) automove centerprint, admin message
+               //      1 (01) automove centerprint, no admin message
+               //      2 (10) no centerprint, admin message
+               //      3 (11) no centerprint, no admin message
 
                if(!teams_matter) {  // death match
                        print("Currently not playing a team game\n");
@@ -825,7 +824,7 @@ void GameCommand(string command)
                        return;
                }
 
-                       client = edict_num(entno);
+               client = edict_num(entno);
 
                // player entity is not a client
                if not(client.flags & FL_CLIENT) {
@@ -835,43 +834,52 @@ void GameCommand(string command)
 
                // find the team to move the player to
                float team_colour;
+               float save;
+
+               save = client.team_forced;
+               client.team_forced = 0;
 
                team_colour = ColourToNumber(argv(2));
 
                if(team_colour == client.team) {  // player already on the team
                        print("Player ", argv(1), " (", client.netname, ") is already on the ", ColoredTeamName(client.team), "\n");
+                       // keep the forcing undone
                        return;
                } else if(team_colour == 0)  // auto team
                        team_colour = NumberToTeamNumber(FindSmallestTeam(client, FALSE));
+               else
+                       CheckAllowedTeams(client);
+
+               client.team_forced = save;
 
                switch(team_colour) {
                        case COLOR_TEAM1:
                                if(c1 == -1) {
                                        print("Sorry, there isn't a red team\n");
                                        return;
-               }
-                       break;
+                               }
+                               break;
 
                        case COLOR_TEAM2:
                                if(c2 == -1) {
                                        print("Sorry, there isn't a blue team\n");
-               return;
-       }
-                       break;
+                                       return;
+                               }
+                               break;
 
                        case COLOR_TEAM3:
                                if(c3 == -1) {
                                        print("Sorry, there isn't a yellow team\n");
                                        return;
                                }
-                       break;
+                               break;
 
                        case COLOR_TEAM4:
                                if(c4 == -1) {
                                        print("Sorry, there isn't a pink team\n");
                                        return;
                                }
-                       break;
+                               break;
 
                        default:
                                print("Sorry, team ", argv(2), " doesn't exist\n");
@@ -879,6 +887,7 @@ void GameCommand(string command)
                }
                print("Player ", argv(1), " (", client.netname, ") has been moved to the ", ColoredTeamName(team_colour), "\n");
 
+               client.team_forced = 0;
                MoveToTeam(client, team_colour, 6, stof(argv(3)));
 
                return;
index 13680e68a8a2719c32ad396fbdef8ef692899e68..b9064c783b852a515586ade5e0826b3323380bf9 100644 (file)
@@ -707,6 +707,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)
@@ -793,7 +803,7 @@ float FindSmallestTeam(entity pl, float ignore_pl)
        if(c4 >= 0)
                totalteams = totalteams + 1;
 
-       if(cvar("bot_vs_human") && totalteams == 1)
+       if((cvar("bot_vs_human") || pl.team_forced > 0) && totalteams == 1)
                totalteams += 1;
 
        if(totalteams <= 1)