]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'terencehill/servers_quickmenu' into 'master'
authorterencehill <piuntn@gmail.com>
Fri, 16 Sep 2022 14:50:10 +0000 (14:50 +0000)
committerterencehill <piuntn@gmail.com>
Fri, 16 Sep 2022 14:50:10 +0000 (14:50 +0000)
Custom server's quickmenu

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

1  2 
qcsrc/client/hud/panel/quickmenu.qc
qcsrc/server/client.qc
qcsrc/server/client.qh

index f274411ae5bd6aed5d490d45f2d2ec66dc2e0e05,e75b5fbf9188055579da4ea99162925e0f7e5b3f..e476e12f05007579d1285b01d0b08b7d59724f21
@@@ -70,7 -70,6 +70,7 @@@ void QuickMenu_Page_ClearEntry(int i
  bool HUD_QuickMenu_Forbidden()
  {
        return (mv_active
 +              || scoreboard_ui_enabled
                || (hud_configure_prev && hud_configure_prev != -1)
                || HUD_MinigameMenu_IsOpened()
                || (QuickMenu_TimeOut && time > QuickMenu_TimeOut));
@@@ -193,7 -192,12 +193,7 @@@ bool QuickMenu_Open(string mode, strin
        mouseClicked = 0;
        hudShiftState = 0;
  
 -      // we must unset the player's buttons, as they aren't released elsewhere
 -      localcmd("-fire\n");
 -      localcmd("-fire2\n");
 -      localcmd("-use\n");
 -      localcmd("-hook\n");
 -      localcmd("-jump\n");
 +      Release_Common_Keys();
  
        QuickMenu_TimeOut_Set();
        return true;
@@@ -868,6 -872,14 +868,14 @@@ void QuickMenu_Default(string target_su
                QUICKMENU_ENTRY(CTX(_("QMCMD^Shuffle teams")), "vcall shuffleteams")
        QUICKMENU_SMENU(CTX(_("QMCMD^Call a vote")), "Call a vote")
  
+       if (autocvar__hud_panel_quickmenu_file_from_server != "")
+       {
+       string entry_name = _("Server's custom quickmenu");
+       if (autocvar__hud_panel_quickmenu_file_from_server == "wpeditor.txt")
+               entry_name = _("Waypoint editor quickmenu");
+       QUICKMENU_ENTRY(entry_name, "quickmenu; wait; quickmenu \"\" \"\" $_hud_panel_quickmenu_file_from_server")
+       }
        if(spectatee_status != 0)
        {
        QUICKMENU_SMENU_PL(CTX(_("QMCMD^Spectate a player")), "Spectate a player", "spectate \"%s^7\"", 0, 1)
diff --combined qcsrc/server/client.qc
index e9955b407dfb6c4ef7a5af4452ddf51dbb967291,3e3eb08cf17ac7e61ee27464ef605341669b7bae..a1195d52cfb9ae579ec684b215e21aa3c6d60b21
@@@ -46,6 -46,7 +46,7 @@@
  #include <server/antilag.qh>
  #include <server/bot/api.qh>
  #include <server/bot/default/cvars.qh>
+ #include <server/bot/default/waypoints.qh>
  #include <server/campaign.qh>
  #include <server/chat.qh>
  #include <server/cheats.qh>
@@@ -540,9 -541,6 +541,9 @@@ void PutPlayerInServer(entity this
        PlayerState_attach(this);
        accuracy_resend(this);
  
 +      if (teamplay && this.bot_forced_team)
 +              SetPlayerTeam(this, this.bot_forced_team, TEAM_CHANGE_MANUAL);
 +
        if (this.team < 0)
                TeamBalance_JoinBestTeam(this);
  
  /** Called when a client spawns in the server */
  void PutClientInServer(entity this)
  {
 -      if (IS_BOT_CLIENT(this)) {
 -              TRANSMUTE(Player, this);
 -      } else if (IS_REAL_CLIENT(this)) {
 +      if (IS_REAL_CLIENT(this)) {
                msg_entity = this;
                WriteByte(MSG_ONE, SVC_SETVIEW);
                WriteEntity(MSG_ONE, this);
@@@ -1019,10 -1019,17 +1020,10 @@@ void ClientPreConnect(entity this
  }
  #endif
  
 -void SendWelcomemessage(entity this, bool force_centerprint)
 -{
 -      msg_entity = this;
 -      WriteHeader(MSG_ONE, TE_CSQC_SERVERWELCOME);
 -      SendWelcomemessage_msg_type(this, force_centerprint, MSG_ONE);
 -}
 -
  // NOTE csqc uses the active mutators list sent by this function
  // to understand which mutators are enabled
  // also note that they aren't all registered mutators, e.g. jetpack, low gravity
 -void SendWelcomemessage_msg_type(entity this, bool force_centerprint, int msg_type)
 +void SendWelcomeMessage(entity this, int msg_type)
  {
        WriteByte(msg_type, boolean(autocvar_g_campaign));
        if (boolean(autocvar_g_campaign))
                WriteString(msg_type, Campaign_GetMessage());
                return;
        }
 -      WriteByte(msg_type, force_centerprint);
        WriteString(msg_type, autocvar_hostname);
        WriteString(msg_type, autocvar_g_xonoticversion);
        WriteByte(msg_type, CS(this).version_mismatch);
@@@ -1138,6 -1146,12 +1139,12 @@@ void ClientConnect(entity this
        {
                if (g_weaponarena_weapons == WEPSET(TUBA))
                        stuffcmd(this, "cl_cmd settemp chase_active 1\n");
+               // quickmenu file must be put in a subfolder with an unique name
+               // to reduce chances of overriding custom client quickmenus
+               if (waypointeditor_enabled)
+                       stuffcmd(this, sprintf("cl_cmd settemp _hud_panel_quickmenu_file_from_server %s\n", "wpeditor.txt"));
+               else if (autocvar_sv_quickmenu_file != "" && strstrofs(autocvar_sv_quickmenu_file, "/", 0) && fexists(autocvar_sv_quickmenu_file))
+                       stuffcmd(this, sprintf("cl_cmd settemp _hud_panel_quickmenu_file_from_server %s\n", autocvar_sv_quickmenu_file));
        }
  
        if (!autocvar_sv_foginterval && world.fog != "")
  
        if (player_count == 1)
                localcmd("\nsv_hook_firstjoin\n");
 -
 -      if (IS_REAL_CLIENT(this) && !IS_PLAYER(this) && !autocvar_g_campaign)
 -              CS(this).motd_actived_time = -1; // the welcome message is shown by the client
  }
  /*
  =============
@@@ -1938,8 -1955,7 +1945,8 @@@ bool ShowTeamSelection(entity this
  {
        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");
 +      if (frametime) // once per frame is more than enough
 +              stuffcmd(this, "_scoreboard_team_selection 1\n");
        return true;
  }
  void Join(entity this)
@@@ -2028,6 -2044,62 +2035,6 @@@ int nJoinAllowed(entity this, entity ig
        return free_slots;
  }
  
 -void PrintWelcomeMessage(entity this)
 -{
 -      if(CS(this).motd_actived_time == 0)
 -      {
 -              if (autocvar_g_campaign) {
 -                      if ((IS_PLAYER(this) && PHYS_INPUT_BUTTON_INFO(this)) || (!IS_PLAYER(this))) {
 -                              CS(this).motd_actived_time = time;
 -                              SendWelcomemessage(this, false);
 -                      }
 -              } else {
 -                      if (PHYS_INPUT_BUTTON_INFO(this)) {
 -                              CS(this).motd_actived_time = time;
 -                              SendWelcomemessage(this, true);
 -                      }
 -              }
 -      }
 -      else if(CS(this).motd_actived_time > 0) // showing MOTD or campaign message
 -      {
 -              if (autocvar_g_campaign) {
 -                      if (PHYS_INPUT_BUTTON_INFO(this))
 -                              CS(this).motd_actived_time = time;
 -                      else if ((time - CS(this).motd_actived_time > 2) && IS_PLAYER(this)) { // hide it some seconds after BUTTON_INFO has been released
 -                              CS(this).motd_actived_time = 0;
 -                              Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_MOTD);
 -                      }
 -              } else {
 -                      if (PHYS_INPUT_BUTTON_INFO(this))
 -                              CS(this).motd_actived_time = time;
 -                      else if (time - CS(this).motd_actived_time > 2) { // hide it some seconds after BUTTON_INFO has been released
 -                              CS(this).motd_actived_time = 0;
 -                              Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_MOTD);
 -                      }
 -              }
 -      }
 -      else //if(CS(this).motd_actived_time < 0) // just connected, motd is active
 -      {
 -              if(PHYS_INPUT_BUTTON_INFO(this)) // BUTTON_INFO hides initial MOTD
 -                      CS(this).motd_actived_time = -2; // wait until BUTTON_INFO gets released
 -              else if (CS(this).motd_actived_time == -2)
 -              {
 -                      // instantly hide MOTD
 -                      CS(this).motd_actived_time = 0;
 -                      Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_MOTD);
 -              }
 -              else if (IS_PLAYER(this) || IS_SPEC(this))
 -              {
 -                      // FIXME occasionally for some reason MOTD never goes away
 -                      // delay MOTD removal a little bit in the hope it fixes this bug
 -                      if (CS(this).motd_actived_time == -1) // MOTD marked to fade away as soon as client becomes player or spectator
 -                              CS(this).motd_actived_time = -(5 + floor(random() * 10)); // add small delay
 -                      else //if (CS(this).motd_actived_time < -2)
 -                              CS(this).motd_actived_time++;
 -              }
 -      }
 -}
 -
  bool joinAllowed(entity this)
  {
        if (CS(this).version_mismatch) return false;
@@@ -2204,14 -2276,6 +2211,14 @@@ void ObserverOrSpectatorThink(entity th
                }
        }
  
 +      if (IS_BOT_CLIENT(this) && !CS(this).autojoin_checked)
 +      {
 +              CS(this).autojoin_checked = true;
 +              TRANSMUTE(Player, this);
 +              PutClientInServer(this);
 +              return;
 +      }
 +
        if (this.flags & FL_JUMPRELEASED) {
                if (PHYS_INPUT_BUTTON_JUMP(this) && (joinAllowed(this) || time < CS(this).jointime + MIN_SPEC_TIME)) {
                        this.flags &= ~FL_JUMPRELEASED;
@@@ -2459,6 -2523,9 +2466,6 @@@ void PlayerPreThink (entity this
                PlayerUseKey(this);
        CS(this).usekeypressed = PHYS_INPUT_BUTTON_USE(this);
  
 -      if (IS_REAL_CLIENT(this))
 -              PrintWelcomeMessage(this);
 -
        if (IS_PLAYER(this)) {
                if (IS_REAL_CLIENT(this) && time < CS(this).jointime + MIN_SPEC_TIME)
                        error("Client can't be spawned as player on connection!");
diff --combined qcsrc/server/client.qh
index 9ba57f1931a33f0c1bf8d911ce0c7db80d6780b4,69bf720db0be48e5cea4c3bf3389baa44ca06029..56cce52a996dd338b551cb08441425f32ce957a0
@@@ -50,11 -50,12 +50,12 @@@ string autocvar_hostname
  int autocvar_spawn_debug;
  string autocvar_sv_motd;
  int autocvar_sv_name_maxlength = 64;
+ string autocvar_sv_quickmenu_file;
  bool autocvar_sv_servermodelsonly;
+ bool autocvar_sv_showspectators;
  int autocvar_sv_spectate;
  bool autocvar_sv_teamnagger;
  float autocvar_sv_player_scale;
- bool autocvar_sv_showspectators;
  
  // WEAPONTODO
  .string weaponorder_byimpulse;
@@@ -64,6 -65,7 +65,6 @@@
  .float jointime; // time of connecting
  .float startplaytime; // time of switching from spectator to player
  .float alivetime; // time of being alive
 -.float motd_actived_time; // used for both motd and campaign_message
  
  .bool wasplayer;
  
@@@ -158,6 -160,7 +159,6 @@@ CLASS(Client, Object
      ATTRIB(Client, teamkill_soundtime, float, this.teamkill_soundtime);
      ATTRIB(Client, teamkill_soundsource, entity, this.teamkill_soundsource);
      ATTRIB(Client, usekeypressed, bool, this.usekeypressed);
 -    ATTRIB(Client, motd_actived_time, float, this.motd_actived_time);
      ATTRIB(Client, jointime, float, this.jointime);
      ATTRIB(Client, spectatortime, float, this.spectatortime);
      ATTRIB(Client, startplaytime, float, this.startplaytime);
@@@ -318,7 -321,7 +319,7 @@@ bool independent_players
  .float nickspamtime; // time of last nick change
  .float nickspamcount;
  
 -void SendWelcomemessage_msg_type(entity this, bool force_centerprint, int msg_type);
 +void SendWelcomeMessage(entity this, int msg_type);
  
  // respawning
  .int respawn_flags;