- place automap marker and scale variables in the level so that saving and restoring works properly without affecting other maps by leaving behind residual data.

This commit is contained in:
Christoph Oelckers 2019-01-12 00:53:58 +01:00
parent fe7112188a
commit 9f1aedd135
6 changed files with 167 additions and 178 deletions

View file

@ -97,10 +97,6 @@ CUSTOM_CVAR (Int, am_emptyspacemargin, 0, CVAR_ARCHIVE)
self = 90;
}
if (nullptr != StatusBar)
{
AM_NewResolution();
}
}
//=============================================================================
@ -606,23 +602,6 @@ void FMapInfoParser::ParseAMColors(bool overlay)
//
//=============================================================================
// scale on entry
#define INITSCALEMTOF .2
// used by MTOF to scale from map-to-frame-buffer coords
static double scale_mtof = INITSCALEMTOF;
// used by FTOM to scale from frame-buffer-to-map coords (=1/scale_mtof)
static double scale_ftom;
// translates between frame-buffer and map distances
inline double FTOM(double x)
{
return x * scale_ftom;
}
inline double MTOF(double x)
{
return x * scale_mtof;
}
static int bigstate = 0;
static bool textured = 1; // internal toggle for texture mode
@ -688,8 +667,6 @@ CUSTOM_CVAR (Int, am_cheat, 0, 0)
#define AM_NUMMARKPOINTS 10
// player radius for automap checking
#define PLAYERRADIUS 16.
@ -704,8 +681,8 @@ CUSTOM_CVAR (Int, am_cheat, 0, 0)
#define M_ZOOMOUT (1/1.02)
// translates between frame-buffer and map coordinates
#define CXMTOF(x) int(MTOF((x)-m_x)/* - f_x*/)
#define CYMTOF(y) int(f_h - MTOF((y)-m_y)/* + f_y*/)
#define CXMTOF(x) int(Level->MTOF((x)-m_x)/* - f_x*/)
#define CYMTOF(y) int(f_h - Level->MTOF((y)-m_y)/* + f_y*/)
struct fpoint_t
{
@ -825,8 +802,6 @@ static double old_m_x, old_m_y;
static mpoint_t f_oldloc;
static FTextureID marknums[10]; // numbers used for marking by the automap
static mpoint_t markpoints[AM_NUMMARKPOINTS]; // where the points are
static int markpointnum = 0; // next point to be assigned
static FTextureID mapback; // the automap background
static double mapystart=0; // y-value for the start of the map bitmap...used in the parallax stuff.
@ -836,12 +811,11 @@ static bool stopped = true;
static void AM_calcMinMaxMtoF();
static void DrawMarker (FTexture *tex, double x, double y, int yadjust,
static void DrawMarker (FLevelLocals *Level, FTexture *tex, double x, double y, int yadjust,
INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle);
void AM_rotatePoint (double *x, double *y);
void AM_rotate (double *x, double *y, DAngle an);
void AM_doFollowPlayer ();
//=============================================================================
@ -850,11 +824,11 @@ void AM_doFollowPlayer ();
//
//=============================================================================
bool AM_addMark ();
bool AM_clearMarks ();
bool AM_addMark (FLevelLocals *);
bool AM_clearMarks (FLevelLocals *);
void AM_saveScaleAndLoc ();
void AM_restoreScaleAndLoc ();
void AM_minOutWindowScale ();
void AM_restoreScaleAndLoc(FLevelLocals *Level);
void AM_minOutWindowScale(FLevelLocals *Level);
CVAR(Bool, am_followplayer, true, CVAR_ARCHIVE)
@ -885,15 +859,16 @@ CCMD(am_toggletexture)
CCMD(am_setmark)
{
if (AM_addMark())
auto Level = who->Level;
if (AM_addMark(Level))
{
Printf ("%s %d\n", GStrings("AMSTR_MARKEDSPOT"), markpointnum);
Printf ("%s %d\n", GStrings("AMSTR_MARKEDSPOT"), Level->am_markpointnum);
}
}
CCMD(am_clearmarks)
{
if (AM_clearMarks())
if (AM_clearMarks(who->Level))
{
Printf ("%s\n", GStrings("AMSTR_MARKSCLEARED"));
}
@ -905,10 +880,10 @@ CCMD(am_gobig)
if (bigstate)
{
AM_saveScaleAndLoc();
AM_minOutWindowScale();
AM_minOutWindowScale(who->Level);
}
else
AM_restoreScaleAndLoc();
AM_restoreScaleAndLoc(who->Level);
}
//=============================================================================
@ -969,7 +944,6 @@ void AM_StaticInit()
mysnprintf (namebuf, countof(namebuf), "AMMNUM%d", i);
marknums[i] = TexMan.CheckForTexture (namebuf, ETextureType::MiscPatch);
}
markpointnum = 0;
mapback.SetInvalid();
}
@ -990,12 +964,12 @@ DVector2 AM_GetPosition()
//
//=============================================================================
void AM_activateNewScale ()
void AM_activateNewScale (FLevelLocals *Level)
{
m_x += m_w/2;
m_y += m_h/2;
m_w = FTOM(f_w);
m_h = FTOM(f_h);
m_w = Level->FTOM(f_w);
m_h = Level->FTOM(f_h);
m_x -= m_w/2;
m_y -= m_h/2;
m_x2 = m_x + m_w;
@ -1022,7 +996,7 @@ void AM_saveScaleAndLoc ()
//
//=============================================================================
void AM_restoreScaleAndLoc ()
void AM_restoreScaleAndLoc (FLevelLocals *Level)
{
m_w = old_m_w;
m_h = old_m_h;
@ -1040,8 +1014,8 @@ void AM_restoreScaleAndLoc ()
m_y2 = m_y + m_h;
// Change the scaling multipliers
scale_mtof = f_w / m_w;
scale_ftom = 1. / scale_mtof;
Level->am_scale_mtof = f_w / m_w;
Level->am_scale_ftom = 1. / Level->am_scale_mtof;
}
//=============================================================================
@ -1050,13 +1024,13 @@ void AM_restoreScaleAndLoc ()
//
//=============================================================================
bool AM_addMark ()
bool AM_addMark (FLevelLocals *Level)
{
if (marknums[0].isValid())
{
markpoints[markpointnum].x = m_x + m_w/2;
markpoints[markpointnum].y = m_y + m_h/2;
markpointnum = (markpointnum + 1) % AM_NUMMARKPOINTS;
Level->am_markpoints[Level->am_markpointnum].x = m_x + m_w/2;
Level->am_markpoints[Level->am_markpointnum].y = m_y + m_h/2;
Level->am_markpointnum = (Level->am_markpointnum + 1) % Level->AM_NUMMARKPOINTS;
return true;
}
return false;
@ -1188,10 +1162,10 @@ static void AM_ClipRotatedExtents (double pivotx, double pivoty)
//
//=============================================================================
static void AM_ScrollParchment (double dmapx, double dmapy)
static void AM_ScrollParchment (FLevelLocals *Level, double dmapx, double dmapy)
{
mapxstart = mapxstart - dmapx * scale_mtof;
mapystart = mapystart - dmapy * scale_mtof;
mapxstart = mapxstart - dmapx * Level->am_scale_mtof;
mapystart = mapystart - dmapy * Level->am_scale_mtof;
mapxstart = clamp(mapxstart, -40000., 40000.);
mapystart = clamp(mapystart, -40000., 40000.);
@ -1223,7 +1197,7 @@ static void AM_ScrollParchment (double dmapx, double dmapy)
//
//=============================================================================
void AM_changeWindowLoc ()
void AM_changeWindowLoc (FLevelLocals *Level)
{
if (m_paninc.x || m_paninc.y)
{
@ -1248,7 +1222,7 @@ void AM_changeWindowLoc ()
m_y += incy;
AM_ClipRotatedExtents (oldmx + m_w/2, oldmy + m_h/2);
AM_ScrollParchment (m_x != oldmx ? oincx : 0, m_y != oldmy ? -oincy : 0);
AM_ScrollParchment (Level, m_x != oldmx ? oincx : 0, m_y != oldmy ? -oincy : 0);
}
@ -1258,7 +1232,7 @@ void AM_changeWindowLoc ()
//
//=============================================================================
void AM_initVariables ()
void AM_initVariables (FLevelLocals *Level)
{
int pnum;
@ -1279,8 +1253,8 @@ void AM_initVariables ()
m_paninc.x = m_paninc.y = 0;
mtof_zoommul = 1.;
m_w = FTOM(SCREENWIDTH);
m_h = FTOM(SCREENHEIGHT);
m_w = Level->FTOM(SCREENWIDTH);
m_h = Level->FTOM(SCREENHEIGHT);
// find player to center on initially
if (!playeringame[pnum = consoleplayer])
@ -1290,7 +1264,7 @@ void AM_initVariables ()
assert(pnum >= 0 && pnum < MAXPLAYERS);
m_x = players[pnum].camera->X() - m_w/2;
m_y = players[pnum].camera->Y() - m_h/2;
AM_changeWindowLoc();
AM_changeWindowLoc(Level);
// for saving & restoring
old_m_x = m_x;
@ -1353,11 +1327,11 @@ static void AM_initColors (bool overlayed)
//
//=============================================================================
bool AM_clearMarks ()
bool AM_clearMarks (FLevelLocals *Level)
{
for (int i = AM_NUMMARKPOINTS-1; i >= 0; i--)
markpoints[i].x = -1; // means empty
markpointnum = 0;
for (int i = Level->AM_NUMMARKPOINTS-1; i >= 0; i--)
Level->am_markpoints[i].x = -1; // means empty
Level->am_markpointnum = 0;
return marknums[0].isValid();
}
@ -1378,13 +1352,13 @@ void AM_LevelInit (FLevelLocals *Level)
mapback = TexMan.CheckForTexture(Level->info->MapBackground, ETextureType::MiscPatch);
}
AM_clearMarks();
AM_clearMarks(Level);
AM_findMinMaxBoundaries(Level);
scale_mtof = min_scale_mtof / 0.7;
if (scale_mtof > max_scale_mtof)
scale_mtof = min_scale_mtof;
scale_ftom = 1 / scale_mtof;
Level->am_scale_mtof = min_scale_mtof / 0.7;
if (Level->am_scale_mtof > max_scale_mtof)
Level->am_scale_mtof = min_scale_mtof;
Level->am_scale_ftom = 1 / Level->am_scale_mtof;
am_showalllines.Callback();
}
@ -1408,11 +1382,11 @@ void AM_Stop ()
//
//=============================================================================
void AM_Start ()
void AM_Start (FLevelLocals *Level)
{
if (!stopped) AM_Stop();
stopped = false;
AM_initVariables();
AM_initVariables(Level);
}
@ -1423,10 +1397,10 @@ void AM_Start ()
//
//=============================================================================
void AM_minOutWindowScale ()
void AM_minOutWindowScale (FLevelLocals *Level)
{
scale_mtof = min_scale_mtof;
scale_ftom = 1/ scale_mtof;
Level->am_scale_mtof = min_scale_mtof;
Level->am_scale_ftom = 1/ Level->am_scale_mtof;
}
//=============================================================================
@ -1435,10 +1409,10 @@ void AM_minOutWindowScale ()
//
//=============================================================================
void AM_maxOutWindowScale ()
void AM_maxOutWindowScale (FLevelLocals *Level)
{
scale_mtof = max_scale_mtof;
scale_ftom = 1 / scale_mtof;
Level->am_scale_mtof = max_scale_mtof;
Level->am_scale_ftom = 1 / Level->am_scale_mtof;
}
//=============================================================================
@ -1447,7 +1421,7 @@ void AM_maxOutWindowScale ()
//
//=============================================================================
void AM_NewResolution()
void AM_NewResolution(FLevelLocals *Level)
{
double oldmin = min_scale_mtof;
@ -1456,15 +1430,15 @@ void AM_NewResolution()
return; // [SP] Not in a game, exit!
}
AM_calcMinMaxMtoF();
scale_mtof = scale_mtof * min_scale_mtof / oldmin;
scale_ftom = 1 / scale_mtof;
if (scale_mtof < min_scale_mtof)
AM_minOutWindowScale();
else if (scale_mtof > max_scale_mtof)
AM_maxOutWindowScale();
Level->am_scale_mtof = Level->am_scale_mtof * min_scale_mtof / oldmin;
Level->am_scale_ftom = 1 / Level->am_scale_mtof;
if (Level->am_scale_mtof < min_scale_mtof)
AM_minOutWindowScale(Level);
else if (Level->am_scale_mtof > max_scale_mtof)
AM_maxOutWindowScale(Level);
f_w = screen->GetWidth();
f_h = StatusBar->GetTopOfStatusbar();
AM_activateNewScale();
AM_activateNewScale(Level);
}
@ -1488,7 +1462,7 @@ CCMD (togglemap)
//
//=============================================================================
void AM_ToggleMap ()
void AM_ToggleMap (FLevelLocals *Level)
{
if (gamestate != GS_LEVEL)
return;
@ -1499,7 +1473,7 @@ void AM_ToggleMap ()
if (!automapactive)
{
AM_Start ();
AM_Start (Level);
viewactive = (am_overlay != 0.f);
}
else
@ -1552,7 +1526,7 @@ bool AM_Responder (event_t *ev, bool last)
//
//=============================================================================
void AM_changeWindowScale ()
void AM_changeWindowScale (FLevelLocals *Level)
{
double mtof_zoommul;
@ -1579,13 +1553,13 @@ void AM_changeWindowScale ()
am_zoomdir = 0;
// Change the scaling multipliers
scale_mtof = scale_mtof * mtof_zoommul;
scale_ftom = 1 / scale_mtof;
Level->am_scale_mtof = Level->am_scale_mtof * mtof_zoommul;
Level->am_scale_ftom = 1 / Level->am_scale_mtof;
if (scale_mtof < min_scale_mtof)
AM_minOutWindowScale();
else if (scale_mtof > max_scale_mtof)
AM_maxOutWindowScale();
if (Level->am_scale_mtof < min_scale_mtof)
AM_minOutWindowScale(Level);
else if (Level->am_scale_mtof > max_scale_mtof)
AM_maxOutWindowScale(Level);
}
CCMD(am_zoom)
@ -1602,7 +1576,7 @@ CCMD(am_zoom)
//
//=============================================================================
void AM_doFollowPlayer ()
void AM_doFollowPlayer (FLevelLocals *Level)
{
double sx, sy;
auto cam = players[consoleplayer].camera;
@ -1625,7 +1599,7 @@ void AM_doFollowPlayer ()
{
AM_rotate(&sx, &sy, cam->Angles.Yaw - 90);
}
AM_ScrollParchment(sx, sy);
AM_ScrollParchment(Level, sx, sy);
f_oldloc.x = ampos.X;
f_oldloc.y = ampos.Y;
@ -1639,7 +1613,7 @@ void AM_doFollowPlayer ()
//
//=============================================================================
void AM_Ticker ()
void AM_Ticker (FLevelLocals *Level)
{
if (!automapactive)
return;
@ -1648,24 +1622,24 @@ void AM_Ticker ()
if (am_followplayer)
{
AM_doFollowPlayer();
AM_doFollowPlayer(Level);
}
else
{
m_paninc.x = m_paninc.y = 0;
if (Button_AM_PanLeft.bDown) m_paninc.x -= FTOM(F_PANINC);
if (Button_AM_PanRight.bDown) m_paninc.x += FTOM(F_PANINC);
if (Button_AM_PanUp.bDown) m_paninc.y += FTOM(F_PANINC);
if (Button_AM_PanDown.bDown) m_paninc.y -= FTOM(F_PANINC);
if (Button_AM_PanLeft.bDown) m_paninc.x -= Level->FTOM(F_PANINC);
if (Button_AM_PanRight.bDown) m_paninc.x += Level->FTOM(F_PANINC);
if (Button_AM_PanUp.bDown) m_paninc.y += Level->FTOM(F_PANINC);
if (Button_AM_PanDown.bDown) m_paninc.y -= Level->FTOM(F_PANINC);
}
// Change the zoom if necessary
if (Button_AM_ZoomIn.bDown || Button_AM_ZoomOut.bDown || am_zoomdir != 0)
AM_changeWindowScale();
AM_changeWindowScale(Level);
// Change x,y location
//if (m_paninc.x || m_paninc.y)
AM_changeWindowLoc();
AM_changeWindowLoc(Level);
}
@ -1723,7 +1697,7 @@ void AM_clearFB (const AMColor &color)
//
//=============================================================================
bool AM_clipMline (mline_t *ml, fline_t *fl)
bool AM_clipMline (FLevelLocals *Level, mline_t *ml, fline_t *fl)
{
enum {
LEFT =1,
@ -1850,19 +1824,19 @@ bool AM_clipMline (mline_t *ml, fline_t *fl)
//
//=============================================================================
void AM_drawMline (mline_t *ml, const AMColor &color)
void AM_drawMline (FLevelLocals *Level, mline_t *ml, const AMColor &color)
{
fline_t fl;
if (AM_clipMline (ml, &fl))
if (AM_clipMline (Level, ml, &fl))
{
screen->DrawLine (f_x + fl.a.x, f_y + fl.a.y, f_x + fl.b.x, f_y + fl.b.y, color.Index, color.RGB);
}
}
inline void AM_drawMline (mline_t *ml, int colorindex)
inline void AM_drawMline (FLevelLocals *Level, mline_t *ml, int colorindex)
{
AM_drawMline(ml, AMColors[colorindex]);
AM_drawMline(Level, ml, AMColors[colorindex]);
}
//=============================================================================
@ -1908,7 +1882,7 @@ void AM_drawGrid (FLevelLocals *Level, int color)
AM_rotatePoint (&ml.a.x, &ml.a.y);
AM_rotatePoint (&ml.b.x, &ml.b.y);
}
AM_drawMline(&ml, color);
AM_drawMline(Level, &ml, color);
}
// Figure out start of horizontal gridlines
@ -1928,7 +1902,7 @@ void AM_drawGrid (FLevelLocals *Level, int color)
AM_rotatePoint (&ml.a.x, &ml.a.y);
AM_rotatePoint (&ml.b.x, &ml.b.y);
}
AM_drawMline (&ml, color);
AM_drawMline (Level, &ml, color);
}
}
@ -2060,7 +2034,7 @@ void AM_drawSubsectors(FLevelLocals *Level)
{
static TArray<FVector2> points;
std::vector<uint32_t> indices;
double scale = scale_mtof;
double scale = Level->am_scale_mtof;
DAngle rotation;
sector_t tempsec;
int floorlight;
@ -2304,7 +2278,7 @@ void AM_drawSeg(seg_t *seg, const AMColor &color)
AM_rotatePoint (&l.a.x, &l.a.y);
AM_rotatePoint (&l.b.x, &l.b.y);
}
AM_drawMline(&l, color);
AM_drawMline(seg->frontsector->Level, &l, color);
}
void AM_drawPolySeg(FLevelLocals *Level, FPolySeg *seg, const AMColor &color)
@ -2320,7 +2294,7 @@ void AM_drawPolySeg(FLevelLocals *Level, FPolySeg *seg, const AMColor &color)
AM_rotatePoint (&l.a.x, &l.a.y);
AM_rotatePoint (&l.b.x, &l.b.y);
}
AM_drawMline(&l, color);
AM_drawMline(Level, &l, color);
}
void AM_showSS(FLevelLocals *Level)
@ -2637,37 +2611,37 @@ void AM_drawWalls (FLevelLocals *Level, bool allmap)
if (line.automapstyle > AMLS_Default && line.automapstyle < AMLS_COUNT
&& (am_cheat == 0 || am_cheat >= 4))
{
AM_drawMline(&l, AUTOMAP_LINE_COLORS[line.automapstyle]);
AM_drawMline(Level, &l, AUTOMAP_LINE_COLORS[line.automapstyle]);
continue;
}
if (portalmode)
{
AM_drawMline(&l, AMColors.PortalColor);
AM_drawMline(Level, &l, AMColors.PortalColor);
}
else if (AM_CheckSecret(&line) == 1)
{
// map secret sectors like Boom
AM_drawMline(&l, AMColors.SecretSectorColor);
AM_drawMline(Level, &l, AMColors.SecretSectorColor);
}
else if (AM_CheckSecret(&line) == 2)
{
AM_drawMline(&l, AMColors.UnexploredSecretColor);
AM_drawMline(Level, &l, AMColors.UnexploredSecretColor);
}
else if (line.flags & ML_SECRET)
{ // secret door
if (am_cheat != 0 && line.backsector != NULL)
AM_drawMline(&l, AMColors.SecretWallColor);
AM_drawMline(Level, &l, AMColors.SecretWallColor);
else
AM_drawMline(&l, AMColors.WallColor);
AM_drawMline(Level, &l, AMColors.WallColor);
}
else if (AM_isTeleportBoundary(line) && AMColors.isValid(AMColors.IntraTeleportColor))
{ // intra-level teleporters
AM_drawMline(&l, AMColors.IntraTeleportColor);
AM_drawMline(Level, &l, AMColors.IntraTeleportColor);
}
else if (AM_isExitBoundary(line) && AMColors.isValid(AMColors.InterTeleportColor))
{ // inter-level/game-ending teleporters
AM_drawMline(&l, AMColors.InterTeleportColor);
AM_drawMline(Level, &l, AMColors.InterTeleportColor);
}
else if (AM_isLockBoundary(line, &lock))
{
@ -2680,40 +2654,40 @@ void AM_drawWalls (FLevelLocals *Level, bool allmap)
if (color >= 0) c.FromRGB(RPART(color), GPART(color), BPART(color));
else c = AMColors[AMColors.LockedColor];
AM_drawMline(&l, c);
AM_drawMline(Level, &l, c);
}
else
{
AM_drawMline(&l, AMColors.LockedColor); // locked special
AM_drawMline(Level, &l, AMColors.LockedColor); // locked special
}
}
else if (am_showtriggerlines
&& AMColors.isValid(AMColors.SpecialWallColor)
&& AM_isTriggerBoundary(line))
{
AM_drawMline(&l, AMColors.SpecialWallColor); // wall with special non-door action the player can do
AM_drawMline(Level, &l, AMColors.SpecialWallColor); // wall with special non-door action the player can do
}
else if (line.backsector == NULL)
{
AM_drawMline(&l, AMColors.WallColor); // one-sided wall
AM_drawMline(Level, &l, AMColors.WallColor); // one-sided wall
}
else if (line.backsector->floorplane
!= line.frontsector->floorplane)
{
AM_drawMline(&l, AMColors.FDWallColor); // floor level change
AM_drawMline(Level, &l, AMColors.FDWallColor); // floor level change
}
else if (line.backsector->ceilingplane
!= line.frontsector->ceilingplane)
{
AM_drawMline(&l, AMColors.CDWallColor); // ceiling level change
AM_drawMline(Level, &l, AMColors.CDWallColor); // ceiling level change
}
else if (AM_Check3DFloors(&line))
{
AM_drawMline(&l, AMColors.EFWallColor); // Extra floor border
AM_drawMline(Level, &l, AMColors.EFWallColor); // Extra floor border
}
else if (am_cheat > 0 && am_cheat < 4)
{
AM_drawMline(&l, AMColors.TSWallColor);
AM_drawMline(Level, &l, AMColors.TSWallColor);
}
}
else if (allmap || (line.flags & ML_REVEALED))
@ -2725,7 +2699,7 @@ void AM_drawWalls (FLevelLocals *Level, bool allmap)
continue;
}
}
AM_drawMline(&l, AMColors.NotSeenColor);
AM_drawMline(Level, &l, AMColors.NotSeenColor);
}
}
}
@ -2786,7 +2760,9 @@ void AM_rotatePoint (double *x, double *y)
void
AM_drawLineCharacter
( const mline_t *lineguy,
(
FLevelLocals *Level,
const mline_t *lineguy,
int lineguylines,
double scale,
DAngle angle,
@ -2826,7 +2802,7 @@ AM_drawLineCharacter
l.b.x += x;
l.b.y += y;
AM_drawMline(&l, color);
AM_drawMline(Level, &l, color);
}
}
@ -2836,7 +2812,7 @@ AM_drawLineCharacter
//
//=============================================================================
void AM_drawPlayers ()
void AM_drawPlayers (FLevelLocals *Level)
{
if (am_cheat >= 2 && am_cheat != 4 && am_showthingsprites > 0)
{
@ -2877,7 +2853,7 @@ void AM_drawPlayers ()
arrow = &MapArrow[0];
numarrowlines = MapArrow.Size();
}
AM_drawLineCharacter(arrow, numarrowlines, 0, angle, AMColors[AMColors.YourColor], pt.x, pt.y);
AM_drawLineCharacter(Level, arrow, numarrowlines, 0, angle, AMColors[AMColors.YourColor], pt.x, pt.y);
return;
}
@ -2930,7 +2906,7 @@ void AM_drawPlayers ()
angle -= players[consoleplayer].camera->Angles.Yaw - 90.;
}
AM_drawLineCharacter(&MapArrow[0], MapArrow.Size(), 0, angle, color, pt.x, pt.y);
AM_drawLineCharacter(Level, &MapArrow[0], MapArrow.Size(), 0, angle, color, pt.x, pt.y);
}
}
}
@ -2973,7 +2949,7 @@ void AM_drawKeys (FLevelLocals *Level)
if (c >= 0) color.FromRGB(RPART(c), GPART(c), BPART(c));
else color = AMColors[AMColors.ThingColor_CountItem];
AM_drawLineCharacter(&EasyKey[0], EasyKey.Size(), 0, 0., color, p.x, p.y);
AM_drawLineCharacter(Level, &EasyKey[0], EasyKey.Size(), 0, 0., color, p.x, p.y);
}
}
}
@ -3028,10 +3004,10 @@ void AM_drawThings (FLevelLocals *Level)
if (texture == NULL) goto drawTriangle; // fall back to standard display if no sprite can be found.
const double spriteXScale = (t->Scale.X * (10. / 16.) * scale_mtof);
const double spriteYScale = (t->Scale.Y * (10. / 16.) * scale_mtof);
const double spriteXScale = (t->Scale.X * (10. / 16.) * Level->am_scale_mtof);
const double spriteYScale = (t->Scale.Y * (10. / 16.) * Level->am_scale_mtof);
DrawMarker (texture, p.x, p.y, 0, !!(frame->Flip & (1 << rotation)),
DrawMarker (Level, texture, p.x, p.y, 0, !!(frame->Flip & (1 << rotation)),
spriteXScale, spriteYScale, t->Translation, 1., 0, LegacyRenderStyles[STYLE_Normal]);
}
else
@ -3072,7 +3048,7 @@ void AM_drawThings (FLevelLocals *Level)
if (c >= 0) color.FromRGB(RPART(c), GPART(c), BPART(c));
else color = AMColors[AMColors.ThingColor_CountItem];
AM_drawLineCharacter(&CheatKey[0], CheatKey.Size(), 0, 0., color, p.x, p.y);
AM_drawLineCharacter(Level, &CheatKey[0], CheatKey.Size(), 0, 0., color, p.x, p.y);
color.Index = -1;
}
else
@ -3088,7 +3064,7 @@ void AM_drawThings (FLevelLocals *Level)
if (color.Index != -1)
{
AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16, angle, color, p.x, p.y);
AM_drawLineCharacter(Level, thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16, angle, color, p.x, p.y);
}
if (am_cheat == 3 || am_cheat == 6)
@ -3101,7 +3077,7 @@ void AM_drawThings (FLevelLocals *Level)
{ { -1, 1 }, { -1, -1 } },
};
AM_drawLineCharacter (box, 4, t->radius, angle - t->Angles.Yaw, color, p.x, p.y);
AM_drawLineCharacter (Level, box, 4, t->radius, angle - t->Angles.Yaw, color, p.x, p.y);
}
}
}
@ -3116,7 +3092,7 @@ void AM_drawThings (FLevelLocals *Level)
//
//=============================================================================
static void DrawMarker (FTexture *tex, double x, double y, int yadjust,
static void DrawMarker (FLevelLocals *Level, FTexture *tex, double x, double y, int yadjust,
INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle)
{
if (tex == NULL || !tex->isValid())
@ -3148,13 +3124,13 @@ static void DrawMarker (FTexture *tex, double x, double y, int yadjust,
//
//=============================================================================
void AM_drawMarks ()
void AM_drawMarks (FLevelLocals *Level)
{
for (int i = 0; i < AM_NUMMARKPOINTS; i++)
for (int i = 0; i < Level->AM_NUMMARKPOINTS; i++)
{
if (markpoints[i].x != -1)
if (Level->am_markpoints[i].x != -1)
{
DrawMarker (TexMan.GetTexture(marknums[i], true), markpoints[i].x, markpoints[i].y, -3, 0,
DrawMarker (Level, TexMan.GetTexture(marknums[i], true), Level->am_markpoints[i].x, Level->am_markpoints[i].y, -3, 0,
1, 1, 0, 1, 0, LegacyRenderStyles[STYLE_Normal]);
}
}
@ -3218,7 +3194,7 @@ void AM_drawAuthorMarkers (FLevelLocals *Level)
{
if (mark->args[1] == 0 || (mark->args[1] == 1 && (marked->subsector->flags & SSECMF_DRAWN)))
{
DrawMarker (tex, marked->X(), marked->Y(), 0, flip, mark->Scale.X, mark->Scale.Y, mark->Translation,
DrawMarker (Level, tex, marked->X(), marked->Y(), 0, flip, mark->Scale.X, mark->Scale.Y, mark->Translation,
mark->Alpha, mark->fillcolor, mark->RenderStyle);
}
marked = mark->args[0] != 0 ? it.Next() : NULL;
@ -3248,6 +3224,8 @@ void AM_Drawer (FLevelLocals *Level, int bottom)
if (!automapactive)
return;
AM_NewResolution(Level);
bool allmap = (Level->flags2 & LEVEL2_ALLMAP) != 0;
bool allthings = allmap && players[consoleplayer].mo->FindInventory(NAME_PowerScanner, true) != nullptr;
@ -3278,7 +3256,7 @@ void AM_Drawer (FLevelLocals *Level, int bottom)
f_w = viewwidth;
f_h = viewheight;
}
AM_activateNewScale();
AM_activateNewScale(Level);
if (am_textured && textured && !viewactive)
AM_drawSubsectors(Level);
@ -3287,7 +3265,7 @@ void AM_Drawer (FLevelLocals *Level, int bottom)
AM_drawGrid(Level, AMColors.GridColor);
AM_drawWalls(Level, allmap);
AM_drawPlayers();
AM_drawPlayers(Level);
if (G_SkillProperty(SKILLP_EasyKey))
AM_drawKeys(Level);
if ((am_cheat >= 2 && am_cheat != 4) || allthings)
@ -3298,25 +3276,7 @@ void AM_Drawer (FLevelLocals *Level, int bottom)
if (!viewactive)
AM_drawCrosshair(AMColors[AMColors.XHairColor]);
AM_drawMarks();
AM_drawMarks(Level);
AM_showSS(Level);
}
//=============================================================================
//
//
//
//=============================================================================
void AM_SerializeMarkers(FSerializer &arc)
{
if (arc.BeginObject("automarkers"))
{
arc("markpointnum", markpointnum)
.Array("markpoints", &markpoints[0].x, AM_NUMMARKPOINTS*2) // write as a double array.
("scale_mtof", scale_mtof)
("scale_ftom", scale_ftom)
.EndObject();
}
}

View file

@ -34,7 +34,7 @@ void AM_ClearColorsets(); // reset data for a restart.
bool AM_Responder (event_t* ev, bool last);
// Called by main loop.
void AM_Ticker (void);
void AM_Ticker (FLevelLocals *Level);
// Called by main loop,
// called instead of view drawer if automap active.
@ -44,10 +44,9 @@ void AM_Drawer (FLevelLocals *Level, int bottom);
// if the level is completed while it is up.
void AM_Stop (void);
void AM_NewResolution ();
void AM_ToggleMap ();
void AM_NewResolution (FLevelLocals *Level);
void AM_ToggleMap (FLevelLocals *Level);
void AM_LevelInit (FLevelLocals *Level);
void AM_SerializeMarkers(FSerializer &arc);
#endif

View file

@ -1078,7 +1078,7 @@ void G_Ticker ()
gameaction = ga_nothing;
break;
case ga_togglemap:
AM_ToggleMap ();
AM_ToggleMap (players[consoleplayer].camera->Level);
gameaction = ga_nothing;
break;
case ga_nothing:
@ -1170,7 +1170,7 @@ void G_Ticker ()
{
case GS_LEVEL:
P_Ticker ();
AM_Ticker ();
AM_Ticker (players[consoleplayer].camera->Level);
break;
case GS_TITLELEVEL:

View file

@ -292,6 +292,33 @@ struct FLevelLocals : public FLevelData
TObjPtr<DSpotState *> SpotState = nullptr;
// scale on entry
static const int AM_NUMMARKPOINTS = 10;
struct mpoint_t
{
double x, y;
};
// used by MTOF to scale from map-to-frame-buffer coords
double am_scale_mtof = 0.2;
// used by FTOM to scale from frame-buffer-to-map coords (=1/scale_mtof)
double am_scale_ftom = 1 / 0.2;
mpoint_t am_markpoints[AM_NUMMARKPOINTS]; // where the points are
int am_markpointnum = 0; // next point to be assigned
// translates between frame-buffer and map distances
inline double FTOM(double x)
{
return x * am_scale_ftom;
}
inline double MTOF(double x)
{
return x * am_scale_mtof;
}
bool IsJumpingAllowed() const;
bool IsCrouchingAllowed() const;
bool IsFreelookAllowed() const;
@ -332,7 +359,6 @@ public:
int nextstartpos; // [RH] Support for multiple starts per level
void SetMusicVolume(float vol);
void Reset();

View file

@ -952,7 +952,13 @@ void G_SerializeLevel(FSerializer &arc, FLevelLocals *Level, bool hubload)
("impactdecalcount", Level->ImpactDecalCount)
("freeze", Level->freeze)
("changefreeze", Level->changefreeze)
("sndseqlisthead", Level->SequenceListHead);
("sndseqlisthead", Level->SequenceListHead)
("am_markpointnum", Level->am_markpointnum)
.Array("am_markpoints", &Level->am_markpoints[0].x, Level->AM_NUMMARKPOINTS * 2) // write as a double array.
("am_scale_mtof", Level->am_scale_mtof)
("am_scale_ftom", Level->am_scale_ftom)
.EndObject();
if (arc.isReading())
@ -978,7 +984,6 @@ void G_SerializeLevel(FSerializer &arc, FLevelLocals *Level, bool hubload)
arc("polyobjs", Level->Polyobjects);
SerializeSubsectors(arc, Level, "subsectors");
StatusBar->SerializeMessages(arc);
AM_SerializeMarkers(arc);
FRemapTable::StaticSerializeTranslations(arc);
Level->canvasTextureInfo.Serialize(arc);
P_SerializePlayers(Level, arc, hubload);

View file

@ -590,7 +590,6 @@ void V_OutputResized (int width, int height)
C_NewModeAdjust();
// Reload crosshair if transitioned to a different size
ST_LoadCrosshair(true);
AM_NewResolution();
}
void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int realheight, int *cleanx, int *cleany, int *_cx1, int *_cx2)