]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Remove autocvar_sv_q3defragcompat and use 1 bitfield to track .arena and .defi files
authorbones_was_here <bones_was_here@yahoo.com.au>
Tue, 14 Jul 2020 10:37:17 +0000 (20:37 +1000)
committerbones_was_here <bones_was_here@yahoo.com.au>
Tue, 14 Jul 2020 10:37:17 +0000 (20:37 +1000)
12 files changed:
qcsrc/common/mapobjects/func/button.qc
qcsrc/common/mapobjects/func/door.qc
qcsrc/common/mapobjects/trigger/hurt.qc
qcsrc/common/mapobjects/trigger/jumppads.qc
qcsrc/common/mapobjects/trigger/multi.qc
qcsrc/common/physics/player.qc
qcsrc/common/stats.qh
qcsrc/server/client.qc
qcsrc/server/compat/quake3.qc
qcsrc/server/compat/quake3.qh
qcsrc/server/g_world.qc
xonotic-server.cfg

index 423ac5e7b6d927f9fa2f8cdd42cf9797fe6b2f56..c716b400c86985e1260faa8aeaad2f85ab8bbbb1 100644 (file)
@@ -206,8 +206,8 @@ spawnfunc(func_button)
        if (!this.lip)
                this.lip = 4;
 
-       if(this.wait == -1 && autocvar_sv_q3defragcompat)
-               this.wait = 0.1; // compatibility for q3df: "instant" return
+       if(this.wait < 0 && q3compat)
+               this.wait = 0.1; // compatibility for q3: -1 = return immediately
 
     if(this.noise != "")
         precache_sound(this.noise);
index 11196ab38d7f2bbcce2418a3bfd3f201be84bed4..48e11ad87bc528c3867b12312a7aa24c86f6710f 100644 (file)
@@ -737,7 +737,7 @@ spawnfunc(func_door)
         }
         else if (!this.speed)
         {
-               if (autocvar_sv_q3defragcompat)
+               if (q3compat)
                        this.speed = 400;
                else
                        this.speed = 100;
index 8c21c509c5643419bb937d1d4170a81d711f12df..19447c41b99d2f3b563264f75601b85d50a2eae0 100644 (file)
@@ -25,7 +25,7 @@ void trigger_hurt_touch(entity this, entity toucher)
                if (toucher.triggerhurttime < time)
                {
                        EXACTTRIGGER_TOUCH(this, toucher);
-                       toucher.triggerhurttime = time + ((autocvar_sv_q3defragcompat && !(this.spawnflags & HURT_SLOW)) ? 0.1 : 1);
+                       toucher.triggerhurttime = time + ((q3compat && !(this.spawnflags & HURT_SLOW)) ? 0.1 : 1);
 
                        entity own;
                        own = this.enemy;
@@ -66,7 +66,7 @@ spawnfunc(trigger_hurt)
        this.use = trigger_hurt_use;
        this.enemy = world; // I hate you all
        if (!this.dmg)
-               this.dmg = ((autocvar_sv_q3defragcompat) ? 5 : 10000);
+               this.dmg = ((q3compat) ? 5 : 10000);
        if (this.message == "")
                this.message = "was in the wrong place";
        if (this.message2 == "")
index 2c160eae95e8a05e75f1ead2512b81c257716242..66daba8307cfb693fb8acca30768fd6795c55a93 100644 (file)
@@ -135,7 +135,7 @@ bool jumppad_push(entity this, entity targ)
 
        vector org = targ.origin;
 #ifdef SVQC
-       if(autocvar_sv_q3defragcompat)
+       if(q3compat)
 #elif defined(CSQC)
        if(STAT(Q3DEFRAGCOMPAT))
 #endif
index df915a649695c34ade16a31051dc9bdb6ce02b32..c087f071a3eeb2611713256f8e0429bfc59b0831 100644 (file)
@@ -176,7 +176,7 @@ spawnfunc(trigger_multiple)
                this.wait = 0;
        this.use = multi_use;
 
-       if(this.wait == -1 && autocvar_sv_q3defragcompat)
+       if(this.wait == -1 && q3compat & BIT(1))
                this.wait = 0.1; // compatibility for q3df: "instant" return
 
        EXACTTRIGGER_INIT;
index 5d4beb1acf1a7615391d14f5f035a264ca7875ca..e2497361049ca19db8ec3491dd497604f6ff02b2 100644 (file)
@@ -53,7 +53,7 @@ void Physics_UpdateStats(entity this)
             : 0;
           STAT(MOVEVARS_AIRSPEEDLIMIT_NONQW, this) = Physics_ClientOption(this, "airspeedlimit_nonqw", autocvar_sv_airspeedlimit_nonqw) * maxspd_mod;
         }
-       bool q3dfcompat = autocvar_sv_q3defragcompat && autocvar_sv_q3defragcompat_changehitbox; // NOTE: these hitboxes are off by 1 due to engine differences
+       bool q3dfcompat = q3compat && autocvar_sv_q3defragcompat_changehitbox; // NOTE: these hitboxes are off by 1 due to engine differences
        STAT(PL_MIN, this) = (q3dfcompat) ? '-15 -15 -20' : autocvar_sv_player_mins;
        STAT(PL_MAX, this) = (q3dfcompat) ? '15 15 36' : autocvar_sv_player_maxs;
        STAT(PL_VIEW_OFS, this) = (q3dfcompat) ? '0 0 30' : autocvar_sv_player_viewoffset;
index c77ca16be2a432043f0d8808fa1506b25b0d3a7d..ba56d924d0409861fb96eddda854351d124c657a 100644 (file)
@@ -3,6 +3,7 @@
 #ifdef SVQC
 #include <server/autocvars.qh>
 #include <server/client.qh>
+#include <server/compat/quake3.qh>
 #endif
 
 // Full list of all stat constants, included in a single location for easy reference
@@ -323,10 +324,7 @@ bool autocvar_sv_slick_applygravity;
 #endif
 REGISTER_STAT(SLICK_APPLYGRAVITY, bool, autocvar_sv_slick_applygravity)
 
-#ifdef SVQC
-bool autocvar_sv_q3defragcompat;
-#endif
-REGISTER_STAT(Q3DEFRAGCOMPAT, bool, autocvar_sv_q3defragcompat)
+REGISTER_STAT(Q3DEFRAGCOMPAT, bool, q3compat)
 
 #ifdef SVQC
 #include "physics/movetypes/movetypes.qh"
index 2c687286b7e503ee6b873708d21173bbeaed97eb..cac8adc58e9f379f65bb10792098da1598a23670 100644 (file)
@@ -612,7 +612,7 @@ void PutPlayerInServer(entity this)
        this.respawn_flags = 0;
        this.respawn_time = 0;
        STAT(RESPAWN_TIME, this) = 0;
-       bool q3dfcompat = autocvar_sv_q3defragcompat && autocvar_sv_q3defragcompat_changehitbox;
+       bool q3dfcompat = q3compat && autocvar_sv_q3defragcompat_changehitbox;
        this.scale = ((q3dfcompat) ? 0.9 : autocvar_sv_player_scale);
        this.fade_time = 0;
        this.pain_frame = 0;
index f7b77d83d1c0a839a13a9b4ead1fe061eb7abaf8..4f2b380ddd0e5b9828a807c6ad3524f5785bab5b 100644 (file)
  NOTE: for best experience, you need to swap MGs with SGs in the map or it won't have a MG
 */
 
-bool q3compat_arena(string mapname)
-{
-       if(fexists(strcat("scripts/", mapname, ".arena"))) return true;
-
-       return false;
-}
-
 // SG -> MG || SG
-SPAWNFUNC_ITEM_COND(ammo_shells, q3compat_arena(mapname), ITEM_Bullets, ITEM_Shells)
-SPAWNFUNC_WEAPON_COND(weapon_shotgun, q3compat_arena(mapname), WEP_MACHINEGUN, WEP_SHOTGUN)
+SPAWNFUNC_ITEM_COND(ammo_shells, q3compat & BIT(0), ITEM_Bullets, ITEM_Shells)
+SPAWNFUNC_WEAPON_COND(weapon_shotgun, q3compat & BIT(0), WEP_MACHINEGUN, WEP_SHOTGUN)
 
 // MG -> SG || MG
-SPAWNFUNC_ITEM_COND(ammo_bullets, q3compat_arena(mapname), ITEM_Shells, ITEM_Bullets)
+SPAWNFUNC_ITEM_COND(ammo_bullets, q3compat & BIT(0), ITEM_Shells, ITEM_Bullets)
 
 // GL -> Mortar
 SPAWNFUNC_ITEM(ammo_grenades, ITEM_Rockets)
@@ -63,7 +56,7 @@ SPAWNFUNC_WEAPON(weapon_chaingun, WEP_HLAC)
 SPAWNFUNC_ITEM(ammo_belt, ITEM_Cells)
 
 // Team Arena Nailgun -> Crylink || Quake Nailgun -> Electro
-SPAWNFUNC_WEAPON_COND(weapon_nailgun, q3compat_arena(mapname), WEP_CRYLINK, WEP_ELECTRO)
+SPAWNFUNC_WEAPON_COND(weapon_nailgun, q3compat & BIT(0), WEP_CRYLINK, WEP_ELECTRO)
 SPAWNFUNC_ITEM(ammo_nails, ITEM_Cells)
 
 // LG -> Electro
@@ -294,9 +287,11 @@ bool DoesQ3ARemoveThisEntity(entity this)
        // Xonotic is usually played with a CPM-based physics so we default to CPM mode
        if(cvar_string("g_mod_physics") == "Q3")
        {
-               if(this.notvq3) return true;
+               if(this.notvq3)
+                       return true;
        }
-       else if(this.notcpm) return true;
+       else if(this.notcpm)
+               return true;
 
        // Q3 mappers use "notq3a" or "notta" to disable an entity in Q3A or Q3TA
        // Xonotic has ~equivalent features to Team Arena
index eb77acd1eefcb1f11cd1eed55639be86f6f158bf..5d759e3783e4f1ee4dc8e036f2ce6c470fe648e5 100644 (file)
@@ -1,6 +1,6 @@
 #pragma once
 
-bool q3compat_arena(string mapname);
+int q3compat = 0;
 bool DoesQ3ARemoveThisEntity(entity this);
 
 .int fragsfilter_cnt;
index 884e6c3be3f3311d92134d8283402219e5570ac6..20cdd488911b35d0964b2f25da0a420269aed6ba 100644 (file)
@@ -878,8 +878,9 @@ spawnfunc(worldspawn)
        MapInfo_Enumerate();
        MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 1);
 
-       if(fexists(strcat("scripts/", mapname, ".defi")))
-               cvar_settemp("sv_q3defragcompat", "1");
+       q3compat = BITSET(q3compat, BIT(0), fexists(strcat("scripts/", mapname, ".arena")));
+       q3compat = BITSET(q3compat, BIT(1), fexists(strcat("scripts/", mapname, ".defi")));
+       LOG_INFO("CHECKED FOR: scripts/", mapname, ".arena and scripts/", mapname, ".defi, q3compat set to ", ftos(q3compat));
 
        if(whichpack(strcat("maps/", mapname, ".cfg")) != "")
        {
index 6f26e726f7cda8609bc0642938fc3b6dd41f0683..11a774b01784bba1b2c72d8ff87a31df21a4b827 100644 (file)
@@ -494,8 +494,6 @@ sv_gameplayfix_consistentplayerprethink 1
 sv_gameplayfix_gravityunaffectedbyticrate 1
 sv_gameplayfix_nogravityonground 1
 
-set sv_q3defragcompat 0 "toggle for some compatibility hacks (for Q3DF map compatibility)"
-
 set g_movement_highspeed 1 "multiplier scale for movement speed (applies to sv_maxspeed and sv_maxairspeed, also applies to air acceleration when g_movement_highspeed_q3_compat is set to 0)"
 set g_movement_highspeed_q3_compat 0 "apply speed modifiers to air movement in a more Q3-compatible way (only apply speed buffs and g_movement_highspeed to max air speed, not to acceleration)"