]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use directly strftime_s() since strftime(false, "%s") isn't reliable
authorterencehill <piuntn@gmail.com>
Sun, 23 May 2021 09:47:09 +0000 (11:47 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 23 May 2021 09:47:09 +0000 (11:47 +0200)
qcsrc/lib/string.qh
qcsrc/server/intermission.qc
qcsrc/server/world.qc

index 49762348efa8bb57819f3510081e1266d21d4019..c99497bc7566c6cd1d6bdf381dc3e1175387b815 100644 (file)
@@ -83,7 +83,8 @@ int days_up_to_date(int Y, int M, int D)
 
 // Returns the number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).
 // This function exists only as a replacement for strftime(false, "%s") which doesn't work
-// on Windows (%s is not supported)
+// on Windows (%s is not supported) and at least in some linux systems doesn't return the
+// correct result
 // NOTE: at the current date, the number (string) returned by both strftime(false, "%s") and
 // strftime_s() is so high that can't be converted to int (with ftos) without precision loss
 ERASEABLE
index 3bb3bdb8e01b65aa552405537573bfd713ccc97a..81850d8df33ce041796423d6ed377c31e28241e8 100644 (file)
@@ -433,9 +433,7 @@ void IntermissionThink(entity this)
                this.autoscreenshot = -1;
                if(IS_REAL_CLIENT(this))
                {
-                       string num = strftime(false, "%s");
-                       if (num == "")
-                               num = strftime_s();
+                       string num = strftime_s(); // strftime(false, "%s") isn't reliable, see strftime_s description
                        stuffcmd(this, sprintf("\nscreenshot screenshots/autoscreenshot/%s-%s.jpg; "
                                "echo \"^5A screenshot has been taken at request of the server.\"\n", GetMapname(), num));
                }
index 7b9697d1740476030af313e0cc6c2a5827de5e19..9cf7b18d99c54e90849879e40419f6c63b5a2277 100644 (file)
@@ -839,9 +839,7 @@ spawnfunc(worldspawn)
        // character set: ASCII 33-126 without the following characters: : ; ' " \ $
        if(autocvar_sv_eventlog)
        {
-               string num = strftime(false, "%s");
-               if (num == "")
-                       num = strftime_s();
+               string num = strftime_s(); // strftime(false, "%s") isn't reliable, see strftime_s description
                string s = sprintf("%s.%s.%06d", itos(autocvar_sv_eventlog_files_counter), num, floor(random() * 1000000));
                matchid = strzone(s);