diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 15fcfe881..4bc01a697 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -778,6 +778,7 @@ set (PCH_SOURCES build/src/voxmodel.cpp core/movie/playmve.cpp + core/automap.cpp core/cheats.cpp core/cheathandler.cpp core/mathutil.cpp diff --git a/source/blood/src/actor.cpp b/source/blood/src/actor.cpp index 69319a7b7..8d3e193a3 100644 --- a/source/blood/src/actor.cpp +++ b/source/blood/src/actor.cpp @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "build.h" +#include "automap.h" #include "pragmas.h" #include "mmulti.h" #include "common.h" @@ -6191,7 +6192,7 @@ spritetype * actSpawnThing(int nSector, int x, int y, int z, int nThingType) pSprite->xrepeat = pThingInfo->xrepeat; if (pThingInfo->yrepeat) pSprite->yrepeat = pThingInfo->yrepeat; - SetBitString(show2dsprite, pSprite->index); + show2dsprite.Set(pSprite->index); switch (nThingType) { case kThingVoodooHead: pXThing->data1 = 0; @@ -6307,7 +6308,7 @@ spritetype* actFireMissile(spritetype *pSprite, int a2, int a3, int a4, int a5, } spritetype *pMissile = actSpawnSprite(pSprite->sectnum, x, y, z, 5, 1); int nMissile = pMissile->index; - SetBitString(show2dsprite, nMissile); + show2dsprite.Set(nMissile); pMissile->type = nType; pMissile->shade = pMissileInfo->shade; pMissile->pal = 0; diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index d2089b917..d8a5d44a4 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "common.h" #include "common_game.h" #include "g_input.h" +#include "automap.h" #include "db.h" #include "blood.h" diff --git a/source/blood/src/db.cpp b/source/blood/src/db.cpp index 59ddb64c5..20da50cca 100644 --- a/source/blood/src/db.cpp +++ b/source/blood/src/db.cpp @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "zstring.h" #include "m_crc32.h" #include "md4.h" +#include "automap.h" //#include "actor.h" #include "globals.h" diff --git a/source/blood/src/messages.cpp b/source/blood/src/messages.cpp index 660daac91..b7aa16109 100644 --- a/source/blood/src/messages.cpp +++ b/source/blood/src/messages.cpp @@ -39,6 +39,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "cheathandler.h" #include "d_protocol.h" #include "gamestate.h" +#include "automap.h" BEGIN_BLD_NS diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index 1d1f0623a..8773daaf9 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -47,6 +47,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "nnexts.h" #include "gstrings.h" #include "gamestate.h" +#include "automap.h" BEGIN_BLD_NS diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index c65c25e8d..c0b45b1e3 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -45,6 +45,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "v_video.h" #include "v_font.h" #include "statusbar.h" +#include "automap.h" #include "glbackend/glbackend.h" BEGIN_BLD_NS diff --git a/source/build/include/build.h b/source/build/include/build.h index 938693037..587a40966 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -435,26 +435,6 @@ EXTERN int16_t headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1]; EXTERN int16_t prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES]; EXTERN int16_t nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; - - //These variables are for auto-mapping with the draw2dscreen function. - //When you load a new board, these bits are all set to 0 - since - //you haven't mapped out anything yet. Note that these arrays are - //bit-mapped. - //If you want draw2dscreen() to show sprite #54 then you say: - // spritenum = 54; - // show2dsprite[spritenum>>3] |= (1<<(spritenum&7)); - //And if you want draw2dscreen() to not show sprite #54 then you say: - // spritenum = 54; - // show2dsprite[spritenum>>3] &= ~(1<<(spritenum&7)); - -EXTERN int automapping; -EXTERN FixedBitArray show2dsector; -EXTERN bool gFullMap; - -EXTERN char show2dwall[(MAXWALLS+7)>>3]; -EXTERN char show2dsprite[(MAXSPRITES+7)>>3]; - - EXTERN uint8_t gotpic[(MAXTILES+7)>>3]; EXTERN char gotsector[(MAXSECTORS+7)>>3]; diff --git a/source/build/include/cstat.h b/source/build/include/cstat.h index 92b98d5b7..51aa9b135 100644 --- a/source/build/include/cstat.h +++ b/source/build/include/cstat.h @@ -1,3 +1,4 @@ +#pragma once // nobody uses these. What's so cool about naked numbers? :( // system defines for status bits diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 89fba4f17..8f138dbbf 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -10,6 +10,7 @@ #include "gl_load.h" #include "build.h" +#include "automap.h" #include "imagehelpers.h" #include "common.h" diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index bb6633fb1..507e2792c 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -6,6 +6,7 @@ Ken Silverman's official web site: http://www.advsys.net/ken #include "build.h" +#include "automap.h" #include "common.h" #include "engine_priv.h" #include "mdsprite.h" @@ -2633,7 +2634,7 @@ void polymost_drawrooms() if (automapping) { for (int z=bunchfirst[closest]; z>=0; z=bunchp2[z]) - show2dwall[thewall[z]>>3] |= pow2char[thewall[z]&7]; + show2dwall.Set(thewall[z]); } numbunches--; @@ -3626,7 +3627,7 @@ void polymost_drawsprite(int32_t snum) } if (automapping == 1 && (unsigned)spritenum < MAXSPRITES) - show2dsprite[spritenum>>3] |= pow2char[spritenum&7]; + show2dsprite.Set(spritenum); _drawsprite_return: ; diff --git a/source/core/automap.cpp b/source/core/automap.cpp new file mode 100644 index 000000000..c554e8ca1 --- /dev/null +++ b/source/core/automap.cpp @@ -0,0 +1,105 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2020 - Christoph Oelckers + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms +Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) +*/ +//------------------------------------------------------------------------- + +#include "automap.h" +#include "cstat.h" +#include "c_dispatch.h" +#include "c_cvars.h" +#include "gstrings.h" +#include "printf.h" + + +bool automapping; +bool gFullMap; +FixedBitArray show2dsector; +FixedBitArray show2dwall; +FixedBitArray show2dsprite; + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +CCMD(allmap) +{ + if (!CheckCheatmode(true, false)) + { + gFullMap = !gFullMap; + Printf("%s\n", GStrings(gFullMap ? "SHOW MAP: ON" : "SHOW MAP: OFF")); + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void ClearAutomap() +{ + show2dsector.Zero(); + show2dwall.Zero(); + show2dsprite.Zero(); +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void MarkSectorSeen(int i) +{ + if (i >= 0) + { + show2dsector.Set(i); + auto wal = &wall[sector[i].wallptr]; + for (int j = sector[i].wallnum; j > 0; j--, wal++) + { + i = wal->nextsector; + if (i < 0) continue; + if (wal->cstat & 0x0071) continue; + if (wall[wal->nextwall].cstat & 0x0071) continue; + if (sector[i].lotag == 32767) continue; + if (sector[i].ceilingz >= sector[i].floorz) continue; + show2dsector.Set(i); + } + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void DrawOverheadMap(int pl_x, int pl_y, int pl_angle) +{ +} + diff --git a/source/core/automap.h b/source/core/automap.h new file mode 100644 index 000000000..0d14a7998 --- /dev/null +++ b/source/core/automap.h @@ -0,0 +1,16 @@ +#pragma once + +#include "tarray.h" +#include "build.h" + +extern bool automapping; +extern bool gFullMap; +extern FixedBitArray show2dsector; +extern FixedBitArray show2dwall; +extern FixedBitArray show2dsprite; + + +void ClearAutomap(); +void MarkSectorSeen(int sect); +void DrawOverheadMap(int x, int y, int ang); + diff --git a/source/core/cheats.cpp b/source/core/cheats.cpp index 2c63150bc..ade259f82 100644 --- a/source/core/cheats.cpp +++ b/source/core/cheats.cpp @@ -150,15 +150,6 @@ CCMD(noclip) } } -CCMD(allmap) -{ - if (!CheckCheatmode(true, false)) - { - gFullMap = !gFullMap; - Printf("%s\n", GStrings(gFullMap ? "SHOW MAP: ON" : "SHOW MAP: OFF")); - } -} - //--------------------------------------------------------------------------- // // diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 5748649c5..c4215d732 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -57,12 +57,6 @@ void CONFIG_ReadCombatMacros(); int GameMain(); int GetAutomapZoom(int gZoom); -// transitional helper inlines to define the interface before rewriting the code. -inline void ClearAutomap() {} -inline void MarkSectorSeen(int sect) {} -inline void DrawOverheadMap(int x, int y, int ang) {} - - void DrawCrosshair(int deftile, int health, double xdelta, double scale, PalEntry color = 0xffffffff); void updatePauseStatus(); void DeferedStartGame(MapRecord* map, int skill); diff --git a/source/core/savegamehelp.cpp b/source/core/savegamehelp.cpp index 4e9f0b66a..965553c68 100644 --- a/source/core/savegamehelp.cpp +++ b/source/core/savegamehelp.cpp @@ -474,7 +474,6 @@ void SaveEngineState() fw->Write(connectpoint2, sizeof(connectpoint2)); fw->Write(&randomseed, sizeof(randomseed)); fw->Write(&numshades, sizeof(numshades)); - fw->Write(&automapping, sizeof(automapping)); fw->Write(&showinvisibility, sizeof(showinvisibility)); WriteMagic(fw); @@ -532,7 +531,6 @@ void LoadEngineState() fr.Read(connectpoint2, sizeof(connectpoint2)); fr.Read(&randomseed, sizeof(randomseed)); fr.Read(&numshades, sizeof(numshades)); - fr.Read(&automapping, sizeof(automapping)); fr.Read(&showinvisibility, sizeof(showinvisibility)); CheckMagic(fr); diff --git a/source/exhumed/src/cheats.cpp b/source/exhumed/src/cheats.cpp index 06cb41dda..8f7258d36 100644 --- a/source/exhumed/src/cheats.cpp +++ b/source/exhumed/src/cheats.cpp @@ -16,6 +16,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- #include "ns.h" +#include "automap.h" #include "compat.h" #include "common.h" #include "engine.h" diff --git a/source/exhumed/src/init.cpp b/source/exhumed/src/init.cpp index 5912407bf..8383366b6 100644 --- a/source/exhumed/src/init.cpp +++ b/source/exhumed/src/init.cpp @@ -16,6 +16,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- #include "ns.h" +#include "automap.h" #include "compat.h" #include "aistuff.h" #include "player.h" diff --git a/source/exhumed/src/map.cpp b/source/exhumed/src/map.cpp index 3594b4c68..086debc6e 100644 --- a/source/exhumed/src/map.cpp +++ b/source/exhumed/src/map.cpp @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "exhumed.h" #include "view.h" #include "v_2ddrawer.h" +#include "automap.h" BEGIN_PS_NS diff --git a/source/games/duke/src/cheats.cpp b/source/games/duke/src/cheats.cpp index 7c31f80e1..f02768441 100644 --- a/source/games/duke/src/cheats.cpp +++ b/source/games/duke/src/cheats.cpp @@ -40,6 +40,7 @@ source as it is released. #include "cheathandler.h" #include "c_dispatch.h" #include "gamestate.h" +#include "automap.h" EXTERN_CVAR(Int, developer) EXTERN_CVAR(Bool, sv_cheats) diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index ddd5b4f44..cb4afe101 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -31,6 +31,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "ns.h" // Must come before everything else! +#include "automap.h" #include "duke3d.h" #include "m_argv.h" #include "mapinfo.h" diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index a54d49ddf..d3fbc24f1 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -33,6 +33,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms #include "statistics.h" #include "gamestate.h" #include "sbar.h" +#include "automap.h" BEGIN_DUKE_NS diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index efeb59152..defe73320 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -36,6 +36,7 @@ source as it is released. #include "ns.h" #include "global.h" #include "sounds.h" +#include "automap.h" BEGIN_DUKE_NS @@ -115,8 +116,8 @@ short EGS(short whatsect, int s_x, int s_y, int s_z, short s_pn, signed char s_s s->hitag = 0; } - if (show2dsector[s->sectnum]) show2dsprite[i >> 3] |= (1 << (i & 7)); - else show2dsprite[i >> 3] &= ~(1 << (i & 7)); + if (show2dsector[s->sectnum]) show2dsprite.Set(i); + else show2dsprite.Clear(i); spriteext[i] = {}; spritesmooth[i] = {}; diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index e694925be..64ee08af6 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -27,6 +27,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #define QUIET #include "build.h" +#include "automap.h" #include "pragmas.h" diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index f6bf7063a..5a3bd88f8 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -42,6 +42,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "lists.h" #include "network.h" #include "pal.h" +#include "automap.h" #include "mytypes.h"