From 18b39fd952e9685a484e3adc43c8c7fbc978e936 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 6 Sep 2020 20:49:43 +0200 Subject: [PATCH] - first stage of generic automap code. Lines and textures get rendered, not all colors are correct - sprites yet to do... --- source/blood/src/controls.cpp | 18 +- source/blood/src/sbar.cpp | 1 + source/build/include/build.h | 3 - source/build/src/engine.cpp | 16 -- source/core/automap.cpp | 473 +++++++++++++++++++++++++++++-- source/core/automap.h | 13 + source/core/console/d_event.cpp | 35 +-- source/core/gamecontrol.cpp | 78 +---- source/core/gamecontrol.h | 9 - source/core/gamecvars.cpp | 3 - source/core/gamestruct.h | 1 - source/core/inputstate.cpp | 5 + source/core/inputstate.h | 4 + source/exhumed/src/gameloop.cpp | 1 + source/exhumed/src/input.cpp | 16 +- source/exhumed/src/player.cpp | 2 + source/exhumed/src/status.cpp | 1 + source/games/duke/src/input.cpp | 2 +- source/games/duke/src/render.cpp | 1 + source/games/duke/src/sbar.cpp | 1 + source/sw/src/cheats.cpp | 5 +- source/sw/src/game.cpp | 2 - source/sw/src/game.h | 8 +- source/sw/src/input.cpp | 11 - source/sw/src/save.cpp | 12 - source/sw/src/sbar.cpp | 1 + source/sw/src/sector.cpp | 13 +- 27 files changed, 494 insertions(+), 241 deletions(-) diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index e9e49a3d2..87eb3ddb2 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -166,20 +166,10 @@ void GetInputInternal(InputPacket &inputParm) input.q16horz -= FloatToFixed(scaleAdjustmentToInterval(info.dpitch / mlookScale)); - if (automapFollow && automapMode != am_off) - { - inputParm.q16horz = 0; - inputParm.q16avel = 0; - inputParm.fvel = 0; - inputParm.svel = 0; - } - else - { - inputParm.fvel = clamp(inputParm.fvel + input.fvel, -2048, 2048); - inputParm.svel = clamp(inputParm.svel + input.svel, -2048, 2048); - inputParm.q16avel += input.q16avel; - inputParm.q16horz = clamp(inputParm.q16horz + input.q16horz, IntToFixed(-127) >> 2, IntToFixed(127) >> 2); - } + inputParm.fvel = clamp(inputParm.fvel + input.fvel, -2048, 2048); + inputParm.svel = clamp(inputParm.svel + input.svel, -2048, 2048); + inputParm.q16avel += input.q16avel; + inputParm.q16horz = clamp(inputParm.q16horz + input.q16horz, IntToFixed(-127) >> 2, IntToFixed(127) >> 2); if (gMe && gMe->pXSprite && gMe->pXSprite->health != 0 && !paused) { diff --git a/source/blood/src/sbar.cpp b/source/blood/src/sbar.cpp index 16af3e52a..e580efb8c 100644 --- a/source/blood/src/sbar.cpp +++ b/source/blood/src/sbar.cpp @@ -46,6 +46,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "v_font.h" #include "glbackend/glbackend.h" #include "statusbar.h" +#include "automap.h" CVARD(Bool, hud_powerupduration, true, CVAR_ARCHIVE/*|CVAR_FRONTEND_BLOOD*/, "enable/disable displaying the remaining seconds for power-ups") diff --git a/source/build/include/build.h b/source/build/include/build.h index 587a40966..d9445c19b 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -626,9 +626,6 @@ void videoInit(); void videoClearViewableArea(int32_t dacol); void videoClearScreen(int32_t dacol); void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang); -void renderDrawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint8_t col); -void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, palette_t p); -void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, PalEntry p); class F2DDrawer; diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 417e685c9..bf680a715 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -1851,22 +1851,6 @@ void FillPolygon(int* rx1, int* ry1, int* xb1, int32_t npoints, int picnum, int twod->AddPoly(tileGetTexture(picnum), points.Data(), points.Size(), indices.data(), indices.size(), translation, pe, rs, clipx1, clipy1, clipx2, clipy2); } -void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, PalEntry p) -{ - twod->AddLine(x1 / 4096.f, y1 / 4096.f, x2 / 4096.f, y2 / 4096.f, windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y, p); -} - -void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, palette_t p) -{ - drawlinergb(x1, y1, x2, y2, PalEntry(p.r, p.g, p.b)); -} - -void renderDrawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint8_t col) -{ - drawlinergb(x1, y1, x2, y2, GPalette.BaseColors[GPalette.Remap[col]]); -} - - //========================================================================== // // diff --git a/source/core/automap.cpp b/source/core/automap.cpp index 003d09629..ddc1e43bc 100644 --- a/source/core/automap.cpp +++ b/source/core/automap.cpp @@ -33,34 +33,40 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "gstrings.h" #include "printf.h" #include "serializer.h" +#include "v_2ddrawer.h" +#include "earcut.hpp" +#include "buildtiles.h" +#include "d_event.h" +#include "c_bind.h" +#include "gamestate.h" +#include "gamecontrol.h" +#include "quotemgr.h" +#include "v_video.h" +#include "gamestruct.h" +CVAR(Bool, am_followplayer, true, CVAR_ARCHIVE) +CVAR(Bool, am_rotate, true, CVAR_ARCHIVE) +CVAR(Bool, am_textfont, false, CVAR_ARCHIVE) +CVAR(Bool, am_showlabel, false, CVAR_ARCHIVE) +CVAR(Bool, am_nameontop, false, CVAR_ARCHIVE) +int automapMode; +static int am_zoomdir; +int follow_x = INT_MAX, follow_y = INT_MAX, follow_a = INT_MAX; +static int gZoom = 768; bool automapping; bool gFullMap; FixedBitArray show2dsector; FixedBitArray show2dwall; FixedBitArray show2dsprite; +static int x_min_bound = INT_MAX, y_min_bound, x_max_bound, y_max_bound; -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void SerializeAutomap(FSerializer& arc) -{ - if (arc.BeginObject("automap")) - { - arc("automapping", automapping) - ("fullmap", gFullMap) - // Only store what's needed. Unfortunately for sprites it is not that easy - .SerializeMemory("mappedsectors", show2dsector.Storage(), (numsectors + 7) / 8) - .SerializeMemory("mappedwalls", show2dwall.Storage(), (numwalls + 7) / 8) - .SerializeMemory("mappedsprites", show2dsprite.Storage(), MAXSPRITES / 8) - .EndObject(); - } -} - +CVAR(Color, am_twosidedcolor, 0xaaaaaa, CVAR_ARCHIVE) +CVAR(Color, am_onesidedcolor, 0xaaaaaa, CVAR_ARCHIVE) +CVAR(Color, am_playercolor, 0xaaaaaa, CVAR_ARCHIVE) +CVAR(Color, am_ovtwosidedcolor, 0xaaaaaa, CVAR_ARCHIVE) +CVAR(Color, am_ovonesidedcolor, 0xaaaaaa, CVAR_ARCHIVE) +CVAR(Color, am_ovplayercolor, 0xaaaaaa, CVAR_ARCHIVE) //--------------------------------------------------------------------------- // @@ -77,6 +83,182 @@ CCMD(allmap) } } +CCMD(togglemap) +{ + if (gamestate == GS_LEVEL) + { + automapMode++; + if (automapMode == am_count) automapMode = am_off; + if ((g_gameType & GAMEFLAG_BLOOD) && automapMode == am_overlay) automapMode = am_full; // todo: investigate if this can be re-enabled + } +} + +CCMD(togglefollow) +{ + am_followplayer = !am_followplayer; + auto msg = quoteMgr.GetQuote(am_followplayer ? 84 : 83); + if (!msg || !*msg) msg = am_followplayer ? GStrings("FOLLOW MODE ON") : GStrings("FOLLOW MODE Off"); + Printf("%s\n", msg); + follow_x = follow_y = 0; +} + +CCMD(am_zoom) +{ + if (argv.argc() >= 2) + { + am_zoomdir = (float)atof(argv[1]); + } +} + +//========================================================================== +// +// AM_Responder +// Handle automap exclusive bindings. +// +//========================================================================== + +bool AM_Responder(event_t* ev, bool last) +{ + if (ev->type == EV_KeyDown || ev->type == EV_KeyUp) + { + if (am_followplayer) + { + // check for am_pan* and ignore in follow mode + const char* defbind = AutomapBindings.GetBind(ev->data1); + if (defbind && !strnicmp(defbind, "+am_pan", 7)) return false; + } + + bool res = C_DoKey(ev, &AutomapBindings, nullptr); + if (res && ev->type == EV_KeyUp && !last) + { + // If this is a release event we also need to check if it released a button in the main Bindings + // so that that button does not get stuck. + const char* defbind = Bindings.GetBind(ev->data1); + return (!defbind || defbind[0] != '+'); // Let G_Responder handle button releases + } + return res; + } + return false; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void CalcMapBounds() +{ + x_min_bound = 999999; + y_min_bound = 999999; + x_max_bound = -999999; + y_max_bound = -999999; + + + for (int i = 0; i < numwalls; i++) + { + // get map min and max coordinates + x_min_bound = min(TrackerCast(wall[i].x), x_min_bound); + y_min_bound = min(TrackerCast(wall[i].y), y_min_bound); + x_max_bound = max(TrackerCast(wall[i].x), x_max_bound); + y_max_bound = max(TrackerCast(wall[i].y), y_max_bound); + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void AutomapControl() +{ + static int nonsharedtimer; + int ms = screen->FrameTime; + int interval; + static int panvert = 0, panhorz = 0; + + if (nonsharedtimer > 0 || ms < nonsharedtimer) + { + interval = ms - nonsharedtimer; + } + else + { + interval = 0; + } + nonsharedtimer = screen->FrameTime; + + if (System_WantGuiCapture()) + return; + + if (automapMode != am_off) + { + const int keymove = 35; + if (am_zoomdir > 0) + { + gZoom = xs_CRoundToInt(gZoom * am_zoomdir); + } + else if (am_zoomdir < 0) + { + gZoom = xs_CRoundToInt(gZoom / -am_zoomdir); + } + am_zoomdir = 0; + + double j = interval * (120. / 1000); + + if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen)) + gZoom += (int)fmulscale6(j, max(gZoom, 256)); + if (buttonMap.ButtonDown(gamefunc_Shrink_Screen)) + gZoom -= (int)fmulscale6(j, max(gZoom, 256)); + + if (buttonMap.ButtonDown(gamefunc_AM_PanLeft)) + panhorz += keymove; + + if (buttonMap.ButtonDown(gamefunc_AM_PanRight)) + panhorz -= keymove; + + if (buttonMap.ButtonDown(gamefunc_AM_PanUp)) + panvert += keymove; + + if (buttonMap.ButtonDown(gamefunc_AM_PanDown)) + panvert -= keymove; + + int momx = mulscale9(panvert, sintable[(follow_a + 512) & 2047]); + int momy = mulscale9(panvert, sintable[follow_a]); + + momx += mulscale9(panhorz, sintable[follow_a]); + momy += mulscale9(panhorz, sintable[(follow_a + 1536) & 2047]); + + follow_x += Scale(momx, gZoom, 768); + follow_y += Scale(momy, gZoom, 768); + + follow_x = clamp(follow_x, x_min_bound, x_max_bound); + follow_y = clamp(follow_y, y_min_bound, y_max_bound); + gZoom = clamp(gZoom, 48, 2048); + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void SerializeAutomap(FSerializer& arc) +{ + if (arc.BeginObject("automap")) + { + arc("automapping", automapping) + ("fullmap", gFullMap) + // Only store what's needed. Unfortunately for sprites it is not that easy + .SerializeMemory("mappedsectors", show2dsector.Storage(), (numsectors + 7) / 8) + .SerializeMemory("mappedwalls", show2dwall.Storage(), (numwalls + 7) / 8) + .SerializeMemory("mappedsprites", show2dsprite.Storage(), MAXSPRITES / 8) + .EndObject(); + } +} + + //--------------------------------------------------------------------------- // // @@ -85,9 +267,10 @@ CCMD(allmap) void ClearAutomap() { - show2dsector.Zero(); - show2dwall.Zero(); - show2dsprite.Zero(); + show2dsector.Zero(); + show2dwall.Zero(); + show2dsprite.Zero(); + x_min_bound = INT_MAX; } //--------------------------------------------------------------------------- @@ -121,7 +304,249 @@ void MarkSectorSeen(int i) // //--------------------------------------------------------------------------- -void DrawOverheadMap(int pl_x, int pl_y, int pl_angle) +void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, PalEntry p) { + twod->AddLine(x1 / 4096.f, y1 / 4096.f, x2 / 4096.f, y2 / 4096.f, windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y, p); +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +PalEntry RedLineColor() +{ + // todo: + // Blood uses palette index 12 (99,99,99) + // Exhumed uses palette index 111 (roughly 170,170,170) but darkens the line in overlay mode the farther it is away from the player in vertical direction. + // Shadow Warrior uses palette index 152 in overlay mode and index 12 in full map mode. (152: 84, 88, 40) + return automapMode == am_overlay? *am_ovtwosidedcolor : *am_twosidedcolor; +} + +PalEntry WhiteLineColor() +{ + + // todo: + // Blood uses palette index 24 + // Exhumed uses palette index 111 (roughly 170,170,170) but darkens the line in overlay mode the farther it is away from the player in vertical direction. + // Shadow Warrior uses palette index 24 (60,60,60) + return automapMode == am_overlay ? *am_ovonesidedcolor : *am_onesidedcolor; +} + +PalEntry PlayerLineColor() +{ + return automapMode == am_overlay ? *am_ovplayercolor : *am_playercolor; +} + + +CCMD(printpalcol) +{ + if (argv.argc() < 2) return; + + int i = atoi(argv[1]); + Printf("%d, %d, %d\n", GPalette.BaseColors[i].r, GPalette.BaseColors[i].g, GPalette.BaseColors[i].b); +} +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +bool ShowRedLine(int j, int i) +{ + auto wal = &wall[j]; + if (!(g_gameType & GAMEFLAG_SW)) + { + return !gFullMap && !show2dsector[wal->nextsector]; + } + else + { + if (!gFullMap) + { + if (!show2dwall[j]) return false; + int k = wal->nextwall; + if (k > j && !show2dwall[k]) return false; //??? + } + if (automapMode == am_full) + { + if (sector[i].floorz != sector[i].ceilingz) + if (sector[wal->nextsector].floorz != sector[wal->nextsector].ceilingz) + if (((wal->cstat | wall[wal->nextwall].cstat) & (16 + 32)) == 0) + if (sector[i].floorz == sector[wal->nextsector].floorz) + return false; + if (sector[i].floorpicnum != sector[wal->nextsector].floorpicnum) + return false; + if (sector[i].floorshade != sector[wal->nextsector].floorshade) + return false; + } + return true; + } +} + +//--------------------------------------------------------------------------- +// +// two sided lines +// +//--------------------------------------------------------------------------- + +void drawredlines(int cposx, int cposy, int czoom, int cang) +{ + int xvect = sintable[(-cang) & 2047] * czoom; + int yvect = sintable[(1536 - cang) & 2047] * czoom; + int xvect2 = mulscale16(xvect, yxaspect); + int yvect2 = mulscale16(yvect, yxaspect); + + for (int i = 0; i < numsectors; i++) + { + if (!gFullMap && !show2dsector[i]) continue; + + int startwall = sector[i].wallptr; + int endwall = sector[i].wallptr + sector[i].wallnum; + + int z1 = sector[i].ceilingz; + int z2 = sector[i].floorz; + walltype* wal; + int j; + + for (j = startwall, wal = &wall[startwall]; j < endwall; j++, wal++) + { + int k = wal->nextwall; + if (k < 0 || k >= MAXWALLS) continue; + + if (sector[wal->nextsector].ceilingz == z1 && sector[wal->nextsector].floorz == z2) + if (((wal->cstat | wall[wal->nextwall].cstat) & (16 + 32)) == 0) continue; + + if (ShowRedLine(j, i)) + { + int ox = wal->x - cposx; + int oy = wal->y - cposy; + int x1 = dmulscale16(ox, xvect, -oy, yvect) + (xdim << 11); + int y1 = dmulscale16(oy, xvect2, ox, yvect2) + (ydim << 11); + + auto wal2 = &wall[wal->point2]; + ox = wal2->x - cposx; + oy = wal2->y - cposy; + int x2 = dmulscale16(ox, xvect, -oy, yvect) + (xdim << 11); + int y2 = dmulscale16(oy, xvect2, ox, yvect2) + (ydim << 11); + + drawlinergb(x1, y1, x2, y2, RedLineColor()); + } + } + } +} + +//--------------------------------------------------------------------------- +// +// one sided lines +// +//--------------------------------------------------------------------------- + +static void drawwhitelines(int cposx, int cposy, int czoom, int cang) +{ + int xvect = sintable[(-cang) & 2047] * czoom; + int yvect = sintable[(1536 - cang) & 2047] * czoom; + int xvect2 = mulscale16(xvect, yxaspect); + int yvect2 = mulscale16(yvect, yxaspect); + + for (int i = numsectors - 1; i >= 0; i--) + { + if (!gFullMap && !show2dsector[i] && !(g_gameType & GAMEFLAG_SW)) continue; + + int startwall = sector[i].wallptr; + int endwall = sector[i].wallptr + sector[i].wallnum; + + walltype* wal; + int j; + + for (j = startwall, wal = &wall[startwall]; j < endwall; j++, wal++) + { + if (wal->nextwall >= 0) continue; + if (!tileGetTexture(wal->picnum)->isValid()) continue; + + if ((g_gameType & GAMEFLAG_SW) && !gFullMap && !show2dwall[j]) + continue; + + int ox = wal->x - cposx; + int oy = wal->y - cposy; + int x1 = dmulscale16(ox, xvect, -oy, yvect) + (xdim << 11); + int y1 = dmulscale16(oy, xvect2, ox, yvect2) + (ydim << 11); + + int k = wal->point2; + auto wal2 = &wall[k]; + ox = wal2->x - cposx; + oy = wal2->y - cposy; + int x2 = dmulscale16(ox, xvect, -oy, yvect) + (xdim << 11); + int y2 = dmulscale16(oy, xvect2, ox, yvect2) + (ydim << 11); + + drawlinergb(x1, y1, x2, y2, WhiteLineColor()); + } + } +} + + +void DrawPlayerArrow(int cposx, int cposy, int cang, int pl_x, int pl_y, int zoom, int pl_angle) +{ + int arrow[] = + { + 0, 65536, 0, -65536, + 0, 65536, -32768, 32878, + 0, 65536, 32768, 32878, + }; + + int xvect = sintable[(-cang) & 2047] * zoom; + int yvect = sintable[(1536 - cang) & 2047] * zoom; + int xvect2 = mulscale16(xvect, yxaspect); + int yvect2 = mulscale16(yvect, yxaspect); + + int pxvect = sintable[(-pl_angle) & 2047]; + int pyvect = sintable[(1536 - pl_angle) & 2047]; + + for (int i = 0; i < 12; i += 4) + { + + int px1 = dmulscale16(arrow[i], pxvect, -arrow[i+1], pyvect); + int py1 = dmulscale16(arrow[i+1], pxvect, arrow[i], pyvect) + (ydim << 11); + int px2 = dmulscale16(arrow[i+2], pxvect, -arrow[i + 3], pyvect); + int py2 = dmulscale16(arrow[i + 3], pxvect, arrow[i+2], pyvect) + (ydim << 11); + + int ox1 = px1 - cposx; + int oy1 = py1 - cposx; + int ox2 = px2 - cposx; + int oy2 = py2 - cposx; + + int sx1 = dmulscale16(ox1, xvect, -oy1, yvect) + (xdim << 11); + int sy1 = dmulscale16(oy1, xvect2, ox1, yvect2) + (ydim << 11); + int sx2 = dmulscale16(ox2, xvect, -oy2, yvect) + (xdim << 11); + int sy2 = dmulscale16(oy2, xvect2, ox2, yvect2) + (ydim << 11); + + drawlinergb(sx1, sy1, sx2, sy2, WhiteLineColor()); + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void DrawOverheadMap(int pl_x, int pl_y, int pl_angle) +{ + int x = am_followplayer ? pl_x : follow_x; + int y = am_followplayer ? pl_y : follow_y; + follow_a = am_rotate ? pl_angle : 0; + + if (automapMode == am_full) + { + twod->ClearScreen(); + renderDrawMapView(x, y, gZoom, follow_a); + } + int32_t tmpydim = (xdim * 5) / 8; + renderSetAspect(65536, divscale16(tmpydim * 320, xdim * 200)); + + drawredlines(x, y, gZoom, follow_a); + drawwhitelines(x, y, gZoom, follow_a); + DrawPlayerArrow(x, y, follow_a, pl_x, pl_y, gZoom, -pl_angle); + } diff --git a/source/core/automap.h b/source/core/automap.h index 1e6b1d097..d92210ab7 100644 --- a/source/core/automap.h +++ b/source/core/automap.h @@ -2,8 +2,10 @@ #include "tarray.h" #include "build.h" +#include "c_cvars.h" class FSerializer; +struct event_t; extern bool automapping; extern bool gFullMap; @@ -15,4 +17,15 @@ void SerializeAutomap(FSerializer& arc); void ClearAutomap(); void MarkSectorSeen(int sect); void DrawOverheadMap(int x, int y, int ang); +bool AM_Responder(event_t* ev, bool last); +enum AM_Mode +{ + am_off, + am_overlay, + am_full, + am_count +}; +extern int automapMode; + +EXTERN_CVAR(Bool, am_followplayer) diff --git a/source/core/console/d_event.cpp b/source/core/console/d_event.cpp index 55b2f82c9..996b326d2 100644 --- a/source/core/console/d_event.cpp +++ b/source/core/console/d_event.cpp @@ -42,40 +42,7 @@ #include "gamestate.h" #include "gamecontrol.h" #include "uiinput.h" - -//========================================================================== -// -// AM_Responder -// Handle automap exclusive bindings. -// -//========================================================================== - -bool AM_Responder (event_t *ev, bool last) -{ - if (ev->type == EV_KeyDown || ev->type == EV_KeyUp) - { -#if 0 // this feature does not exist yet. - if (automapFollow) - { - // check for am_pan* and ignore in follow mode - const char *defbind = AutomapBindings.GetBind(ev->data1); - if (defbind && !strnicmp(defbind, "+am_pan", 7)) return false; - } -#endif - - bool res = C_DoKey(ev, &AutomapBindings, nullptr); - if (res && ev->type == EV_KeyUp && !last) - { - // If this is a release event we also need to check if it released a button in the main Bindings - // so that that button does not get stuck. - const char *defbind = Bindings.GetBind(ev->data1); - return (!defbind || defbind[0] != '+'); // Let G_Responder handle button releases - } - return res; - } - return false; -} - +#include "automap.h" //========================================================================== // diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index b09eac735..923100633 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -70,6 +70,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "statusbar.h" #include "uiinput.h" #include "d_net.h" +#include "automap.h" CVAR(Bool, autoloadlights, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, autoloadbrightmaps, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) @@ -98,27 +99,8 @@ int connecthead, connectpoint2[MAXMULTIPLAYERS]; auto vsnprintfptr = vsnprintf; // This is an inline in Visual Studio but we need an address for it to satisfy the MinGW compiled libraries. int lastTic; -int automapMode; -bool automapFollow; extern bool pauseext; -CCMD(togglemap) -{ - if (gamestate == GS_LEVEL) - { - automapMode++; - if (automapMode == am_count) automapMode = am_off; - if ((g_gameType & GAMEFLAG_BLOOD) && automapMode == am_overlay) automapMode = am_full; // todo: investigate if this can be re-enabled - gi->ResetFollowPos(false); - } -} - -CCMD(togglefollow) -{ - automapFollow = !automapFollow; - gi->ResetFollowPos(true); -} - cycle_t thinktime, actortime, gameupdatetime, drawtime; gamestate_t gamestate = GS_STARTUP; @@ -1265,64 +1247,6 @@ void GameInterface::FreeLevelData() currentLevel = nullptr; } -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- -static float am_zoomdir; - -int GetAutomapZoom(int gZoom) -{ - static int nonsharedtimer; - int ms = screen->FrameTime; - int interval; - if (nonsharedtimer > 0 || ms < nonsharedtimer) - { - interval = ms - nonsharedtimer; - } - else - { - interval = 0; - } - nonsharedtimer = screen->FrameTime; - - if (System_WantGuiCapture()) - return gZoom; - - if (automapMode != am_off) - { - if (am_zoomdir > 0) - { - gZoom = xs_CRoundToInt(gZoom * am_zoomdir); - } - else if (am_zoomdir < 0) - { - gZoom = xs_CRoundToInt(gZoom / -am_zoomdir); - } - am_zoomdir = 0; - - double j = interval * (120. / 1000); - - if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen)) - gZoom += (int)fmulscale6(j, max(gZoom, 256)); - if (buttonMap.ButtonDown(gamefunc_Shrink_Screen)) - gZoom -= (int)fmulscale6(j, max(gZoom, 256)); - - gZoom = clamp(gZoom, 48, 2048); - - } - return gZoom; -} - -CCMD(am_zoom) -{ - if (argv.argc() >= 2) - { - am_zoomdir = (float)atof(argv[1]); - } -} - //--------------------------------------------------------------------------- // // Load crosshair definitions diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index c4215d732..1103b0c6c 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -220,15 +220,6 @@ enum extern int paused; extern int chatmodeon; -enum AM_Mode -{ - am_off, - am_overlay, - am_full, - am_count -}; -extern int automapMode; -extern bool automapFollow; extern bool sendPause; extern int lastTic; diff --git a/source/core/gamecvars.cpp b/source/core/gamecvars.cpp index 09429c3d4..608273068 100644 --- a/source/core/gamecvars.cpp +++ b/source/core/gamecvars.cpp @@ -357,9 +357,6 @@ CUSTOM_CVAR(Int, playergender, 0, CVAR_USERINFO|CVAR_ARCHIVE) } -CVAR(Bool, am_textfont, false, CVAR_ARCHIVE) -CVAR(Bool, am_showlabel, false, CVAR_ARCHIVE) -CVAR(Bool, am_nameontop, false, CVAR_ARCHIVE) CVAR(Int, m_coop, 0, CVAR_NOSET) diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index 49fdb5d49..f1b052cd4 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -92,7 +92,6 @@ struct GameInterface virtual FString GetCoordString() { return "'stat coord' not implemented"; } virtual void ExitFromMenu() { throw CExitEvent(0); } virtual ReservedSpace GetReservedScreenSpace(int viewsize) { return { 0, 0 }; } - virtual void ResetFollowPos(bool) {} virtual void GetInput(InputPacket* packet) {} virtual void UpdateSounds() {} virtual void ErrorCleanup() {} diff --git a/source/core/inputstate.cpp b/source/core/inputstate.cpp index 2a0929f5d..12c8e1d7e 100644 --- a/source/core/inputstate.cpp +++ b/source/core/inputstate.cpp @@ -230,6 +230,11 @@ void SetupGameButtons() "Dpad_Aiming", "Toggle_Crouch", "Quick_Kick", + "AM_PanLeft", + "AM_PanRight", + "AM_PanUp", + "AM_PanDown", + }; buttonMap.SetButtons(actions, NUM_ACTIONS); } diff --git a/source/core/inputstate.h b/source/core/inputstate.h index aa07f9d8f..e4d5db410 100644 --- a/source/core/inputstate.h +++ b/source/core/inputstate.h @@ -92,6 +92,10 @@ enum GameFunction_t gamefunc_Dpad_Aiming, gamefunc_Toggle_Crouch, gamefunc_Quick_Kick, + gamefunc_AM_PanLeft, + gamefunc_AM_PanRight, + gamefunc_AM_PanUp, + gamefunc_AM_PanDown, NUM_ACTIONS }; diff --git a/source/exhumed/src/gameloop.cpp b/source/exhumed/src/gameloop.cpp index f23d5be5e..253569074 100644 --- a/source/exhumed/src/gameloop.cpp +++ b/source/exhumed/src/gameloop.cpp @@ -47,6 +47,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "g_input.h" #include "core/menu/menu.h" #include "d_net.h" +#include "automap.h" BEGIN_PS_NS diff --git a/source/exhumed/src/input.cpp b/source/exhumed/src/input.cpp index 344913bfd..805c5bd47 100644 --- a/source/exhumed/src/input.cpp +++ b/source/exhumed/src/input.cpp @@ -220,19 +220,9 @@ void PlayerInterruptKeys(bool after) if (buttonMap.ButtonDown(gamefunc_Move_Backward)) tempinput.fvel += -keyMove; - if ((automapFollow && automapMode != am_off)) - { - // neutralize all movement when in automap follow mode - localInput.fvel = localInput.svel = 0; - localInput.q16avel = localInput.q16horz = 0; - input_angle = 0; - } - else - { - localInput.fvel = clamp(localInput.fvel + tempinput.fvel, -12, 12); - localInput.svel = clamp(localInput.svel + tempinput.svel, -12, 12); - localInput.q16avel += input_angle; - } + localInput.fvel = clamp(localInput.fvel + tempinput.fvel, -12, 12); + localInput.svel = clamp(localInput.svel + tempinput.svel, -12, 12); + localInput.q16avel += input_angle; if (!nFreeze) { diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index 79932543f..25cbd9de9 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -32,6 +32,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gstrings.h" #include "gamestate.h" #include "mapinfo.h" +#include "automap.h" + #include #include #include diff --git a/source/exhumed/src/status.cpp b/source/exhumed/src/status.cpp index 0d8f7aa54..00a6b8a8b 100644 --- a/source/exhumed/src/status.cpp +++ b/source/exhumed/src/status.cpp @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "texturemanager.h" #include "statusbar.h" #include "v_draw.h" +#include "automap.h" #include #include #include diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 187fcea3c..e3063d2f8 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -928,7 +928,7 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle) auto p = &ps[playerNum]; bool blocked = movementBlocked(playerNum) || sprite[p->i].extra <= 0 || (p->dead_flag && !ud.god); - if ((automapFollow && automapMode != am_off) || blocked) + if (blocked) { // neutralize all movement when blocked or in automap follow mode loc.fvel = loc.svel = 0; diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index e74651c28..0b2675980 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -30,6 +30,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "build.h" #include "v_video.h" #include "prediction.h" +#include "automap.h" BEGIN_DUKE_NS diff --git a/source/games/duke/src/sbar.cpp b/source/games/duke/src/sbar.cpp index 299cc68a6..f5e0b81b9 100644 --- a/source/games/duke/src/sbar.cpp +++ b/source/games/duke/src/sbar.cpp @@ -40,6 +40,7 @@ source as it is released. #include "v_draw.h" #include "texturemanager.h" #include "mapinfo.h" +#include "automap.h" BEGIN_DUKE_NS diff --git a/source/sw/src/cheats.cpp b/source/sw/src/cheats.cpp index 70894c56d..a43cb1914 100644 --- a/source/sw/src/cheats.cpp +++ b/source/sw/src/cheats.cpp @@ -40,6 +40,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "d_protocol.h" #include "cheats.h" #include "gamestate.h" +#include "automap.h" //#include "inv.h" BEGIN_SW_NS @@ -128,9 +129,9 @@ bool MapCheat(cheatseq_t* c) { PLAYERp pp; if (!(pp=checkCheat(c))) return false; - mapcheat = !mapcheat; + gFullMap = !gFullMap; // Need to do this differently. The code here was completely broken. - PutStringInfo(pp, GStrings(mapcheat ? "TXTS_AMON" : "TXTS_AMOFF")); + PutStringInfo(pp, GStrings(gFullMap ? "TXTS_AMON" : "TXTS_AMOFF")); return true; } diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 5a3bd88f8..1adcd10d6 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -96,8 +96,6 @@ extern int sw_snd_scratch; int GameVersion = 20; -int Follow_posx=0,Follow_posy=0; - SWBOOL NoMeters = false; SWBOOL FinishAnim = 0; SWBOOL ReloadPrompt = false; diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 6fa650b8e..7b367eb15 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -762,8 +762,6 @@ extern FString ThemeSongs[6]; // #define MAX_EPISODE_NAME_LEN 24 extern char EpisodeNames[3][MAX_EPISODE_NAME_LEN+2]; -extern int Follow_posx, Follow_posy; - enum { MAX_KEYS = 8, @@ -1625,7 +1623,6 @@ typedef struct extern SPIN Spin[17]; extern DOOR_AUTO_CLOSE DoorAutoClose[MAX_DOOR_AUTO_CLOSE]; -extern int x_min_bound, y_min_bound, x_max_bound, y_max_bound; #define MAXANIM 256 typedef void ANIM_CALLBACK (ANIMp, void *); @@ -1998,8 +1995,6 @@ extern int GodMode; extern SWBOOL ReloadPrompt; -extern int x_min_bound, y_min_bound, x_max_bound, y_max_bound; - //extern unsigned char synctics, lastsynctics; extern short snum; @@ -2205,8 +2200,7 @@ struct GameInterface : ::GameInterface FString GetCoordString() override; ReservedSpace GetReservedScreenSpace(int viewsize) override; void QuitToTitle() override; - void ResetFollowPos(bool message) override; - void UpdateSounds() override; + void UpdateSounds() override; void ErrorCleanup() override; void GetInput(InputPacket* input) override; void DrawBackground(void) override; diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index d086b4f38..9287a2fb8 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -60,13 +60,6 @@ InitTimingVars(void) -void GameInterface::ResetFollowPos(bool) -{ - auto pp = &Player[myconnectindex]; - Follow_posx = pp->posx; - Follow_posy = pp->posy; -} - static void getinput(InputPacket *loc) { int i; @@ -107,10 +100,6 @@ static void getinput(InputPacket *loc) if (paused) return; - // !JIM! Added M_Active() so that you don't move at all while using menus - if (M_Active() || (automapFollow && automapMode != am_off)) - return; - int32_t turnamount; int32_t keymove; diff --git a/source/sw/src/save.cpp b/source/sw/src/save.cpp index 3dd664349..6d416267c 100644 --- a/source/sw/src/save.cpp +++ b/source/sw/src/save.cpp @@ -451,12 +451,6 @@ bool GameInterface::SaveGame(FSaveGameNode *sv) MWRITE(SineWaveFloor, sizeof(SineWaveFloor),1,fil); MWRITE(SineWall, sizeof(SineWall),1,fil); MWRITE(SpringBoard, sizeof(SpringBoard),1,fil); - //MWRITE(Rotate, sizeof(Rotate),1,fil); - //MWRITE(DoorAutoClose, sizeof(DoorAutoClose),1,fil); - MWRITE(&x_min_bound, sizeof(x_min_bound),1,fil); - MWRITE(&y_min_bound, sizeof(y_min_bound),1,fil); - MWRITE(&x_max_bound, sizeof(x_max_bound),1,fil); - MWRITE(&y_max_bound, sizeof(y_max_bound),1,fil); MWRITE(Track, sizeof(Track),1,fil); @@ -838,12 +832,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) MREAD(SineWaveFloor, sizeof(SineWaveFloor),1,fil); MREAD(SineWall, sizeof(SineWall),1,fil); MREAD(SpringBoard, sizeof(SpringBoard),1,fil); - //MREAD(Rotate, sizeof(Rotate),1,fil); - //MREAD(DoorAutoClose, sizeof(DoorAutoClose),1,fil); - MREAD(&x_min_bound, sizeof(x_min_bound),1,fil); - MREAD(&y_min_bound, sizeof(y_min_bound),1,fil); - MREAD(&x_max_bound, sizeof(x_max_bound),1,fil); - MREAD(&y_max_bound, sizeof(y_max_bound),1,fil); MREAD(Track, sizeof(Track),1,fil); for (i = 0; i < MAX_TRACKS; i++) diff --git a/source/sw/src/sbar.cpp b/source/sw/src/sbar.cpp index c1f89bf31..e43db115c 100644 --- a/source/sw/src/sbar.cpp +++ b/source/sw/src/sbar.cpp @@ -40,6 +40,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "network.h" #include "v_draw.h" #include "menus.h" +#include "automap.h" BEGIN_SW_NS diff --git a/source/sw/src/sector.cpp b/source/sw/src/sector.cpp index 8524953c4..f42b13b8c 100644 --- a/source/sw/src/sector.cpp +++ b/source/sw/src/sector.cpp @@ -92,7 +92,6 @@ short AnimCnt = 0; SINE_WAVE_FLOOR SineWaveFloor[MAX_SINE_WAVE][21]; SINE_WALL SineWall[MAX_SINE_WALL][MAX_SINE_WALL_POINTS]; SPRING_BOARD SpringBoard[20]; -int x_min_bound, y_min_bound, x_max_bound, y_max_bound; void SetSectorWallBits(short sectnum, int bit_mask, SWBOOL set_sectwall, SWBOOL set_nextwall) { @@ -178,11 +177,7 @@ WallSetup(void) memset(SineWall, -1, sizeof(SineWall)); - x_min_bound = 999999; - y_min_bound = 999999; - x_max_bound = -999999; - y_max_bound = -999999; - + extern int x_min_bound, y_min_bound, x_max_bound, y_max_bound; for (wp = wall, i = 0; wp < &wall[numwalls]; i++, wp++) { @@ -192,12 +187,6 @@ WallSetup(void) if (wall[i].picnum == FAF_PLACE_MIRROR_PIC+1) wall[i].picnum = FAF_MIRROR_PIC+1; - // get map min and max coordinates - x_min_bound = min(TrackerCast(wp->x), x_min_bound); - y_min_bound = min(TrackerCast(wp->y), y_min_bound); - x_max_bound = max(TrackerCast(wp->x), x_max_bound); - y_max_bound = max(TrackerCast(wp->y), y_max_bound); - // this overwrites the lotag so it needs to be called LAST - its down there // SetupWallForBreak(wp);