From 5062ab8773092db76bff36a52a6854a8fe43c53c Mon Sep 17 00:00:00 2001 From: hnt_ts Date: Sat, 9 Aug 2008 19:59:41 +0000 Subject: [PATCH] Added a CON command: getdate sec seconds after the minute min minutes after the hour hour hours since midnight mday day of the month mon months since January year years since 1900 wday days since Sunday yday days since January git-svn-id: https://svn.eduke32.com/eduke32@955 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/gamedef.c | 23 ++++++++++++++--------- polymer/eduke32/source/gamedef.h | 19 ++++++++++--------- polymer/eduke32/source/gameexec.c | 22 ++++++++++++++++++++++ polymer/eduke32/source/premap.c | 3 ++- 4 files changed, 48 insertions(+), 19 deletions(-) diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 506defddb..c1de7fdce 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -421,18 +421,18 @@ static const char *keyw[] = "dynamicremap", // 285 "setinput", // 286 "getinput", // 287 - "save", // 288 + "save", // 288 "cansee", // 289 "canseespr", // 290 "findnearactorz", // 291 "findnearactorzvar", // 292 "findnearspritez", // 293 "findnearspritezvar", // 294 - "zshootvar", // 295 - "ezshootvar", // 296 - "getcurraddress", // 297 - "jump", // 298 - "qstrlen", // 299 + "zshootvar", // 295 + "ezshootvar", // 296 + "getcurraddress", // 297 + "jump", // 298 + "qstrlen", // 299 "getincangle", // 300 "quake", // 301 "showview", // 302 @@ -454,9 +454,9 @@ static const char *keyw[] = "resizearray", // 318 "writearraytofile", // 319 "readarrayfromfile", // 320 - "starttrackvar", // 321 - "qgetsysstr", // 322 - "getticks", // 323 + "starttrackvar", // 321 + "qgetsysstr", // 322 + "getticks", // 323 "gettspr", // 324 "settspr", // 325 "savemapstate", // 326 @@ -465,6 +465,7 @@ static const char *keyw[] = "scriptsize", // 329 "definegamename", // 330 "cmenu", // 331 + "getdate", // 332 "" }; @@ -3862,6 +3863,10 @@ static int parsecommand(void) } break; + case CON_GETDATE: + transmultvarstype(GAMEVAR_FLAG_READONLY,8); + break; + case CON_MOVESPRITE: case CON_SETSPRITE: if (!CheckEventSync(current_event)) diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index 22bcedc86..c0d7ab1f4 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -798,18 +798,18 @@ enum keywords CON_DYNAMICREMAP, // 285 CON_SETINPUT, // 286 CON_GETINPUT, // 287 - CON_SAVE, // 288 + CON_SAVE, // 288 CON_CANSEE, // 289 CON_CANSEESPR, // 290 CON_FINDNEARACTORZ, // 291 CON_FINDNEARACTORZVAR, // 292 CON_FINDNEARSPRITEZ, // 293 CON_FINDNEARSPRITEZVAR, // 294 - CON_ZSHOOTVAR, // 295 - CON_EZSHOOTVAR, // 296 - CON_GETCURRADDRESS, // 297 - CON_JUMP, // 298 - CON_QSTRLEN, // 299 + CON_ZSHOOTVAR, // 295 + CON_EZSHOOTVAR, // 296 + CON_GETCURRADDRESS, // 297 + CON_JUMP, // 298 + CON_QSTRLEN, // 299 CON_GETINCANGLE, // 300 CON_QUAKE, // 301 CON_SHOWVIEW, // 302 @@ -831,9 +831,9 @@ enum keywords CON_RESIZEARRAY, // 318 CON_WRITEARRAYTOFILE, // 319 CON_READARRAYFROMFILE, // 320 - CON_STARTTRACKVAR, // 321 - CON_QGETSYSSTR, // 322 - CON_GETTICKS, // 323 + CON_STARTTRACKVAR, // 321 + CON_QGETSYSSTR, // 322 + CON_GETTICKS, // 323 CON_GETTSPR, // 324 CON_SETTSPR, // 325 CON_SAVEMAPSTATE, // 326 @@ -842,4 +842,5 @@ enum keywords CON_SCRIPTSIZE, // 329 CON_DEFINEGAMENAME, // 330 CON_CMENU, // 331 + CON_GETDATE, // 332 }; diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 829748a7c..c7cc14784 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -6090,6 +6090,28 @@ static int parse(void) break; } + case CON_GETDATE: + insptr++; + { + int v1=*insptr++,v2=*insptr++,v3=*insptr++,v4=*insptr++,v5=*insptr++,v6=*insptr++,v7=*insptr++,v8=*insptr++; + time_t rawtime; + struct tm * ti; + + time(&rawtime); + ti=localtime(&rawtime); + // initprintf("Time&date: %s\n",asctime (ti)); + + SetGameVarID(v1, ti->tm_sec, g_i, g_p); + SetGameVarID(v2, ti->tm_min, g_i, g_p); + SetGameVarID(v3, ti->tm_hour, g_i, g_p); + SetGameVarID(v4, ti->tm_mday, g_i, g_p); + SetGameVarID(v5, ti->tm_mon, g_i, g_p); + SetGameVarID(v6, ti->tm_year+1900, g_i, g_p); + SetGameVarID(v7, ti->tm_wday, g_i, g_p); + SetGameVarID(v8, ti->tm_yday, g_i, g_p); + break; + } + case CON_MOVESPRITE: case CON_SETSPRITE: insptr++; diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 0f29f7f85..d0df0e09a 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -1887,4 +1887,5 @@ void FreeMapState(int mapnum) } Bfree(map[mapnum].savedstate); map[mapnum].savedstate = NULL; -} \ No newline at end of file +} +