// CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
void Shutdown()
{
+ // 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);
return strcasecmp(substring(haystack, 0, strlen(needle)), needle) == 0;
}
+noref string _endsWith_suffix;
+#define endsWith(this, suffix) (_endsWith_suffix = suffix, substring(this, -strlen(_endsWith_suffix), -1) == _endsWith_suffix)
+
/** unzone the string, and return it as tempstring. Safe to be called on string_null */
string fstrunzone(string s)
{
void WeaponStats_Shutdown();
spawnfunc(worldspawn)
{
+ {
+ 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))
+ {
+ 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)
+ {
+ 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;
+ }
+ }
+ }
+ if (wantrestart) changelevel(mapname);
+ // let initialization continue, shutdown depends on it
+ }
+
float fd, l;
string s;
for (int i = 0, n = tokenize_console(cvar_string("sv_curl_serverpackages")); i < n; ++i)
{
string pkg = argv(i);
- if (substring(pkg, -18, -1) == "-serverpackage.txt") continue;
- if (substring(pkg, -14, -1) == ".serverpackage") continue; // OLD legacy
+ if (startsWith(pkg, "csprogs-")) continue;
+ if (endsWith(pkg, "-serverpackage.txt")) continue;
+ if (endsWith(pkg, ".serverpackage")) continue; // OLD legacy
s = cons(s, pkg);
}
// add automatically managed files to the list