From 1ebebb5690086a6ebc888ff1af521a256b44451c Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 05:00:07 +0200 Subject: [PATCH 01/12] extract the date out of replay + display em in replay hut this is kinda horrid, but essentially, the number at the start of replay names is actually the time when the replay was recorded, so i can extract that and convert it to a readable format this probably can be done alot cleaner lmao --- src/d_main.c | 3 ++ src/d_netcmd.c | 29 ++++++++++++-------- src/g_game.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/g_game.h | 1 + src/m_menu.c | 16 +++++++++-- 5 files changed, 110 insertions(+), 13 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 71541c2cc..49da3bb01 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1487,6 +1487,8 @@ static void D_CheckSaturnExtraFiles(void) memcpy(inputdisplay_cons_t, inputdisplay_cons_temp, sizeof(inputdisplay_cons_t)); } +#include + // // D_SRB2Main // @@ -1684,6 +1686,7 @@ void D_SRB2Main(void) CONS_Printf("I_InitializeTime()...\n"); I_InitializeTime(); + setlocale(LC_TIME, ""); // Make backups of some SOCcable tables. P_BackupTables(); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 3f7641af8..9e7190c81 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -954,7 +954,7 @@ void D_RegisterClientCommands(void) COM_AddCommand("displayplayer", Command_Displayplayer_f); - CV_RegisterVar(&cv_audbuffersize); + CV_RegisterVar(&cv_audbuffersize); // m_menu.c CV_RegisterVar(&cv_chatheight); @@ -965,10 +965,10 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_chatnotifications); CV_RegisterVar(&cv_chatbacktint); CV_RegisterVar(&cv_songcredits); - CV_RegisterVar(&cv_showfreeplay); + CV_RegisterVar(&cv_showfreeplay); CV_RegisterVar(&cv_skinselectspin); CV_RegisterVar(&cv_showallmaps); - + CV_RegisterVar(&cv_growmusic); CV_RegisterVar(&cv_supermusic); @@ -1054,7 +1054,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_midimusicvolume); #endif CV_RegisterVar(&cv_numChannels); - + #ifdef HAVE_OPENMPT CV_RegisterVar(&cv_modfilter); CV_RegisterVar(&cv_stereosep); @@ -3074,18 +3074,25 @@ static void Command_ReplayMarker(void) CONS_Printf(M_GetText("You must be in a level to use this.\n")); return; } - if (demo.savemode == DSM_WILLAUTOSAVE) { + if (demo.savemode == DSM_WILLAUTOSAVE) + { demo.savemode = DSM_NOTSAVING; CONS_Printf("Replay unmarked.\n"); - } else { - int adjustedleveltime = leveltime - starttime; + } + else + { demo.savemode = DSM_WILLAUTOSAVE; + + int adjustedleveltime = leveltime - starttime; + if (adjustedleveltime < 0) adjustedleveltime = 0; + char *title = G_BuildMapTitle(gamemap); snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); if (title) Z_Free(title); + CONS_Printf("Replay will be saved!\n"); } } @@ -4545,7 +4552,7 @@ Command_Addskins (void) /* if (fasticmp(COM_Argv(2), "-force") || fasticmp(COM_Argv(2), "-f")) { CONS_Alert(CONS_NOTICE, M_GetText("Adding file %s. May or may not be a skin.\n"), COM_Argv(1)); - P_AddWadFile(COM_Argv(1), 0, true); + P_AddWadFile(COM_Argv(1), 0, true); } else { if (DumbStartsWith("KC_", COM_Argv(1))) { P_AddWadFile(COM_Argv(1), 0, true); @@ -4625,7 +4632,7 @@ static void Command_GLocalSkin (void) { int i; - for (i = 0; i < MAXPLAYERS; ++i) + for (i = 0; i < MAXPLAYERS; ++i) { if (!playeringame[i]) continue; @@ -6012,7 +6019,7 @@ static void Command_ListSkins(void) } static void Command_SkinSearch(void) -{ +{ size_t i; UINT16 s; UINT16 ic = 0; @@ -6022,7 +6029,7 @@ static void Command_SkinSearch(void) { skin_t *skininput = &skins[s]; if (strcasestr(skininput->realname,COM_Argv(i))) - { + { ic++; CONS_Printf("%d. %s%s:\x80 %s\n", ic,HU_SkinColorToConsoleColor(skininput->prefcolor),skininput->realname,skininput->name); } diff --git a/src/g_game.c b/src/g_game.c index 3cbe4bfb8..3dbba7d51 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6794,6 +6794,71 @@ void G_LoadDemoInfo(menudemo_t *pdemo) Z_Free(infobuffer); } +#include +#include + +static char *G_GetDemoDate(menudemo_t *pdemo) +{ + char *datetime; + datetime = malloc(sizeof(pdemo->date)); // mallocma balls + + // no mallocma balls... :c + if (!datetime) + { + free(datetime); + return NULL; + } + + // get the actual filename Zzz... + const char *filename; + + filename = strrchr(pdemo->filepath, '/'); + if (!filename) + filename = strrchr(pdemo->filepath, '\\'); + + if (!filename) + { + free(datetime); + return NULL; + } + + filename = filename + 1; // filename, filename, filename, filename..... + + // get only the first 10 characters (time before conversion) + char timestr[10]; + strncpy(timestr , filename, 10); + + // convert it to long Zzz.... + long longtime = 0; + longtime = strtol(timestr, NULL, 10); + + // then throw it into localtime to get an actual human readable format lmao + struct tm tm_buf; + time_t demo_date = 0; + + demo_date = longtime; + localtime_r(&demo_date, &tm_buf); + + // cant believe we ended up in 1970 + if (tm_buf.tm_year == 70) + { + free(datetime); + return NULL; + } + + const char *format; + + // US ppl are special (: + if (strstr(setlocale(LC_TIME, NULL), "en_US")) + format = "%m.%d.%Y"; + else + format = "%d.%m.%Y"; + + strftime(datetime, sizeof(pdemo->date), format, &tm_buf); + + return datetime; +} + void G_LoadDemoTitle(menudemo_t *pdemo) { UINT8 infobuffer[96], *info_p; @@ -6827,11 +6892,20 @@ void G_LoadDemoTitle(menudemo_t *pdemo) READUINT8(info_p); pdemoversion = READUINT16(info_p); + memset(pdemo->date, 0, sizeof(pdemo->date)); + switch(pdemoversion) { case DEMOVERSION: // latest always supported // demo title M_Memcpy(pdemo->title, info_p, 64); + + // demo date + char *demodate; + demodate = G_GetDemoDate(pdemo); + if (demodate) + strncpy(pdemo->date, demodate, sizeof(pdemo->date)); + free(demodate); break; #ifdef DEMO_COMPAT_100 case 0x0001: diff --git a/src/g_game.h b/src/g_game.h index 39b266b5a..aa89a6368 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -83,6 +83,7 @@ typedef struct menudemo_s { menudemotype_e type; char title[65]; // Null-terminated for string prints + char date[11]; // date when replay was recorded UINT16 map; UINT8 addonstatus; // What do we need to do addon-wise to play this demo? UINT8 gametype; diff --git a/src/m_menu.c b/src/m_menu.c index 08394c2c9..098f55e29 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6826,7 +6826,15 @@ static void ReplayNamesLoadThread(void* userdata) for (size_t i = 0; i < demolist_all_size; ++i) { if (demolist_all_local[i].type != MD_SUBDIR) + { G_LoadDemoTitle(&demolist_all_local[i]); + + // this is fucking horrid, but i wanna be able to search for dates + /*if (demolist_all_local[i].date[0] != '\0') + { + snprintf(demolist_all_local[i].title, sizeof(demolist_all_local[i].title), "%s %s", demolist_all_local[i].title, demolist_all_local[i].date); + }*/ + } } Lock_search_state(); @@ -7236,8 +7244,12 @@ static void DrawReplayHutReplayInfo(void) else V_DrawString(x, y, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT, "Level is not loaded."); - if (demolist[dir_on[menudepthleft]].numlaps) - V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("(%d laps)", demolist[dir_on[menudepthleft]].numlaps)); + //if (demolist[dir_on[menudepthleft]].numlaps) + //V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("(%d laps)", demolist[dir_on[menudepthleft]].numlaps)); + + // not the final place for this + if (demolist[dir_on[menudepthleft]].date[0] != '\0') + V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("%s", demolist[dir_on[menudepthleft]].date)); V_DrawString(x, y+20, V_SNAPTOTOP|V_ALLOWLOWERCASE, demolist[dir_on[menudepthleft]].gametype == GT_RACE ? va("Race (%s speed)", kartspeed_cons_t[demolist[dir_on[menudepthleft]].kartspeed & ~DF_ENCORE].strvalue) : From f1bcdaf68feec85d086e107b8a921765ad2a0b05 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 05:07:18 +0200 Subject: [PATCH 02/12] do pathseperator check like this --- src/g_game.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 3dbba7d51..d4195dedc 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6797,6 +6797,12 @@ void G_LoadDemoInfo(menudemo_t *pdemo) #include #include +#if defined (_WIN32) +#define PATHSEPSTR '\\' +#else +#define PATHSEPSTR '/' +#endif + static char *G_GetDemoDate(menudemo_t *pdemo) { char *datetime; @@ -6812,9 +6818,7 @@ static char *G_GetDemoDate(menudemo_t *pdemo) // get the actual filename Zzz... const char *filename; - filename = strrchr(pdemo->filepath, '/'); - if (!filename) - filename = strrchr(pdemo->filepath, '\\'); + filename = strrchr(pdemo->filepath, PATHSEPSTR); if (!filename) { @@ -6858,6 +6862,7 @@ static char *G_GetDemoDate(menudemo_t *pdemo) return datetime; } +#undef PATHSEPSTR void G_LoadDemoTitle(menudemo_t *pdemo) { From b7542a2106341806f5e93efcde90be67c1b1fb11 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 11:51:58 +0200 Subject: [PATCH 03/12] try to catch more bad demo dates i mean this game did not exist in 2010 lmao but occasionally it actually returned dates other than 1970 depending on what was passed to it lmao --- src/g_game.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index d4195dedc..2d9452ba1 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6815,6 +6815,8 @@ static char *G_GetDemoDate(menudemo_t *pdemo) return NULL; } + time_t file_time = 0; + // get the actual filename Zzz... const char *filename; @@ -6833,18 +6835,14 @@ static char *G_GetDemoDate(menudemo_t *pdemo) strncpy(timestr , filename, 10); // convert it to long Zzz.... - long longtime = 0; - longtime = strtol(timestr, NULL, 10); + file_time = strtol(timestr, NULL, 10); // then throw it into localtime to get an actual human readable format lmao struct tm tm_buf; - time_t demo_date = 0; - - demo_date = longtime; - localtime_r(&demo_date, &tm_buf); + localtime_r(&file_time, &tm_buf); // cant believe we ended up in 1970 - if (tm_buf.tm_year == 70) + if (tm_buf.tm_year <= 110) { free(datetime); return NULL; From 2201d58f7de1d939f9b6ea8900e000577bd300c3 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 12:35:14 +0200 Subject: [PATCH 04/12] try and get file creation time in some cases on windoze builds untested as of right now --- src/g_game.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 2d9452ba1..754182e6e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6799,6 +6799,17 @@ void G_LoadDemoInfo(menudemo_t *pdemo) #if defined (_WIN32) #define PATHSEPSTR '\\' +// return the file creation time +// useful for demos that were renamed +static long G_GetCreationTime(char *filepath) +{ + struct stat fileinfo; + + if (stat(filepath, &fileinfo) == 0) + return fileinfo.st_ctime; + + return 0; +} #else #define PATHSEPSTR '/' #endif @@ -6811,7 +6822,6 @@ static char *G_GetDemoDate(menudemo_t *pdemo) // no mallocma balls... :c if (!datetime) { - free(datetime); return NULL; } @@ -6822,11 +6832,20 @@ static char *G_GetDemoDate(menudemo_t *pdemo) filename = strrchr(pdemo->filepath, PATHSEPSTR); +#if defined (_WIN32) + if (!filename) + { + // if we cant get a filename try just getting the file create time + file_time = G_GetCreationTime(pdemo->filepath); + goto skipfilenametime; + } +#else if (!filename) { free(datetime); return NULL; } +#endif filename = filename + 1; // filename, filename, filename, filename..... @@ -6837,6 +6856,10 @@ static char *G_GetDemoDate(menudemo_t *pdemo) // convert it to long Zzz.... file_time = strtol(timestr, NULL, 10); +#if defined (_WIN32) +skipfilenametime: +#endif + // then throw it into localtime to get an actual human readable format lmao struct tm tm_buf; localtime_r(&file_time, &tm_buf); @@ -6844,10 +6867,29 @@ static char *G_GetDemoDate(menudemo_t *pdemo) // cant believe we ended up in 1970 if (tm_buf.tm_year <= 110) { +#if defined (_WIN32) + // uh ohh, we got an invalid time + // try one more time getting the creation time + file_time = G_GetCreationTime(pdemo->filepath); + localtime_r(&file_time, &tm_buf); + + if (tm_buf.tm_year <= 110) + { + free(datetime); + return NULL; + } + else + goto gotcreationtime; +#else free(datetime); return NULL; +#endif } +#if defined (_WIN32) +gotcreationtime: +#endif + const char *format; // US ppl are special (: From 02c1a9a58ded214102d79d2b846826600d36eba6 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 13:03:57 +0200 Subject: [PATCH 05/12] apparently we have "nameonly" ty indev <3 --- src/g_game.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 754182e6e..7887bb434 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6798,7 +6798,6 @@ void G_LoadDemoInfo(menudemo_t *pdemo) #include #if defined (_WIN32) -#define PATHSEPSTR '\\' // return the file creation time // useful for demos that were renamed static long G_GetCreationTime(char *filepath) @@ -6810,8 +6809,6 @@ static long G_GetCreationTime(char *filepath) return 0; } -#else -#define PATHSEPSTR '/' #endif static char *G_GetDemoDate(menudemo_t *pdemo) @@ -6827,10 +6824,9 @@ static char *G_GetDemoDate(menudemo_t *pdemo) time_t file_time = 0; - // get the actual filename Zzz... - const char *filename; - - filename = strrchr(pdemo->filepath, PATHSEPSTR); + // get le filepath + char *filename; + filename = strdup(pdemo->filepath); #if defined (_WIN32) if (!filename) @@ -6847,11 +6843,13 @@ static char *G_GetDemoDate(menudemo_t *pdemo) } #endif - filename = filename + 1; // filename, filename, filename, filename..... + // get the actual filename Zzz... + nameonly(filename); // get only the first 10 characters (time before conversion) char timestr[10]; strncpy(timestr , filename, 10); + free(filename); // dont need this anymore a // convert it to long Zzz.... file_time = strtol(timestr, NULL, 10); From e8c6dca8c167189455612b623d31b09aba7544a8 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 13:07:14 +0200 Subject: [PATCH 06/12] dont need le strncpy --- src/g_game.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 7887bb434..b1963a7ab 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6846,13 +6846,9 @@ static char *G_GetDemoDate(menudemo_t *pdemo) // get the actual filename Zzz... nameonly(filename); - // get only the first 10 characters (time before conversion) - char timestr[10]; - strncpy(timestr , filename, 10); - free(filename); // dont need this anymore a - // convert it to long Zzz.... - file_time = strtol(timestr, NULL, 10); + file_time = strtol(filename, NULL, 10); + free(filename); // dont need this anymore a #if defined (_WIN32) skipfilenametime: From 9c25d99156899604b44b2c3a6d7bf998c313fa4e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 13:47:05 +0200 Subject: [PATCH 07/12] print demo version on "outdated" demos idk if this is fine lel --- src/g_game.c | 3 +++ src/g_game.h | 1 + src/m_menu.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index b1963a7ab..e5355c324 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6653,6 +6653,9 @@ void G_LoadDemoInfo(menudemo_t *pdemo) subversion = READUINT8(info_p); pdemoversion = READUINT16(info_p); + memset(pdemo->version, 0, sizeof(pdemo->version)); + sprintf(pdemo->version, "v%d.%d", version, subversion); + switch(pdemoversion) { case DEMOVERSION: // latest always supported diff --git a/src/g_game.h b/src/g_game.h index aa89a6368..ddc4ff40e 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -84,6 +84,7 @@ typedef struct menudemo_s { char title[65]; // Null-terminated for string prints char date[11]; // date when replay was recorded + char version[6]; // combined version and subversion UINT16 map; UINT8 addonstatus; // What do we need to do addon-wise to play this demo? UINT8 gametype; diff --git a/src/m_menu.c b/src/m_menu.c index 098f55e29..1cf674f6f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7203,7 +7203,7 @@ static void DrawReplayHutReplayInfo(void) break; // Can't think of anything to draw here right now case MD_OUTDATED: - V_DrawThinString(17, 64, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT|highlightflags, "Recorded on an outdated version."); + V_DrawThinString(17, 64, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT|highlightflags, va("Recorded on an outdated version. %s", demolist[dir_on[menudepthleft]].version)); /*fallthru*/ default: // Draw level stuff From 3e60b1b388b09e7d34137ea174220375d6df7ba0 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 13:53:19 +0200 Subject: [PATCH 08/12] bigger buffer for demo version thing --- src/g_game.c | 2 +- src/g_game.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index e5355c324..edd6ed467 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6654,7 +6654,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo) pdemoversion = READUINT16(info_p); memset(pdemo->version, 0, sizeof(pdemo->version)); - sprintf(pdemo->version, "v%d.%d", version, subversion); + snprintf(pdemo->version, sizeof(pdemo->version), "v%d.%d", version, subversion); switch(pdemoversion) { diff --git a/src/g_game.h b/src/g_game.h index ddc4ff40e..39c5027da 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -84,7 +84,7 @@ typedef struct menudemo_s { char title[65]; // Null-terminated for string prints char date[11]; // date when replay was recorded - char version[6]; // combined version and subversion + char version[12]; // combined version and subversion UINT16 map; UINT8 addonstatus; // What do we need to do addon-wise to play this demo? UINT8 gametype; From 892a59ff154e283d6923693bfa61fb6231654611 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 14:18:10 +0200 Subject: [PATCH 09/12] add cvar to change the demo date formatting bruh --- src/d_netcmd.c | 2 ++ src/g_game.c | 9 +++++++-- src/g_game.h | 1 + src/m_menu.c | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9e7190c81..9b68717db 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1093,6 +1093,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_verticallook[i]); } + CV_RegisterVar(&cv_demodateformat); + // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); COM_AddCommand("writethings", Command_Writethings_f); diff --git a/src/g_game.c b/src/g_game.c index edd6ed467..363b4caa4 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -341,6 +341,9 @@ consvar_t cv_maxdemosize = {"maxdemosize", "10", CV_SAVE, maxdemosize_cons_t, NU static CV_PossibleValue_t demochangemap_cons_t[] = {{0, "Disabled"}, {1, "Diff Map"}, {2, "Always"}, {0, NULL}}; consvar_t cv_demochangemap = {"netdemo_savemapchange", "Disabled", CV_SAVE, demochangemap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t demodateformat_cons_t[] = {{0, "Automatic"}, {1, "EU"}, {2, "US"}, {0, NULL}}; +consvar_t cv_demodateformat = {"netdemo_dateformat", "Automatic", CV_SAVE, demodateformat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + // Analog Control void SendWeaponPref(void); void SendWeaponPref2(void); @@ -6890,10 +6893,12 @@ gotcreationtime: const char *format; // US ppl are special (: - if (strstr(setlocale(LC_TIME, NULL), "en_US")) + if (cv_demodateformat.value == 2) format = "%m.%d.%Y"; - else + else if (cv_demodateformat.value == 1) format = "%d.%m.%Y"; + else + format = strstr(setlocale(LC_TIME, NULL), "en_US") ? "%m.%d.%Y" : "%d.%m.%Y"; strftime(datetime, sizeof(pdemo->date), format, &tm_buf); diff --git a/src/g_game.h b/src/g_game.h index 39c5027da..e50557a9d 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -42,6 +42,7 @@ extern savebuffer_t demobuf; // demoplaying back and demo recording extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality, cv_maxdemosize, cv_demochangemap; +extern consvar_t cv_demodateformat; // Publicly-accessible demo vars struct demovars_s { diff --git a/src/m_menu.c b/src/m_menu.c index 1cf674f6f..0248dbaf1 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -647,6 +647,7 @@ static menuitem_t MISC_ReplayOptionsMenu[] = {IT_CVAR|IT_STRING, NULL, "Sync Check Interval", &cv_netdemosyncquality, 20}, {IT_CVAR|IT_STRING, NULL, "Max demo size (MiB)", &cv_maxdemosize, 30}, {IT_CVAR|IT_STRING, NULL, "Replay Search Rate", &cv_replaysearchrate, 40}, + {IT_CVAR|IT_STRING, NULL, "Replay Date Format", &cv_demodateformat, 50}, }; static tic_t playback_last_menu_interaction_leveltime = 0; From 804ca985f3e6ccdeffdaceadad6bdb1dadae90af Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 11 Apr 2025 14:23:21 +0200 Subject: [PATCH 10/12] just make the numlaps draw besides the date idk theres no good place for this otherwise --- src/m_menu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 0248dbaf1..32e28c888 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7245,12 +7245,16 @@ static void DrawReplayHutReplayInfo(void) else V_DrawString(x, y, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT, "Level is not loaded."); - //if (demolist[dir_on[menudepthleft]].numlaps) - //V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("(%d laps)", demolist[dir_on[menudepthleft]].numlaps)); + INT32 datew = 0; - // not the final place for this if (demolist[dir_on[menudepthleft]].date[0] != '\0') + { + datew = V_StringWidth(demolist[dir_on[menudepthleft]].date, 0); V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("%s", demolist[dir_on[menudepthleft]].date)); + } + + if (demolist[dir_on[menudepthleft]].numlaps) + V_DrawThinString(x+datew, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("(%d laps)", demolist[dir_on[menudepthleft]].numlaps)); V_DrawString(x, y+20, V_SNAPTOTOP|V_ALLOWLOWERCASE, demolist[dir_on[menudepthleft]].gametype == GT_RACE ? va("Race (%s speed)", kartspeed_cons_t[demolist[dir_on[menudepthleft]].kartspeed & ~DF_ENCORE].strvalue) : From 98f35b6e06978541b59993bcde84a20c678d4db2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Apr 2025 14:33:11 +0100 Subject: [PATCH 11/12] windoze stimky well this atleast should work for everyone, but be noted that the normal "localtime" function is apparently not thread safe --- src/g_game.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 363b4caa4..54e509be6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -59,6 +59,10 @@ #include "discord.h" #endif +// for replay dates +#include +#include + gameaction_t gameaction; gamestate_t gamestate = GS_NULL; UINT8 ultimatemode = false; @@ -6800,9 +6804,6 @@ void G_LoadDemoInfo(menudemo_t *pdemo) Z_Free(infobuffer); } -#include -#include - #if defined (_WIN32) // return the file creation time // useful for demos that were renamed @@ -6861,25 +6862,25 @@ skipfilenametime: #endif // then throw it into localtime to get an actual human readable format lmao - struct tm tm_buf; - localtime_r(&file_time, &tm_buf); + struct tm *tm_buf = NULL; + tm_buf = localtime(&file_time); // cant believe we ended up in 1970 - if (tm_buf.tm_year <= 110) + if (tm_buf == NULL || tm_buf->tm_year <= 110) { #if defined (_WIN32) // uh ohh, we got an invalid time // try one more time getting the creation time file_time = G_GetCreationTime(pdemo->filepath); - localtime_r(&file_time, &tm_buf); + tm_buf = localtime(&file_time); - if (tm_buf.tm_year <= 110) + if (tm_buf == NULL || tm_buf->tm_year <= 110) { free(datetime); return NULL; } - else - goto gotcreationtime; + + goto gotcreationtime; #else free(datetime); return NULL; @@ -6900,11 +6901,10 @@ gotcreationtime: else format = strstr(setlocale(LC_TIME, NULL), "en_US") ? "%m.%d.%Y" : "%d.%m.%Y"; - strftime(datetime, sizeof(pdemo->date), format, &tm_buf); + strftime(datetime, sizeof(pdemo->date), format, tm_buf); return datetime; } -#undef PATHSEPSTR void G_LoadDemoTitle(menudemo_t *pdemo) { From 48113cb1563768385f99fd486e830a416f1a6693 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Apr 2025 14:36:36 +0100 Subject: [PATCH 12/12] spr->mobj not thing lel --- src/hardware/hw_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 93054e3f0..9e07efa14 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3318,11 +3318,11 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, GLPatch_t *gpatch) float offset = 0; // technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again - const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(thing)->flags & SF_HIRES); + const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(spr->mobj)->flags & SF_HIRES); if (spr->mobj) this_scale = FIXED_TO_FLOAT(spr->mobj->scale); if (hires) - this_scale = this_scale * FIXED_TO_FLOAT(K_GetMobjSkin(thing)->highresscale); + this_scale = this_scale * FIXED_TO_FLOAT(K_GetMobjSkin(spr->mobj)->highresscale); R_GetShadowZ(spr->mobj, &floorslope);