From cd3288860a772008d0625dc5fc7cdf2a25e96c81 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 26 Nov 2021 23:11:59 +0100 Subject: [PATCH] - fixed automap player drawing for follpw mode off in all games. --- source/core/automap.cpp | 2 +- source/core/gamestruct.h | 2 +- source/games/blood/src/blood.h | 2 +- source/games/blood/src/view.cpp | 16 ++++++++++++---- source/games/duke/src/duke3d.h | 2 +- source/games/duke/src/game_misc.cpp | 12 ++++++++++-- source/games/exhumed/src/exhumed.h | 2 +- source/games/exhumed/src/map.cpp | 16 ++++++++++++---- source/games/sw/src/draw.cpp | 14 ++++++++------ source/games/sw/src/game.h | 2 +- 10 files changed, 48 insertions(+), 22 deletions(-) diff --git a/source/core/automap.cpp b/source/core/automap.cpp index fd387ed11..0007e6593 100644 --- a/source/core/automap.cpp +++ b/source/core/automap.cpp @@ -688,7 +688,7 @@ void DrawOverheadMap(int pl_x, int pl_y, int pl_angle, double const smoothratio) } drawredlines(x, y, gZoom, follow_a); drawwhitelines(x, y, gZoom, follow_a); - if (!gi->DrawAutomapPlayer(x, y, gZoom, follow_a, smoothratio)) + if (!gi->DrawAutomapPlayer(pl_x, pl_y, x, y, gZoom, follow_a, smoothratio)) DrawPlayerArrow(x, y, follow_a, pl_x, pl_y, gZoom, -pl_angle); } diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index f44c3dc24..270301311 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -103,7 +103,7 @@ struct GameInterface virtual void NextLevel(MapRecord* map, int skill) {} virtual void NewGame(MapRecord* map, int skill, bool special = false) {} virtual void LevelCompleted(MapRecord* map, int skill) {} - virtual bool DrawAutomapPlayer(int x, int y, int z, int a, double const smoothratio) { return false; } + virtual bool DrawAutomapPlayer(int mx, int my, 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/games/blood/src/blood.h b/source/games/blood/src/blood.h index fdb936fdd..5c8e745c9 100644 --- a/source/games/blood/src/blood.h +++ b/source/games/blood/src/blood.h @@ -133,7 +133,7 @@ struct GameInterface : public ::GameInterface void NewGame(MapRecord *sng, int skill, bool) 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, double const smoothratio) override; + bool DrawAutomapPlayer(int mx, int my, 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/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index d0413b927..1740b403b 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -753,14 +753,22 @@ FString GameInterface::GetCoordString() } -bool GameInterface::DrawAutomapPlayer(int x, int y, int z, int a, double const smoothratio) +bool GameInterface::DrawAutomapPlayer(int mx, int my, int x, int y, int z, int a, double const smoothratio) { for (int i = connecthead; i >= 0; i = connectpoint2[i]) { PLAYER* pPlayer = &gPlayer[i]; spritetype* pSprite = pPlayer->pSprite; - int x1 = pSprite->x - x; - int y1 = pSprite->y - y; + + int xvect = -bsin(a) * z; + int yvect = -bcos(a) * z; + int ox = mx - x; + int oy = my - y; + int x1 = DMulScale(ox, xvect, -oy, yvect, 16); + int y1 = DMulScale(oy, xvect, ox, yvect, 16); + int xx = xdim / 2. + x1 / 4096.; + int yy = ydim / 2. + y1 / 4096.; + if (i == gView->nPlayer || gGameOptions.nGameType == 1) { int nTile = pSprite->picnum; @@ -775,7 +783,7 @@ bool GameInterface::DrawAutomapPlayer(int x, int y, int z, int a, double const s double x = xdim / 2. + x1 / double(1 << 12); double y = ydim / 2. + y1 / double(1 << 12); // This very likely needs fixing later - DrawTexture(twod, tileGetTexture(nTile, true), x, y, DTA_ClipLeft, windowxy1.x, DTA_ClipTop, windowxy1.y, DTA_ScaleX, z/1536., DTA_ScaleY, z/1536., DTA_CenterOffset, true, + DrawTexture(twod, tileGetTexture(nTile, true), xx, yy, DTA_ClipLeft, windowxy1.x, DTA_ClipTop, windowxy1.y, DTA_ScaleX, z/1536., DTA_ScaleY, z/1536., DTA_CenterOffset, true, DTA_ClipRight, windowxy2.x + 1, DTA_ClipBottom, windowxy2.y + 1, DTA_Alpha, (pSprite->cstat & 2 ? 0.5 : 1.), TAG_DONE); } } diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index b769231c0..d8dcf6c39 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -54,7 +54,7 @@ struct GameInterface : public ::GameInterface void NextLevel(MapRecord* map, int skill) override; void NewGame(MapRecord* map, int skill, bool) override; void LevelCompleted(MapRecord* map, int skill) override; - bool DrawAutomapPlayer(int x, int y, int z, int a, double const smoothratio) override; + bool DrawAutomapPlayer(int mx, int my, 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 059dee8fa..f0e4a48cc 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -383,7 +383,7 @@ ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize) // //--------------------------------------------------------------------------- -bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang, double const smoothratio) +bool GameInterface::DrawAutomapPlayer(int mx, int my, 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; @@ -547,6 +547,14 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang, auto act = ps[p].GetActor(); auto pspr = act->s; auto spos = pspr->interpolatedvec2(smoothratio); + + ox = mx - cposx; + oy = my - cposy; + x1 = DMulScale(ox, xvect, -oy, yvect, 16); + y1 = DMulScale(oy, xvect, ox, yvect, 16); + int xx = xdim / 2. + x1 / 4096.; + int yy = ydim / 2. + y1 / 4096.; + daang = ((!SyncInput() ? pspr->ang : pspr->interpolatedang(smoothratio)) - cang) & 2047; if (p == screenpeek || ud.coop == 1) @@ -563,7 +571,7 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang, if (j < 22000) j = 22000; else if (j > (65536 << 1)) j = (65536 << 1); - DrawTexture(twod, tileGetTexture(i), xdim / 2. + spos.x / 4096., ydim / 2. + spos.y / 4096., DTA_TranslationIndex, TRANSLATION(Translation_Remap + setpal(&pp), pspr->pal), DTA_CenterOffset, true, + DrawTexture(twod, tileGetTexture(i), xx, yy, DTA_TranslationIndex, TRANSLATION(Translation_Remap + setpal(&pp), pspr->pal), DTA_CenterOffset, true, DTA_Rotate, daang * -BAngToDegree, DTA_Color, shadeToLight(pspr->shade), DTA_ScaleX, j / 65536., DTA_ScaleY, j / 65536., TAG_DONE); } } diff --git a/source/games/exhumed/src/exhumed.h b/source/games/exhumed/src/exhumed.h index 643ce7ec4..6205853aa 100644 --- a/source/games/exhumed/src/exhumed.h +++ b/source/games/exhumed/src/exhumed.h @@ -235,7 +235,7 @@ struct GameInterface : public ::GameInterface void NewGame(MapRecord *map, int skill, bool) 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, double const smoothratio) override; + bool DrawAutomapPlayer(int mx, int my, 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/games/exhumed/src/map.cpp b/source/games/exhumed/src/map.cpp index ba4af5491..baf007196 100644 --- a/source/games/exhumed/src/map.cpp +++ b/source/games/exhumed/src/map.cpp @@ -71,14 +71,22 @@ template void GetSpriteExtents(T const* const pSprite, int* top, int } } -bool GameInterface::DrawAutomapPlayer(int x, int y, int z, int a, double const smoothratio) +bool GameInterface::DrawAutomapPlayer(int mx, int my, int x, int y, int z, int a, double const smoothratio) { for (int i = connecthead; i >= 0; i = connectpoint2[i]) { auto pPlayerActor = PlayerList[i].Actor(); spritetype* pSprite = &pPlayerActor->s(); - int x1 = pSprite->x - x; - int y1 = pSprite->y - y; + + int xvect = -bsin(a) * z; + int yvect = -bcos(a) * z; + int ox = mx - x; + int oy = my - y; + int x1 = DMulScale(ox, xvect, -oy, yvect, 16); + int y1 = DMulScale(oy, xvect, ox, yvect, 16); + int xx = xdim / 2. + x1 / 4096.; + int yy = ydim / 2. + y1 / 4096.; + if (i == nLocalPlayer)// || gGameOptions.nGameType == 1) { int nTile = pSprite->picnum; @@ -92,7 +100,7 @@ bool GameInterface::DrawAutomapPlayer(int x, int y, int z, int a, double const s double x = xdim / 2. + x1 / double(1 << 12); double y = ydim / 2. + y1 / double(1 << 12); // This very likely needs fixing later - DrawTexture(twod, tileGetTexture(nTile /*+ ((PlayClock >> 4) & 3)*/, true), x, y, DTA_ClipLeft, windowxy1.x, DTA_ClipTop, windowxy1.y, DTA_ScaleX, z / 1536., DTA_ScaleY, z / 1536., DTA_CenterOffset, true, + DrawTexture(twod, tileGetTexture(nTile /*+ ((PlayClock >> 4) & 3)*/, true), xx, yy, DTA_ClipLeft, windowxy1.x, DTA_ClipTop, windowxy1.y, DTA_ScaleX, z / 1536., DTA_ScaleY, z / 1536., DTA_CenterOffset, true, DTA_ClipRight, windowxy2.x + 1, DTA_ClipBottom, windowxy2.y + 1, DTA_Alpha, (pSprite->cstat & 2 ? 0.5 : 1.), TAG_DONE); break; } diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 4d038cc9a..7251da5a0 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -1686,7 +1686,7 @@ bool GameInterface::GenerateSavePic() -bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang, double const smoothratio) +bool GameInterface::DrawAutomapPlayer(int mx, int my, int cposx, int cposy, int czoom, int cang, double const smoothratio) { int i, k, l, x1, y1, x2, y2, x3, y3, x4, y4, ox, oy, xoff, yoff; int dax, day, cosang, sinang, xspan, yspan, sprx, spry; @@ -1747,8 +1747,12 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang, case 0: // Regular sprite if (Player[p].Actor() == actor) { - x1 = sprx - cposx; - y1 = spry - cposy; + ox = mx - cposx; + oy = my - cposy; + x1 = DMulScale(ox, xvect, -oy, yvect, 16); + y1 = DMulScale(oy, xvect, ox, yvect, 16); + int xx = xdim / 2. + x1 / 4096.; + int yy = ydim / 2. + y1 / 4096.; if (czoom > 192) { @@ -1765,12 +1769,10 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang, } else spnum = spr->picnum; - double xd = ((x1 << 4) + (xdim << 15)) / 65536.; - double yd = ((y1 << 4) + (ydim << 15)) / 65536.; double sc = czoom * (spr->yrepeat) / 32768.; if (spnum >= 0) { - DrawTexture(twod, tileGetTexture(1196 + pspr_ndx[myconnectindex], true), xd, yd, DTA_ScaleX, sc, DTA_ScaleY, sc, DTA_Rotate, daang * -BAngToDegree, + DrawTexture(twod, tileGetTexture(1196 + pspr_ndx[myconnectindex], true), xx, yy, DTA_ScaleX, sc, DTA_ScaleY, sc, DTA_Rotate, daang * -BAngToDegree, DTA_CenterOffsetRel, true, DTA_TranslationIndex, TRANSLATION(Translation_Remap, spr->pal), DTA_Color, shadeToLight(spr->shade), DTA_Alpha, (spr->cstat & 2) ? 0.33 : 1., TAG_DONE); } diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 5532955f6..e9ee642ae 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2181,7 +2181,7 @@ struct GameInterface : public ::GameInterface void LevelCompleted(MapRecord *map, int skill) override; void NextLevel(MapRecord *map, int skill) override; void NewGame(MapRecord *map, int skill, bool) override; - bool DrawAutomapPlayer(int x, int y, int z, int a, double const smoothratio) override; + bool DrawAutomapPlayer(int mx, int my, 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;