G_DoPlayDemo: Add support for replays stored inside map vres
This commit is contained in:
parent
5fee047fe6
commit
76dcbec741
1 changed files with 60 additions and 10 deletions
70
src/g_demo.c
70
src/g_demo.c
|
|
@ -2804,7 +2804,7 @@ void G_DoPlayDemo(char *defdemoname)
|
|||
{
|
||||
UINT8 i, p;
|
||||
lumpnum_t l;
|
||||
char skin[17],color[MAXCOLORNAME+1],follower[17],*n,*pdemoname;
|
||||
char skin[17],color[MAXCOLORNAME+1],follower[17],mapname[MAXMAPLUMPNAME],*n,*pdemoname;
|
||||
UINT8 version,subversion;
|
||||
UINT32 randseed;
|
||||
char msg[1024];
|
||||
|
|
@ -2856,18 +2856,68 @@ void G_DoPlayDemo(char *defdemoname)
|
|||
// load demo resource from WAD
|
||||
else
|
||||
{
|
||||
if ((l = W_CheckNumForName(defdemoname)) == LUMPERROR)
|
||||
if (n == defdemoname)
|
||||
{
|
||||
snprintf(msg, 1024, M_GetText("Failed to read lump '%s'.\n"), defdemoname);
|
||||
CONS_Alert(CONS_ERROR, "%s", msg);
|
||||
gameaction = ga_nothing;
|
||||
M_StartMessage(msg, NULL, MM_NOTHING);
|
||||
return;
|
||||
}
|
||||
// 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(msg, NULL, MM_NOTHING);
|
||||
return;
|
||||
}
|
||||
|
||||
P_SaveBufferFromLump(&demobuf, l);
|
||||
P_SaveBufferFromLump(&demobuf, l);
|
||||
}
|
||||
else
|
||||
{
|
||||
// vres GHOST_%u
|
||||
virtres_t *vRes;
|
||||
virtlump_t *vLump;
|
||||
UINT16 mapnum;
|
||||
size_t step = 0;
|
||||
|
||||
step = 0;
|
||||
while (defdemoname+step < n-1)
|
||||
{
|
||||
mapname[step] = defdemoname[step];
|
||||
step++;
|
||||
}
|
||||
mapname[step] = '\0';
|
||||
|
||||
mapnum = G_MapNumber(mapname);
|
||||
if (mapnum >= nummapheaders || mapheaderinfo[mapnum]->lumpnum == LUMPERROR)
|
||||
{
|
||||
snprintf(msg, 1024, M_GetText("Failed to read lump '%s (couldn't find map %s)'.\n"), defdemoname, mapname);
|
||||
CONS_Alert(CONS_ERROR, "%s", msg);
|
||||
Z_Free(pdemoname);
|
||||
gameaction = ga_nothing;
|
||||
M_StartMessage(msg, NULL, MM_NOTHING);
|
||||
return;
|
||||
}
|
||||
|
||||
vRes = vres_GetMap(mapheaderinfo[mapnum]->lumpnum);
|
||||
vLump = vres_Find(vRes, pdemoname);
|
||||
|
||||
if (vLump == NULL)
|
||||
{
|
||||
snprintf(msg, 1024, M_GetText("Failed to read lump '%s (couldn't find lump %s in %s)'.\n"), defdemoname, pdemoname, mapname);
|
||||
CONS_Alert(CONS_ERROR, "%s", msg);
|
||||
Z_Free(pdemoname);
|
||||
gameaction = ga_nothing;
|
||||
M_StartMessage(msg, NULL, MM_NOTHING);
|
||||
return;
|
||||
}
|
||||
|
||||
P_SaveBufferAlloc(&demobuf, vLump->size);
|
||||
memcpy(demobuf.buffer, vLump->data, vLump->size);
|
||||
|
||||
vres_Free(vRes);
|
||||
}
|
||||
#if defined(SKIPERRORS) && !defined(DEVELOP)
|
||||
skiperrors = true; // SRB2Kart: Don't print warnings for staff ghosts, since they'll inevitably happen when we make bugfixes/changes...
|
||||
skiperrors = true; // RR: Don't print warnings for staff ghosts, since they'll inevitably happen when we make bugfixes/changes...
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue