]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix autoswitch bug from !1398
authork9er <k9wolf@pm.me>
Sun, 19 Jan 2025 18:33:10 +0000 (18:33 +0000)
committerterencehill <piuntn@gmail.com>
Sun, 19 Jan 2025 18:33:10 +0000 (18:33 +0000)
qcsrc/server/items/items.qc
xonotic-client.cfg

index e94b752ffde6d3149979477ca0bb7212b3b90d33..ebe9212d54ca34402ccbfb70b9ff203395fad2ca 100644 (file)
@@ -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
index 5b620f00702179549211129f7e47e565eeff64eb..297bf876cc26c62f928f23adaf6d25b8af6bca44 100644 (file)
@@ -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!)"