From: bones_was_here Date: Thu, 6 Jun 2024 10:43:13 +0000 (+1000) Subject: Fix and extend networking of sv_teamnagger X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fe144c3f07ea9c3eb5d9bc084cfbd543aa136ab8;p=xonotic%2Fxonotic-data.pk3dir.git Fix and extend networking of sv_teamnagger 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 --- diff --git a/qcsrc/client/hud/hud.qh b/qcsrc/client/hud/hud.qh index 312aaea99..d1daf4197 100644 --- a/qcsrc/client/hud/hud.qh +++ b/qcsrc/client/hud/hud.qh @@ -122,7 +122,7 @@ float weapontime; float weaponprevtime; float timer; -float teamnagger; +int teamnagger; int hudShiftState; const int S_SHIFT = 1; diff --git a/qcsrc/client/hud/panel/infomessages.qc b/qcsrc/client/hud/panel/infomessages.qc index ff5bd8d5d..8d11b6fbd 100644 --- a/qcsrc/client/hud/panel/infomessages.qc +++ b/qcsrc/client/hud/panel/infomessages.qc @@ -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); diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 0185d06cd..e59300a7c 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -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(); diff --git a/qcsrc/common/net_linked.qh b/qcsrc/common/net_linked.qh index f9e40965b..d88b4124c 100644 --- a/qcsrc/common/net_linked.qh +++ b/qcsrc/common/net_linked.qh @@ -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) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 854c1f0d0..9c371ae00 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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(); diff --git a/xonotic-server.cfg b/xonotic-server.cfg index 7aceeaa37..19a82c977 100644 --- a/xonotic-server.cfg +++ b/xonotic-server.cfg @@ -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"