diff --git a/Makefile b/Makefile index 8e8b615..ab676eb 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,7 @@ apply-patches: $(PATCH) < patches/parseplayer.patch $(PATCH) < patches/nextfollowteam.patch $(PATCH) < patches/proxy_setip.patch + $(PATCH) < patches/server_demo_name.patch unix2dos src/vcpp/sauerbraten.nsi unix2dos src/vcpp/sauerbraten.vcxproj cd src && make depend diff --git a/patches/server_demo_name.patch b/patches/server_demo_name.patch new file mode 100644 index 0000000..73eb137 --- /dev/null +++ b/patches/server_demo_name.patch @@ -0,0 +1,19 @@ +diff --git src/fpsgame/server.cpp src/fpsgame/server.cpp +index cde1a60..b3c2373 100644 +--- src/fpsgame/server.cpp ++++ src/fpsgame/server.cpp +@@ -745,10 +745,11 @@ namespace server + if(!demotmp) return; + int len = (int)min(demotmp->size(), stream::offset((maxdemosize<<20) + 0x10000)); + demofile &d = demos.add(); ++ static string timestr; + time_t t = time(NULL); +- char *timestr = ctime(&t), *trim = timestr + strlen(timestr); +- while(trim>timestr && iscubespace(*--trim)) *trim = '\0'; +- formatstring(d.info, "%s: %s, %s, %.2f%s", timestr, modename(gamemode), smapname, len > 1024*1024 ? len/(1024*1024.f) : len/1024.0f, len > 1024*1024 ? "MB" : "kB"); ++ size_t timestrlen = strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S UTC", gmtime(&t)); ++ timestr[min(timestrlen, sizeof(timestr)-1)] = '\0'; ++ formatstring(d.info, "%s on %s, ended %s (%.2f %s)", modename(gamemode), smapname, timestr, len > 1024*1024 ? len/(1024*1024.f) : len/1024.0f, len > 1024*1024 ? "MB" : "kB"); + sendservmsgf("demo \"%s\" recorded on server", d.info); + d.data = new uchar[len]; + d.len = len; diff --git a/src/fpsgame/server.cpp b/src/fpsgame/server.cpp index cde1a60..ae9528d 100644 --- a/src/fpsgame/server.cpp +++ b/src/fpsgame/server.cpp @@ -745,10 +745,11 @@ namespace server if(!demotmp) return; int len = (int)min(demotmp->size(), stream::offset((maxdemosize<<20) + 0x10000)); demofile &d = demos.add(); + static string timestr; time_t t = time(NULL); - char *timestr = ctime(&t), *trim = timestr + strlen(timestr); - while(trim>timestr && iscubespace(*--trim)) *trim = '\0'; - formatstring(d.info, "%s: %s, %s, %.2f%s", timestr, modename(gamemode), smapname, len > 1024*1024 ? len/(1024*1024.f) : len/1024.0f, len > 1024*1024 ? "MB" : "kB"); + size_t timestrlen = strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S UTC", gmtime(&t)); + timestr[min(timestrlen, sizeof(timestr)-1)] = '\0'; + formatstring(d.info, "%s on %s, ended %s (%.2f %s)", modename(gamemode), smapname, timestr, len > 1024*1024 ? len/(1024*1024.f) : len/1024.0f, len > 1024*1024 ? "MB" : "kB"); sendservmsgf("demo \"%s\" recorded on server", d.info); d.data = new uchar[len]; d.len = len;