Convert old frame flags in Metal recordings to their 2.2.10 equivalents.

This commit is contained in:
spherallic 2022-02-14 14:57:00 +01:00
parent fdee3a2b7f
commit a4778075b2
2 changed files with 58 additions and 5 deletions

View file

@ -94,7 +94,7 @@ demoghost *ghosts = NULL;
// DEMO RECORDING // DEMO RECORDING
// //
#define DEMOVERSION 0x000e #define DEMOVERSION 0x000f
#define DEMOHEADER "\xF0" "SRB2Replay" "\x0F" #define DEMOHEADER "\xF0" "SRB2Replay" "\x0F"
#define DF_GHOST 0x01 // This demo contains ghost data too! #define DF_GHOST 0x01 // This demo contains ghost data too!
@ -1029,7 +1029,11 @@ void G_ReadMetalTic(mobj_t *metal)
if (ziptic & GZT_ANGLE) if (ziptic & GZT_ANGLE)
metal->angle = READUINT8(metal_p)<<24; metal->angle = READUINT8(metal_p)<<24;
if (ziptic & GZT_FRAME) if (ziptic & GZT_FRAME)
{
oldmetal.frame = READUINT32(metal_p); oldmetal.frame = READUINT32(metal_p);
if (metalversion < 0x000f)
oldmetal.frame = G_ConvertOldFrameFlags(oldmetal.frame);
}
if (ziptic & GZT_SPR2) if (ziptic & GZT_SPR2)
oldmetal.sprite2 = READUINT8(metal_p); oldmetal.sprite2 = READUINT8(metal_p);
@ -1169,6 +1173,8 @@ void G_ReadMetalTic(mobj_t *metal)
follow->sprite2 = 0; follow->sprite2 = 0;
follow->sprite = READUINT16(metal_p); follow->sprite = READUINT16(metal_p);
follow->frame = READUINT32(metal_p); // NOT & FF_FRAMEMASK here, so 32 bits follow->frame = READUINT32(metal_p); // NOT & FF_FRAMEMASK here, so 32 bits
if (metalversion < 0x000f)
follow->frame = G_ConvertOldFrameFlags(follow->frame);
follow->angle = metal->angle; follow->angle = metal->angle;
follow->color = (metalversion==0x000c) ? READUINT8(metal_p) : READUINT16(metal_p); follow->color = (metalversion==0x000c) ? READUINT8(metal_p) : READUINT16(metal_p);
@ -1680,8 +1686,9 @@ UINT8 G_CmpDemoTime(char *oldname, char *newname)
switch(oldversion) // demoversion switch(oldversion) // demoversion
{ {
case DEMOVERSION: // latest always supported case DEMOVERSION: // latest always supported
case 0x000d: // The previous demoversion also supported case 0x000e: // The previous demoversions also supported
case 0x000c: // all that changed between then and now was longer color name case 0x000d: // all that changed between then and now was longer color name
case 0x000c:
break; break;
// too old, cannot support. // too old, cannot support.
default: default:
@ -1824,6 +1831,7 @@ void G_DoPlayDemo(char *defdemoname)
switch(demoversion) switch(demoversion)
{ {
case 0x000d: case 0x000d:
case 0x000e:
case DEMOVERSION: // latest always supported case DEMOVERSION: // latest always supported
cnamelen = MAXCOLORNAME; cnamelen = MAXCOLORNAME;
break; break;
@ -2077,6 +2085,7 @@ void G_AddGhost(char *defdemoname)
switch(ghostversion) switch(ghostversion)
{ {
case 0x000d: case 0x000d:
case 0x000e:
case DEMOVERSION: // latest always supported case DEMOVERSION: // latest always supported
cnamelen = MAXCOLORNAME; cnamelen = MAXCOLORNAME;
break; break;
@ -2337,8 +2346,9 @@ void G_DoPlayMetal(void)
switch(metalversion) switch(metalversion)
{ {
case DEMOVERSION: // latest always supported case DEMOVERSION: // latest always supported
case 0x000d: // There are checks wheter the momentum is from older demo versions or not case 0x000e: // There are checks wheter the momentum is from older demo versions or not
case 0x000c: // all that changed between then and now was longer color name case 0x000d: // all that changed between then and now was longer color name
case 0x000c:
break; break;
// too old, cannot support. // too old, cannot support.
default: default:
@ -2554,3 +2564,45 @@ boolean G_CheckDemoStatus(void)
return false; return false;
} }
// 2.2.10 shifted some frame flags around, this function converts frame flags from older versions to their 2.2.10 equivalents.
INT32 G_ConvertOldFrameFlags(INT32 frame)
{
if (frame & 0x01000000) // was FF_ANIMATE, is now FF_VERTICALFLIP
{
frame &= ~0x01000000;
frame |= FF_ANIMATE;
}
if (frame & 0x02000000) // was FF_RANDOMANIM, is now FF_HORIZONTALFLIP
{
frame &= ~0x02000000;
frame |= FF_RANDOMANIM;
}
if (frame & 0x04000000) // was FF_GLOBALANIM, is now empty
{
frame &= ~0x04000000;
frame |= FF_GLOBALANIM;
}
if (frame & 0x00200000) // was FF_VERTICALFLIP, is now FF_FULLDARK
{
frame &= ~0x00200000;
frame |= FF_VERTICALFLIP;
}
if (frame & 0x00400000) // was FF_HORIZONTALFLIP, is now FF_PAPERSPRITE
{
frame &= ~0x00400000;
frame |= FF_HORIZONTALFLIP;
}
if (frame & 0x00800000) // was FF_PAPERSPRITE, is now FF_FLOORSPRITE
{
frame &= ~0x00800000;
frame |= FF_PAPERSPRITE;
}
return frame;
}

View file

@ -82,5 +82,6 @@ void G_StopMetalDemo(void);
ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(boolean kill); ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(boolean kill);
void G_StopDemo(void); void G_StopDemo(void);
boolean G_CheckDemoStatus(void); boolean G_CheckDemoStatus(void);
INT32 G_ConvertOldFrameFlags(INT32 frame);
#endif // __G_DEMO__ #endif // __G_DEMO__