mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
G_DoPlayDemoEx: Fix compiling with ERRORMODE + cleanup
- Additional comments, since this has always been kind of a rat's nest
- Use W_CheckNumForLongName for extensionless string parameter
- So you can play staffghosts.pk3 lumps via the `playdemo` console command
- If missing at launch, would have been a regression compared to the previous entry in the series
- Gate the virtres support behind a `#define`
- This isn't how we're shipping staff ghosts with the game anymore, so this would have been the only way to access them
- SKIPERRORS `#define`: Only show errors if the demo is guaranteed external, instead of suppressing them exclusively if confirmed internal
- Hides errors for restarting a staff ghost
- Prevents duplication of errors for restarting an external ghost
This commit is contained in:
parent
1a9dc17945
commit
2b515fa847
1 changed files with 51 additions and 40 deletions
|
|
@ -2897,7 +2897,6 @@ void G_DoPlayDemoEx(const char *defdemoname, lumpnum_t deflumpnum)
|
||||||
UINT8 p, numslots = 0;
|
UINT8 p, numslots = 0;
|
||||||
lumpnum_t l;
|
lumpnum_t l;
|
||||||
char color[MAXCOLORNAME+1],follower[17],mapname[MAXMAPLUMPNAME],gtname[MAXGAMETYPELENGTH];
|
char color[MAXCOLORNAME+1],follower[17],mapname[MAXMAPLUMPNAME],gtname[MAXGAMETYPELENGTH];
|
||||||
const char *n;
|
|
||||||
char *pdemoname;
|
char *pdemoname;
|
||||||
UINT8 availabilities[MAXPLAYERS][MAXAVAILABILITY];
|
UINT8 availabilities[MAXPLAYERS][MAXAVAILABILITY];
|
||||||
UINT8 version,subversion;
|
UINT8 version,subversion;
|
||||||
|
|
@ -2908,7 +2907,11 @@ void G_DoPlayDemoEx(const char *defdemoname, lumpnum_t deflumpnum)
|
||||||
UINT8 slots[MAXPLAYERS], lastfakeskin[MAXPLAYERS];
|
UINT8 slots[MAXPLAYERS], lastfakeskin[MAXPLAYERS];
|
||||||
|
|
||||||
#if defined(SKIPERRORS) && !defined(DEVELOP)
|
#if defined(SKIPERRORS) && !defined(DEVELOP)
|
||||||
boolean skiperrors = false;
|
// RR: Don't print warnings for staff ghosts, since they'll inevitably
|
||||||
|
// happen when we make bugfixes/changes...
|
||||||
|
// Unlike usual, true by default since most codepaths in this func are internal
|
||||||
|
// lumps (or for restarted external files, shouldn't re-print existing errors)
|
||||||
|
boolean skiperrors = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
G_InitDemoRewind();
|
G_InitDemoRewind();
|
||||||
|
|
@ -2917,33 +2920,43 @@ void G_DoPlayDemoEx(const char *defdemoname, lumpnum_t deflumpnum)
|
||||||
color[MAXCOLORNAME] = '\0';
|
color[MAXCOLORNAME] = '\0';
|
||||||
gtname[MAXGAMETYPELENGTH-1] = '\0';
|
gtname[MAXGAMETYPELENGTH-1] = '\0';
|
||||||
|
|
||||||
// No demo name means we're restarting the current demo
|
if (deflumpnum != LUMPERROR)
|
||||||
if (defdemoname == NULL && deflumpnum == LUMPERROR)
|
|
||||||
{
|
{
|
||||||
|
// Load demo resource from explicitly provided lump ID.
|
||||||
|
// (we do NOT care for defdemoname here)
|
||||||
|
|
||||||
|
P_SaveBufferFromLump(&demobuf, deflumpnum);
|
||||||
|
pdemoname = Z_StrDup(wadfiles[WADFILENUM(deflumpnum)]->lumpinfo[LUMPNUM(deflumpnum)].fullname);
|
||||||
|
}
|
||||||
|
else if (defdemoname == NULL)
|
||||||
|
{
|
||||||
|
// No demo name means we're restarting the current demo!
|
||||||
|
|
||||||
demobuf.p = demobuf.buffer;
|
demobuf.p = demobuf.buffer;
|
||||||
pdemoname = static_cast<char*>(ZZ_Alloc(1)); // Easier than adding checks for this everywhere it's freed
|
pdemoname = static_cast<char*>(ZZ_Alloc(1)); // Easier than adding checks for this everywhere it's freed
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// We have to guess by the string provided... :face_holding_back_tears:
|
||||||
|
|
||||||
// FIXME: this file doesn't manage its memory and actually free this when it's done using it
|
// FIXME: this file doesn't manage its memory and actually free this when it's done using it
|
||||||
//Z_Free(demobuf.buffer);
|
//Z_Free(demobuf.buffer);
|
||||||
demobuf.buffer = NULL;
|
demobuf.buffer = NULL;
|
||||||
|
|
||||||
if (defdemoname != NULL)
|
// This weird construct turns `./media/replay/online/2.0/lmao.lmp` into `lmao.lmp`
|
||||||
{
|
// I'd wrap it in braces, but the VRES_GHOST feature needs access to n
|
||||||
n = defdemoname+strlen(defdemoname);
|
const char *n = defdemoname+strlen(defdemoname);
|
||||||
while (*n != '/' && *n != '\\' && n != defdemoname)
|
while (*n != '/' && *n != '\\' && n != defdemoname)
|
||||||
n--;
|
n--;
|
||||||
if (n != defdemoname)
|
if (n != defdemoname)
|
||||||
n++;
|
n++;
|
||||||
pdemoname = static_cast<char*>(ZZ_Alloc(strlen(n)+1));
|
pdemoname = static_cast<char*>(ZZ_Alloc(strlen(n)+1));
|
||||||
strcpy(pdemoname,n);
|
strcpy(pdemoname,n);
|
||||||
}
|
|
||||||
|
|
||||||
M_SetPlaybackMenuPointer();
|
M_SetPlaybackMenuPointer();
|
||||||
|
|
||||||
// Internal if no extension, external if one exists
|
// Internal if no extension, external if one exists
|
||||||
if (defdemoname != NULL && FIL_CheckExtension(defdemoname))
|
if (FIL_CheckExtension(defdemoname))
|
||||||
{
|
{
|
||||||
//FIL_DefaultExtension(defdemoname, ".lmp");
|
//FIL_DefaultExtension(defdemoname, ".lmp");
|
||||||
if (P_SaveBufferFromFile(&demobuf, defdemoname) == false)
|
if (P_SaveBufferFromFile(&demobuf, defdemoname) == false)
|
||||||
|
|
@ -2955,31 +2968,16 @@ void G_DoPlayDemoEx(const char *defdemoname, lumpnum_t deflumpnum)
|
||||||
M_StartMessage("Demo Playback", msg, NULL, MM_NOTHING, NULL, "Return to Menu");
|
M_StartMessage("Demo Playback", msg, NULL, MM_NOTHING, NULL, "Return to Menu");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(SKIPERRORS) && !defined(DEVELOP)
|
||||||
|
skiperrors = false; // DO print warnings for external lumps
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
// load demo resource from WAD
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (deflumpnum != LUMPERROR)
|
// load demo resource from WAD by name
|
||||||
{
|
#ifdef VRES_GHOST
|
||||||
P_SaveBufferFromLump(&demobuf, deflumpnum);
|
if (n != defdemoname)
|
||||||
pdemoname = Z_StrDup(wadfiles[WADFILENUM(deflumpnum)]->lumpinfo[LUMPNUM(deflumpnum)].fullname);
|
|
||||||
}
|
|
||||||
else if (n == defdemoname)
|
|
||||||
{
|
|
||||||
// Raw lump.
|
|
||||||
if ((l = W_CheckNumForName(defdemoname)) == LUMPERROR)
|
|
||||||
{
|
|
||||||
snprintf(msg, 1024, M_GetText("Failed to read lump '%s'.\n"), defdemoname);
|
|
||||||
CONS_Alert(CONS_ERROR, "%s", msg);
|
|
||||||
Z_Free(pdemoname);
|
|
||||||
gameaction = ga_nothing;
|
|
||||||
M_StartMessage("Demo Playback", msg, NULL, MM_NOTHING, NULL, "Return to Menu");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
P_SaveBufferFromLump(&demobuf, l);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// vres GHOST_%u
|
// vres GHOST_%u
|
||||||
virtres_t *vRes;
|
virtres_t *vRes;
|
||||||
|
|
@ -3027,9 +3025,22 @@ void G_DoPlayDemoEx(const char *defdemoname, lumpnum_t deflumpnum)
|
||||||
|
|
||||||
vres_Free(vRes);
|
vres_Free(vRes);
|
||||||
}
|
}
|
||||||
#if defined(SKIPERRORS) && !defined(DEVELOP)
|
else
|
||||||
skiperrors = true; // RR: Don't print warnings for staff ghosts, since they'll inevitably happen when we make bugfixes/changes...
|
#endif // VRES_GHOST
|
||||||
#endif
|
{
|
||||||
|
// Raw lump.
|
||||||
|
if ((l = W_CheckNumForLongName(defdemoname)) == LUMPERROR)
|
||||||
|
{
|
||||||
|
snprintf(msg, 1024, M_GetText("Failed to read lump '%s'.\n"), defdemoname);
|
||||||
|
CONS_Alert(CONS_ERROR, "%s", msg);
|
||||||
|
Z_Free(pdemoname);
|
||||||
|
gameaction = ga_nothing;
|
||||||
|
M_StartMessage("Demo Playback", msg, NULL, MM_NOTHING, NULL, "Return to Menu");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
P_SaveBufferFromLump(&demobuf, l);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue