Update demos to save power levels

This commit is contained in:
TehRealSalt 2019-09-23 07:03:00 -04:00
parent 31534fe96b
commit 932f8a1f61
3 changed files with 51 additions and 343 deletions

View file

@ -158,9 +158,6 @@ extern FILE *logstream;
// AND appveyor.yml, for the build bots!
#endif
// Maintain compatibility with 1.0.x record attack replays?
#define DEMO_COMPAT_100
// Does this version require an added patch file?
// Comment or uncomment this as necessary.
//#define USE_PATCH_FILE

View file

@ -4776,7 +4776,7 @@ char *G_BuildMapTitle(INT32 mapnum)
// DEMO RECORDING
//
#define DEMOVERSION 0x0002
#define DEMOVERSION 0x0003
#define DEMOHEADER "\xF0" "KartReplay" "\x0F"
#define DF_GHOST 0x01 // This demo contains ghost data too!
@ -4787,12 +4787,6 @@ char *G_BuildMapTitle(INT32 mapnum)
#define DF_ENCORE 0x40
#define DF_MULTIPLAYER 0x80 // This demo was recorded in multiplayer mode!
#ifdef DEMO_COMPAT_100
#define DF_FILELIST 0x08 // This demo contains an extra files list
#define DF_GAMETYPEMASK 0x30
#define DF_GAMESHIFT 4
#endif
#define DEMO_SPECTATOR 0x40
// For demos
@ -5651,16 +5645,9 @@ void G_ConsGhostTic(INT32 playernum)
else
ghostext[playernum].desyncframes = 0;
if (
#ifdef DEMO_COMPAT_100
demo.version != 0x0001 &&
#endif
(
players[playernum].kartstuff[k_itemtype] != ghostext[playernum].kartitem ||
players[playernum].kartstuff[k_itemamount] != ghostext[playernum].kartamount ||
players[playernum].kartstuff[k_bumper] != ghostext[playernum].kartbumpers
)
)
if (players[playernum].kartstuff[k_itemtype] != ghostext[playernum].kartitem
|| players[playernum].kartstuff[k_itemamount] != ghostext[playernum].kartamount
|| players[playernum].kartstuff[k_bumper] != ghostext[playernum].kartbumpers)
{
if (demosynced)
CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n"));
@ -5688,10 +5675,6 @@ void G_GhostTicker(void)
// Skip normal demo data.
UINT8 ziptic = READUINT8(g->p);
#ifdef DEMO_COMPAT_100
if (g->version != 0x0001)
{
#endif
while (ziptic != DW_END) // Get rid of extradata stuff
{
if (ziptic == 0) // Only support player 0 info for now
@ -5715,9 +5698,6 @@ void G_GhostTicker(void)
}
ziptic = READUINT8(g->p); // Back to actual ziptic stuff
#ifdef DEMO_COMPAT_100
}
#endif
if (ziptic & ZT_FWD)
g->p++;
@ -5737,18 +5717,12 @@ void G_GhostTicker(void)
// Grab ghost data.
ziptic = READUINT8(g->p);
#ifdef DEMO_COMPAT_100
if (g->version != 0x0001)
{
#endif
if (ziptic == 0xFF)
goto skippedghosttic; // Didn't write ghost info this frame
else if (ziptic != 0)
I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this
ziptic = READUINT8(g->p);
#ifdef DEMO_COMPAT_100
}
#endif
if (ziptic & GZT_XYZ)
{
g->oldmo.x = READFIXED(g->p);
@ -5889,15 +5863,8 @@ void G_GhostTicker(void)
g->p += 12; // kartitem, kartamount, kartbumpers
}
#ifdef DEMO_COMPAT_100
if (g->version != 0x0001)
{
#endif
if (READUINT8(g->p) != 0xFF) // Make sure there isn't other ghost data here.
I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this
#ifdef DEMO_COMPAT_100
}
#endif
skippedghosttic:
// Tick ghost colors (Super and Mario Invincibility flashing)
@ -6407,20 +6374,15 @@ void G_BeginRecording(void)
switch ((demoflags & DF_ATTACKMASK)>>DF_ATTACKSHIFT)
{
case ATTACKING_NONE: // 0
break;
case ATTACKING_RECORD: // 1
demotime_p = demo_p;
WRITEUINT32(demo_p,UINT32_MAX); // time
WRITEUINT32(demo_p,UINT32_MAX); // lap
break;
/*case ATTACKING_NIGHTS: // 2
demotime_p = demo_p;
WRITEUINT32(demo_p,UINT32_MAX); // time
WRITEUINT32(demo_p,0); // score
break;*/
default: // 3
break;
case ATTACKING_NONE: // 0
break;
case ATTACKING_RECORD: // 1
demotime_p = demo_p;
WRITEUINT32(demo_p,UINT32_MAX); // time
WRITEUINT32(demo_p,UINT32_MAX); // lap
break;
default: // 3
break;
}
WRITEUINT32(demo_p,P_GetInitSeed());
@ -6460,6 +6422,9 @@ void G_BeginRecording(void)
// Score, since Kart uses this to determine where you start on the map
WRITEUINT32(demo_p, player->score);
// Power Levels
WRITEUINT16(demo_p, clientpowerlevels[p][G_BattleGametype() ? 1 : 0]);
// Kart speed and weight
WRITEUINT8(demo_p, skins[player->skin].kartspeed);
WRITEUINT8(demo_p, skins[player->skin].kartweight);
@ -6558,18 +6523,13 @@ void G_SetDemoTime(UINT32 ptime, UINT32 plap)
{
if (!demo.recording || !demotime_p)
return;
if (demoflags & DF_RECORDATTACK)
{
WRITEUINT32(demotime_p, ptime);
WRITEUINT32(demotime_p, plap);
demotime_p = NULL;
}
/*else if (demoflags & DF_NIGHTSATTACK)
{
WRITEUINT32(demotime_p, ptime);
WRITEUINT32(demotime_p, pscore);
demotime_p = NULL;
}*/
}
static void G_LoadDemoExtraFiles(UINT8 **pp)
@ -6812,13 +6772,6 @@ UINT8 G_CmpDemoTime(char *oldname, char *newname)
case DEMOVERSION: // latest always supported
p += 64; // full demo title
break;
#ifdef DEMO_COMPAT_100
case 0x0001:
// Old replays gotta go :]
CONS_Alert(CONS_NOTICE, M_GetText("File '%s' outdated version. It will be overwritten. Nyeheheh.\n"), oldname);
Z_Free(buffer);
return UINT8_MAX;
#endif
// too old, cannot support.
default:
CONS_Alert(CONS_NOTICE, M_GetText("File '%s' invalid format. It will be overwritten.\n"), oldname);
@ -6910,12 +6863,6 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
info_p += 64;
break;
#ifdef DEMO_COMPAT_100
case 0x0001:
pdemo->type = MD_OUTDATED;
sprintf(pdemo->title, "Legacy Replay");
break;
#endif
// too old, cannot support.
default:
CONS_Alert(CONS_ERROR, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemo->filepath);
@ -6950,16 +6897,6 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
Z_Free(infobuffer);
return;
}
#ifdef DEMO_COMPAT_100
else if (pdemoversion == 0x0001)
{
CONS_Alert(CONS_ERROR, M_GetText("%s is a legacy multiplayer replay and cannot be played.\n"), pdemo->filepath);
pdemo->type = MD_INVALID;
sprintf(pdemo->title, "INVALID REPLAY");
Z_Free(infobuffer);
return;
}
#endif
pdemo->gametype = READUINT8(info_p);
@ -7160,10 +7097,6 @@ void G_DoPlayDemo(char *defdemoname)
demo_p += 64;
break;
#ifdef DEMO_COMPAT_100
case 0x0001:
break;
#endif
// too old, cannot support.
default:
snprintf(msg, 1024, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemoname);
@ -7192,24 +7125,6 @@ void G_DoPlayDemo(char *defdemoname)
demo_p += 16; // mapmd5
demoflags = READUINT8(demo_p);
#ifdef DEMO_COMPAT_100
if (demo.version == 0x0001)
{
if (demoflags & DF_MULTIPLAYER)
{
snprintf(msg, 1024, M_GetText("%s is an alpha multiplayer replay and cannot be played.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demo.playback = false;
demo.title = false;
return;
}
}
else
{
#endif
gametype = READUINT8(demo_p);
if (demo.title) // Titledemos should always play and ought to always be compatible with whatever wadlist is running.
@ -7267,9 +7182,6 @@ void G_DoPlayDemo(char *defdemoname)
return;
}
}
#ifdef DEMO_COMPAT_100
}
#endif
modeattacking = (demoflags & DF_ATTACKMASK)>>DF_ATTACKSHIFT;
multiplayer = !!(demoflags & DF_MULTIPLAYER);
@ -7297,110 +7209,8 @@ void G_DoPlayDemo(char *defdemoname)
// Random seed
randseed = READUINT32(demo_p);
#ifdef DEMO_COMPAT_100
if (demo.version != 0x0001)
#endif
demo_p += 4; // Extrainfo location
#ifdef DEMO_COMPAT_100
if (demo.version == 0x0001)
{
// Player name
M_Memcpy(player_names[0],demo_p,16);
demo_p += 16;
// Skin
M_Memcpy(skin,demo_p,16);
demo_p += 16;
// Color
M_Memcpy(color,demo_p,16);
demo_p += 16;
demo_p += 5; // Backwards compat - some stats
// SRB2kart
kartspeed[0] = READUINT8(demo_p);
kartweight[0] = READUINT8(demo_p);
//
demo_p += 9; // Backwards compat - more stats
// Skin not loaded?
if (!SetPlayerSkin(0, skin))
{
snprintf(msg, 1024, M_GetText("%s features a character that is not currently loaded.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demo.playback = false;
demo.title = false;
return;
}
// ...*map* not loaded?
if (!gamemap || (gamemap > NUMMAPS) || !mapheaderinfo[gamemap-1] || !(mapheaderinfo[gamemap-1]->menuflags & LF2_EXISTSHACK))
{
snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demo.playback = false;
demo.title = false;
return;
}
// Set color
for (i = 0; i < MAXSKINCOLORS; i++)
if (!stricmp(KartColor_Names[i],color)) // SRB2kart
{
players[0].skincolor = i;
break;
}
// net var data
CV_LoadNetVars(&demo_p);
// Sigh ... it's an empty demo.
if (*demo_p == DEMOMARKER)
{
snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname);
CONS_Alert(CONS_ERROR, "%s", msg);
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demo.playback = false;
demo.title = false;
return;
}
Z_Free(pdemoname);
memset(&oldcmd,0,sizeof(oldcmd));
memset(&oldghost,0,sizeof(oldghost));
memset(&ghostext,0,sizeof(ghostext));
CONS_Alert(CONS_WARNING, M_GetText("Demo version does not match game version. Desyncs may occur.\n"));
// console warning messages
#if defined(SKIPERRORS) && !defined(DEVELOP)
demosynced = (!skiperrors);
#else
demosynced = true;
#endif
// didn't start recording right away.
demo.deferstart = false;
consoleplayer = 0;
memset(displayplayers, 0, sizeof(displayplayers));
memset(playeringame, 0, sizeof(playeringame));
playeringame[0] = true;
goto post_compat;
}
#endif
// net var data
CV_LoadNetVars(&demo_p);
@ -7514,6 +7324,9 @@ void G_DoPlayDemo(char *defdemoname)
// Score, since Kart uses this to determine where you start on the map
players[p].score = READUINT32(demo_p);
// Power Levels
clientpowerlevels[p][G_BattleGametype() ? 1 : 0] = READUINT16(demo_p);
// Kart stats, temporarily
kartspeed[p] = READUINT8(demo_p);
kartweight[p] = READUINT8(demo_p);
@ -7538,10 +7351,6 @@ void G_DoPlayDemo(char *defdemoname)
R_ExecuteSetViewSize();
#ifdef DEMO_COMPAT_100
post_compat:
#endif
P_SetRandSeed(randseed);
G_InitNew(demoflags & DF_ENCORE, G_BuildMapName(gamemap), true, true); // Doesn't matter whether you reset or not here, given changes to resetplayer.
@ -7632,10 +7441,6 @@ void G_AddGhost(char *defdemoname)
case DEMOVERSION: // latest always supported
p += 64; // title
break;
#ifdef DEMO_COMPAT_100
case 0x0001:
break;
#endif
// too old, cannot support.
default:
CONS_Alert(CONS_NOTICE, M_GetText("Ghost %s: Demo version incompatible.\n"), pdemoname);
@ -7676,15 +7481,9 @@ void G_AddGhost(char *defdemoname)
return;
}
#ifdef DEMO_COMPAT_100
if (ghostversion != 0x0001)
#endif
p++; // gametype
p++; // gametype
G_SkipDemoExtraFiles(&p); // Don't wanna modify the file list for ghosts.
#ifdef DEMO_COMPAT_100
if (ghostversion != 0x0001)
#endif
G_SkipDemoExtraFiles(&p); // Don't wanna modify the file list for ghosts.
switch ((flags & DF_ATTACKMASK)>>DF_ATTACKSHIFT)
{
case ATTACKING_NONE: // 0
@ -7700,41 +7499,6 @@ void G_AddGhost(char *defdemoname)
}
p += 4; // random seed
#ifdef DEMO_COMPAT_100
if (ghostversion == 0x0001)
{
// Player name (TODO: Display this somehow if it doesn't match cv_playername!)
M_Memcpy(name, p,16);
p += 16;
// Skin
M_Memcpy(skin, p,16);
p += 16;
// Color
M_Memcpy(color, p,16);
p += 16;
// Ghosts do not have a player structure to put this in.
p++; // charability
p++; // charability2
p++; // actionspd
p++; // mindash
p++; // maxdash
// SRB2kart
p++; // kartspeed
p++; // kartweight
//
p++; // normalspeed
p++; // runspeed
p++; // thrustfactor
p++; // accelstart
p++; // acceleration
p += 4; // jumpfactor
}
else
#endif
p += 4; // Extra data location reference
// net var data
@ -7754,10 +7518,6 @@ void G_AddGhost(char *defdemoname)
return;
}
#ifdef DEMO_COMPAT_100
if (ghostversion != 0x0001)
{
#endif
if (READUINT8(p) != 0)
{
CONS_Alert(CONS_NOTICE, M_GetText("Failed to add ghost %s: Invalid player slot.\n"), pdemoname);
@ -7779,6 +7539,7 @@ void G_AddGhost(char *defdemoname)
p += 16;
p += 4; // score
p += 2; // powerlevel
kartspeed = READUINT8(p);
kartweight = READUINT8(p);
@ -7790,9 +7551,6 @@ void G_AddGhost(char *defdemoname)
Z_Free(buffer);
return;
}
#ifdef DEMO_COMPAT_100
}
#endif
for (i = 0; i < numskins; i++)
if (!stricmp(skins[i].name,skin))
@ -7892,18 +7650,13 @@ void G_UpdateStaffGhostName(lumpnum_t l)
ghostversion = READUINT16(p);
switch(ghostversion)
{
case DEMOVERSION: // latest always supported
p += 64; // full demo title
break;
case DEMOVERSION: // latest always supported
p += 64; // full demo title
break;
#ifdef DEMO_COMPAT_100
case 0x0001:
break;
#endif
// too old, cannot support.
default:
goto fail;
// too old, cannot support.
default:
goto fail;
}
p += 16; // demo checksum
@ -7923,43 +7676,22 @@ void G_UpdateStaffGhostName(lumpnum_t l)
goto fail; // we don't NEED to do it here, but whatever
}
#ifdef DEMO_COMPAT_100
if (ghostversion != 0x0001)
#endif
p++; // Gametype
#ifdef DEMO_COMPAT_100
if (ghostversion != 0x0001)
#endif
G_SkipDemoExtraFiles(&p);
switch ((flags & DF_ATTACKMASK)>>DF_ATTACKSHIFT)
{
case ATTACKING_NONE: // 0
break;
case ATTACKING_RECORD: // 1
p += 8; // demo time, lap
break;
/*case ATTACKING_NIGHTS: // 2
p += 8; // demo time left, score
break;*/
default: // 3
break;
case ATTACKING_NONE: // 0
break;
case ATTACKING_RECORD: // 1
p += 8; // demo time, lap
break;
default: // 3
break;
}
p += 4; // random seed
#ifdef DEMO_COMPAT_100
if (ghostversion == 0x0001)
{
// Player name
M_Memcpy(dummystaffname, p,16);
dummystaffname[16] = '\0';
goto fail; // Not really a failure but whatever
}
#endif
p += 4; // Extrainfo location marker
// Ehhhh don't need ghostversion here (?) so I'll reuse the var here
@ -8044,10 +7776,6 @@ void G_DoPlayMetal(void)
{
case DEMOVERSION: // latest always supported
break;
#ifdef DEMO_COMPAT_100
case 0x0001:
I_Error("You need to implement demo compat here, doofus! %s:%d", __FILE__, __LINE__);
#endif
// too old, cannot support.
default:
CONS_Alert(CONS_WARNING, M_GetText("Failed to load bot recording for this map, format version incompatible.\n"));

View file

@ -617,33 +617,21 @@ void P_Ticker(boolean run)
}
if (demo.playback)
{
G_ReadDemoExtraData();
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i])
{
//@TODO all this throwdir stuff shouldn't be here! But it's added to maintain 1.0.4 compat for now...
// Remove for 1.1!
if (players[i].cmd.buttons & BT_FORWARD)
players[i].kartstuff[k_throwdir] = 1;
else if (players[i].cmd.buttons & BT_BACKWARD)
players[i].kartstuff[k_throwdir] = -1;
else
players[i].kartstuff[k_throwdir] = 0;
#ifdef DEMO_COMPAT_100
if (demo.version == 0x0001)
{
G_ReadDemoTiccmd(&players[consoleplayer].cmd, 0);
}
else
{
#endif
G_ReadDemoExtraData();
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i])
{
//@TODO all this throwdir stuff shouldn't be here! But it's added to maintain 1.0.4 compat for now...
// Remove for 1.1!
if (players[i].cmd.buttons & BT_FORWARD)
players[i].kartstuff[k_throwdir] = 1;
else if (players[i].cmd.buttons & BT_BACKWARD)
players[i].kartstuff[k_throwdir] = -1;
else
players[i].kartstuff[k_throwdir] = 0;
G_ReadDemoTiccmd(&players[i].cmd, i);
}
#ifdef DEMO_COMPAT_100
}
#endif
G_ReadDemoTiccmd(&players[i].cmd, i);
}
}
for (i = 0; i < MAXPLAYERS; i++)
@ -759,11 +747,6 @@ void P_Ticker(boolean run)
}
else if (demo.playback) // Use Ghost data for consistency checks.
{
#ifdef DEMO_COMPAT_100
if (demo.version == 0x0001)
G_ConsGhostTic(0);
else
#endif
G_ConsAllGhostTics();
}