From 9d39f770d435d8d4c327414ca0d13f32fd039a31 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 6 Sep 2020 21:15:59 +0200 Subject: [PATCH] - reimplemented player sprite display on Blood's automap. --- source/blood/src/blood.h | 2 +- source/blood/src/view.cpp | 45 ++++++++++++++++++++++++++++++++++++++- source/core/automap.cpp | 3 ++- source/core/gamestruct.h | 1 + 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/source/blood/src/blood.h b/source/blood/src/blood.h index 5b89de332..e772e65d9 100644 --- a/source/blood/src/blood.h +++ b/source/blood/src/blood.h @@ -97,7 +97,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; GameStats getStats() override; }; diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index c0b45b1e3..d68ff8e39 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -1053,7 +1053,50 @@ bool GameInterface::GenerateSavePic() FString GameInterface::GetCoordString() { - return "Player pos is unknown"; // todo: output at least something useful. + FString out; + + out.Format("pos= %d, %d, %d - angle = %2.3f", + gMe->pSprite->x, gMe->pSprite->y, gMe->pSprite->z, gMe->pSprite->ang); + + return out; +} + + +bool GameInterface::DrawAutomapPlayer(int x, int y, int z, int a) +{ + int nCos = z * sintable[(0 - a) & 2047]; + int nSin = z * sintable[(1536 - a) & 2047]; + int nCos2 = mulscale16(nCos, yxaspect); + int nSin2 = mulscale16(nSin, yxaspect); + int nPSprite = gView->pSprite->index; + + for (int i = connecthead; i >= 0; i = connectpoint2[i]) + { + PLAYER* pPlayer = &gPlayer[i]; + spritetype* pSprite = pPlayer->pSprite; + int px = pSprite->x - x; + int py = pSprite->y - y; + int pa = (pSprite->ang - a) & 2047; + int x1 = dmulscale16(px, nCos, -py, nSin); + int y1 = dmulscale16(py, nCos2, px, nSin2); + if (i == gView->nPlayer || gGameOptions.nGameType == 1) + { + int nTile = pSprite->picnum; + int ceilZ, ceilHit, floorZ, floorHit; + GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, (pSprite->clipdist << 2) + 16, CLIPMASK0, PARALLAXCLIP_CEILING | PARALLAXCLIP_FLOOR); + int nTop, nBottom; + GetSpriteExtents(pSprite, &nTop, &nBottom); + int nScale = mulscale((pSprite->yrepeat + ((floorZ - nBottom) >> 8)) * z, yxaspect, 16); + nScale = ClipRange(nScale, 8000, 65536 << 1); + // Players on automap + 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, + DTA_ClipRight, windowxy2.x + 1, DTA_ClipBottom, windowxy2.y + 1, DTA_Alpha, (pSprite->cstat & 2 ? 0.5 : 1.), TAG_DONE); + } + } + return true; } diff --git a/source/core/automap.cpp b/source/core/automap.cpp index ddc1e43bc..bbb1ffcb2 100644 --- a/source/core/automap.cpp +++ b/source/core/automap.cpp @@ -546,7 +546,8 @@ void DrawOverheadMap(int pl_x, int pl_y, int pl_angle) drawredlines(x, y, gZoom, follow_a); drawwhitelines(x, y, gZoom, follow_a); - DrawPlayerArrow(x, y, follow_a, pl_x, pl_y, gZoom, -pl_angle); + if (!gi->DrawAutomapPlayer(x, y, gZoom, follow_a)) + 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 f1b052cd4..3f01c8c5d 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -105,6 +105,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 FString statFPS() {