]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'Lyberta/TeamplayOverhaul2' into 'master'
authorMario <zacjardine@y7mail.com>
Fri, 7 Sep 2018 19:12:55 +0000 (19:12 +0000)
committerMario <zacjardine@y7mail.com>
Fri, 7 Sep 2018 19:12:55 +0000 (19:12 +0000)
Teamplay overhaul - step 2

Closes #1982 and #2071

See merge request xonotic/xonotic-data.pk3dir!581

1  2 
qcsrc/server/client.qc
qcsrc/server/command/cmd.qc

diff --combined qcsrc/server/client.qc
index 262d1d1a7d12425cfcec14c609c267f10eb73775,2d0ec2617b2c826dd9dff87608f0bf83752fbaf0..8e6a26961b02c6b845103254f56222496d24a10e
@@@ -285,25 -285,11 +285,11 @@@ void PutObserverInServer(entity this
  
        WaypointSprite_PlayerDead(this);
  
-       if (mutator_returnvalue) {
-           // mutator prevents resetting teams+score
-       } else {
-               Player_SetTeamIndex(this, -1);
-               this.frags = FRAGS_SPECTATOR;
-         PlayerScore_Clear(this);  // clear scores when needed
-     }
        if (CS(this).killcount != FRAGS_SPECTATOR)
        {
-               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, this.netname);
                if(!game_stopped)
                if(autocvar_g_chat_nospectators == 1 || (!warmup_stage && autocvar_g_chat_nospectators == 2))
                        Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_CHAT_NOSPECTATORS);
-               if(!CS(this).just_joined)
-                       LogTeamchange(this.playerid, -1, TEAM_CHANGE_SPECTATOR);
-               else
-                       CS(this).just_joined = false;
        }
  
        accuracy_resend(this);
                if(axh.owner == this && axh != NULL && !wasfreed(axh))
                        delete(axh);
        }
+       
+       if (mutator_returnvalue)
+       {
+               // mutator prevents resetting teams+score
+       }
+       else
+       {
+               SetPlayerTeam(this, -1, TEAM_CHANGE_SPECTATOR);
+               this.frags = FRAGS_SPECTATOR;
+     }
  }
  
  int player_getspecies(entity this)
@@@ -1070,38 -1066,7 +1066,7 @@@ void ClientConnect(entity this
  
        bot_clientconnect(this);
  
-       // identify the right forced team
-       if (autocvar_g_campaign)
-       {
-               if (IS_REAL_CLIENT(this)) // only players, not bots
-               {
-                       switch (autocvar_g_campaign_forceteam)
-                       {
-                               case 1: this.team_forced = NUM_TEAM_1; break;
-                               case 2: this.team_forced = NUM_TEAM_2; break;
-                               case 3: this.team_forced = NUM_TEAM_3; break;
-                               case 4: this.team_forced = NUM_TEAM_4; break;
-                               default: this.team_forced = 0;
-                       }
-               }
-       }
-       else if (PlayerInList(this, autocvar_g_forced_team_red))    this.team_forced = NUM_TEAM_1;
-       else if (PlayerInList(this, autocvar_g_forced_team_blue))   this.team_forced = NUM_TEAM_2;
-       else if (PlayerInList(this, autocvar_g_forced_team_yellow)) this.team_forced = NUM_TEAM_3;
-       else if (PlayerInList(this, autocvar_g_forced_team_pink))   this.team_forced = NUM_TEAM_4;
-       else switch (autocvar_g_forced_team_otherwise)
-       {
-               default: this.team_forced = 0; break;
-               case "red": this.team_forced = NUM_TEAM_1; break;
-               case "blue": this.team_forced = NUM_TEAM_2; break;
-               case "yellow": this.team_forced = NUM_TEAM_3; break;
-               case "pink": this.team_forced = NUM_TEAM_4; break;
-               case "spectate":
-               case "spectator":
-                       this.team_forced = -1;
-                       break;
-       }
-       if (!teamplay && this.team_forced > 0) this.team_forced = 0;
+       Player_DetermineForcedTeam(this);
  
        TRANSMUTE(Observer, this);
  
@@@ -1647,7 -1612,7 +1612,7 @@@ void GetPressedKeys(entity this
        keys = BITSET(keys, KEY_LEFT,           CS(this).movement.y < 0);
  
        keys = BITSET(keys, KEY_JUMP,           PHYS_INPUT_BUTTON_JUMP(this));
 -      keys = BITSET(keys, KEY_CROUCH,         PHYS_INPUT_BUTTON_CROUCH(this));
 +      keys = BITSET(keys, KEY_CROUCH,         IS_DUCKED(this)); // workaround: player can't un-crouch until their path is clear, so we keep the button held here
        keys = BITSET(keys, KEY_ATCK,           PHYS_INPUT_BUTTON_ATCK(this));
        keys = BITSET(keys, KEY_ATCK2,          PHYS_INPUT_BUTTON_ATCK2(this));
        CS(this).pressedkeys = keys; // store for other users
@@@ -1905,7 -1870,7 +1870,7 @@@ void ShowRespawnCountdown(entity this
  .bool team_selected;
  bool ShowTeamSelection(entity this)
  {
-       if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || this.team_selected || (CS(this).wasplayer && autocvar_g_changeteam_banned) || this.team_forced > 0)
+       if (!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || this.team_selected || (CS(this).wasplayer && autocvar_g_changeteam_banned) || Player_HasRealForcedTeam(this))
                return false;
        stuffcmd(this, "menu_showteamselect\n");
        return true;
@@@ -1928,7 -1893,6 +1893,6 @@@ void Join(entity this
        if(IS_PLAYER(this))
        if(teamplay && this.team != -1)
        {
-               //Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_JOIN_PLAY_TEAM), this.netname);
        }
        else
                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_JOIN_PLAY, this.netname);
@@@ -1953,7 -1917,7 +1917,7 @@@ int nJoinAllowed(entity this, entity ig
                        return 0;
        }
  
-       if(this && this.team_forced < 0)
+       if(this && (Player_GetForcedTeamIndex(this) == TEAM_FORCE_SPECTATOR))
                return 0; // forced spectators can never join
  
        // TODO simplify this
@@@ -2505,7 -2469,7 +2469,7 @@@ void PlayerPreThink (entity this
                // don't do this in ClientConnect
                // many things can go wrong if a client is spawned as player on connection
                if (MUTATOR_CALLHOOK(AutoJoinOnConnection, this)
-                       || (!(autocvar_sv_spectate || autocvar_g_campaign || this.team_forced < 0)
+                       || (!(autocvar_sv_spectate || autocvar_g_campaign || (Player_GetForcedTeamIndex(this) == TEAM_FORCE_SPECTATOR))
                                && (!teamplay || autocvar_g_balance_teams)))
                {
                        campaign_bots_may_start = true;
index 1b398a8b21c2e27274bf66dfb9e86660b78b40df,6f1d60dd9bffe1a9dd9970408ec715f3071f29f1..915fea7ee0ca2ca02ffb14d9341d539b4b4a7d14
@@@ -8,8 -8,6 +8,8 @@@
  #include "common.qh"
  #include "vote.qh"
  
 +#include "../bot/api.qh"
 +
  #include "../campaign.qh"
  #include "../cheats.qh"
  #include "../client.qh"
@@@ -121,7 -119,7 +121,7 @@@ void ClientCommand_clientversion(entit
                                        {
                                                // JoinBestTeam(caller, false, true);
                                        }
-                                       else if (teamplay && !autocvar_sv_spectate && !(caller.team_forced > 0))
+                                       else if (teamplay && !autocvar_sv_spectate && !(Player_GetForcedTeamIndex(caller) > 0))
                                        {
                                                TRANSMUTE(Observer, caller);  // really?
                                                stuffcmd(caller, "menu_showteamselect\n");
@@@ -168,61 -166,6 +168,61 @@@ void ClientCommand_mv_getpicture(entit
        }
  }
  
 +void ClientCommand_wpeditor(entity caller, int request, int argc)
 +{
 +      switch (request)
 +      {
 +              case CMD_REQUEST_COMMAND:
 +              {
 +                      if (!autocvar_g_waypointeditor)
 +                      {
 +                              sprint(caller, "ERROR: this command works only if the waypoint editor is on\n");
 +                              return;
 +                      }
 +
 +                      if (argv(1) != "")
 +                      {
 +                              if (argv(1) == "spawn")
 +                              {
 +                                      if (!IS_PLAYER(caller))
 +                                              sprint(caller, "ERROR: this command works only if you are player\n");
 +                                      else
 +                                              waypoint_spawn_fromeditor(caller);
 +                              }
 +                              else if (argv(1) == "remove")
 +                              {
 +                                      if (!IS_PLAYER(caller))
 +                                              sprint(caller, "ERROR: this command works only if you are player\n");
 +                                      else
 +                                              waypoint_remove_fromeditor(caller);
 +                              }
 +                              else if (argv(1) == "unreachable")
 +                              {
 +                                      if (!IS_PLAYER(caller))
 +                                              sprint(caller, "ERROR: this command works only if you are player\n");
 +                                      else
 +                                              waypoint_unreachable(caller);
 +                              }
 +                              else if (argv(1) == "saveall")
 +                                      waypoint_saveall();
 +                              else if (argv(1) == "relinkall")
 +                                      waypoint_schedulerelinkall();
 +
 +                              return;
 +                      }
 +              }
 +
 +              default:
 +                      sprint(caller, "Incorrect parameters for ^2wpeditor^7\n");
 +              case CMD_REQUEST_USAGE:
 +              {
 +                      sprint(caller, "\nUsage:^3 cmd wpeditor action\n");
 +                      sprint(caller, "  Where 'action' can be: spawn, remove, unreachable, saveall, relinkall\n");
 +                      return;
 +              }
 +      }
 +}
 +
  void ClientCommand_join(entity caller, int request)
  {
        switch (request)
@@@ -363,7 -306,19 +363,7 @@@ void ClientCommand_say_team(entity call
                case CMD_REQUEST_COMMAND:
                {
                        if (argc >= 2)
 -                      {
 -                              string _classname = string_null;
 -                              if (!IS_PLAYER(caller) && caller.caplayer)
 -                              {
 -                                      // CA: make work team chat for killed players
 -                                      _classname = caller.classname;
 -                                      caller.classname = STR_PLAYER;
 -                              }
 -
                                Say(caller, true, NULL, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1);
 -                              if (_classname)
 -                                      caller.classname = _classname;
 -                      }
                        return;  // never fall through to usage
                }
  
@@@ -397,7 -352,7 +397,7 @@@ void ClientCommand_selectteam(entity ca
                                sprint(caller, "^7selectteam can only be used in teamgames\n");
                                return;
                        }
-                       if (caller.team_forced > 0)
+                       if (Player_GetForcedTeamIndex(caller) > 0)
                        {
                                sprint(caller, "^7selectteam can not be used as your team is forced\n");
                                return;
@@@ -743,7 -698,6 +743,7 @@@ void ClientCommand_(entity caller, int 
        CLIENT_COMMAND("suggestmap", ClientCommand_suggestmap(ent, request, arguments), "Suggest a map to the mapvote at match end") \
        CLIENT_COMMAND("tell", ClientCommand_tell(ent, request, arguments, command), "Send a message directly to a player") \
        CLIENT_COMMAND("voice", ClientCommand_voice(ent, request, arguments, command), "Send voice message via sound") \
 +      CLIENT_COMMAND("wpeditor", ClientCommand_wpeditor(ent, request, arguments), "Waypoint editor commands") \
        /* nothing */
  
  void ClientCommand_macro_help(entity caller)
@@@ -818,7 -772,6 +818,7 @@@ void SV_ParseClientCommand(entity this
                case "begin": break;                               // handled by engine in host_cmd.c
                case "download": break;                            // handled by engine in cl_parse.c
                case "mv_getpicture": break;                       // handled by server in this file
 +              case "wpeditor": break;                            // handled by server in this file
                case "pause": break;                               // handled by engine in host_cmd.c
                case "prespawn": break;                            // handled by engine in host_cmd.c
                case "sentcvar": break;                            // handled by server in this file