From 654bbb9eaa7ff1653c64f833e0920867764cf045 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 23 May 2021 11:47:09 +0200 Subject: [PATCH] Use directly strftime_s() since strftime(false, "%s") isn't reliable --- qcsrc/lib/string.qh | 3 ++- qcsrc/server/intermission.qc | 4 +--- qcsrc/server/world.qc | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-) 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); -- 2.39.2