From b9477f147ef6ba22275a09ccea0d3341ac07633c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 26 Nov 2020 16:03:40 +0100 Subject: [PATCH] - migrated Duke's interpolations to the common system and added handling for texture scrollers. --- source/games/duke/src/funct.h | 5 -- source/games/duke/src/game_misc.cpp | 5 +- source/games/duke/src/gameloop.cpp | 3 +- source/games/duke/src/global.h | 6 -- source/games/duke/src/interpolate.cpp | 84 ++++----------------------- source/games/duke/src/premap.cpp | 13 +++-- source/games/duke/src/render.cpp | 5 +- source/games/duke/src/sectors.cpp | 8 ++- source/games/duke/src/spawn.cpp | 20 +++++-- source/sw/src/game.cpp | 2 +- 10 files changed, 49 insertions(+), 102 deletions(-) diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 6212c3aea..7216b5567 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -241,11 +241,6 @@ bool movementBlocked(int snum); void loadcons(); void recordoldspritepos(); -void updateinterpolations(); -void restoreinterpolations(); -void setinterpolation(int* posptr); -void stopinterpolation(int* posptr); -void dointerpolations(int smoothratio); int* animateptr(int i); void backuppos(player_struct* p, bool noclipping = false); diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index 5aeae5d89..05908e7e2 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -44,6 +44,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "glbackend/glbackend.h" #include "gamestate.h" #include "dukeactor.h" +#include "interpolate.h" BEGIN_DUKE_NS @@ -267,7 +268,7 @@ void drawoverlays(double smoothratio) if (automapMode != am_off) { - dointerpolations(smoothratio); + DoInterpolations(smoothratio / 65536.); if (pp->newOwner == nullptr && playrunning()) { @@ -291,7 +292,7 @@ void drawoverlays(double smoothratio) cang = pp->angle.oang.asbuild(); } DrawOverheadMap(cposx, cposy, cang); - restoreinterpolations(); + RestoreInterpolations(); } } diff --git a/source/games/duke/src/gameloop.cpp b/source/games/duke/src/gameloop.cpp index d3e625825..44db00ee0 100644 --- a/source/games/duke/src/gameloop.cpp +++ b/source/games/duke/src/gameloop.cpp @@ -34,6 +34,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "m_argv.h" #include "mapinfo.h" #include "texturemanager.h" +#include "interpolate.h" #include "glbackend/glbackend.h" BEGIN_DUKE_NS @@ -60,7 +61,7 @@ void GameInterface::Ticker() show_shareware--; } - updateinterpolations(); + UpdateInterpolations(); if (playrunning()) { diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index 78799afdf..4765e1a32 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -13,12 +13,6 @@ BEGIN_DUKE_NS extern user_defs ud; -// Interpolation code is the same in all games with slightly different naming - this needs to be unified and cleaned up. -// Interpolations are reconstructed on load and do not need to be saved. -enum { MAXINTERPOLATIONS = MAXSPRITES }; -extern int numinterpolations; -extern int* curipos[MAXINTERPOLATIONS]; -extern int bakipos[MAXINTERPOLATIONS]; // Variables that do not need to be saved. extern int respawnactortime; diff --git a/source/games/duke/src/interpolate.cpp b/source/games/duke/src/interpolate.cpp index ecd8aa254..750fd26a7 100644 --- a/source/games/duke/src/interpolate.cpp +++ b/source/games/duke/src/interpolate.cpp @@ -34,72 +34,10 @@ source as it is released. #include "ns.h" // Must come before everything else! #include "global.h" +#include "interpolate.h" BEGIN_DUKE_NS -int32_t numinterpolations; -int32_t g_interpolationLock; -int32_t oldipos[MAXINTERPOLATIONS]; -int32_t *curipos[MAXINTERPOLATIONS]; -int32_t bakipos[MAXINTERPOLATIONS]; - - -void updateinterpolations() //Stick at beginning of domovethings -{ - int i; - - for(i=numinterpolations-1;i>=0;i--) oldipos[i] = *curipos[i]; -} - - -void setinterpolation(int *posptr) -{ - int i; - - if (numinterpolations >= MAXINTERPOLATIONS) return; - for(i=numinterpolations-1;i>=0;i--) - if (curipos[i] == posptr) return; - curipos[numinterpolations] = posptr; - oldipos[numinterpolations] = *posptr; - numinterpolations++; -} - -void stopinterpolation(int *posptr) -{ - int i; - - for(i=numinterpolations-1;i>=0;i--) - if (curipos[i] == posptr) - { - numinterpolations--; - oldipos[i] = oldipos[numinterpolations]; - bakipos[i] = bakipos[numinterpolations]; - curipos[i] = curipos[numinterpolations]; - } -} - -void dointerpolations(int smoothratio) //Stick at beginning of drawscreen -{ - int i, j, odelta, ndelta; - - ndelta = 0; j = 0; - for(i=numinterpolations-1;i>=0;i--) - { - bakipos[i] = *curipos[i]; - odelta = ndelta; ndelta = (*curipos[i])-oldipos[i]; - if (odelta != ndelta) j = mulscale16(ndelta,smoothratio); - *curipos[i] = oldipos[i]+j; - } -} - -void restoreinterpolations() //Stick at end of drawscreen -{ - int i; - - for(i=numinterpolations-1;i>=0;i--) *curipos[i] = bakipos[i]; -} - - void setsectinterpolate(int sectnum) { int j, k, startwall,endwall; @@ -110,16 +48,16 @@ void setsectinterpolate(int sectnum) for(j=startwall;j= 0) { - setinterpolation(&wall[k].x); - setinterpolation(&wall[k].y); + StartInterpolation(k, Interp_Wall_X); + StartInterpolation(k, Interp_Wall_Y); k = wall[k].point2; - setinterpolation(&wall[k].x); - setinterpolation(&wall[k].y); + StartInterpolation(k, Interp_Wall_X); + StartInterpolation(k, Interp_Wall_Y); } } } @@ -133,12 +71,12 @@ void clearsectinterpolate(int sectnum) endwall = startwall + sect->wallnum; for(j=startwall;j= 0) { - stopinterpolation(&wall[wall[j].nextwall].x); - stopinterpolation(&wall[wall[j].nextwall].y); + StopInterpolation(wall[j].nextwall, Interp_Wall_X); + StopInterpolation(wall[j].nextwall, Interp_Wall_Y); } } } diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 934283b46..31164a273 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -35,6 +35,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms #include "sbar.h" #include "automap.h" #include "dukeactor.h" +#include "interpolate.h" BEGIN_DUKE_NS @@ -426,9 +427,6 @@ void resetprestat(int snum,int g) BellTime = 0; BellSprite = nullptr; - numinterpolations = 0; - //startofdynamicinterpolations = 0; - if(p->curr_weapon == HANDREMOTE_WEAPON) { p->ammo_amount[HANDBOMB_WEAPON]++; @@ -965,11 +963,18 @@ void enterlevel(MapRecord *mi, int gamemode) global_random = 0; ud.last_level = currentLevel->levelNumber; - for (int i=numinterpolations-1; i>=0; i--) bakipos[i] = *curipos[i]; ps[myconnectindex].over_shoulder_on = 0; clearfrags(); resettimevars(); // Here we go setLevelStarted(mi); + if (isRRRA() && ps[screenpeek].sea_sick_stat == 1) + { + for (int i = 0; i < MAXWALLS; i++) + { + if (wall[i].picnum == 7873 || wall[i].picnum == 7870) + StartInterpolation(i, Interp_Wall_PanX); + } + } } //--------------------------------------------------------------------------- diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index f7b80de4b..3e8077787 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -32,6 +32,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "prediction.h" #include "automap.h" #include "dukeactor.h" +#include "interpolate.h" BEGIN_DUKE_NS @@ -502,7 +503,7 @@ void displayrooms(int snum, double smoothratio) if (sect < 0 || sect >= MAXSECTORS) return; GLInterface.SetMapFog(fogactive != 0); - dointerpolations(smoothratio); + DoInterpolations(smoothratio / 65536.); setgamepalette(BASEPAL); animatecamsprite(smoothratio); @@ -647,7 +648,7 @@ void displayrooms(int snum, double smoothratio) } } //GLInterface.SetMapFog(false); - restoreinterpolations(); + RestoreInterpolations(); if (!isRRRA() || !fogactive) { diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index d3cb55672..2963fa2f2 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -37,12 +37,15 @@ source as it is released. #include "global.h" #include "sounds.h" #include "dukeactor.h" +#include "interpolate.h" using std::min; using std::max; // PRIMITIVE BEGIN_DUKE_NS +static int interptype[] = { Interp_Sect_Floorz, Interp_Sect_Ceilingz, Interp_Wall_X, Interp_Wall_Y }; + //--------------------------------------------------------------------------- // // @@ -318,7 +321,7 @@ void doanimations(void) if (a == animategoal[i]) { - stopinterpolation(animateptr(i)); + StopInterpolation(animatetarget[i], interptype[animatetype[i]]); animatecnt--; animatetype[i] = animatetype[animatecnt]; @@ -419,8 +422,7 @@ int setanimation(short animsect, int animtype, int animtarget, int thegoal, int if (j == animatecnt) animatecnt++; - setinterpolation(animptr); - + StartInterpolation(animatetarget[i], interptype[animatetype[i]]); return(j); } diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index c3efc2cce..1962c01f7 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -38,6 +38,7 @@ source as it is released. #include "sounds.h" #include "automap.h" #include "dukeactor.h" +#include "interpolate.h" BEGIN_DUKE_NS @@ -694,7 +695,7 @@ void spawneffector(DDukeActor* actor) t[4] = sector[sect].ceilingz; sector[sect].ceilingz = sp->z; - setinterpolation(§or[sect].ceilingz); + StartInterpolation(sect, Interp_Sect_Ceilingz); break; case SE_35: sector[sect].ceilingz = sp->z; @@ -781,13 +782,20 @@ void spawneffector(DDukeActor* actor) if (numplayers < 2) { - setinterpolation(§or[sect].floorz); - setinterpolation(§or[sect].ceilingz); + StartInterpolation(sect, Interp_Sect_Floorz); + StartInterpolation(sect, Interp_Sect_Ceilingz); } break; } + case 156: + if (!isRRRA()) break; + case 34: + StartInterpolation(sect, Interp_Sect_FloorPanX); + break; + case SE_24_CONVEYOR: + StartInterpolation(sect, Interp_Sect_FloorPanX); sp->yvel <<= 1; case SE_36_PROJ_SHOOTER: break; @@ -833,6 +841,8 @@ void spawneffector(DDukeActor* actor) } t[2] = clostest; + StartInterpolation(sect, Interp_Sect_FloorPanX); + StartInterpolation(sect, Interp_Sect_FloorPanY); break; } @@ -871,7 +881,7 @@ void spawneffector(DDukeActor* actor) for (s = startwall; s < endwall; s++) if (wall[s].hitag == 0) wall[s].hitag = 9999; - setinterpolation(§or[sect].floorz); + StartInterpolation(sect, Interp_Sect_Floorz); break; case SE_32_CEILING_RISE_FALL: @@ -885,7 +895,7 @@ void spawneffector(DDukeActor* actor) for (s = startwall; s < endwall; s++) if (wall[s].hitag == 0) wall[s].hitag = 9999; - setinterpolation(§or[sect].ceilingz); + StartInterpolation(sect, Interp_Sect_Ceilingz); break; diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index fcbd208ad..571cea8c4 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -287,7 +287,7 @@ void InitLevelGlobals(void) gNet.TimeLimitClock = gNet.TimeLimit; - serpwasseen = false; + serpwasseen = false; sumowasseen = false; zillawasseen = false; memset(BossSpriteNum,-1,sizeof(BossSpriteNum));