]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Show client-side queue indicators
authorz411 <z411@omaera.org>
Sun, 28 May 2023 07:57:03 +0000 (03:57 -0400)
committerz411 <z411@omaera.org>
Sun, 28 May 2023 07:57:03 +0000 (03:57 -0400)
qcsrc/client/hud/panel/infomessages.qc
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/common/ent_cs.qc
qcsrc/common/ent_cs.qh
qcsrc/server/client.qc
qcsrc/server/clientkill.qc
qcsrc/server/command/cmd.qc
qcsrc/server/teamplay.qc

index e85a7f30c3e82a022a543d640ae0621f90bf1a0b..2b8072245ce9959b0776d58668fb98c5e9416bdc 100644 (file)
@@ -127,7 +127,13 @@ void HUD_InfoMessages()
 
                        if(!mutator_returnvalue)
                        {
-                               s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey(_("jump"), "+jump"));
+                               if(entcs_GetWantsJoin(current_player))
+                               {
+                                       int tm = Team_IndexToTeam(entcs_GetWantsJoin(current_player));
+                                       s = sprintf(_("^2You're queued to join the %s%s^2 team"), Team_ColorCode(tm), Team_ColorName(tm));
+                               }
+                               else
+                                       s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey(_("jump"), "+jump"));
                                InfoMessage(s);
                        }
                }
index 566f5a695635fe93419460c58ba81ec955162345..bcc95f532be700a703f8de51e0bd25b5467b0c43 100644 (file)
@@ -1392,6 +1392,15 @@ vector Scoreboard_DrawOthers(vector item_pos, vector rgb, int this_team, entity
                if(pl == ignored_pl)
                        continue;
 
+               if(entcs_GetWantsJoin(pl.sv_entnum))
+               {
+                       vector tmcolor = Team_ColorRGB(Team_IndexToTeam(entcs_GetWantsJoin(pl.sv_entnum)));
+                       tmcolor -= tmcolor * sin(2*M_PI*time);
+
+                       drawstring(pos, "(Q)", hud_fontsize, tmcolor, sbt_fg_alpha, DRAWFLAG_NORMAL);
+                       pos.x += stringwidth("(Q) ", true, hud_fontsize);
+               }
+
                field = "";
                if(this_team == NUM_SPECTATOR)
                {
index 85119de08825c52ab9c6692d87d4d9a3eb9fd83b..11c5e7bb019da168b83b30481683c7d6b537e274 100644 (file)
@@ -152,6 +152,10 @@ ENTCS_PROP(FRAGS, true, frags, frags, ENTCS_SET_NORMAL,
        { WriteShort(chan, ent.frags); },
        { ent.frags = ReadShort(); })
 
+ENTCS_PROP(WANTSJOIN, true, wants_join, wants_join, ENTCS_SET_NORMAL,
+       { WriteByte(chan, ent.wants_join); },
+       { ent.wants_join = ReadByte(); })
+
 // use sv_solid to avoid changing solidity state of entcs entities
 ENTCS_PROP(SOLID, true, sv_solid, solid, ENTCS_SET_NORMAL,
        { WriteByte(chan, ent.sv_solid); },
index aa689e59d707684eda169334528faf49cce8eefe..3c96661e60b678c5cd2db85ef57d7d200d11bbe1 100644 (file)
@@ -71,6 +71,7 @@ REGISTER_NET_TEMP(CLIENT_ENTCS)
      * @param i zero indexed player
      */
     .int frags;
+    .int wants_join;
        const int ENTCS_SPEC_PURE = 1; // real spectator
        const int ENTCS_SPEC_IN_SCOREBOARD = 2; // spectator but still in game (can be in a team)
        #define entcs_IsSpectating(i) boolean(entcs_GetSpecState(i))
@@ -90,6 +91,15 @@ REGISTER_NET_TEMP(CLIENT_ENTCS)
 
        /**
      * @param i zero indexed player
+     */
+       int entcs_GetWantsJoin(int i)
+       {
+               entity e = entcs_receiver(i);
+               return e.wants_join;
+       }
+
+       /**
+     * @param i zero indexed player
      */
        int entcs_GetClientColors(int i)
        {
index c0d29cfe2de15933d4171aea12dba8f2057a8ea3..da1daaf0af1b222ca53634ed1ed77ccef1988e7f 100644 (file)
@@ -412,8 +412,8 @@ void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint)
 
        if (CS(this).just_joined)
                CS(this).just_joined = false;
-       if (CS(this).wants_join)
-               CS(this).wants_join = false;
+       if (this.wants_join)
+               this.wants_join = 0;
 }
 
 int player_getspecies(entity this)
@@ -1118,7 +1118,7 @@ void ClientConnect(entity this)
                GameLogEcho(strcat(":join:", ftos(this.playerid), ":", ftos(etof(this)), ":", ((IS_REAL_CLIENT(this)) ? GameLog_ProcessIP(this.netaddress) : "bot"), ":", playername(this.netname, this.team, false)));
 
        CS(this).just_joined = true;  // stop spamming the eventlog with additional lines when the client connects
-       CS(this).wants_join = false;
+       this.wants_join = false;
 
        stuffcmd(this, clientstuff, "\n");
        stuffcmd(this, "cl_particles_reloadeffects\n"); // TODO do we still need this?
@@ -2000,7 +2000,7 @@ void Join(entity this)
        if(IS_PLAYER(this))
        if(teamplay && this.team != -1)
        {
-               if(CS(this).wants_join)
+               if(this.wants_join)
                        Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_JOIN_PLAY_TEAM), this.netname);
        }
        else
@@ -2008,7 +2008,7 @@ void Join(entity this)
        this.team_selected = false;
 
        if(queued_join)
-               CS(queued_join).wants_join = false;
+               this.wants_join = 0;
 }
 
 int GetPlayerLimit()
@@ -2079,7 +2079,7 @@ bool joinAllowed(entity this)
        if (teamplay && lockteams) return false;
        if (MUTATOR_CALLHOOK(ForbidSpawn, this)) return false;
        if (ShowTeamSelection(this)) return false;
-       if (CS(this).wants_join) return false;
+       if (this.wants_join) return false;
        if (IsQueueNeeded(this) && autocvar_g_balance_teams)
        {
                TeamBalance_JoinBestTeam(this);
index 660d02e36cfb59fd9f63bfed306a94e730137bea..f0959357c32fd87ec2a20fc3dc8e023d67f00d62 100644 (file)
@@ -26,7 +26,7 @@ void ClientKill_Now_TeamChange(entity this)
                if (blockSpectators)
                        Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
 
-               if (CS(this).wants_join)
+               if (this.wants_join)
                        SetPlayerTeam(this, -1, TEAM_CHANGE_SPECTATOR);
                else
                        PutObserverInServer(this, false, true);
index 67016dd89926f379eec297c4b8ba7ec8d9561b09..690b658fb73231e78cd31af6cb3d0501b9f6a695 100644 (file)
@@ -593,7 +593,7 @@ void ClientCommand_spectate(entity caller, int request)
 
                                if (mutator_returnvalue == MUT_SPECCMD_RETURN) return;
 
-                               if ((IS_PLAYER(caller) || mutator_returnvalue == MUT_SPECCMD_FORCE || CS(caller).wants_join))
+                               if ((IS_PLAYER(caller) || mutator_returnvalue == MUT_SPECCMD_FORCE || caller.wants_join))
                                if (autocvar_sv_spectate == 1)
                                        ClientKill_TeamChange(caller, -2); // observe
                        }
index 89d9ad1cf2262f863558c89063f4f408a0083f32..4afe7d1e4df85504cdfe00fc788835857a7becd0 100644 (file)
@@ -243,7 +243,7 @@ entity SpectatorWantsJoin(entity this)
 {
        FOREACH_CLIENT(IS_REAL_CLIENT(it), {
                if(it == this) continue;
-               if(CS(it).wants_join) {
+               if(it.wants_join) {
                        LOG_DEBUGF("Player is waiting to join: %s", it.netname);
                        return it;
                }
@@ -277,7 +277,7 @@ bool SetPlayerTeam(entity player, int team_index, int type)
                        {
                                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(player.team, INFO_JOIN_WANTS_TEAM), player.netname);
                                Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_JOIN_PREVENT_QUEUE);
-                               CS(player).wants_join = true; // TODO : Refactor
+                               player.wants_join = team_index; // Player queued to join
                        }
                        else
                                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(player.team, INFO_JOIN_PLAY_TEAM), player.netname);
@@ -292,9 +292,9 @@ bool SetPlayerTeam(entity player, int team_index, int type)
                        Kill_Notification(NOTIF_ONE_ONLY, player, MSG_CENTER, CPID_IDLING);
                        CS(player).idlekick_lasttimeleft = 0;
                }
-               else if (CS(player).wants_join)
+               else if (player.wants_join)
                {
-                       CS(player).wants_join = false;
+                       player.wants_join = 0;
                        Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, player.netname);
                }
                else if (!CS(player).just_joined && player.frags != FRAGS_SPECTATOR)