]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
q3compat: reduce entity field allocation
authorbones_was_here <bones_was_here@xonotic.au>
Thu, 21 Mar 2024 06:40:45 +0000 (16:40 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Wed, 17 Apr 2024 14:49:40 +0000 (00:49 +1000)
These fields are only read during worldspawn on Q3 maps, we don't need
them on every entity.

I retained .gametype and .not_gametype as I expect we'll want to
implement these for Xonotic mappers, and we're already using the
.gametype field elsewhere.

Will now support edge cases where the mapper used \ as the .music path
separator instead of the canonical /

qcsrc/server/compat/quake3.qc
qcsrc/server/world.qc
qcsrc/server/world.qh

index 39a26540539fb8edc8496ff28b4550f5f3d10f31..a4c55116bc02c7a7f95e556a9e1bda391a2a4e21 100644 (file)
@@ -333,12 +333,6 @@ spawnfunc(target_smallprint)
        spawnfunc_target_print(this);
 }
 
-.bool notteam;
-.bool notsingle;
-.bool notfree;
-.bool notta;
-.bool notvq3;
-.bool notcpm;
 .string gametype;
 .string not_gametype;
 bool DoesQ3ARemoveThisEntity(entity this)
@@ -352,29 +346,29 @@ 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)
+               if(stof(GetField_fullspawndata(this, "notvq3")))
                        return true;
        }
-       else if(this.notcpm)
+       else if(stof(GetField_fullspawndata(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
-       if(this.notta)
+       if(stof(GetField_fullspawndata(this, "notta")))
                return true;
 
        // FIXME: singleplayer does not use maxclients 1 as that would prevent bots,
        // this is the case in Q3 also, it uses another method to block clients.
        // Only accessible in VQ3, via the `spmap` command.
-       if(this.notsingle)
+       if(stof(GetField_fullspawndata(this, "notsingle")))
                if(maxclients == 1 && IS_GAMETYPE(DEATHMATCH))
                        return true;
 
-       if(this.notteam)
+       if(stof(GetField_fullspawndata(this, "notteam")))
                if(teamplay)
                        return true;
 
-       if(this.notfree)
+       if(stof(GetField_fullspawndata(this, "notfree")))
                if(!teamplay)
                        return true;
 
index b6fbe0d85f3796c649a639dabcf31b2a9cb11c53..6d173d7973eb12f7c08612ac1a3d94eb1d99666b 100644 (file)
@@ -930,18 +930,12 @@ spawnfunc(worldspawn)
        q3compat = BITSET(q3compat, Q3COMPAT_DEFI, _MapInfo_FindArenaFile(mapname, ".defi") != "");
 
        // quake 3 music support
-       if(world.music || world.noise)
-       {
+       // bones_was_here: Q3 doesn't support .noise but the Nexuiz _MapInfo_Generate() does.
+       // TODO: Q3 supports an optional intro file: "music/intro.wav music/loop.wav"
+       string music = GetField_fullspawndata(world, "music", true);
+       if (music || world.noise)
                // prefer .music over .noise
-               string chosen_music;
-               if(world.music)
-                       chosen_music = world.music;
-               else
-                       chosen_music = world.noise;
-
-               string newstuff = strcat(clientstuff, "cd loop \"", chosen_music, "\"\n");
-               strcpy(clientstuff, newstuff);
-       }
+               strcpy(clientstuff, strcat(clientstuff, "cd loop \"", (music ? music : world.noise), "\"\n"));
 
        if(whichpack(strcat("maps/", mapname, ".cfg")) != "")
        {
index 6348c72f6072a5862fdcb0ede96c7b981f7d48f3..09ee564cf9e6a169cbcb241a9416d2807a29e9ab 100644 (file)
@@ -156,10 +156,6 @@ float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, f
 void CheckRules_World();
 float RedirectionThink();
 
-// quake 3 music compatibility
-.string music;
-.string noise;
-
 void readplayerstartcvars();
 
 void readlevelcvars();