2019-11-20 16:21:32 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 sirlemonhead, Nuke.YKT
|
|
|
|
This file is part of PCExhumed.
|
|
|
|
PCExhumed is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-11-22 23:11:37 +00:00
|
|
|
#include "ns.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include "player.h"
|
|
|
|
#include "engine.h"
|
|
|
|
#include "exhumed.h"
|
2019-11-18 20:31:08 +00:00
|
|
|
#include "view.h"
|
2019-12-31 18:25:49 +00:00
|
|
|
#include "v_2ddrawer.h"
|
2020-09-06 10:44:58 +00:00
|
|
|
#include "automap.h"
|
2020-09-08 19:41:02 +00:00
|
|
|
#include "v_draw.h"
|
2019-08-26 03:59:14 +00:00
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
BEGIN_PS_NS
|
|
|
|
|
|
|
|
|
2021-11-21 19:13:19 +00:00
|
|
|
bool bShowTowers = false;
|
2019-08-26 03:59:14 +00:00
|
|
|
|
|
|
|
void GrabMap()
|
|
|
|
{
|
2019-08-31 07:47:15 +00:00
|
|
|
for (int i = 0; i < numsectors; i++) {
|
|
|
|
MarkSectorSeen(i);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2019-11-18 20:31:08 +00:00
|
|
|
|
2019-08-26 03:59:14 +00:00
|
|
|
void UpdateMap()
|
|
|
|
{
|
2021-05-13 17:15:53 +00:00
|
|
|
if (sector[initsect].ceilingpal != 3 || (PlayerList[nLocalPlayer].nTorch != 0)) {
|
2019-08-31 07:47:15 +00:00
|
|
|
MarkSectorSeen(initsect);
|
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
|
|
|
|
2021-01-02 07:23:01 +00:00
|
|
|
void DrawMap(double const smoothratio)
|
2019-08-26 03:59:14 +00:00
|
|
|
{
|
2020-09-06 08:23:38 +00:00
|
|
|
if (!nFreeze && automapMode != am_off)
|
|
|
|
{
|
2021-10-19 18:03:11 +00:00
|
|
|
auto pPlayerActor = PlayerList[nLocalPlayer].Actor();
|
|
|
|
auto psp = &pPlayerActor->s();
|
2021-01-10 17:30:56 +00:00
|
|
|
|
|
|
|
int x = psp->interpolatedx(smoothratio);
|
|
|
|
int y = psp->interpolatedy(smoothratio);
|
2021-01-02 08:49:06 +00:00
|
|
|
int ang = (!SyncInput() ? PlayerList[nLocalPlayer].angle.sum() : PlayerList[nLocalPlayer].angle.interpolatedsum(smoothratio)).asbuild();
|
|
|
|
DrawOverheadMap(x, y, ang, smoothratio);
|
2019-08-31 07:47:15 +00:00
|
|
|
}
|
2019-08-26 03:59:14 +00:00
|
|
|
}
|
2020-09-08 19:41:02 +00:00
|
|
|
|
|
|
|
template<typename T> void GetSpriteExtents(T const* const pSprite, int* top, int* bottom)
|
|
|
|
{
|
|
|
|
*top = *bottom = pSprite->z;
|
|
|
|
if ((pSprite->cstat & 0x30) != 0x20)
|
|
|
|
{
|
|
|
|
int height = tileHeight(pSprite->picnum);
|
|
|
|
int center = height / 2 + tileTopOffset(pSprite->picnum);
|
|
|
|
*top -= (pSprite->yrepeat << 2) * center;
|
|
|
|
*bottom += (pSprite->yrepeat << 2) * (height - center);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-26 22:11:59 +00:00
|
|
|
bool GameInterface::DrawAutomapPlayer(int mx, int my, int x, int y, int z, int a, double const smoothratio)
|
2020-09-08 19:41:02 +00:00
|
|
|
{
|
|
|
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
|
|
|
{
|
2021-10-19 18:03:11 +00:00
|
|
|
auto pPlayerActor = PlayerList[i].Actor();
|
|
|
|
spritetype* pSprite = &pPlayerActor->s();
|
2021-11-26 22:11:59 +00:00
|
|
|
|
|
|
|
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.;
|
|
|
|
|
2020-09-08 19:41:02 +00:00
|
|
|
if (i == nLocalPlayer)// || gGameOptions.nGameType == 1)
|
|
|
|
{
|
|
|
|
int nTile = pSprite->picnum;
|
|
|
|
int ceilZ, ceilHit, floorZ, floorHit;
|
2021-10-30 11:37:43 +00:00
|
|
|
getzrange(&pSprite->pos, pSprite->sectnum, &ceilZ, &ceilHit, &floorZ, &floorHit, (pSprite->clipdist << 2) + 16, CLIPMASK0);
|
2020-09-08 19:41:02 +00:00
|
|
|
int nTop, nBottom;
|
|
|
|
GetSpriteExtents(pSprite, &nTop, &nBottom);
|
2021-03-24 19:28:58 +00:00
|
|
|
int nScale = (pSprite->yrepeat + ((floorZ - nBottom) >> 8)) * z;
|
2020-09-08 19:41:02 +00:00
|
|
|
nScale = clamp(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
|
2021-11-26 22:11:59 +00:00
|
|
|
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,
|
2020-09-08 19:41:02 +00:00
|
|
|
DTA_ClipRight, windowxy2.x + 1, DTA_ClipBottom, windowxy2.y + 1, DTA_Alpha, (pSprite->cstat & 2 ? 0.5 : 1.), TAG_DONE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-11-22 23:11:37 +00:00
|
|
|
END_PS_NS
|