]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/main.qc
Fix string length checks in world.qc and add VM_TEMPSTRING_MAXSIZE
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / main.qc
index 0d36ea47ede68762063b9780ac487f3053c13582..b5832d8939ae91b28b44f671007e9a619d5ec44f 100644 (file)
@@ -5,6 +5,7 @@
 #include <common/deathtypes/all.qh>
 #include <common/debug.qh>
 #include <common/mapinfo.qh>
+#include <common/mapobjects/_mod.qh>
 #include <common/monsters/sv_monsters.qh>
 #include <common/util.qh>
 #include <common/vehicles/all.qh>
@@ -187,12 +188,14 @@ void CreatureFrame_All()
        });
 }
 
+// called shortly after map change in dedicated
 void Pause_TryPause_Dedicated(entity this)
 {
-       if (player_count == 0)
+       if (player_count == 0 && !intermission_running && !autocvar__endmatch)
                setpause(1);
 }
 
+// called every normal frame in singleplayer/listen
 void Pause_TryPause()
 {
        int n = 0, p = 0;
@@ -207,9 +210,12 @@ void Pause_TryPause()
                setpause(0);
 }
 
+// called every paused frame by DP
 void SV_PausedTic(float elapsedtime)
 {
-       if (!server_is_dedicated)
+       if (autocvar__endmatch) // `endmatch` while paused
+               setpause(0); // proceed to intermission
+       else if (!server_is_dedicated)
        {
                if (autocvar_sv_autopause)
                        Pause_TryPause();
@@ -293,7 +299,6 @@ void StartFrame()
        IL_EACH(g_players, IS_FAKE_CLIENT(it), PlayerPreThink(it));
 
        execute_next_frame();
-       if (autocvar_sv_autopause && !server_is_dedicated) Pause_TryPause();
 
        delete_fn = remove_unsafely; // not during spawning!
        serverprevtime = servertime;
@@ -346,6 +351,10 @@ void StartFrame()
        CreatureFrame_All();
        CheckRules_World();
 
+       // after CheckRules_World() as it may set intermission_running, and after RedirectionThink() in case listen server is closing
+       if (autocvar_sv_autopause && !server_is_dedicated && !intermission_running)
+               Pause_TryPause();
+
        if (warmup_stage && !game_stopped && warmup_limit > 0 && time - game_starttime >= warmup_limit) {
                ReadyRestart(true);
                return;
@@ -468,6 +477,32 @@ string GetField_fullspawndata(entity e, string f, ...)
        return v;
 }
 
+/*
+=============
+FindFileInMapPack
+
+Returns the first matching VFS file path that exists in the current map's pack.
+Returns string_null if no files match or the map isn't packaged.
+=============
+*/
+string FindFileInMapPack(string pattern)
+{
+       if (!checkextension("DP_QC_FS_SEARCH_PACKFILE"))
+               return string_null;
+
+       string base_pack = whichpack(strcat("maps/", mapname, ".bsp"));
+       if (base_pack == "" || !base_pack) // this map isn't packaged or there was an error
+               return string_null;
+
+       int glob = search_packfile_begin(pattern, true, true, base_pack);
+       if (glob < 0)
+               return string_null;
+
+       string file = search_getfilename(glob, 0);
+       search_end(glob);
+       return file;
+}
+
 void WarpZone_PostInitialize_Callback()
 {
        // create waypoint links for warpzones