From 43484a1ae01c53a63177463f870530cc573d55b5 Mon Sep 17 00:00:00 2001 From: k9er Date: Sun, 19 Jan 2025 18:33:10 +0000 Subject: [PATCH] Fix autoswitch bug from !1398 --- qcsrc/server/items/items.qc | 7 +++++-- xonotic-client.cfg | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index e94b752ff..ebe9212d5 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -1742,7 +1742,9 @@ float GiveItems(entity e, float beginarg, float endarg) }); FOREACH(Weapons, it != WEP_Null && (cmd == it.netname || cmd == it.m_deprecated_netname), { got += GiveWeapon(e, it.m_id, op, val); - last_wep = it; + if(use_cts_autoswitch && CS_CVAR(e).cvar_cl_autoswitch_cts == 1) + if(val > 0 && (op == OP_SET && op == OP_PLUS || op == OP_MIN)) // switch to any given weapons, even if we already had it + last_wep = it; // (... non-CTS autoswitching can switch to a weapon we already have, so CTS autoswitch should be the same) break; }); break; @@ -1783,9 +1785,10 @@ float GiveItems(entity e, float beginarg, float endarg) if(e.statuseffects) StatusEffects_update(e); - if(last_wep != WEP_Null && use_cts_autoswitch) + if(use_cts_autoswitch) { // CTS handling: never switch (0), always switch (1) + if(last_wep != WEP_Null) if(CS_CVAR(e).cvar_cl_autoswitch_cts == 1) { // crude hack to enforce switching weapons diff --git a/xonotic-client.cfg b/xonotic-client.cfg index 5b620f007..297bf876c 100644 --- a/xonotic-client.cfg +++ b/xonotic-client.cfg @@ -719,7 +719,7 @@ seta cl_race_cptimes_namesize 10 "maximum length of player names in race checkpo seta cl_race_checkpoint_splits_console 1 "print race checkpoint splits to console" seta cl_race_checkpoint_splits_hud 1 "show race checkpoint splits on HUD in infomessages" -seta cl_autoswitch_cts -1 "\"-1\" = fallback to the behavior of cl_autoswitch, \"0\" = never autoswitch in CTS, \"1\" = always autoswitch in CTS" +seta cl_autoswitch_cts -1 "\"-1\" = fallback to the behavior of cl_autoswitch, \"0\" = never autoswitch in CTS, \"1\" = always autoswitch in CTS (regardless of weapon priority)" set cl_stripcolorcodes 0 "experimental feature (NOTE: strips ALL color codes from messages!)" -- 2.39.5