From 3fa22c508b36e62b8c264dda3dde874e652c6254 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 30 Mar 2020 17:41:48 -0700 Subject: [PATCH 1/4] Put screenshots, movies and replays under a "media" directory --- src/m_menu.c | 15 ++++++++------- src/m_misc.c | 8 ++++---- src/p_setup.c | 12 +++++++----- src/y_inter.c | 9 +++++---- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 267dbe07f..3abf64476 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2101,14 +2101,14 @@ static void Nextmap_OnChange(void) if (currentMenu == &SP_TimeAttackDef) { // see also p_setup.c's P_LoadRecordGhosts - const size_t glen = strlen(srb2home)+1+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; + const size_t glen = strlen(srb2home)+1+strlen("media")+1+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; char *gpath = malloc(glen); INT32 i; if (!gpath) return; - sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)); + sprintf(gpath,"%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)); CV_StealthSetValue(&cv_dummystaff, 0); @@ -5142,7 +5142,7 @@ void M_ReplayHut(INT32 choice) if (!demo.inreplayhut) { - snprintf(menupath, 1024, "%s"PATHSEP"replay"PATHSEP"online"PATHSEP, srb2home); + snprintf(menupath, 1024, "%s"PATHSEP"media"PATHSEP"replay"PATHSEP"online"PATHSEP, srb2home); menupathindex[(menudepthleft = menudepth-1)] = strlen(menupath); } if (!preparefilemenu(false, true)) @@ -7876,20 +7876,21 @@ static boolean M_QuitTimeAttackMenu(void) static void M_ChooseTimeAttack(INT32 choice) { char *gpath; - const size_t glen = strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; + const size_t glen = strlen("media")+1+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; char nameofdemo[256]; (void)choice; emeralds = 0; M_ClearMenus(true); modeattacking = (levellistmode == LLM_BREAKTHECAPSULES ? ATTACKING_CAPSULES : ATTACKING_RECORD); - I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); - I_mkdir(va("%s"PATHSEP"replay"PATHSEP"%s", srb2home, timeattackfolder), 0755); + gpath = va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s", + srb2home, timeattackfolder); + M_MkdirEach(gpath, M_PathParts(gpath) - 3, 0755); if ((gpath = malloc(glen)) == NULL) I_Error("Out of memory for replay filepath\n"); - sprintf(gpath,"replay"PATHSEP"%s"PATHSEP"%s", timeattackfolder, G_BuildMapName(cv_nextmap.value)); + sprintf(gpath,"media"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", timeattackfolder, G_BuildMapName(cv_nextmap.value)); snprintf(nameofdemo, sizeof nameofdemo, "%s-%s-last", gpath, cv_chooseskin.string); if (!cv_autorecord.value) diff --git a/src/m_misc.c b/src/m_misc.c index 2de64d589..34cfb200a 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1121,8 +1121,8 @@ void M_StartMovie(void) if (cv_movie_option.value != 3) { - strcat(pathname, PATHSEP"movies"PATHSEP); - I_mkdir(pathname, 0755); + strcat(pathname, PATHSEP"media"PATHSEP"movies"PATHSEP); + M_MkdirEach(pathname, M_PathParts(pathname) - 2, 0755); } if (rendermode == render_none) @@ -1483,8 +1483,8 @@ void M_DoScreenShot(void) if (cv_screenshot_option.value != 3) { - strcat(pathname, PATHSEP"screenshots"PATHSEP); - I_mkdir(pathname, 0755); + strcat(pathname, PATHSEP"media"PATHSEP"screenshots"PATHSEP); + M_MkdirEach(pathname, M_PathParts(pathname) - 2, 0755); } #ifdef USE_PNG diff --git a/src/p_setup.c b/src/p_setup.c index 40ea643b7..d569c6452 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2621,14 +2621,14 @@ static void P_ForceCharacter(const char *forcecharskin) static void P_LoadRecordGhosts(void) { // see also m_menu.c's Nextmap_OnChange - const size_t glen = strlen(srb2home)+1+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; + const size_t glen = strlen(srb2home)+1+strlen("media")+1+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; char *gpath = malloc(glen); INT32 i; if (!gpath) return; - sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); + sprintf(gpath,"%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); // Best Time ghost if (cv_ghost_besttime.value) @@ -3203,10 +3203,12 @@ boolean P_SetupLevel(boolean skipprecip) //@TODO I'd like to fix dedis crashing when recording replays for the future too... if (!demo.playback && multiplayer && !dedicated) { static char buf[256]; - sprintf(buf, "replay"PATHSEP"online"PATHSEP"%d-%s", (int) (time(NULL)), G_BuildMapName(gamemap)); + char *path; + sprintf(buf, "media"PATHSEP"replay"PATHSEP"online"PATHSEP"%d-%s", (int) (time(NULL)), G_BuildMapName(gamemap)); + + path = va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"online", srb2home); + M_MkdirEach(path, M_PathParts(path) - 4, 0755); - I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); - I_mkdir(va("%s"PATHSEP"replay"PATHSEP"online", srb2home), 0755); G_RecordDemo(buf); } diff --git a/src/y_inter.c b/src/y_inter.c index e9e243b04..93771be5c 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -787,7 +787,7 @@ void Y_Ticker(void) // static void Y_UpdateRecordReplays(void) { - const size_t glen = strlen(srb2home)+1+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; + const size_t glen = strlen(srb2home)+1+strlen("media")+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; char *gpath; char lastdemo[256], bestdemo[256]; UINT8 earnedEmblems; @@ -823,13 +823,14 @@ static void Y_UpdateRecordReplays(void) G_SetDemoTime(players[consoleplayer].realtime, bestlap); G_CheckDemoStatus(); - I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); - I_mkdir(va("%s"PATHSEP"replay"PATHSEP"%s", srb2home, timeattackfolder), 0755); + gpath = va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s", + srb2home, timeattackfolder); + M_MkdirEach(gpath, M_PathParts(gpath) - 3, 0755); if ((gpath = malloc(glen)) == NULL) I_Error("Out of memory for replay filepath\n"); - sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); + sprintf(gpath,"%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); snprintf(lastdemo, 255, "%s-%s-last.lmp", gpath, cv_chooseskin.string); if (FIL_FileExists(lastdemo)) From 735dd26dc64ff0d0e1207fcec327486ea22793f0 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 31 Mar 2020 15:23:24 -0700 Subject: [PATCH 2/4] Put downloads in addons/downloads instead of DOWNLOAD --- src/d_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index aed861e7d..8f42fc918 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1083,7 +1083,6 @@ void D_SRB2Main(void) // use user specific config file #ifdef DEFAULTDIR snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome); - snprintf(downloaddir, sizeof downloaddir, "%s" PATHSEP "DOWNLOAD", srb2home); if (dedicated) snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, srb2home); else @@ -1094,7 +1093,6 @@ void D_SRB2Main(void) #else snprintf(srb2home, sizeof srb2home, "%s", userhome); - snprintf(downloaddir, sizeof downloaddir, "%s", userhome); if (dedicated) snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, userhome); else @@ -1116,6 +1114,10 @@ void D_SRB2Main(void) snprintf(addonsdir, sizeof addonsdir, "%s%s%s", srb2home, PATHSEP, "addons"); I_mkdir(addonsdir, 0755); + /* and downloads in a subdirectory */ + snprintf(downloaddir, sizeof downloaddir, "%.255s%.1s%.255s",/* fuck!! */ + addonsdir, PATHSEP, "downloads"); + // rand() needs seeded regardless of password srand((unsigned int)time(NULL)); From e4094bc2a92bdfd742c5de2af2fc9c2a88379682 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 31 Mar 2020 15:26:22 -0700 Subject: [PATCH 3/4] Remove some redundant code --- src/d_main.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 8f42fc918..1f2eafb3a 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1083,6 +1083,10 @@ void D_SRB2Main(void) // use user specific config file #ifdef DEFAULTDIR snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome); +#else + snprintf(srb2home, sizeof srb2home, "%s", userhome); +#endif + if (dedicated) snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, srb2home); else @@ -1090,17 +1094,6 @@ void D_SRB2Main(void) // can't use sprintf since there is %u in savegamename strcatbf(savegamename, srb2home, PATHSEP); - -#else - snprintf(srb2home, sizeof srb2home, "%s", userhome); - if (dedicated) - snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, userhome); - else - snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, userhome); - - // can't use sprintf since there is %u in savegamename - strcatbf(savegamename, userhome, PATHSEP); -#endif } configfile[sizeof configfile - 1] = '\0'; From 4a3a4c0801c258dbb7e68a8c5cbcdd3990ad3466 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 31 Mar 2020 15:50:39 -0700 Subject: [PATCH 4/4] This won't be needed --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index 1f2eafb3a..a67c8addd 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1108,7 +1108,7 @@ void D_SRB2Main(void) I_mkdir(addonsdir, 0755); /* and downloads in a subdirectory */ - snprintf(downloaddir, sizeof downloaddir, "%.255s%.1s%.255s",/* fuck!! */ + snprintf(downloaddir, sizeof downloaddir, "%s%s%s", addonsdir, PATHSEP, "downloads"); // rand() needs seeded regardless of password