Skip to content

Commit

Permalink
add server_demo_name.patch
Browse files Browse the repository at this point in the history
closes #43
  • Loading branch information
sauerbraten committed Mar 17, 2022
1 parent 41ab2f4 commit 382cf92
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions patches/server_demo_name.patch
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 4 additions & 3 deletions src/fpsgame/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 382cf92

Please sign in to comment.