]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
csqc_progname: reset when starting a listen server, not when unloading csqc
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 9 Jan 2016 06:22:19 +0000 (17:22 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 9 Jan 2016 06:22:19 +0000 (17:22 +1100)
qcsrc/client/main.qc
qcsrc/server/g_world.qc

index c251df0daeb1c494e0e9cd074d2bad1858b144aa..7682198338308463520b72a815e03e4b8cd91b0d 100644 (file)
@@ -128,21 +128,9 @@ void CSQC_Init()
        draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin")));
 }
 
-bool autocvar_debug_csprogs = false;
-
 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
 void Shutdown()
 {
-       if (autocvar_debug_csprogs && cvar_string("csqc_progname") == "csprogs-" WATERMARK ".dat")
-       {
-               // Reset csqc_progname changes here to keep listen servers working
-               // The engine should do this, but doesn't
-               string csqc_progname_prev = "csprogs.dat";
-               if (fexists(csqc_progname_prev))
-                       cvar_set("csqc_progname", csqc_progname_prev);
-               else
-                       LOG_WARNING("Don't know what to reset csqc_progname to");
-       }
        WarpZone_Shutdown();
 
        remove(teams);
index eac04a62900191da17087d541fad05a0d6d8fea5..0c70b03845068392ff4c117f7e74f47a90bfaece 100644 (file)
@@ -563,41 +563,56 @@ void WeaponStats_Init();
 void WeaponStats_Shutdown();
 spawnfunc(worldspawn)
 {
+       server_is_dedicated = boolean(stof(cvar_defstring("is_dedicated")));
+
        {
                bool wantrestart = false;
-               // Try to use versioned csprogs from pk3
-               // Only ever use versioned csprogs.dat files on dedicated servers;
-               // we need to reset csqc_progname on clients ourselves, and it's easier if the client's release name is constant
-               string pk3csprogs = "csprogs-" WATERMARK ".dat";
-               if (cvar_string_normal("csqc_progname") != pk3csprogs && fexists(pk3csprogs))
+
+               if (!server_is_dedicated)
                {
-                       cvar_set_normal("csqc_progname", pk3csprogs);
-                       wantrestart = true;
+                       // force unloading of server pk3 files when starting a listen server
+                       localcmd("\nfs_rescan\n");
+                       // restore csqc_progname too
+                       string expect = "csprogs.dat";
+                       wantrestart = cvar_string_normal("csqc_progname") != expect;
+                       cvar_set_normal("csqc_progname", expect);
                }
-               // Check for updates on startup
-               // We do it this way for atomicity so that connecting clients still match the server progs and don't disconnect
-               int sentinel = fopen("progs.txt", FILE_READ);
-               if (sentinel >= 0)
+               else
                {
-                       string switchversion = fgets(sentinel);
-                       fclose(sentinel);
-                       if (switchversion != "" && switchversion != WATERMARK)
+                       // Try to use versioned csprogs from pk3
+                       // Only ever use versioned csprogs.dat files on dedicated servers;
+                       // we need to reset csqc_progname on clients ourselves, and it's easier if the client's release name is constant
+                       string pk3csprogs = "csprogs-" WATERMARK ".dat";
+                       if (cvar_string_normal("csqc_progname") != pk3csprogs && fexists(pk3csprogs))
                        {
-                               LOG_INFOF("Switching progs: " WATERMARK " -> %s\n", switchversion);
-                               // if it doesn't exist, assume either:
-                               //   a) the current program was overwritten
-                               //   b) this is a client only update
-                               string newprogs = sprintf("progs-%s.dat", switchversion);
-                               if (fexists(newprogs))
-                               {
-                                       cvar_set_normal("sv_progs", newprogs);
-                                       wantrestart = true;
-                               }
-                               string newcsprogs = sprintf("csprogs-%s.dat", switchversion);
-                               if (fexists(newcsprogs))
+                               cvar_set_normal("csqc_progname", pk3csprogs);
+                               wantrestart = true;
+                       }
+                       // Check for updates on startup
+                       // We do it this way for atomicity so that connecting clients still match the server progs and don't disconnect
+                       int sentinel = fopen("progs.txt", FILE_READ);
+                       if (sentinel >= 0)
+                       {
+                               string switchversion = fgets(sentinel);
+                               fclose(sentinel);
+                               if (switchversion != "" && switchversion != WATERMARK)
                                {
-                                       cvar_set_normal("csqc_progname", newcsprogs);
-                                       wantrestart = true;
+                                       LOG_INFOF("Switching progs: " WATERMARK " -> %s\n", switchversion);
+                                       // if it doesn't exist, assume either:
+                                       //   a) the current program was overwritten
+                                       //   b) this is a client only update
+                                       string newprogs = sprintf("progs-%s.dat", switchversion);
+                                       if (fexists(newprogs))
+                                       {
+                                               cvar_set_normal("sv_progs", newprogs);
+                                               wantrestart = true;
+                                       }
+                                       string newcsprogs = sprintf("csprogs-%s.dat", switchversion);
+                                       if (fexists(newcsprogs))
+                                       {
+                                               cvar_set_normal("csqc_progname", newcsprogs);
+                                               wantrestart = true;
+                                       }
                                }
                        }
                }
@@ -628,8 +643,6 @@ spawnfunc(worldspawn)
                ++maxclients;
        }
 
-       server_is_dedicated = (stof(cvar_defstring("is_dedicated")) ? true : false);
-
        // needs to be done so early because of the constants they create
        static_init();
 
@@ -824,9 +837,6 @@ spawnfunc(worldspawn)
 
        localcmd("\n_sv_hook_gamestart ", GetGametype(), "\n");
 
-       // force unloading of server pk3 files when starting a listen server
-       if (!server_is_dedicated) localcmd("\nfs_rescan\n");
-
        // fill sv_curl_serverpackages from .serverpackage files
        if (autocvar_sv_curl_serverpackages_auto)
        {