- hooked up the new automap framework.

This commit is contained in:
Christoph Oelckers 2020-09-06 12:44:58 +02:00
parent a6c92aec64
commit 809f8b5d4b
25 changed files with 146 additions and 43 deletions

View file

@ -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

View file

@ -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;

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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<MAXSECTORS> 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];

View file

@ -1,3 +1,4 @@
#pragma once
// nobody uses these. What's so cool about naked numbers? :(
// system defines for status bits

View file

@ -10,6 +10,7 @@
#include "gl_load.h"
#include "build.h"
#include "automap.h"
#include "imagehelpers.h"
#include "common.h"

View file

@ -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:
;

105
source/core/automap.cpp Normal file
View file

@ -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<MAXSECTORS> show2dsector;
FixedBitArray<MAXWALLS> show2dwall;
FixedBitArray<MAXSPRITES> 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)
{
}

16
source/core/automap.h Normal file
View file

@ -0,0 +1,16 @@
#pragma once
#include "tarray.h"
#include "build.h"
extern bool automapping;
extern bool gFullMap;
extern FixedBitArray<MAXSECTORS> show2dsector;
extern FixedBitArray<MAXWALLS> show2dwall;
extern FixedBitArray<MAXSPRITES> show2dsprite;
void ClearAutomap();
void MarkSectorSeen(int sect);
void DrawOverheadMap(int x, int y, int ang);

View file

@ -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"));
}
}
//---------------------------------------------------------------------------
//
//

View file

@ -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);

View file

@ -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);

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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)

View file

@ -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"

View file

@ -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

View file

@ -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] = {};

View file

@ -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"

View file

@ -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"