Merge branch 'folders-plus' into 'master'

Directory revision

See merge request KartKrew/Kart!231
This commit is contained in:
Sal 2020-04-15 16:13:39 -04:00
commit fc32689b36
5 changed files with 32 additions and 33 deletions

View file

@ -1083,7 +1083,10 @@ void D_SRB2Main(void)
// use user specific config file // use user specific config file
#ifdef DEFAULTDIR #ifdef DEFAULTDIR
snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome); snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome);
snprintf(downloaddir, sizeof downloaddir, "%s" PATHSEP "DOWNLOAD", srb2home); #else
snprintf(srb2home, sizeof srb2home, "%s", userhome);
#endif
if (dedicated) if (dedicated)
snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, srb2home); snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, srb2home);
else else
@ -1091,18 +1094,6 @@ void D_SRB2Main(void)
// can't use sprintf since there is %u in savegamename // can't use sprintf since there is %u in savegamename
strcatbf(savegamename, srb2home, PATHSEP); strcatbf(savegamename, srb2home, PATHSEP);
#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
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'; configfile[sizeof configfile - 1] = '\0';
@ -1116,6 +1107,10 @@ void D_SRB2Main(void)
snprintf(addonsdir, sizeof addonsdir, "%s%s%s", srb2home, PATHSEP, "addons"); snprintf(addonsdir, sizeof addonsdir, "%s%s%s", srb2home, PATHSEP, "addons");
I_mkdir(addonsdir, 0755); I_mkdir(addonsdir, 0755);
/* and downloads in a subdirectory */
snprintf(downloaddir, sizeof downloaddir, "%s%s%s",
addonsdir, PATHSEP, "downloads");
// rand() needs seeded regardless of password // rand() needs seeded regardless of password
srand((unsigned int)time(NULL)); srand((unsigned int)time(NULL));

View file

@ -2101,14 +2101,14 @@ static void Nextmap_OnChange(void)
if (currentMenu == &SP_TimeAttackDef) if (currentMenu == &SP_TimeAttackDef)
{ {
// see also p_setup.c's P_LoadRecordGhosts // 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); char *gpath = malloc(glen);
INT32 i; INT32 i;
if (!gpath) if (!gpath)
return; 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); CV_StealthSetValue(&cv_dummystaff, 0);
@ -5142,7 +5142,7 @@ void M_ReplayHut(INT32 choice)
if (!demo.inreplayhut) 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); menupathindex[(menudepthleft = menudepth-1)] = strlen(menupath);
} }
if (!preparefilemenu(false, true)) if (!preparefilemenu(false, true))
@ -7876,20 +7876,21 @@ static boolean M_QuitTimeAttackMenu(void)
static void M_ChooseTimeAttack(INT32 choice) static void M_ChooseTimeAttack(INT32 choice)
{ {
char *gpath; 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]; char nameofdemo[256];
(void)choice; (void)choice;
emeralds = 0; emeralds = 0;
M_ClearMenus(true); M_ClearMenus(true);
modeattacking = (levellistmode == LLM_BREAKTHECAPSULES ? ATTACKING_CAPSULES : ATTACKING_RECORD); modeattacking = (levellistmode == LLM_BREAKTHECAPSULES ? ATTACKING_CAPSULES : ATTACKING_RECORD);
I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); gpath = va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s",
I_mkdir(va("%s"PATHSEP"replay"PATHSEP"%s", srb2home, timeattackfolder), 0755); srb2home, timeattackfolder);
M_MkdirEach(gpath, M_PathParts(gpath) - 3, 0755);
if ((gpath = malloc(glen)) == NULL) if ((gpath = malloc(glen)) == NULL)
I_Error("Out of memory for replay filepath\n"); 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); snprintf(nameofdemo, sizeof nameofdemo, "%s-%s-last", gpath, cv_chooseskin.string);
if (!cv_autorecord.value) if (!cv_autorecord.value)

View file

@ -1121,8 +1121,8 @@ void M_StartMovie(void)
if (cv_movie_option.value != 3) if (cv_movie_option.value != 3)
{ {
strcat(pathname, PATHSEP"movies"PATHSEP); strcat(pathname, PATHSEP"media"PATHSEP"movies"PATHSEP);
I_mkdir(pathname, 0755); M_MkdirEach(pathname, M_PathParts(pathname) - 2, 0755);
} }
if (rendermode == render_none) if (rendermode == render_none)
@ -1483,8 +1483,8 @@ void M_DoScreenShot(void)
if (cv_screenshot_option.value != 3) if (cv_screenshot_option.value != 3)
{ {
strcat(pathname, PATHSEP"screenshots"PATHSEP); strcat(pathname, PATHSEP"media"PATHSEP"screenshots"PATHSEP);
I_mkdir(pathname, 0755); M_MkdirEach(pathname, M_PathParts(pathname) - 2, 0755);
} }
#ifdef USE_PNG #ifdef USE_PNG

View file

@ -2621,14 +2621,14 @@ static void P_ForceCharacter(const char *forcecharskin)
static void P_LoadRecordGhosts(void) static void P_LoadRecordGhosts(void)
{ {
// see also m_menu.c's Nextmap_OnChange // 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); char *gpath = malloc(glen);
INT32 i; INT32 i;
if (!gpath) if (!gpath)
return; 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 // Best Time ghost
if (cv_ghost_besttime.value) 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... //@TODO I'd like to fix dedis crashing when recording replays for the future too...
if (!demo.playback && multiplayer && !dedicated) { if (!demo.playback && multiplayer && !dedicated) {
static char buf[256]; 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); G_RecordDemo(buf);
} }

View file

@ -787,7 +787,7 @@ void Y_Ticker(void)
// //
static void Y_UpdateRecordReplays(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 *gpath;
char lastdemo[256], bestdemo[256]; char lastdemo[256], bestdemo[256];
UINT8 earnedEmblems; UINT8 earnedEmblems;
@ -823,13 +823,14 @@ static void Y_UpdateRecordReplays(void)
G_SetDemoTime(players[consoleplayer].realtime, bestlap); G_SetDemoTime(players[consoleplayer].realtime, bestlap);
G_CheckDemoStatus(); G_CheckDemoStatus();
I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); gpath = va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s",
I_mkdir(va("%s"PATHSEP"replay"PATHSEP"%s", srb2home, timeattackfolder), 0755); srb2home, timeattackfolder);
M_MkdirEach(gpath, M_PathParts(gpath) - 3, 0755);
if ((gpath = malloc(glen)) == NULL) if ((gpath = malloc(glen)) == NULL)
I_Error("Out of memory for replay filepath\n"); 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); snprintf(lastdemo, 255, "%s-%s-last.lmp", gpath, cv_chooseskin.string);
if (FIL_FileExists(lastdemo)) if (FIL_FileExists(lastdemo))