- Blood: Ensure looped QAVs interpolate using last frame in the array.

This commit is contained in:
Mitchell Richters 2021-08-04 11:38:00 +10:00
parent c75778c08d
commit ab502ebc66
5 changed files with 18 additions and 16 deletions

View file

@ -46,16 +46,16 @@ public:
int lastTick; int lastTick;
bool bWideScreen; bool bWideScreen;
bool bClearBackground; bool bClearBackground;
const char* filename; bool bLooped;
CGameMenuItemQAV(int, int, const char*, bool widescreen = false, bool clearbackground = false); CGameMenuItemQAV(int, int, const char*, bool widescreen = false, bool clearbackground = false, bool looped = false);
void Draw(void); void Draw(void);
}; };
CGameMenuItemQAV::CGameMenuItemQAV(int a3, int a4, const char* name, bool widescreen, bool clearbackground) CGameMenuItemQAV::CGameMenuItemQAV(int a3, int a4, const char* name, bool widescreen, bool clearbackground, bool looped)
{ {
bWideScreen = widescreen; bWideScreen = widescreen;
bClearBackground = clearbackground; bClearBackground = clearbackground;
filename = name; bLooped = looped;
if (name) if (name)
{ {
@ -96,13 +96,13 @@ void CGameMenuItemQAV::Draw(void)
int backX = data->x; int backX = data->x;
for (int i = 0; i < nCount; i++) for (int i = 0; i < nCount; i++)
{ {
data->Draw(currentDuration, 10 + kQavOrientationLeft, 0, 0, false, smoothratio, filename == "BDRIP.QAV"); data->Draw(currentDuration, 10 + kQavOrientationLeft, 0, 0, false, smoothratio, bLooped);
data->x += 320; data->x += 320;
} }
data->x = backX; data->x = backX;
} }
else else
data->Draw(currentDuration, 10, 0, 0, false, smoothratio, filename == "BDRIP.QAV"); data->Draw(currentDuration, 10, 0, 0, false, smoothratio, bLooped);
} }
} }
@ -137,7 +137,7 @@ void UpdateNetworkMenus(void)
void GameInterface::MenuOpened() void GameInterface::MenuOpened()
{ {
itemBloodQAV.reset(new CGameMenuItemQAV(160, 100, "BDRIP.QAV", true)); itemBloodQAV.reset(new CGameMenuItemQAV(160, 100, "BDRIP.QAV", true, false, true));
} }
void GameInterface::MenuClosed() void GameInterface::MenuClosed()

View file

@ -6200,13 +6200,13 @@ void playerQavSceneDraw(PLAYER* pPlayer, int a2, double a3, double a4, int a5, d
if (!(pSprite->flags & kModernTypeFlag1)) { if (!(pSprite->flags & kModernTypeFlag1)) {
pQAV->x = int(a3); pQAV->y = int(a4); pQAV->x = int(a3); pQAV->y = int(a4);
pQAV->Draw(a3, a4, v4, flags, a2, a5, true, smoothratio); pQAV->Draw(a3, a4, v4, flags, a2, a5, true, smoothratio, pPlayer->qavLoop);
// draw fullscreen (currently 4:3 only) // draw fullscreen (currently 4:3 only)
} else { } else {
// What an awful hack. This throws proper ordering out of the window, but there is no way to reproduce this better with strict layering of elements. // What an awful hack. This throws proper ordering out of the window, but there is no way to reproduce this better with strict layering of elements.
// From the above commit it seems to be incomplete anyway... // From the above commit it seems to be incomplete anyway...
pQAV->Draw(v4, flags, a2, a5, false, smoothratio); pQAV->Draw(v4, flags, a2, a5, false, smoothratio, pPlayer->qavLoop);
} }
} }

View file

@ -72,7 +72,7 @@ void DrawFrame(double x, double y, double z, double a, TILE_FRAME *pTile, int st
} }
} }
void QAV::Draw(double x, double y, int ticks, int stat, int shade, int palnum, bool to3dview, double const smoothratio, bool const menudrip) void QAV::Draw(double x, double y, int ticks, int stat, int shade, int palnum, bool to3dview, double const smoothratio, bool const looped)
{ {
assert(ticksPerFrame > 0); assert(ticksPerFrame > 0);
@ -89,7 +89,7 @@ void QAV::Draw(double x, double y, int ticks, int stat, int shade, int palnum, b
lastframetic = 0; lastframetic = 0;
} }
int oFrame = nFrame == 0 || (lastframetic && ticks > lastframetic) ? nFrame : nFrame - 1; int oFrame = nFrame == 0 || (lastframetic && ticks > lastframetic) ? !looped ? nFrame : nFrames - 1 : nFrame - 1;
assert(oFrame >= 0 && oFrame < nFrames); assert(oFrame >= 0 && oFrame < nFrames);
FRAMEINFO *prevFrame = &frames[oFrame]; FRAMEINFO *prevFrame = &frames[oFrame];
@ -126,7 +126,7 @@ void QAV::Draw(double x, double y, int ticks, int stat, int shade, int palnum, b
if (thisTile->picnum > 0) if (thisTile->picnum > 0)
{ {
// Menu's blood drip requires special treatment. // Menu's blood drip requires special treatment.
if (menudrip) if (res_id == 256)
{ {
if (i != 0) if (i != 0)
{ {
@ -295,6 +295,7 @@ QAV* getQAV(int res_id)
} }
// Write out additions. // Write out additions.
qavdata->res_id = res_id;
qavdata->ticrate = 120. / qavdata->ticksPerFrame; qavdata->ticrate = 120. / qavdata->ticksPerFrame;
qavcache.Insert(res_id, qavdata); qavcache.Insert(res_id, qavdata);

View file

@ -75,11 +75,12 @@ struct QAV
int y; // 18 int y; // 18
int nSprite; // 1c int nSprite; // 1c
//SPRITE *pSprite; // 1c //SPRITE *pSprite; // 1c
char pad3[3]; // 20 char pad3[1]; // 20
char lastframetic; char lastframetic;
unsigned short res_id;
FRAMEINFO frames[1]; // 24 FRAMEINFO frames[1]; // 24
void Draw(double x, double y, int ticks, int stat, int shade, int palnum, bool to3dview, double const smoothratio = 65536, bool const menudrip = false); void Draw(double x, double y, int ticks, int stat, int shade, int palnum, bool to3dview, double const smoothratio = 65536, bool const looped = false);
void Draw(int ticks, int stat, int shade, int palnum, bool to3dview, double const smoothratio = 65536, bool const menudrip = false) { Draw(x, y, ticks, stat, shade, palnum, to3dview, smoothratio, menudrip); } void Draw(int ticks, int stat, int shade, int palnum, bool to3dview, double const smoothratio = 65536, bool const looped = false) { Draw(x, y, ticks, stat, shade, palnum, to3dview, smoothratio, looped); }
void Play(int, int, int, void *); void Play(int, int, int, void *);
void Precache(int palette = 0); void Precache(int palette = 0);
}; };

View file

@ -281,7 +281,7 @@ void WeaponDraw(PLAYER *pPlayer, int shade, double xpos, double ypos, int palnum
shade = -128; shade = -128;
flags |= 1; flags |= 1;
} }
pQAV->Draw(xpos, ypos, duration, flags, shade, palnum, true, smoothratio); pQAV->Draw(xpos, ypos, duration, flags, shade, palnum, true, smoothratio, pPlayer->qavLoop);
} }
void WeaponPlay(PLAYER *pPlayer) void WeaponPlay(PLAYER *pPlayer)