From 47436c58d71ba7fad3be50cd2135a17d02419c54 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Nov 2021 23:49:37 +0100 Subject: [PATCH] - WH: enable sprite interpolation. For all games: completely disable interpolation by setting smoothratio to 1 when cl_interpolate == 0 or cl_capfps == 1. --- source/core/gamecvars.h | 1 + source/games/blood/src/d_menu.cpp | 2 +- source/games/blood/src/qav.cpp | 2 +- source/games/blood/src/view.cpp | 2 +- source/games/duke/src/gameloop.cpp | 2 +- source/games/exhumed/src/exhumed.cpp | 2 +- source/games/sw/src/game.cpp | 2 +- source/games/whaven/src/ai.cpp | 3 +++ source/games/whaven/src/aidragon.cpp | 1 + source/games/whaven/src/aifatwitch.cpp | 1 + source/games/whaven/src/aigonzo.cpp | 2 ++ source/games/whaven/src/aigron.cpp | 1 + source/games/whaven/src/aijudy.cpp | 1 + source/games/whaven/src/ainewguy.cpp | 1 + source/games/whaven/src/main.cpp | 6 ++++++ source/games/whaven/src/potions.cpp | 1 + source/games/whaven/src/render.cpp | 2 +- source/games/whaven/src/spellbooks.cpp | 1 + source/games/whaven/src/weapons.cpp | 11 +++++++++++ source/games/whaven/src/whani.cpp | 2 ++ source/games/whaven/src/whfx.cpp | 6 ++++++ source/games/whaven/src/whmap.cpp | 2 ++ source/games/whaven/src/whobj.cpp | 10 +++++++++- source/games/whaven/src/whplr.cpp | 2 ++ 24 files changed, 58 insertions(+), 8 deletions(-) diff --git a/source/core/gamecvars.h b/source/core/gamecvars.h index 6a3533602..f7d674276 100644 --- a/source/core/gamecvars.h +++ b/source/core/gamecvars.h @@ -16,6 +16,7 @@ EXTERN_CVAR(Bool, cl_weaponsway) EXTERN_CVAR(Bool, cl_viewhbob) EXTERN_CVAR(Bool, cl_viewvbob) EXTERN_CVAR(Bool, cl_interpolate) +EXTERN_CVAR(Bool, cl_capfps) EXTERN_CVAR(Bool, cl_slopetilting) EXTERN_CVAR(Int, cl_showweapon) EXTERN_CVAR(Int, cl_weaponswitch) diff --git a/source/games/blood/src/d_menu.cpp b/source/games/blood/src/d_menu.cpp index 3be8a729b..5e20bc5d5 100644 --- a/source/games/blood/src/d_menu.cpp +++ b/source/games/blood/src/d_menu.cpp @@ -83,7 +83,7 @@ void CGameMenuItemQAV::Draw(void) duration = data->duration; } auto currentDuration = data->duration - duration; - auto smoothratio = I_GetTimeFrac(data->ticrate) * MaxSmoothRatio; + auto smoothratio = !cl_interpolate || cl_capfps? MaxSmoothRatio : I_GetTimeFrac(data->ticrate) * MaxSmoothRatio; data->Play(currentDuration - data->ticksPerFrame, currentDuration, -1, NULL); diff --git a/source/games/blood/src/qav.cpp b/source/games/blood/src/qav.cpp index 3f30a957d..452c3d6d9 100644 --- a/source/games/blood/src/qav.cpp +++ b/source/games/blood/src/qav.cpp @@ -307,7 +307,7 @@ void qavProcessTimer(PLAYER* const pPlayer, QAV* const pQAV, int* duration, doub { // Apply normal values. *duration = pQAV->duration - pPlayer->qavTimer; - *smoothratio = I_GetTimeFrac(pQAV->ticrate) * MaxSmoothRatio; + *smoothratio = !cl_interpolate || cl_capfps ? MaxSmoothRatio : I_GetTimeFrac(pQAV->ticrate) * MaxSmoothRatio; } } else diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 2d109ca08..5d836ce40 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -552,7 +552,7 @@ void viewDrawScreen(bool sceneonly) if (!paused && (!M_Active() || gGameOptions.nGameType != 0)) { - gInterpolate = I_GetTimeFrac() * MaxSmoothRatio; + gInterpolate = !cl_interpolate || cl_capfps ? MaxSmoothRatio : I_GetTimeFrac() * MaxSmoothRatio; } else gInterpolate = MaxSmoothRatio; pm_smoothratio = (int)gInterpolate; diff --git a/source/games/duke/src/gameloop.cpp b/source/games/duke/src/gameloop.cpp index 5e6e6930a..05e322a49 100644 --- a/source/games/duke/src/gameloop.cpp +++ b/source/games/duke/src/gameloop.cpp @@ -128,7 +128,7 @@ void GameInterface::Render() drawtime.Reset(); drawtime.Clock(); videoSetBrightness(thunder_brightness); - double const smoothRatio = playrunning() ? I_GetTimeFrac() * MaxSmoothRatio : MaxSmoothRatio; + double const smoothRatio = !playrunning() || !cl_interpolate || cl_capfps ? MaxSmoothRatio : I_GetTimeFrac() * MaxSmoothRatio; displayrooms(screenpeek, smoothRatio); drawoverlays(smoothRatio); drawtime.Unclock(); diff --git a/source/games/exhumed/src/exhumed.cpp b/source/games/exhumed/src/exhumed.cpp index 3e086e245..58fca2df4 100644 --- a/source/games/exhumed/src/exhumed.cpp +++ b/source/games/exhumed/src/exhumed.cpp @@ -231,7 +231,7 @@ void DrawClock() double calc_smoothratio() { - if (bRecord || bPlayback || nFreeze != 0 || paused) + if (bRecord || bPlayback || nFreeze != 0 || paused || cl_capfps || !cl_interpolate) return MaxSmoothRatio; return I_GetTimeFrac() * MaxSmoothRatio; diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index 967074292..70ca41a35 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -621,7 +621,7 @@ void GameInterface::Render() } else { - smoothratio = I_GetTimeFrac() * MaxSmoothRatio; + smoothratio = !cl_interpolate || cl_capfps ? MaxSmoothRatio : I_GetTimeFrac() * MaxSmoothRatio; } drawtime.Reset(); diff --git a/source/games/whaven/src/ai.cpp b/source/games/whaven/src/ai.cpp index cf5f56676..9e3049b82 100644 --- a/source/games/whaven/src/ai.cpp +++ b/source/games/whaven/src/ai.cpp @@ -634,6 +634,7 @@ void castspell(PLAYER& plr, DWHActor* actor) { spawned.clipdist = 16; spawned.lotag = 512; spawned.hitag = 0; + spawned.backuploc(); } void skullycastspell(PLAYER& plr, int i) { @@ -670,6 +671,7 @@ void skullycastspell(PLAYER& plr, int i) { spawned.lotag = 512; spawned.hitag = 0; spawned.pal = 7; + spawned.backuploc(); } void attack(PLAYER& plr, int const i) { @@ -1011,6 +1013,7 @@ void monsterweapon(int i) { weap.cstat = 0; weap.cstat &= ~3; weap.pal = 0; + weap.backuploc(); int type = (krand() % 4); weap.picnum = (short)(FLASKBLUE + type); diff --git a/source/games/whaven/src/aidragon.cpp b/source/games/whaven/src/aidragon.cpp index 6a52829ef..f9c6a70fa 100644 --- a/source/games/whaven/src/aidragon.cpp +++ b/source/games/whaven/src/aidragon.cpp @@ -374,6 +374,7 @@ static void firebreath(PLAYER& plr, int i, int a, int b, int c) spawned.clipdist = 16; spawned.lotag = 512; spawned.hitag = 0; + spawned.backuploc(); } } diff --git a/source/games/whaven/src/aifatwitch.cpp b/source/games/whaven/src/aifatwitch.cpp index 31b84fae7..b45460f3c 100644 --- a/source/games/whaven/src/aifatwitch.cpp +++ b/source/games/whaven/src/aifatwitch.cpp @@ -280,6 +280,7 @@ static void throwspank(PLAYER& plr, DWHActor* actor) spawned.lotag = 512; spawned.hitag = 0; spawned.pal = 0; + spawned.backuploc(); } void createFatwitchAI() { diff --git a/source/games/whaven/src/aigonzo.cpp b/source/games/whaven/src/aigonzo.cpp index cccdf2c1b..6d88a757d 100644 --- a/source/games/whaven/src/aigonzo.cpp +++ b/source/games/whaven/src/aigonzo.cpp @@ -692,6 +692,7 @@ static void gonzopike(short s, PLAYER& plr) { spr.lotag = 1024; spr.hitag = 0; spr.pal = 0; + spr.backuploc(); } @@ -813,6 +814,7 @@ void deaddude(short sn) { spawned.owner = 0; spawned.lotag = 0; spawned.hitag = 0; + spawned.backuploc(); } END_WH_NS diff --git a/source/games/whaven/src/aigron.cpp b/source/games/whaven/src/aigron.cpp index f94a2aeb6..e73b72d7f 100644 --- a/source/games/whaven/src/aigron.cpp +++ b/source/games/whaven/src/aigron.cpp @@ -490,6 +490,7 @@ static void throwhalberd(int s) { movesprite((short)j, (bcos(spr.extra) * TICSPERFRAME) << 7, (bsin(spr.extra) * TICSPERFRAME) << 7, daz, 4 << 8, 4 << 8, 1); spr.cstat = 21; + spr.backuploc(); } void createGronAI() { diff --git a/source/games/whaven/src/aijudy.cpp b/source/games/whaven/src/aijudy.cpp index 79c5c5cf8..d53dc6e18 100644 --- a/source/games/whaven/src/aijudy.cpp +++ b/source/games/whaven/src/aijudy.cpp @@ -409,6 +409,7 @@ void spawnabaddy(DWHActor* actor, int monster) { killcnt++; setsprite(j, spawned.x, spawned.y, spawned.z); + spawned.backuploc(); } diff --git a/source/games/whaven/src/ainewguy.cpp b/source/games/whaven/src/ainewguy.cpp index 9fa586d41..7622627c1 100644 --- a/source/games/whaven/src/ainewguy.cpp +++ b/source/games/whaven/src/ainewguy.cpp @@ -398,6 +398,7 @@ static void newguyarrow(short s, PLAYER& plr) { spr.lotag = 1024; spr.hitag = 0; spr.pal = 0; + spr.backuploc(); } void createNewGuyAI() { diff --git a/source/games/whaven/src/main.cpp b/source/games/whaven/src/main.cpp index 67049068e..05ec75ced 100644 --- a/source/games/whaven/src/main.cpp +++ b/source/games/whaven/src/main.cpp @@ -671,6 +671,12 @@ void GameInterface::Ticker() return; } UpdateInterpolations(); + + WHSpriteIterator it; + while (auto ac = it.Next()) + { + ac->s().backuploc(); + } for (int i = connecthead; i >= 0; i = connectpoint2[i]) player[i].oldsector = player[i].sector; diff --git a/source/games/whaven/src/potions.cpp b/source/games/whaven/src/potions.cpp index 54f9d0895..3017f209e 100644 --- a/source/games/whaven/src/potions.cpp +++ b/source/games/whaven/src/potions.cpp @@ -155,6 +155,7 @@ void randompotion(int i) { int type = krand() % 4; spawned.picnum = (short)(FLASKBLUE + type); spawned.detail = (short)(FLASKBLUETYPE + type); + spawned.backuploc(); } END_WH_NS diff --git a/source/games/whaven/src/render.cpp b/source/games/whaven/src/render.cpp index d51f1eeec..52479588b 100644 --- a/source/games/whaven/src/render.cpp +++ b/source/games/whaven/src/render.cpp @@ -129,7 +129,7 @@ void GameInterface::processSprites(spritetype* tsprite, int& spritesortcnt, int void GameInterface::Render() { - double const smoothRatio = playrunning() ? I_GetTimeFrac() * MaxSmoothRatio : MaxSmoothRatio; + double const smoothRatio = !playrunning() || !cl_interpolate || cl_capfps ? MaxSmoothRatio : I_GetTimeFrac() * MaxSmoothRatio; drawscreen(pyrn, smoothRatio, false); if (!paused && isWh2() && attacktheme && !Mus_IsPlaying()) diff --git a/source/games/whaven/src/spellbooks.cpp b/source/games/whaven/src/spellbooks.cpp index 2252c6eb8..79e05b39c 100644 --- a/source/games/whaven/src/spellbooks.cpp +++ b/source/games/whaven/src/spellbooks.cpp @@ -274,6 +274,7 @@ void nukespell(PLAYER& plr, short const j) { spawned.y = spr.y; spawned.z = spr.z; spawned.cstat = spr.cstat; + spawned.backuploc(); return; } diff --git a/source/games/whaven/src/weapons.cpp b/source/games/whaven/src/weapons.cpp index c0194ec43..e867a8a8c 100644 --- a/source/games/whaven/src/weapons.cpp +++ b/source/games/whaven/src/weapons.cpp @@ -1723,6 +1723,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.owner = sprite[plr.spritenum].owner; spawned.lotag = 32; spawned.hitag = 0; + spawned.backuploc(); spritesound(S_ARROWHIT, &spawned); if (isWh2() && plr.weapon[6] == 3 && plr.currweapon == 6) { @@ -1745,6 +1746,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.owner = 0; spawned.lotag = 1200; spawned.hitag = 0; + spawned.backuploc(); } } @@ -1773,6 +1775,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.hitag = 0; movesprite((short) j, (bcos(spawned.ang) * TICSPERFRAME) << 3, (bsin(spawned.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0); + spawned.backuploc(); } if ((pHitInfo.hitsprite >= 0) && (sprite[pHitInfo.hitsprite].statnum < MAXSTATUS)) { auto& hitspr = sprite[pHitInfo.hitsprite]; @@ -1980,6 +1983,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { movesprite((short) j, (bcos(spawned.extra) * TICSPERFRAME) << 3, (bsin(spawned.extra) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0); setsprite((short) j, spawned.x, spawned.y, spawned.z); + spawned.backuploc(); } else { j = insertsprite(plr.sector, MISSILE); auto& spawned = sprite[j]; @@ -2002,6 +2006,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.lotag = 1024; spawned.hitag = 0; spawned.pal = 0; + spawned.backuploc(); } } else { j = insertsprite(plr.sector, MISSILE); @@ -2030,6 +2035,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.lotag = 1024; spawned.hitag = 0; spawned.pal = 0; + spawned.backuploc(); } } } @@ -2072,6 +2078,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { movesprite((short) j, (bcos(spawned.extra) * TICSPERFRAME) << 3, (bsin(spawned.extra) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0); setsprite((short) j, spawned.x, spawned.y, spawned.z); + spawned.backuploc(); } else { j = insertsprite(plr.sector, MISSILE); auto& spawned = sprite[j]; @@ -2094,6 +2101,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.lotag = 1024; spawned.hitag = 0; spawned.pal = 0; + spawned.backuploc(); } } else { j = insertsprite(plr.sector, MISSILE); @@ -2120,6 +2128,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { spawned.lotag = 1024; spawned.hitag = 0; spawned.pal = 0; + spawned.backuploc(); } } @@ -2162,6 +2171,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { movesprite((short) j, (bcos(spawned.ang) * TICSPERFRAME) << 3, (bsin(spawned.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0); setsprite(j, spawned.x, spawned.y, spawned.z); + spawned.backuploc(); break; } @@ -2204,6 +2214,7 @@ void shootgun(PLAYER& plr, float ang, int guntype) { movesprite((short) j, (bcos(spawned.ang) * TICSPERFRAME) << 3, (bsin(spawned.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0); setsprite(j, spawned.x, spawned.y, spawned.z); + spawned.backuploc(); break; } diff --git a/source/games/whaven/src/whani.cpp b/source/games/whaven/src/whani.cpp index 2d3f33627..684188d7c 100644 --- a/source/games/whaven/src/whani.cpp +++ b/source/games/whaven/src/whani.cpp @@ -271,6 +271,7 @@ void animateobjs(PLAYER& plr) { spawned.hitag = 0; spawned.detail = GONZOTYPE; DeleteActor(actor); + spawned.backuploc(); } } @@ -1352,6 +1353,7 @@ void animateobjs(PLAYER& plr) { spawned.owner = spr.owner; spawned.lotag = 256; spawned.hitag = 0; + spawned.backuploc(); } if (spr.lotag < 0) { diff --git a/source/games/whaven/src/whfx.cpp b/source/games/whaven/src/whfx.cpp index 486c4e9c7..338b7906f 100644 --- a/source/games/whaven/src/whfx.cpp +++ b/source/games/whaven/src/whfx.cpp @@ -829,6 +829,7 @@ void makeasplash(int picnum, PLAYER& plr) { movesprite((short) j, (bcos(spawned.ang) * TICSPERFRAME) << 3, (bsin(spawned.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0); + spawned.backuploc(); } void makemonstersplash(int picnum, int i) { @@ -860,6 +861,7 @@ void makemonstersplash(int picnum, int i) { spawned.clipdist = 16; spawned.lotag = 8; spawned.hitag = 0; + spawned.backuploc(); // JSA 5/3 start switch (picnum) { @@ -902,6 +904,7 @@ void bats(PLAYER& plr, int k) { spawned.lotag = 128; spawned.hitag = (short) k; spawned.extra = 0; + spawned.backuploc(); newstatus(j, FLOCK); @@ -1029,6 +1032,7 @@ void warpfxsprite(int s) { movesprite((short) j, (bcos(daang) * TICSPERFRAME) << 3, (bsin(daang) * TICSPERFRAME) << 3, daz, 4 << 8, 4 << 8, 1); + spawned.backuploc(); } void resetEffects() { @@ -1122,6 +1126,7 @@ void makesparks(short i, int type) { spawned.extra = 0; spawned.pal = 0; + spawned.backuploc(); } void shards(int i, int type) { @@ -1144,6 +1149,7 @@ void shards(int i, int type) { spawned.hitag = 0; spawned.extra = (short) type; spawned.pal = 0; + spawned.backuploc(); } diff --git a/source/games/whaven/src/whmap.cpp b/source/games/whaven/src/whmap.cpp index 1917667f3..1fe6ac916 100644 --- a/source/games/whaven/src/whmap.cpp +++ b/source/games/whaven/src/whmap.cpp @@ -768,6 +768,7 @@ boolean prepareboard(const char* fname) { sp.cstat = 515; sp.shade = -3; sp.xrepeat = sp.yrepeat = 64; + sp.backuploc(); } } } @@ -809,6 +810,7 @@ boolean prepareboard(const char* fname) { // dont forget to cleanup values plr.treasure[TONYXRING] = 0; soundEngine->StopAllChannels(); + pspr.backuploc(); justteleported = false; } else { diff --git a/source/games/whaven/src/whobj.cpp b/source/games/whaven/src/whobj.cpp index 565d4e5f6..d3f62deeb 100644 --- a/source/games/whaven/src/whobj.cpp +++ b/source/games/whaven/src/whobj.cpp @@ -1390,6 +1390,7 @@ void makeafire(int i, int firetype) { spawned.lotag = 2047; spawned.hitag = 0; changespritestat(j, FIRE); + spawned.backuploc(); } void explosion(int i, int x, int y, int z, int owner) { @@ -1427,6 +1428,7 @@ void explosion(int i, int x, int y, int z, int owner) { spawned.picnum = EXPLOSTART; spawned.lotag = 12; } + spawned.backuploc(); } void explosion2(int i, int x, int y, int z, int owner) { @@ -1466,7 +1468,8 @@ void explosion2(int i, int x, int y, int z, int owner) { spawned.picnum = EXPLOSTART; spawned.lotag = 12; } - + spawned.backuploc(); + } void trailingsmoke(DWHActor* actor, boolean ball) { @@ -1494,6 +1497,7 @@ void trailingsmoke(DWHActor* actor, boolean ball) { spawned.owner = spr.owner; spawned.lotag = 256; spawned.hitag = 0; + spawned.backuploc(); } void icecubes(int i, int x, int y, int z, int owner) { @@ -1525,6 +1529,7 @@ void icecubes(int i, int x, int y, int z, int owner) { spawned.lotag = 2048; else spawned.lotag = 999; spawned.hitag = 0; + spawned.backuploc(); } @@ -1834,6 +1839,7 @@ void trowajavlin(int s) { spawned.lotag = 0; spawned.hitag = 0; spawned.pal = 0; + spawned.backuploc(); } void spawnhornskull(short i) { @@ -1851,6 +1857,7 @@ void spawnhornskull(short i) { spawned.detail = HORNEDSKULLTYPE; spawned.xrepeat = 64; spawned.yrepeat = 64; + spawned.backuploc(); } void spawnapentagram(int sn) { @@ -1873,6 +1880,7 @@ void spawnapentagram(int sn) { spawned.detail = PENTAGRAMTYPE; setsprite(j, spawned.x, spawned.y, spawned.z); + spawned.backuploc(); } END_WH_NS diff --git a/source/games/whaven/src/whplr.cpp b/source/games/whaven/src/whplr.cpp index a25dff2f7..a7c03ebc9 100644 --- a/source/games/whaven/src/whplr.cpp +++ b/source/games/whaven/src/whplr.cpp @@ -211,6 +211,7 @@ void initplayersprite(PLAYER& plr) { plr.nightglowtime = -1; plr.strongtime = -1; plr.invisibletime = -1; + spr.backuploc(); } void updateviewmap(PLAYER& plr) { @@ -434,6 +435,7 @@ void chunksofmeat(PLAYER& plr, DWHActor* hitActor, int hitx, int hity, int hitz, spawned.pal = 0; movesprite((short) j, (bcos(spawned.ang) * TICSPERFRAME) << 3, (bsin(spawned.ang) * TICSPERFRAME) << 3, 0, 4 << 8, 4 << 8, 0); + spawned.backuploc(); } }