From: terencehill Date: Sun, 23 May 2021 09:47:09 +0000 (+0200) Subject: Use directly strftime_s() since strftime(false, "%s") isn't reliable X-Git-Tag: xonotic-v0.8.5~405^2~35^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=654bbb9eaa7ff1653c64f833e0920867764cf045;p=xonotic%2Fxonotic-data.pk3dir.git Use directly strftime_s() since strftime(false, "%s") isn't reliable --- diff --git a/qcsrc/lib/string.qh b/qcsrc/lib/string.qh index 49762348e..c99497bc7 100644 --- a/qcsrc/lib/string.qh +++ b/qcsrc/lib/string.qh @@ -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 diff --git a/qcsrc/server/intermission.qc b/qcsrc/server/intermission.qc index 3bb3bdb8e..81850d8df 100644 --- a/qcsrc/server/intermission.qc +++ b/qcsrc/server/intermission.qc @@ -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)); } diff --git a/qcsrc/server/world.qc b/qcsrc/server/world.qc index 7b9697d17..9cf7b18d9 100644 --- a/qcsrc/server/world.qc +++ b/qcsrc/server/world.qc @@ -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);