- fixed automap player drawing for follpw mode off in all games.

This commit is contained in:
Christoph Oelckers 2021-11-26 23:11:59 +01:00
parent 2949361c82
commit cd3288860a
10 changed files with 48 additions and 22 deletions

View file

@ -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);
}

View file

@ -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); }

View file

@ -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); }

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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; }

View file

@ -71,14 +71,22 @@ template<typename T> 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;
}

View file

@ -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);
}

View file

@ -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;