From: z411 Date: Sun, 28 May 2023 07:57:03 +0000 (-0400) Subject: Show client-side queue indicators X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=76a87f8d500c1e6bf376148e14e9e6ef588c6f93;p=xonotic%2Fxonotic-data.pk3dir.git Show client-side queue indicators --- diff --git a/qcsrc/client/hud/panel/infomessages.qc b/qcsrc/client/hud/panel/infomessages.qc index e85a7f30c..2b8072245 100644 --- a/qcsrc/client/hud/panel/infomessages.qc +++ b/qcsrc/client/hud/panel/infomessages.qc @@ -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); } } diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index 566f5a695..bcc95f532 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -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) { diff --git a/qcsrc/common/ent_cs.qc b/qcsrc/common/ent_cs.qc index 85119de08..11c5e7bb0 100644 --- a/qcsrc/common/ent_cs.qc +++ b/qcsrc/common/ent_cs.qc @@ -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); }, diff --git a/qcsrc/common/ent_cs.qh b/qcsrc/common/ent_cs.qh index aa689e59d..3c96661e6 100644 --- a/qcsrc/common/ent_cs.qh +++ b/qcsrc/common/ent_cs.qh @@ -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) { diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index c0d29cfe2..da1daaf0a 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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); diff --git a/qcsrc/server/clientkill.qc b/qcsrc/server/clientkill.qc index 660d02e36..f0959357c 100644 --- a/qcsrc/server/clientkill.qc +++ b/qcsrc/server/clientkill.qc @@ -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); diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 67016dd89..690b658fb 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -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 } diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index 89d9ad1cf..4afe7d1e4 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -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)