diff --git a/changelog.txt b/changelog.txt index ff289bc4..a4217629 100644 --- a/changelog.txt +++ b/changelog.txt @@ -175,6 +175,8 @@ CubeScript [*] numconlines - Returns the current number of lines on the console. (e.g. echo $numconlines // Example output: 153) [*] Multiple Idents - New helper aliases for voting for SURV, TPF, and TLSS. (e.g. /surv ac_desert) [*] looplist - Browses a list executing a body for each element (e.g. looplist "zero one two three" number [ echo $number ]) +[*] gametimestart - Returns the time (in milliseconds) when the last map was loaded. +[*] mapbackupsonsave - Determines if map backups (.bak) should be created when a map is saved. [*] "Sleeps" can be persistent. (e.g. "Persist" even through map loads - new optional 3rd argument of the /sleep command) [*] Substr crash bug is fixed. Also the command can now use a negative position value. [*] New stat in (pstat_score) for teamkills. New list is: FLAGS FRAGS DEATHS POINTS TEAM TEAMKILLS NAME // TODO move to compatibility.cfg diff --git a/config/docs.cfg b/config/docs.cfg index 4c7c4b95..547f342b 100644 --- a/config/docs.cfg +++ b/config/docs.cfg @@ -545,6 +545,7 @@ docremark [This does not work in multiplayer. For entertainment purposes only :) docident [gametimecurrent] [Returns the time (in milliseconds) of the currently played game. READ ONLY]; docexample [showtime = [ if (> $lastgametimeupdate 0) [ gmr = (- $gametimemaximum (+ $gametimecurrent (- (millis) $lastgametimeupdate))) gsr = (div $gmr 1000) gts = (mod $gsr 60) if (< $gts 10) [ gts = (concatword 0 $gts) ] [ ] gtm = (div $gsr 60) if (< $gtm 10) [ gtm = (concatword 0 $gtm) ] [ ] echo (concatword $gtm : $gts) remaining ] [ echo gametime not updated yet ] ]] []; docident [gametimemaximum] [Returns the maximum time (in milliseconds) of the currently played game. READ ONLY]; +docident [gametimestart] [Returns the time "(in milliseconds)" when the last map was loaded.]; docident [getclientmode] [Returns the current game mode number.]; docident [getdemo] []; docargument [X] [number in list] [] [0]; @@ -918,6 +919,8 @@ docident [savemap] [Saves the current map.]; docargument [M] [file name of the map, see command 'map' for the naming scheme] [string] [0]; docremark [savemap makes a versioned backup (mapname_N.BAK) if a map by that name already exists. If the name argument is omitted, it is saved under the current map name.]; docremark [Where you store a map depends on the complexity of what you are creating: if its a single map (maybe with its own .cfg) then the "base" package is the best place. If its multiple maps or a map with new media (textures etc.) its better to store it in its own package (a directory under "packages"), which makes distributing it less messy.]; +docident [mapbackupsonsave] [Determines if map backups (.bak) should be created when a map is saved.]; +docargument [N] [0 off, 1 on] [min 0/max 1/default 1] [0]; docident [scalelights] [Scales all lights in the map.]; docargument [S] [size change (percentage)] [] [0]; docargument [I] [intensity change (percentage)] [] [0]; diff --git a/docs/reference.xml b/docs/reference.xml index ef410921..d10db47e 100644 --- a/docs/reference.xml +++ b/docs/reference.xml @@ -3003,6 +3003,16 @@ Output: + + + Returns the time (in milliseconds) when the last map was loaded. + + + + + + + Returns the last time (in milliseconds) the gametime was updated. READ ONLY @@ -3708,6 +3718,11 @@ Output: + + + Determines if map backups (.bak) should be created when a map is saved. + + Creates a new map. diff --git a/source/src/command.cpp b/source/src/command.cpp index 95723b80..715167cb 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -1487,7 +1487,7 @@ void timestring_() result(res[0] == '0' ? res + 1 : res); } -int millis_() { extern int totalmillis; return totalmillis; } +extern int millis_() { extern int totalmillis; return totalmillis; } void strlen_(char *s) { string r; formatstring(r)("%d", strlen(s)); result(r); } void substr_(char *fs, char *pa, char *len) diff --git a/source/src/protos.h b/source/src/protos.h index 2a2c5a04..842e7a46 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -772,6 +772,7 @@ extern int execcontext; extern const char *currentserver(int i); extern void setcontext(const char *context, const char *info); extern void resetcontext(); +extern int millis_(); // server extern int modeacronyms; diff --git a/source/src/world.cpp b/source/src/world.cpp index d6936c3d..9019f689 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -510,6 +510,8 @@ void newmap(int i) { addmsg(SV_NEWMAP, "ri", max(i, 0)); if(identexists("onNewMap")) execute("onNewMap"); } + defformatstring(startmillis)("%d", millis_()); + alias("gametimestart", startmillis); } } diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 5af3e6f3..406f8a15 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -363,6 +363,8 @@ void wrapCMD(int i) { checkmapdependencies(false, i!=0); } //COMMAND(checkmapdependencies, ARG_NONE); // for some reason this still results in silent==true - WTF? It used to work with the _proper_ default. COMMANDN(checkmapdependencies, wrapCMD, ARG_1INT); +VARP(mapbackupsonsave, 0, 1, 1); + void save_world(char *mname) { if(!*mname) mname = getclientmap(); @@ -370,7 +372,7 @@ void save_world(char *mname) voptimize(); toptimize(); setnames(mname); - backup(cgzname, bakname); + if(mapbackupsonsave) backup(cgzname, bakname); checkmapdependencies(true); copystring(hdr.mediareq, reqmpak, 128); stream *f = opengzfile(cgzname, "wb"); @@ -696,6 +698,8 @@ bool load_world(char *mname) // still supports all map formats that have printf("loaded mapsounds (%d milliseconds)\n", watch.stop()); c2skeepalive(); + defformatstring(startmillis)("%d", millis_()); + alias("gametimestart", startmillis); startmap(mname); return true; }