Merge branch 'master' of https://git.do.srb2.org/KartKrew/Kart into special-stages

This commit is contained in:
toaster 2022-10-14 18:40:30 +01:00
commit 54a1ac9944
3 changed files with 11 additions and 16 deletions

View file

@ -517,7 +517,6 @@ tic_t G_GetBestLap(INT16 map)
// //
static void G_UpdateRecordReplays(void) static void G_UpdateRecordReplays(void)
{ {
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;
@ -557,12 +556,13 @@ static void G_UpdateRecordReplays(void)
srb2home, timeattackfolder); srb2home, timeattackfolder);
M_MkdirEach(gpath, M_PathParts(gpath) - 3, 0755); M_MkdirEach(gpath, M_PathParts(gpath) - 3, 0755);
if ((gpath = malloc(glen)) == NULL) strcat(gpath, PATHSEP);
I_Error("Out of memory for replay filepath\n"); strcat(gpath, 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);
gpath = Z_StrDup(gpath);
if (FIL_FileExists(lastdemo)) if (FIL_FileExists(lastdemo))
{ {
UINT8 *buf; UINT8 *buf;
@ -593,7 +593,8 @@ static void G_UpdateRecordReplays(void)
Z_Free(buf); Z_Free(buf);
} }
free(gpath);
Z_Free(gpath);
// Check emblems when level data is updated // Check emblems when level data is updated
if ((earnedEmblems = M_CheckLevelEmblems())) if ((earnedEmblems = M_CheckLevelEmblems()))

View file

@ -3666,7 +3666,6 @@ void M_SetGuestReplay(INT32 choice)
void M_StartTimeAttack(INT32 choice) void M_StartTimeAttack(INT32 choice)
{ {
char *gpath; char *gpath;
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;
@ -3709,10 +3708,9 @@ void M_StartTimeAttack(INT32 choice)
srb2home, timeattackfolder); srb2home, timeattackfolder);
M_MkdirEach(gpath, M_PathParts(gpath) - 3, 0755); M_MkdirEach(gpath, M_PathParts(gpath) - 3, 0755);
if ((gpath = malloc(glen)) == NULL) strcat(gpath, PATHSEP);
I_Error("Out of memory for replay filepath\n"); strcat(gpath, G_BuildMapName(levellist.choosemap+1));
sprintf(gpath,"media"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", timeattackfolder, G_BuildMapName(levellist.choosemap+1));
snprintf(nameofdemo, sizeof nameofdemo, "%s-%s-last", gpath, cv_skin[0].string); snprintf(nameofdemo, sizeof nameofdemo, "%s-%s-last", gpath, cv_skin[0].string);
if (!cv_autorecord.value) if (!cv_autorecord.value)

View file

@ -3704,14 +3704,10 @@ static void P_ResetSpawnpoints(void)
static void P_LoadRecordGhosts(void) static void P_LoadRecordGhosts(void)
{ {
// see also k_menu.c's Nextmap_OnChange // see also k_menu.c's Nextmap_OnChange
const size_t glen = strlen(srb2home)+1+strlen("media")+1+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; char *gpath;
char *gpath = malloc(glen);
INT32 i; INT32 i;
if (!gpath) gpath = Z_StrDup(va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)));
return;
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)
@ -3774,7 +3770,7 @@ static void P_LoadRecordGhosts(void)
} }
#endif //#ifdef STAFFGHOSTS #endif //#ifdef STAFFGHOSTS
free(gpath); Z_Free(gpath);
} }
static void P_SetupCamera(UINT8 pnum, camera_t *cam) static void P_SetupCamera(UINT8 pnum, camera_t *cam)