From d61d279168040dfc87c9b92cd179e08e2b37000a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 6 Sep 2020 10:59:45 +0200 Subject: [PATCH] - excised Blood's entire automap code. --- source/blood/CMakeLists.txt | 1 - source/blood/src/animatesprite.cpp | 1 - source/blood/src/blood.cpp | 3 - source/blood/src/controls.cpp | 25 ++-- source/blood/src/db.cpp | 4 +- source/blood/src/hudsprites.cpp | 1 - source/blood/src/map2d.cpp | 196 ----------------------------- source/blood/src/map2d.h | 43 ------- source/blood/src/player.cpp | 4 - source/blood/src/prediction.cpp | 1 - source/blood/src/sbar.cpp | 1 - source/blood/src/view.cpp | 22 +++- source/blood/src/view.h | 1 - source/games/duke/src/duke3d.h | 1 - source/games/duke/src/input.cpp | 5 - 15 files changed, 31 insertions(+), 278 deletions(-) delete mode 100644 source/blood/src/map2d.h diff --git a/source/blood/CMakeLists.txt b/source/blood/CMakeLists.txt index 05cc62bdb..78f88be81 100644 --- a/source/blood/CMakeLists.txt +++ b/source/blood/CMakeLists.txt @@ -45,7 +45,6 @@ set( PCH_SOURCES src/inifile.cpp src/levels.cpp src/loadsave.cpp - src/map2d.cpp src/messages.cpp src/mirrors.cpp src/misc.cpp diff --git a/source/blood/src/animatesprite.cpp b/source/blood/src/animatesprite.cpp index d35050478..00401b3a8 100644 --- a/source/blood/src/animatesprite.cpp +++ b/source/blood/src/animatesprite.cpp @@ -33,7 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "endgame.h" #include "aistate.h" -#include "map2d.h" #include "loadsave.h" #include "sectorfx.h" #include "choke.h" diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index caa2ee99c..d2089b917 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -62,7 +62,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "choke.h" #include "d_net.h" #include "v_video.h" -#include "map2d.h" BEGIN_BLD_NS @@ -495,8 +494,6 @@ void GameInterface::Startup() void GameInterface::Render() { - gZoom = GetAutomapZoom(gZoom); - gViewMap.nZoom = gZoom; drawtime.Reset(); drawtime.Clock(); viewDrawScreen(); diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index a783fdc74..e9e49a3d2 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -31,7 +31,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "controls.h" #include "globals.h" #include "levels.h" -#include "map2d.h" #include "view.h" #include "d_event.h" #include "gamestate.h" @@ -167,19 +166,21 @@ void GetInputInternal(InputPacket &inputParm) input.q16horz -= FloatToFixed(scaleAdjustmentToInterval(info.dpitch / mlookScale)); - if (!automapFollow && automapMode != am_off) + if (automapFollow && automapMode != am_off) { - gViewMap.turn += input.q16avel<<2; - gViewMap.forward += input.fvel; - gViewMap.strafe += input.svel; - input.q16avel = 0; - input.fvel = 0; - input.svel = 0; + inputParm.q16horz = 0; + inputParm.q16avel = 0; + inputParm.fvel = 0; + inputParm.svel = 0; } - 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); + 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); + } + if (gMe && gMe->pXSprite && gMe->pXSprite->health != 0 && !paused) { int upAngle = 289; diff --git a/source/blood/src/db.cpp b/source/blood/src/db.cpp index 6e803b9c8..59ddb64c5 100644 --- a/source/blood/src/db.cpp +++ b/source/blood/src/db.cpp @@ -594,9 +594,7 @@ const int nXWallSize = 24; int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short *pSector, unsigned int *pCRC) { int16_t tpskyoff[256]; - show2dsector.Zero(); - memset(show2dwall, 0, sizeof(show2dwall)); - memset(show2dsprite, 0, sizeof(show2dsprite)); + ClearAutomap(); #ifdef NOONE_EXTENSIONS gModernMap = false; #endif diff --git a/source/blood/src/hudsprites.cpp b/source/blood/src/hudsprites.cpp index 8ba2330a7..130c2f1a4 100644 --- a/source/blood/src/hudsprites.cpp +++ b/source/blood/src/hudsprites.cpp @@ -33,7 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "endgame.h" #include "aistate.h" -#include "map2d.h" #include "loadsave.h" #include "sectorfx.h" #include "choke.h" diff --git a/source/blood/src/map2d.cpp b/source/blood/src/map2d.cpp index c9d6c7adb..d0bd4ff4e 100644 --- a/source/blood/src/map2d.cpp +++ b/source/blood/src/map2d.cpp @@ -26,7 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "mmulti.h" #include "common_game.h" #include "levels.h" -#include "map2d.h" #include "view.h" #include "v_2ddrawer.h" #include "v_draw.h" @@ -34,200 +33,5 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS -void sub_2541C(int x, int y, int z, short a) -{ - int tmpydim = (xdim * 5) / 8; - renderSetAspect(65536, divscale16(tmpydim * 320, xdim * 200)); - int nCos = z*sintable[(0-a)&2047]; - int nSin = z*sintable[(1536-a)&2047]; - int nCos2 = mulscale16(nCos, yxaspect); - int nSin2 = mulscale16(nSin, yxaspect); - for (int i = 0; i < numsectors; i++) - { - if (gFullMap || show2dsector[i]) - { - int nStartWall = sector[i].wallptr; - int nEndWall = nStartWall+sector[i].wallnum; - int nZCeil = sector[i].ceilingz; - int nZFloor = sector[i].floorz; - walltype *pWall = &wall[nStartWall]; - for (int j = nStartWall; j < nEndWall; j++, pWall++) - { - int nNextWall = pWall->nextwall; - if (nNextWall < 0) - continue; - if (sector[pWall->nextsector].ceilingz == nZCeil && sector[pWall->nextsector].floorz == nZFloor - && ((wall[nNextWall].cstat | pWall->cstat) & 0x30) == 0) - continue; - if (gFullMap || show2dsector[pWall->nextsector]) - continue; - int wx = pWall->x-x; - int wy = pWall->y-y; - int cx = xdim<<11; - int x1 = cx+dmulscale16(wx, nCos, -wy, nSin); - int cy = ydim<<11; - int y1 = cy+dmulscale16(wy, nCos2, wx, nSin2); - walltype *pWall2 = &wall[pWall->point2]; - wx = pWall2->x-x; - wy = pWall2->y-y; - int x2 = cx+dmulscale16(wx, nCos, -wy, nSin); - int y2 = cy+dmulscale16(wy, nCos2, wx, nSin2); - renderDrawLine(x1,y1,x2,y2,24); - } - } - } - int nPSprite = gView->pSprite->index; - for (int i = 0; i < numsectors; i++) - { - if (gFullMap || show2dsector[i]) - { - for (int nSprite = headspritesect[i]; nSprite >= 0; nSprite = nextspritesect[nSprite]) - { - spritetype *pSprite = &sprite[nSprite]; - if (nSprite == nPSprite) - continue; - if (pSprite->cstat&32768) - continue; - } - } - } - for (int i = 0; i < numsectors; i++) - { - if (gFullMap || show2dsector[i]) - { - int nStartWall = sector[i].wallptr; - int nEndWall = nStartWall+sector[i].wallnum; - walltype *pWall = &wall[nStartWall]; - int nNWall = -1; - int x1, y1, x2 = 0, y2 = 0; - for (int j = nStartWall; j < nEndWall; j++, pWall++) - { - int nNextWall = pWall->nextwall; - if (nNextWall >= 0) - continue; - if (!tilesiz[pWall->picnum].x || !tilesiz[pWall->picnum].y) - continue; - if (nNWall == j) - { - x1 = x2; - y1 = y2; - } - else - { - int wx = pWall->x-x; - int wy = pWall->y-y; - x1 = (xdim<<11)+dmulscale16(wx, nCos, -wy, nSin); - y1 = (ydim<<11)+dmulscale16(wy, nCos2, wx, nSin2); - } - nNWall = pWall->point2; - walltype *pWall2 = &wall[nNWall]; - int wx = pWall2->x-x; - int wy = pWall2->y-y; - x2 = (xdim<<11)+dmulscale16(wx, nCos, -wy, nSin); - y2 = (ydim<<11)+dmulscale16(wy, nCos2, wx, nSin2); - renderDrawLine(x1,y1,x2,y2,24); - } - } - } - videoSetCorrectedAspect(); - - for (int i = connecthead; i >= 0; i = connectpoint2[i]) - { - if (automapFollow || gView->nPlayer != i) - { - PLAYER *pPlayer = &gPlayer[i]; - spritetype *pSprite = pPlayer->pSprite; - int px = pSprite->x-x; - int py = pSprite->y-y; - int pa = (pSprite->ang-a)&2047; - if (i == gView->nPlayer) - { - px = 0; - py = 0; - pa = 0; - } - int x1 = dmulscale16(px, nCos, -py, nSin); - int y1 = dmulscale16(py, nCos2, px, nSin2); - if (i == gView->nPlayer || gGameOptions.nGameType == 1) - { - int nTile = pSprite->picnum; - int ceilZ, ceilHit, floorZ, floorHit; - GetZRange(pSprite, &ceilZ, &ceilHit, &floorZ, &floorHit, (pSprite->clipdist<<2)+16, CLIPMASK0, PARALLAXCLIP_CEILING|PARALLAXCLIP_FLOOR); - int nTop, nBottom; - GetSpriteExtents(pSprite, &nTop, &nBottom); - int nScale = mulscale((pSprite->yrepeat+((floorZ-nBottom)>>8))*z, yxaspect, 16); - nScale = ClipRange(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 - DrawTexture(twod, tileGetTexture(nTile, true), x, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ViewportX, windowxy1.x, DTA_ViewportY, windowxy1.y, - DTA_ViewportWidth, windowxy2.x - windowxy1.x+1, DTA_ViewportHeight, windowxy2.y - windowxy1.y+1, DTA_Alpha, (pSprite->cstat&2? 0.5:1.), TAG_DONE); - } - } - } -} - -void CViewMap::sub_25C38(int _x, int _y, int _angle, short zoom) -{ - x = _x; - y = _y; - angle = _angle; - nZoom = zoom; - forward = 0; - turn = 0; - strafe = 0; -} - -void CViewMap::sub_25C74(void) -{ - int tm = 0; - if (windowxy1.x > 0) - { - setViewport(Hud_Stbar); - tm = 1; - } - // only clear the actual window. - twod->AddColorOnlyQuad(windowxy1.x, windowxy1.y, (windowxy2.x + 1) - windowxy1.x, (windowxy2.y + 1) - windowxy1.y, 0xff000000); - renderDrawMapView(x,y,nZoom>>1,angle); - sub_2541C(x,y,nZoom>>1,angle); - if (tm) - setViewport(hud_size); -} - -void CViewMap::sub_25DB0(spritetype *pSprite) -{ - nZoom = gZoom; - if (automapFollow) - { - x = pSprite->x; - y = pSprite->y; - angle = pSprite->ang; - } - else - { - angle += FixedToInt(turn)>>3; - x += mulscale24(forward>>8, Cos(angle)); - y += mulscale24(forward>>8, Sin(angle)); - x -= mulscale24(strafe>>8, Cos(angle+512)); - y -= mulscale24(strafe>>8, Sin(angle+512)); - forward = 0; - strafe = 0; - turn = 0; - } - sub_25C74(); -} - -void CViewMap::sub_25E84(int *_x, int *_y) -{ - if (_x) - *_x = x; - if (_y) - *_y = y; -} - - -CViewMap gViewMap; - END_BLD_NS diff --git a/source/blood/src/map2d.h b/source/blood/src/map2d.h deleted file mode 100644 index 0b5ba2df5..000000000 --- a/source/blood/src/map2d.h +++ /dev/null @@ -1,43 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2010-2019 EDuke32 developers and contributors -Copyright (C) 2019 Nuke.YKT - -This file is part of NBlood. - -NBlood 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. -*/ -//------------------------------------------------------------------------- -#pragma once -#include "build.h" - -BEGIN_BLD_NS - -class CViewMap { -public: - char bActive; - int x, y, nZoom; - short angle; - int forward, strafe; - fixed_t turn; - void sub_25C38(int, int, int, short); - void sub_25C74(void); - void sub_25DB0(spritetype *pSprite); - void sub_25E84(int *, int*); -}; - -extern CViewMap gViewMap; - -END_BLD_NS diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index 5f379262c..1d1f0623a 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -37,7 +37,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "globals.h" #include "levels.h" #include "loadsave.h" -#include "map2d.h" #include "player.h" #include "seq.h" #include "sound.h" @@ -806,9 +805,6 @@ void playerStart(int nPlayer, int bNewLevel) viewInitializePrediction(); gViewLook = pPlayer->q16look; gViewAngle = pPlayer->q16ang; - gViewMap.x = pPlayer->pSprite->x; - gViewMap.y = pPlayer->pSprite->y; - gViewMap.angle = pPlayer->pSprite->ang; } if (IsUnderwaterSector(pSprite->sectnum)) { diff --git a/source/blood/src/prediction.cpp b/source/blood/src/prediction.cpp index 4c4a3655b..718621aaf 100644 --- a/source/blood/src/prediction.cpp +++ b/source/blood/src/prediction.cpp @@ -33,7 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "endgame.h" #include "aistate.h" -#include "map2d.h" #include "loadsave.h" #include "sectorfx.h" #include "choke.h" diff --git a/source/blood/src/sbar.cpp b/source/blood/src/sbar.cpp index 6bad9101d..16af3e52a 100644 --- a/source/blood/src/sbar.cpp +++ b/source/blood/src/sbar.cpp @@ -33,7 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "endgame.h" #include "aistate.h" -#include "map2d.h" #include "loadsave.h" #include "sectorfx.h" #include "choke.h" diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 8e1e906d0..c65c25e8d 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -33,7 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "endgame.h" #include "aistate.h" -#include "map2d.h" #include "loadsave.h" #include "sectorfx.h" #include "choke.h" @@ -45,6 +44,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "v_2ddrawer.h" #include "v_video.h" #include "v_font.h" +#include "statusbar.h" #include "glbackend/glbackend.h" BEGIN_BLD_NS @@ -266,8 +266,6 @@ void viewDrawAimedPlayerName(void) static TArray lensdata; int *lensTable; -int gZoom = 1024; - extern int dword_172CE0[16][3]; void viewInit(void) @@ -299,7 +297,6 @@ void viewInit(void) dword_172CE0[i][1] = mulscale16(wrand(), 2048); dword_172CE0[i][2] = mulscale16(wrand(), 2048); } - gViewMap.sub_25C38(0, 0, gZoom, 0); } int othercameradist = 1280; @@ -597,6 +594,21 @@ int gLastPal = 0; int32_t g_frameRate; +static void DrawMap(spritetype* pSprite) +{ + int tm = 0; + if (windowxy1.x > 0) + { + setViewport(Hud_Stbar); + tm = 1; + } + DrawOverheadMap(pSprite->x, pSprite->y, pSprite->ang); + if (tm) + setViewport(hud_size); +} + + + void viewDrawScreen(bool sceneonly) { int nPalette = 0; @@ -985,7 +997,7 @@ void viewDrawScreen(bool sceneonly) UpdateDacs(0, true); // keep the view palette active only for the actual 3D view and its overlays. if (automapMode != am_off) { - gViewMap.sub_25DB0(gView->pSprite); + DrawMap (gView->pSprite); } UpdateStatusBar(); int zn = ((gView->zWeapon-gView->zView-(12<<8))>>7)+220; diff --git a/source/blood/src/view.h b/source/blood/src/view.h index 416cc88fa..656f0db07 100644 --- a/source/blood/src/view.h +++ b/source/blood/src/view.h @@ -127,7 +127,6 @@ enum #define kFontNum 5 -extern int gZoom; extern FFont *gFont[kFontNum]; extern VIEWPOS gViewPos; extern int gViewIndex; diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index de249f658..1e75f97cb 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -50,7 +50,6 @@ struct GameInterface : public ::GameInterface void ExitFromMenu() override; ReservedSpace GetReservedScreenSpace(int viewsize) override; void DrawPlayerSprite(const DVector2& origin, bool onteam) override; - void ResetFollowPos(bool message) override; void GetInput(InputPacket* packet) override; void UpdateSounds() override; void Startup() override; diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 4065583d8..187fcea3c 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -46,11 +46,6 @@ static int lastcontroltime; static double lastCheck; static InputPacket loc; // input accumulation buffer. -void GameInterface::ResetFollowPos(bool message) -{ - if (message) FTA(automapFollow? QUOTE_MAP_FOLLOW_ON : QUOTE_MAP_FOLLOW_OFF, &ps[myconnectindex]); - -} //--------------------------------------------------------------------------- // // handles all HUD related input, i.e. inventory item selection and activation plus weapon selection.