diff --git a/src/f_finale.c b/src/f_finale.c index 5f4046f2c..0b593e2e7 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1743,10 +1743,10 @@ void F_TitleScreenTicker(boolean run) if (!(--demoIdleLeft)) { char dname[MAXMAPLUMPNAME+1+8+1]; + lumpnum_t dlump; UINT16 mapnum; UINT8 numstaff; static boolean use_netreplay = false; - const char *lumpname; staffbrief_t *brief; if ((use_netreplay = !use_netreplay)) @@ -1760,6 +1760,7 @@ void F_TitleScreenTicker(boolean run) { numstaff = M_RandomKey(numstaff)+1; snprintf(dname, 9, "TDEMO%03u", numstaff); + dlump = LUMPERROR; goto loadreplay; } } @@ -1777,14 +1778,14 @@ void F_TitleScreenTicker(boolean run) // Setup demo name brief = mapheaderinfo[mapnum]->ghostBrief[numstaff]; - lumpname = W_CheckNameForNumPwad(brief->wad, brief->lump); - strlcpy(dname, lumpname, sizeof(dname)); + strcpy(dname, ""); + dlump = (brief->wad << 16) | brief->lump; loadreplay: demo.attract = DEMO_ATTRACT_TITLE; demo.ignorefiles = true; demo.loadfiles = false; - G_DoPlayDemo(dname); + G_DoPlayDemoEx(dname, dlump); } } diff --git a/src/g_demo.cpp b/src/g_demo.cpp index 36fa470ea..82dc30251 100644 --- a/src/g_demo.cpp +++ b/src/g_demo.cpp @@ -2891,7 +2891,7 @@ void G_DeferedPlayDemo(const char *name) #define SKIPERRORS -void G_DoPlayDemo(const char *defdemoname) +void G_DoPlayDemoEx(const char *defdemoname, lumpnum_t deflumpnum) { INT32 i; UINT8 p, numslots = 0; @@ -2918,7 +2918,7 @@ void G_DoPlayDemo(const char *defdemoname) gtname[MAXGAMETYPELENGTH-1] = '\0'; // No demo name means we're restarting the current demo - if (defdemoname == NULL) + if (defdemoname == NULL && deflumpnum == LUMPERROR) { demobuf.p = demobuf.buffer; pdemoname = static_cast(ZZ_Alloc(1)); // Easier than adding checks for this everywhere it's freed @@ -2929,18 +2929,21 @@ void G_DoPlayDemo(const char *defdemoname) //Z_Free(demobuf.buffer); demobuf.buffer = NULL; - n = defdemoname+strlen(defdemoname); - while (*n != '/' && *n != '\\' && n != defdemoname) - n--; - if (n != defdemoname) - n++; - pdemoname = static_cast(ZZ_Alloc(strlen(n)+1)); - strcpy(pdemoname,n); + if (defdemoname != NULL) + { + n = defdemoname+strlen(defdemoname); + while (*n != '/' && *n != '\\' && n != defdemoname) + n--; + if (n != defdemoname) + n++; + pdemoname = static_cast(ZZ_Alloc(strlen(n)+1)); + strcpy(pdemoname,n); + } M_SetPlaybackMenuPointer(); // Internal if no extension, external if one exists - if (FIL_CheckExtension(defdemoname)) + if (defdemoname != NULL && FIL_CheckExtension(defdemoname)) { //FIL_DefaultExtension(defdemoname, ".lmp"); if (P_SaveBufferFromFile(&demobuf, defdemoname) == false) @@ -2956,7 +2959,12 @@ void G_DoPlayDemo(const char *defdemoname) // load demo resource from WAD else { - if (n == defdemoname) + if (deflumpnum != LUMPERROR) + { + P_SaveBufferFromLump(&demobuf, deflumpnum); + pdemoname = Z_StrDup(wadfiles[WADFILENUM(deflumpnum)]->lumpinfo[LUMPNUM(deflumpnum)].fullname); + } + else if (n == defdemoname) { // Raw lump. if ((l = W_CheckNumForName(defdemoname)) == LUMPERROR) diff --git a/src/g_demo.h b/src/g_demo.h index a7f99b241..3decd2059 100644 --- a/src/g_demo.h +++ b/src/g_demo.h @@ -214,7 +214,8 @@ extern demoghost *ghosts; #define DFILE_ERROR_CORRUPT 0x06 // Demo file is corrupted void G_DeferedPlayDemo(const char *demo); -void G_DoPlayDemo(const char *defdemoname); +void G_DoPlayDemoEx(const char *defdemoname, lumpnum_t deflumpnum); +#define G_DoPlayDemo(defdemoname) G_DoPlayDemoEx(defdemoname, LUMPERROR) void G_TimeDemo(const char *name); void G_AddGhost(savebuffer_t *buffer, const char *defdemoname); staffbrief_t *G_GetStaffGhostBrief(UINT8 *buffer); diff --git a/src/k_credits.cpp b/src/k_credits.cpp index 266e163ea..83219e60d 100644 --- a/src/k_credits.cpp +++ b/src/k_credits.cpp @@ -521,7 +521,7 @@ static boolean F_CreditsPlayDemo(void) demo.ignorefiles = true; demo.loadfiles = false; - G_DoPlayDemo(demo_name.c_str()); + G_DoPlayDemoEx("", (brief->wad << 16) | brief->lump); g_fast_forward = 30 * TICRATE; g_credits.demo_exit = 0; diff --git a/src/menus/play-local-race-time-attack.c b/src/menus/play-local-race-time-attack.c index 055d53d09..146b7df8c 100644 --- a/src/menus/play-local-race-time-attack.c +++ b/src/menus/play-local-race-time-attack.c @@ -416,7 +416,6 @@ void M_HandleStaffReplay(INT32 choice) { mapheader_t *mapheader; staffbrief_t *staffbrief; - const char* lumpname = NULL; restoreMenu = &PLAY_TimeAttackDef; M_ClearMenus(true); @@ -426,9 +425,7 @@ void M_HandleStaffReplay(INT32 choice) mapheader = mapheaderinfo[levellist.choosemap]; staffbrief = mapheader->ghostBrief[cv_dummystaff.value]; - lumpname = W_CheckNameForNumPwad(staffbrief->wad, staffbrief->lump); - - G_DoPlayDemo(lumpname); + G_DoPlayDemoEx("", (staffbrief->wad << 16) | staffbrief->lump); return; }