raze/source/games/exhumed/src/map.cpp

107 lines
3.8 KiB
C++
Raw Normal View History

//-------------------------------------------------------------------------
/*
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.
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include <string.h>
#include "player.h"
#include "engine.h"
#include "exhumed.h"
#include "view.h"
#include "v_2ddrawer.h"
2020-09-06 10:44:58 +00:00
#include "automap.h"
#include "v_draw.h"
BEGIN_PS_NS
bool bShowTowers = false;
void GrabMap()
{
for(auto&sec: sector)
2021-12-02 00:05:07 +00:00
MarkSectorSeen(&sec);
}
void UpdateMap()
{
2021-11-22 23:41:21 +00:00
if (initsectp->ceilingpal != 3 || (PlayerList[nLocalPlayer].nTorch != 0)) {
2021-12-02 00:05:07 +00:00
MarkSectorSeen(initsectp);
}
}
void DrawMap(double const smoothratio)
{
if (!nFreeze && automapMode != am_off)
{
auto pPlayerActor = PlayerList[nLocalPlayer].pActor;
2021-01-10 17:30:56 +00:00
int x = pPlayerActor->interpolatedx(smoothratio);
int y = pPlayerActor->interpolatedy(smoothratio);
int ang = (!SyncInput() ? PlayerList[nLocalPlayer].angle.sum() : PlayerList[nLocalPlayer].angle.interpolatedsum(smoothratio)).asbuild();
DrawOverheadMap(x, y, ang, smoothratio);
}
}
void GetActorExtents(DExhumedActor* actor, int* top, int* bottom)
{
2022-01-31 22:33:44 +00:00
*top = *bottom = actor->int_pos().Z;
if ((actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != CSTAT_SPRITE_ALIGNMENT_FLOOR)
{
int height = tileHeight(actor->spr.picnum);
int center = height / 2 + tileTopOffset(actor->spr.picnum);
*top -= (actor->spr.yrepeat << 2) * center;
*bottom += (actor->spr.yrepeat << 2) * (height - center);
}
}
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].pActor;
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 = twod->GetWidth() / 2. + x1 / 4096.;
int yy = twod->GetHeight() / 2. + y1 / 4096.;
if (i == nLocalPlayer)// || gGameOptions.nGameType == 1)
{
int nTile = pPlayerActor->spr.picnum;
int ceilZ, floorZ;
Collision ceilHit, floorHit;
2022-01-31 22:33:44 +00:00
getzrange(pPlayerActor->int_pos(), pPlayerActor->sector(), &ceilZ, ceilHit, &floorZ, floorHit, (pPlayerActor->spr.clipdist << 2) + 16, CLIPMASK0);
int nTop, nBottom;
GetActorExtents(pPlayerActor, &nTop, &nBottom);
int nScale = (pPlayerActor->spr.yrepeat + ((floorZ - nBottom) >> 8)) * z;
nScale = clamp(nScale, 8000, 65536 << 1);
// This very likely needs fixing later
DrawTexture(twod, tileGetTexture(nTile /*+ ((PlayClock >> 4) & 3)*/, true), xx, yy, DTA_ClipLeft, viewport3d.Left(), DTA_ClipTop, viewport3d.Top(), DTA_ScaleX, z / 1536., DTA_ScaleY, z / 1536., DTA_CenterOffset, true,
DTA_ClipRight, viewport3d.Right(), DTA_ClipBottom, viewport3d.Bottom(), DTA_Alpha, (pPlayerActor->spr.cstat & CSTAT_SPRITE_TRANSLUCENT ? 0.5 : 1.), TAG_DONE);
break;
}
}
return true;
}
END_PS_NS