From: TimePath Date: Sat, 9 Jan 2016 06:22:19 +0000 (+1100) Subject: csqc_progname: reset when starting a listen server, not when unloading csqc X-Git-Tag: xonotic-v0.8.2~1257 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fc8e9c69c244e7908c6e036d6f711e6e43b5d8a8;p=xonotic%2Fxonotic-data.pk3dir.git csqc_progname: reset when starting a listen server, not when unloading csqc --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index c251df0da..768219833 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -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); diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index eac04a629..0c70b0384 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -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) {