From 0c37ad857b7f7b5e97f3090fa8857d11eb755ab5 Mon Sep 17 00:00:00 2001 From: ac_stef Date: Thu, 11 Dec 2008 15:59:54 +0000 Subject: [PATCH] nice filenames for server-stored demos git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@3997 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/server.cpp | 2 +- source/src/tools.cpp | 10 ++++++++++ source/src/tools.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/src/server.cpp b/source/src/server.cpp index 94eb923e..b1a90e71 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -709,7 +709,7 @@ void enddemorecord() demotmp = NULL; if(demopath[0]) { - s_sprintf(msg)("%s%lld_%s_%s.dmo", demopath, ((long long) time(NULL)) / 100, behindpath(smapname), modestr(gamemode, true)); + s_sprintf(msg)("%s%s_%s_%s.dmo", demopath, filenametime(), behindpath(smapname), modestr(gamemode, true)); path(msg); FILE *demo = openfile(msg, "wb"); if(demo) diff --git a/source/src/tools.cpp b/source/src/tools.cpp index 303d5123..0235db9b 100644 --- a/source/src/tools.cpp +++ b/source/src/tools.cpp @@ -40,6 +40,16 @@ char *getregszvalue(HKEY root, const char *keystr, const char *query) } #endif +const char *filenametime() +{ + static string asciitime; + time_t t = time(NULL); + struct tm * timeinfo; + timeinfo = gmtime (&t); + strftime(asciitime, sizeof(string) - 1, "%Y%m%d_%H.%M.%S", timeinfo); + return asciitime; +} + char *path(char *s) { for(char *t = s; (t = strpbrk(t, "/\\")); *t++ = PATHDIV); diff --git a/source/src/tools.h b/source/src/tools.h index b68216aa..e3325e06 100644 --- a/source/src/tools.h +++ b/source/src/tools.h @@ -567,6 +567,7 @@ inline char *newstring(const char *s) { return newstring(s, strlen(s)) inline char *newstringbuf() { return newstring(_MAXDEFSTR-1); } inline char *newstringbuf(const char *s) { return newstring(s, _MAXDEFSTR-1); } +extern const char *filenametime(); extern char *path(char *s); extern char *path(const char *s, bool copy); extern const char *behindpath(const char *s);