From a067ea2a0b7750bbad824e97228e38ebc33e359e Mon Sep 17 00:00:00 2001 From: ac-stef Date: Mon, 11 May 2015 17:07:11 +0200 Subject: [PATCH] add timestamp to map files --- source/src/world.h | 3 ++- source/src/worldio.cpp | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/src/world.h b/source/src/world.h index a06e0c87..be3a868c 100644 --- a/source/src/world.h +++ b/source/src/world.h @@ -58,7 +58,8 @@ struct header // map file format header int maprevision; int ambient; int flags; // MHF_* - int reserved[11]; + int timestamp; // UTC unixtime of time of save (yes, this will break in 2038) + int reserved[10]; //char mediareq[128]; // version 7 and 8 only. }; diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 12008f13..12f4943f 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -541,6 +541,7 @@ void save_world(char *mname, bool skipoptimise, bool addcomfort) strncpy(hdr.head, "ACMP", 4); // ensure map now declares itself as an AssaultCube map, even if imported as CUBE hdr.version = MAPVERSION; hdr.headersize = sizeof(header); + hdr.timestamp = (int) time(NULL); hdr.numents = 0; loopv(ents) if(ents[i].type!=NOTUSED) hdr.numents++; if(hdr.numents > MAXENTITIES) @@ -556,7 +557,7 @@ void save_world(char *mname, bool skipoptimise, bool addcomfort) DEBUG("version " << tmp.version << " headersize " << tmp.headersize << " entities " << tmp.numents << " factor " << tmp.sfactor << " revision " << tmp.maprevision); lilswap(&tmp.version, 4); // version, headersize, sfactor, numents lilswap(&tmp.waterlevel, 1); - lilswap(&tmp.maprevision, 3); // maprevision, ambient, flags + lilswap(&tmp.maprevision, 4); // maprevision, ambient, flags, timestamp f->write(&tmp, sizeof(header)); if(writeextra) f->write(hx.buf, writeextra); delete[] hx.buf; @@ -681,7 +682,7 @@ bool load_world(char *mname) // still supports all map formats that have { lilswap(&hdr.waterlevel, 1); if(!hdr.watercolor[3]) setwatercolor(); - lilswap(&hdr.maprevision, 3); // maprevision, ambient, flags + lilswap(&hdr.maprevision, 4); // maprevision, ambient, flags, timestamp curmaprevision = hdr.maprevision; } else