Create folder with branch name when saving replays

This commit is contained in:
James R 2021-12-18 22:31:33 -08:00 committed by SinnamonLat
parent a90953c22d
commit 912f9eaa15
2 changed files with 10 additions and 8 deletions

View file

@ -60,7 +60,7 @@ boolean nodrawers; // for comparative timing purposes
boolean noblit; // for comparative timing purposes
tic_t demostarttime; // for comparative timing purposes
static char demoname[128];
static char demoname[MAX_WADPATH];
static UINT8 *demobuffer = NULL;
static UINT8 *demotime_p, *demoinfo_p;
UINT8 *demo_p;
@ -3791,7 +3791,7 @@ void G_SaveDemo(void)
demo_slug[strindex] = 0;
if (dash) demo_slug[strindex-1] = 0;
writepoint = strstr(demoname, "-") + 1;
writepoint = strstr(strrchr(demoname, *PATHSEP), "-") + 1;
demo_slug[128 - (writepoint - demoname) - 4] = 0;
sprintf(writepoint, "%s.lmp", demo_slug);
}
@ -3808,7 +3808,7 @@ void G_SaveDemo(void)
md5_buffer((char *)p+16, (demobuffer + length) - (p+16), p);
#endif
if (FIL_WriteFile(va(pandf, srb2home, demoname), demobuffer, demo_p - demobuffer)) // finally output the file.
if (FIL_WriteFile(demoname, demobuffer, demo_p - demobuffer)) // finally output the file.
demo.savemode = DSM_SAVED;
free(demobuffer);
demo.recording = false;

View file

@ -3798,12 +3798,14 @@ static void P_InitGametype(void)
//@TODO I'd like to fix dedis crashing when recording replays for the future too...
if (!demo.playback && multiplayer && !dedicated)
{
static char buf[256];
char *path;
sprintf(buf, "media"PATHSEP"replay"PATHSEP"online"PATHSEP"%d-%s", (int) (time(NULL)), G_BuildMapName(gamemap));
char buf[MAX_WADPATH];
int parts;
path = va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"online", srb2home);
M_MkdirEach(path, M_PathParts(path) - 4, 0755);
sprintf(buf, "%s"PATHSEP"media"PATHSEP"replay"PATHSEP"online"PATHSEP"%s-%s"PATHSEP"%d-%s",
srb2home, compbranch, comprevision, (int) (time(NULL)), G_BuildMapName(gamemap));
parts = M_PathParts(buf);
M_MkdirEachUntil(buf, parts - 5, parts - 1, 0755);
G_RecordDemo(buf);
}