From: bones_was_here Date: Thu, 21 Mar 2024 06:40:45 +0000 (+1000) Subject: q3compat: reduce entity field allocation X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=014810007e44f3d712b4d7988f7d22a7c1acabbc q3compat: reduce entity field allocation 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 / --- diff --git a/qcsrc/server/compat/quake3.qc b/qcsrc/server/compat/quake3.qc index 39a265405..a4c55116b 100644 --- a/qcsrc/server/compat/quake3.qc +++ b/qcsrc/server/compat/quake3.qc @@ -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; diff --git a/qcsrc/server/world.qc b/qcsrc/server/world.qc index b6fbe0d85..6d173d797 100644 --- a/qcsrc/server/world.qc +++ b/qcsrc/server/world.qc @@ -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")) != "") { diff --git a/qcsrc/server/world.qh b/qcsrc/server/world.qh index 6348c72f6..09ee564cf 100644 --- a/qcsrc/server/world.qh +++ b/qcsrc/server/world.qh @@ -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();