]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix and extend networking of sv_teamnagger
authorbones_was_here <bones_was_here@xonotic.au>
Thu, 6 Jun 2024 10:43:13 +0000 (20:43 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Mon, 5 Aug 2024 16:26:23 +0000 (02:26 +1000)
It wasn't enabled reliably because the message could be received before
CSQC was ready for it.
Adds support for specifying a team size difference, mainly for use with
g_balance_teams_queue.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
qcsrc/client/hud/hud.qh
qcsrc/client/hud/panel/infomessages.qc
qcsrc/client/main.qc
qcsrc/common/net_linked.qh
qcsrc/server/client.qc
xonotic-server.cfg

index 312aaea99be3a978b1ca78e996452cea18e5479d..d1daf419760a13ebd4dab8c22b0049eecb3b711c 100644 (file)
@@ -122,7 +122,7 @@ float weapontime;
 float weaponprevtime;
 
 float timer;
-float teamnagger;
+int teamnagger;
 
 int hudShiftState;
 const int S_SHIFT = 1;
index ff5bd8d5d8e30e407a34b780a452713a3ca27def..8d11b6fbda0e3e1cbc0607f0defac25641c8376f 100644 (file)
@@ -201,7 +201,7 @@ void HUD_InfoMessages()
                                        if(!ts_max) ts_max = tm.team_size;
                                        else ts_max = max(ts_max, tm.team_size);
                                }
-                               if ((ts_max - ts_min) > 1)
+                               if ((ts_max - ts_min) >= teamnagger)
                                {
                                        s = strcat(blinkcolor, _("Teamnumbers are unbalanced!"));
                                        tm = GetTeam(myteam, false);
index 0185d06cd3906c4e6249f4179b40be315f22e7c5..e59300a7c706523cbc33d780209b9620c39daec7 100644 (file)
@@ -711,6 +711,8 @@ NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew)
        spectatee_status = newspectatee_status;
 
        // we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
+
+       teamnagger = (f & 0x60) >> 5; // 0x60 = BIT(5) | BIT(6)
 }
 
 NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew)
@@ -1352,12 +1354,6 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew)
        return true;
 }
 
-NET_HANDLE(TE_CSQC_TEAMNAGGER, bool isNew)
-{
-       teamnagger = 1;
-       return true;
-}
-
 NET_HANDLE(TE_CSQC_PINGPLREPORT, bool isNew)
 {
        int i = ReadByte();
index f9e40965b8473282a398fdcedd9dd29c462b8532..d88b4124c9757a82e140a552e1f3614b2ea2cfaf 100644 (file)
@@ -2,7 +2,6 @@
 
 REGISTER_NET_TEMP(TE_CSQC_PICTURE)
 REGISTER_NET_TEMP(TE_CSQC_RACE)
-REGISTER_NET_TEMP(TE_CSQC_TEAMNAGGER)
 REGISTER_NET_TEMP(TE_CSQC_PINGPLREPORT)
 REGISTER_NET_TEMP(TE_CSQC_WEAPONCOMPLAIN)
 REGISTER_NET_TEMP(TE_CSQC_SERVERWELCOME)
index 854c1f0d07c193b3058b24fb752c637aea0b3762..9c371ae0052bc815e76fac4dfb0eadbb13992bfe 100644 (file)
@@ -97,10 +97,6 @@ STATIC_METHOD(Client, Remove, void(Client this))
     ClientDisconnect(this);
 }
 
-void send_CSQC_teamnagger() {
-       WriteHeader(MSG_BROADCAST, TE_CSQC_TEAMNAGGER);
-}
-
 int CountSpectators(entity player, entity to)
 {
        if(!player) { return 0; } // not sure how, but best to be safe
@@ -144,6 +140,9 @@ bool ClientData_Send(entity this, entity to, int sf)
                                        sf |= BIT(3); // observing blocked
        if (autocvar_sv_showspectators == 1 || (autocvar_sv_showspectators && IS_SPEC(to)))
                                        sf |= BIT(4); // show spectators
+       if (autocvar_sv_teamnagger && teamplay && !(autocvar_bot_vs_human && AVAILABLE_TEAMS == 2))
+               if (!MUTATOR_CALLHOOK(HideTeamNagger, this)) // enable teamnagger
+                                                 sf |= (autocvar_sv_teamnagger & 0x03) << 5; // BIT(5) | BIT(6)
 
        WriteHeader(MSG_ENTITY, ENT_CLIENT_CLIENTDATA);
        WriteByte(MSG_ENTITY, sf);
@@ -1103,6 +1102,7 @@ void SendWelcomeMessage(entity this, int msg_type)
 ClientConnect
 
 Called when a client connects to the server
+Do not send temp entity headers directly here, they may arrive before CSQC is ready.
 =============
 */
 void ClientConnect(entity this)
@@ -1186,10 +1186,6 @@ void ClientConnect(entity this)
        if (!autocvar_sv_foginterval && world.fog != "")
                stuffcmd(this, strcat("\nfog ", world.fog, "\nr_fog_exp2 0\nr_drawfog 1\n"));
 
-       if (autocvar_sv_teamnagger && !(autocvar_bot_vs_human && AVAILABLE_TEAMS == 2))
-               if(!MUTATOR_CALLHOOK(HideTeamNagger, this))
-                       send_CSQC_teamnagger();
-
        CSQCMODEL_AUTOINIT(this);
 
        CS(this).model_randomizer = random();
index 7aceeaa37b221d5e953f864432c1645894af1c65..19a82c977104c7135b326304a8e6f71513b1d8cd 100644 (file)
@@ -286,7 +286,7 @@ set g_balance_teams_remove 0 "remove excess players from teams to maintain balan
 set g_balance_teams_remove_wait 10 "seconds to warn everyone before removing an excess player (0 = immediately)"
 set g_changeteam_banned 0 "not allowed to change team"
 
-set sv_teamnagger 1 "enable a nag message when the teams are unbalanced"
+set sv_teamnagger 2 "enable a nag message when the teams are unbalanced, value sets team size difference threshold, 1 is recommended when g_balance_teams_queue is enabled"
 
 set g_bloodloss 0   "amount of health below which blood loss occurs"