From be12da6bfba8bd87332847bd1014269c8a918a7b Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sat, 2 Jan 2021 18:23:01 +1100 Subject: [PATCH] - Automap: Put in framework to interpolate automap player. --- source/blood/src/blood.h | 2 +- source/blood/src/view.cpp | 4 ++-- source/core/automap.cpp | 4 ++-- source/core/automap.h | 2 +- source/core/gamestruct.h | 2 +- source/exhumed/src/engine.h | 2 +- source/exhumed/src/exhumed.h | 2 +- source/exhumed/src/map.cpp | 6 +++--- source/exhumed/src/view.cpp | 4 ++-- source/games/duke/src/actors.cpp | 1 + source/games/duke/src/duke3d.h | 2 +- source/games/duke/src/game_misc.cpp | 4 ++-- source/sw/src/draw.cpp | 4 ++-- source/sw/src/game.h | 2 +- 14 files changed, 21 insertions(+), 20 deletions(-) diff --git a/source/blood/src/blood.h b/source/blood/src/blood.h index b1ae46cb0..5892dd8ac 100644 --- a/source/blood/src/blood.h +++ b/source/blood/src/blood.h @@ -122,7 +122,7 @@ struct GameInterface : ::GameInterface void NewGame(MapRecord *sng, int skill) override; void NextLevel(MapRecord* map, int skill) override; void LevelCompleted(MapRecord* map, int skill) override; - bool DrawAutomapPlayer(int x, int y, int z, int a) override; + bool DrawAutomapPlayer(int x, int y, int z, int a, double const smoothratio) override; void SetTileProps(int til, int surf, int vox, int shade) override; fixed_t playerHorizMin() override { return IntToFixed(-180); } fixed_t playerHorizMax() override { return IntToFixed(120); } diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 15b7ba6ca..c9cac47f8 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -489,7 +489,7 @@ static void DrawMap(spritetype* pSprite) setViewport(Hud_Stbar); tm = 1; } - DrawOverheadMap(pSprite->x, pSprite->y, pSprite->ang); + DrawOverheadMap(pSprite->x, pSprite->y, pSprite->ang, gInterpolate); if (tm) setViewport(hud_size); } @@ -932,7 +932,7 @@ FString GameInterface::GetCoordString() } -bool GameInterface::DrawAutomapPlayer(int x, int y, int z, int a) +bool GameInterface::DrawAutomapPlayer(int x, int y, int z, int a, double const smoothratio) { // [MR]: Confirm that this is correct as math doesn't match the variable names. int nCos = z * -bsin(a); diff --git a/source/core/automap.cpp b/source/core/automap.cpp index e039094fe..65be2c524 100644 --- a/source/core/automap.cpp +++ b/source/core/automap.cpp @@ -544,7 +544,7 @@ void DrawPlayerArrow(int cposx, int cposy, int cang, int pl_x, int pl_y, int zoo // //--------------------------------------------------------------------------- -void DrawOverheadMap(int pl_x, int pl_y, int pl_angle) +void DrawOverheadMap(int pl_x, int pl_y, int pl_angle, double const smoothratio) { if (am_followplayer || follow_x == INT_MAX) { @@ -566,7 +566,7 @@ void DrawOverheadMap(int pl_x, int pl_y, int pl_angle) drawredlines(x, y, gZoom, follow_a); drawwhitelines(x, y, gZoom, follow_a); - if (!gi->DrawAutomapPlayer(x, y, gZoom, follow_a)) + if (!gi->DrawAutomapPlayer(x, y, gZoom, follow_a, smoothratio)) DrawPlayerArrow(x, y, follow_a, pl_x, pl_y, gZoom, -pl_angle); } diff --git a/source/core/automap.h b/source/core/automap.h index 5ee3bd6f0..14c10e0b1 100644 --- a/source/core/automap.h +++ b/source/core/automap.h @@ -17,7 +17,7 @@ extern FixedBitArray show2dsprite; void SerializeAutomap(FSerializer& arc); void ClearAutomap(); void MarkSectorSeen(int sect); -void DrawOverheadMap(int x, int y, int ang); +void DrawOverheadMap(int x, int y, int ang, double const smoothratio); bool AM_Responder(event_t* ev, bool last); void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, PalEntry p); diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index 4e303f6fc..b52257b4c 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -88,7 +88,7 @@ struct GameInterface virtual void NextLevel(MapRecord* map, int skill) {} virtual void NewGame(MapRecord* map, int skill) {} virtual void LevelCompleted(MapRecord* map, int skill) {} - virtual bool DrawAutomapPlayer(int x, int y, int z, int a) { return false; } + virtual bool DrawAutomapPlayer(int x, int y, int z, int a, double const smoothratio) { return false; } virtual void SetTileProps(int tile, int surf, int vox, int shade) {} virtual fixed_t playerHorizMin() { return IntToFixed(-200); } virtual fixed_t playerHorizMax() { return IntToFixed(200); } diff --git a/source/exhumed/src/engine.h b/source/exhumed/src/engine.h index 659b0252c..39d677bed 100644 --- a/source/exhumed/src/engine.h +++ b/source/exhumed/src/engine.h @@ -103,7 +103,7 @@ extern short bShowTowers; void GrabMap(); void UpdateMap(); -void DrawMap(); +void DrawMap(double const smoothratio); // random diff --git a/source/exhumed/src/exhumed.h b/source/exhumed/src/exhumed.h index 8e9beaedc..173905c5d 100644 --- a/source/exhumed/src/exhumed.h +++ b/source/exhumed/src/exhumed.h @@ -249,7 +249,7 @@ struct GameInterface : ::GameInterface void NewGame(MapRecord *map, int skill) override; void LevelCompleted(MapRecord *map, int skill) override; void NextLevel(MapRecord *map, int skill) override; - bool DrawAutomapPlayer(int x, int y, int z, int a) override; + bool DrawAutomapPlayer(int x, int y, int z, int a, double const smoothratio) override; fixed_t playerHorizMin() override { return IntToFixed(-150); } fixed_t playerHorizMax() override { return IntToFixed(150); } int playerKeyMove() override { return 6; } diff --git a/source/exhumed/src/map.cpp b/source/exhumed/src/map.cpp index 213792ad6..2fb5d4528 100644 --- a/source/exhumed/src/map.cpp +++ b/source/exhumed/src/map.cpp @@ -46,11 +46,11 @@ void UpdateMap() } } -void DrawMap() +void DrawMap(double const smoothratio) { if (!nFreeze && automapMode != am_off) { - DrawOverheadMap(initx, inity, inita); + DrawOverheadMap(initx, inity, inita, smoothratio); } } @@ -66,7 +66,7 @@ template void GetSpriteExtents(T const* const pSprite, int* top, int } } -bool GameInterface::DrawAutomapPlayer(int x, int y, int z, int a) +bool GameInterface::DrawAutomapPlayer(int x, int y, int z, int a, double const smoothratio) { // [MR]: Confirm that this is correct as math doesn't match the variable names. int nCos = z * -bsin(a); diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index 82e184d36..f738f2290 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -436,7 +436,7 @@ void DrawView(double smoothRatio, bool sceneonly) if (nSnakeCam < 0) { DrawWeapons(smoothRatio); - DrawMap(); + DrawMap(smoothRatio); } else { @@ -445,7 +445,7 @@ void DrawView(double smoothRatio, bool sceneonly) sprite[enemy].pal = nEnemyPal; } - DrawMap(); + DrawMap(smoothRatio); } } } diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 0edd16b79..14edf9177 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -5391,6 +5391,7 @@ void recordoldspritepos() ac->bposx = ac->s.x; ac->bposy = ac->s.y; ac->bposz = ac->s.z; + ac->tempang = ac->s.ang; } } } diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 0d484c29b..34db4bd52 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -57,7 +57,7 @@ struct GameInterface : public ::GameInterface void NextLevel(MapRecord* map, int skill) override; void NewGame(MapRecord* map, int skill) override; void LevelCompleted(MapRecord* map, int skill) override; - bool DrawAutomapPlayer(int x, int y, int z, int a) override; + bool DrawAutomapPlayer(int x, int y, int z, int a, double const smoothratio) override; int playerKeyMove() override { return 40; } void WarpToCoords(int x, int y, int z, int a, int h) override; void ToggleThirdPerson() override; diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index d2674a558..1811bd76f 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -283,7 +283,7 @@ void drawoverlays(double smoothratio) cposy = pp->oposy; cang = pp->angle.oang.asbuild(); } - DrawOverheadMap(cposx, cposy, cang); + DrawOverheadMap(cposx, cposy, cang, smoothratio); RestoreInterpolations(); } } @@ -394,7 +394,7 @@ ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize) // //--------------------------------------------------------------------------- -bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang) +bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang, double const smoothratio) { int i, j, k, l, x1, y1, x2, y2, x3, y3, x4, y4, ox, oy, xoff, yoff; int dax, day, cosang, sinang, xspan, yspan, sprx, spry; diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index ed7e3ebce..1e62a24f6 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -1812,7 +1812,7 @@ drawscreen(PLAYERp pp, double smoothratio) } } } - DrawOverheadMap(tx, ty, tang.asbuild()); + DrawOverheadMap(tx, ty, tang.asbuild(), smoothratio); } for (j = 0; j < MAXSPRITES; j++) @@ -1873,7 +1873,7 @@ bool GameInterface::GenerateSavePic() -bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang) +bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang, double const smoothratio) { int i, j, k, l, x1, y1, x2, y2, x3, y3, x4, y4, ox, oy, xoff, yoff; int dax, day, cosang, sinang, xspan, yspan, sprx, spry; diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 355827b71..bb20e8297 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -2252,7 +2252,7 @@ struct GameInterface : ::GameInterface void LevelCompleted(MapRecord *map, int skill) override; void NextLevel(MapRecord *map, int skill) override; void NewGame(MapRecord *map, int skill) override; - bool DrawAutomapPlayer(int x, int y, int z, int a) override; + bool DrawAutomapPlayer(int x, int y, int z, int a, double const smoothratio) override; int playerKeyMove() override { return 35; } void WarpToCoords(int x, int y, int z, int a, int h) override; void ToggleThirdPerson() override;