- unlimited the bit arrays for the automap and the bunch drawer, removed some leftover constants/declarations.

This commit is contained in:
Christoph Oelckers 2021-11-21 00:03:56 +01:00
parent d30bf8c8bb
commit d5c27e6239
15 changed files with 38 additions and 39 deletions

View file

@ -61,8 +61,8 @@ int follow_x = INT_MAX, follow_y = INT_MAX, follow_a = INT_MAX;
static int gZoom = 768; static int gZoom = 768;
bool automapping; bool automapping;
bool gFullMap; bool gFullMap;
FixedBitArray<MAXSECTORS> show2dsector; BitArray show2dsector;
FixedBitArray<MAXWALLS> show2dwall; BitArray show2dwall;
static int x_min_bound = INT_MAX, y_min_bound, x_max_bound, y_max_bound; static int x_min_bound = INT_MAX, y_min_bound, x_max_bound, y_max_bound;
CVAR(Color, am_twosidedcolor, 0xaaaaaa, CVAR_ARCHIVE) CVAR(Color, am_twosidedcolor, 0xaaaaaa, CVAR_ARCHIVE)
@ -268,8 +268,8 @@ void SerializeAutomap(FSerializer& arc)
arc("automapping", automapping) arc("automapping", automapping)
("fullmap", gFullMap) ("fullmap", gFullMap)
// Only store what's needed. Unfortunately for sprites it is not that easy // Only store what's needed. Unfortunately for sprites it is not that easy
.SerializeMemory("mappedsectors", show2dsector.Storage(), (numsectors + 7) / 8) .SerializeMemory("mappedsectors", show2dsector.Storage().Data(), (numsectors + 7) / 8)
.SerializeMemory("mappedwalls", show2dwall.Storage(), (numwalls + 7) / 8) .SerializeMemory("mappedwalls", show2dwall.Storage().Data(), (numwalls + 7) / 8)
.EndObject(); .EndObject();
} }
} }

View file

@ -10,8 +10,8 @@ struct event_t;
extern bool automapping; extern bool automapping;
extern bool gFullMap; extern bool gFullMap;
extern FixedBitArray<MAXSECTORS> show2dsector; extern BitArray show2dsector;
extern FixedBitArray<MAXWALLS> show2dwall; extern BitArray show2dwall;
void SerializeAutomap(FSerializer& arc); void SerializeAutomap(FSerializer& arc);
void ClearAutomap(); void ClearAutomap();

View file

@ -184,9 +184,9 @@ void setsectinterpolate(int sectnum)
{ {
StartInterpolation(&wal, Interp_Wall_X); StartInterpolation(&wal, Interp_Wall_X);
StartInterpolation(&wal, Interp_Wall_Y); StartInterpolation(&wal, Interp_Wall_Y);
auto nwal = wal.nextWall(); if (wal.twoSided())
if (nwal)
{ {
auto nwal = wal.nextWall();
StartInterpolation(nwal, Interp_Wall_X); StartInterpolation(nwal, Interp_Wall_X);
StartInterpolation(nwal, Interp_Wall_Y); StartInterpolation(nwal, Interp_Wall_Y);
nwal = nwal->point2Wall(); nwal = nwal->point2Wall();
@ -204,7 +204,7 @@ void clearsectinterpolate(int sectnum)
{ {
StopInterpolation(&wal, Interp_Wall_X); StopInterpolation(&wal, Interp_Wall_X);
StopInterpolation(&wal, Interp_Wall_Y); StopInterpolation(&wal, Interp_Wall_Y);
if (wal.nextwall >= 0) if (wal.twoSided())
{ {
StopInterpolation(wal.nextWall(), Interp_Wall_X); StopInterpolation(wal.nextWall(), Interp_Wall_X);
StopInterpolation(wal.nextWall(), Interp_Wall_Y); StopInterpolation(wal.nextWall(), Interp_Wall_Y);

View file

@ -411,6 +411,9 @@ void allocateMapArrays(int numsprites)
ClearInterpolations(); ClearInterpolations();
show2dsector.Resize(numsectors);
show2dwall.Resize(numwalls);
mapDataArena.FreeAll(); mapDataArena.FreeAll();
sector.Resize(numsectors); sector.Resize(numsectors);
memset(sector.Data(), 0, sizeof(sectortype) * numsectors); memset(sector.Data(), 0, sizeof(sectortype) * numsectors);

View file

@ -76,6 +76,8 @@ void BunchDrawer::Init(HWDrawInfo *_di, Clipper* c, vec2_t& view, binangle a1, b
} }
memset(sectionstartang, -1, sizeof(sectionstartang)); memset(sectionstartang, -1, sizeof(sectionstartang));
memset(sectionendang, -1, sizeof(sectionendang)); memset(sectionendang, -1, sizeof(sectionendang));
gotwall.Resize(numwalls);
blockwall.Resize(numwalls);
} }
//========================================================================== //==========================================================================

View file

@ -29,8 +29,8 @@ class BunchDrawer
float gcosang, gsinang; float gcosang, gsinang;
FixedBitArray<MAXSECTORS> gotsector; FixedBitArray<MAXSECTORS> gotsector;
FixedBitArray<MAXSECTORS*5/4> gotsection2; FixedBitArray<MAXSECTORS*5/4> gotsection2;
FixedBitArray<MAXWALLS> gotwall; BitArray gotwall;
FixedBitArray<MAXWALLS> blockwall; BitArray blockwall;
binangle ang1, ang2, angrange; binangle ang1, ang2, angrange;
int sectionstartang[MAXSECTORS*5/4], sectionendang[MAXSECTORS*5/4]; int sectionstartang[MAXSECTORS*5/4], sectionendang[MAXSECTORS*5/4];

View file

@ -3851,7 +3851,7 @@ void actHitcodeToData(int a1, HITINFO* pHitInfo, DBloodActor** pActor, walltype*
case 0: case 0:
case 4: case 4:
nWall = pHitInfo->hitwall; nWall = pHitInfo->hitwall;
if (nWall >= 0 && nWall < kMaxWalls) pWall = &wall[nWall]; if (validWallIndex(nWall)) pWall = &wall[nWall];
break; break;
default: default:
break; break;
@ -6818,7 +6818,7 @@ bool actCheckRespawn(DBloodActor* actor)
bool actCanSplatWall(int nWall) bool actCanSplatWall(int nWall)
{ {
assert(nWall >= 0 && nWall < kMaxWalls); assert(validWallIndex(nWall));
walltype* pWall = &wall[nWall]; walltype* pWall = &wall[nWall];
if (pWall->cstat & 16384) return 0; if (pWall->cstat & 16384) return 0;
if (pWall->cstat & 32768) return 0; if (pWall->cstat & 32768) return 0;
@ -6895,7 +6895,7 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6,
case 0: case 0:
{ {
int nWall = gHitInfo.hitwall; int nWall = gHitInfo.hitwall;
assert(nWall >= 0 && nWall < kMaxWalls); assert(validWallIndex(nWall));
auto pWall = &wall[nWall]; auto pWall = &wall[nWall];
nSurf = surfType[pWall->picnum]; nSurf = surfType[pWall->picnum];
if (actCanSplatWall(nWall)) if (actCanSplatWall(nWall))
@ -6920,7 +6920,7 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6,
case 4: case 4:
{ {
int nWall = gHitInfo.hitwall; int nWall = gHitInfo.hitwall;
assert(nWall >= 0 && nWall < kMaxWalls); assert(validWallIndex(nWall));
auto pWall = &wall[nWall]; auto pWall = &wall[nWall];
nSurf = surfType[pWall->overpicnum]; nSurf = surfType[pWall->overpicnum];
if (pWall->hasX()) if (pWall->hasX())

View file

@ -35,8 +35,6 @@ void QuitGame(void);
enum enum
{ {
kMaxSectors = MAXSECTORS,
kMaxWalls = MAXWALLS,
kMaxSprites = MAXSPRITES, kMaxSprites = MAXSPRITES,
kMaxTiles = MAXTILES, kMaxTiles = MAXTILES,

View file

@ -145,7 +145,7 @@ void RemoveSpriteStat(int nSprite)
void qinitspritelists(void) // Replace void qinitspritelists(void) // Replace
{ {
for (int i = 0; i <= kMaxSectors; i++) for (int i = 0; i <= MAXSECTORS; i++)
{ {
headspritesect[i] = -1; headspritesect[i] = -1;
} }

View file

@ -33,7 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS BEGIN_BLD_NS
POINT2D baseWall[kMaxWalls];
HITINFO gHitInfo; HITINFO gHitInfo;
bool FindSector(int nX, int nY, int nZ, int *nSector) bool FindSector(int nX, int nY, int nZ, int *nSector)
@ -299,7 +298,7 @@ int GetWallAngle(walltype* pWall)
void GetWallNormal(int nWall, int *pX, int *pY) void GetWallNormal(int nWall, int *pX, int *pY)
{ {
assert(nWall >= 0 && nWall < kMaxWalls); assert(validWallIndex(nWall));
int nWall2 = wall[nWall].point2; int nWall2 = wall[nWall].point2;
int dX = -(wall[nWall2].y - wall[nWall].y); int dX = -(wall[nWall2].y - wall[nWall].y);
dX >>= 4; dX >>= 4;

View file

@ -42,7 +42,6 @@ struct HITINFO {
void set(hitdata_t* hit); void set(hitdata_t* hit);
}; };
extern POINT2D baseWall[kMaxWalls];
extern HITINFO gHitInfo; extern HITINFO gHitInfo;
enum { enum {

View file

@ -716,7 +716,7 @@ void seqProcess(int nTicks)
else if (pInst->type == SS_MASKED) else if (pInst->type == SS_MASKED)
{ {
assert(index >= 0 && index < kMaxWalls); assert(validWallIndex(index));
auto pWall = &wall[index]; auto pWall = &wall[index];
pWall->cstat &= ~(8 + 16 + 32); pWall->cstat &= ~(8 + 16 + 32);
if (pWall->twoSided()) if (pWall->twoSided())

View file

@ -827,8 +827,8 @@ void TranslateSector(int nSector, int a2, int a3, int a4, int a5, int a6, int a7
{ {
for (int i = 0; i < pSector->wallnum; nWall++, i++) for (int i = 0; i < pSector->wallnum; nWall++, i++)
{ {
x = baseWall[nWall].x; x = wall[nWall].baseWall.x;
y = baseWall[nWall].y; y = wall[nWall].baseWall.y;
if (vbp) if (vbp)
RotatePoint((int*)&x, (int*)&y, vbp, a4, a5); RotatePoint((int*)&x, (int*)&y, vbp, a4, a5);
DragPoint(nWall, x+vc-a4, y+v8-a5); DragPoint(nWall, x+vc-a4, y+v8-a5);
@ -839,8 +839,8 @@ void TranslateSector(int nSector, int a2, int a3, int a4, int a5, int a6, int a7
for (int i = 0; i < pSector->wallnum; nWall++, i++) for (int i = 0; i < pSector->wallnum; nWall++, i++)
{ {
int v10 = wall[nWall].point2; int v10 = wall[nWall].point2;
x = baseWall[nWall].x; x = wall[nWall].baseWall.x;
y = baseWall[nWall].y; y = wall[nWall].baseWall.y;
if (wall[nWall].cstat&16384) if (wall[nWall].cstat&16384)
{ {
if (vbp) if (vbp)
@ -848,8 +848,8 @@ void TranslateSector(int nSector, int a2, int a3, int a4, int a5, int a6, int a7
DragPoint(nWall, x+vc-a4, y+v8-a5); DragPoint(nWall, x+vc-a4, y+v8-a5);
if ((wall[v10].cstat&49152) == 0) if ((wall[v10].cstat&49152) == 0)
{ {
x = baseWall[v10].x; x = wall[v10].baseWall.x;
y = baseWall[v10].y; y = wall[v10].baseWall.y;
if (vbp) if (vbp)
RotatePoint((int*)&x, (int*)&y, vbp, a4, a5); RotatePoint((int*)&x, (int*)&y, vbp, a4, a5);
DragPoint(v10, x+vc-a4, y+v8-a5); DragPoint(v10, x+vc-a4, y+v8-a5);
@ -863,8 +863,8 @@ void TranslateSector(int nSector, int a2, int a3, int a4, int a5, int a6, int a7
DragPoint(nWall, x-(vc-a4), y-(v8-a5)); DragPoint(nWall, x-(vc-a4), y-(v8-a5));
if ((wall[v10].cstat&49152) == 0) if ((wall[v10].cstat&49152) == 0)
{ {
x = baseWall[v10].x; x = wall[v10].baseWall.x;
y = baseWall[v10].y; y = wall[v10].baseWall.y;
if (vbp) if (vbp)
RotatePoint((int*)&x, (int*)&y, -vbp, a4, a5); RotatePoint((int*)&x, (int*)&y, -vbp, a4, a5);
DragPoint(v10, x-(vc-a4), y-(v8-a5)); DragPoint(v10, x-(vc-a4), y-(v8-a5));
@ -1997,8 +1997,8 @@ void trInit(void)
gBusyCount = 0; gBusyCount = 0;
for (int i = 0; i < numwalls; i++) for (int i = 0; i < numwalls; i++)
{ {
baseWall[i].x = wall[i].x; wall[i].baseWall.x = wall[i].x;
baseWall[i].y = wall[i].y; wall[i].baseWall.y = wall[i].y;
} }
BloodLinearSpriteIterator it; BloodLinearSpriteIterator it;
while (auto actor = it.Next()) while (auto actor = it.Next())
@ -2053,8 +2053,8 @@ void trInit(void)
TranslateSector(i, 0, -65536, pSprite1->x, pSprite1->y, pSprite1->x, pSprite1->y, pSprite1->ang, pSprite2->x, pSprite2->y, pSprite2->ang, pSector->type == kSectorSlide); TranslateSector(i, 0, -65536, pSprite1->x, pSprite1->y, pSprite1->x, pSprite1->y, pSprite1->ang, pSprite2->x, pSprite2->y, pSprite2->ang, pSector->type == kSectorSlide);
for (int j = 0; j < pSector->wallnum; j++) for (int j = 0; j < pSector->wallnum; j++)
{ {
baseWall[pSector->wallptr+j].x = wall[pSector->wallptr+j].x; wall[pSector->wallptr + j].baseWall.x = wall[pSector->wallptr+j].x;
baseWall[pSector->wallptr+j].y = wall[pSector->wallptr+j].y; wall[pSector->wallptr + j].baseWall.y = wall[pSector->wallptr+j].y;
} }
BloodSectIterator it(i); BloodSectIterator it(i);
while (auto actor = it.Next()) while (auto actor = it.Next())
@ -2072,8 +2072,8 @@ void trInit(void)
TranslateSector(i, 0, -65536, pSprite1->x, pSprite1->y, pSprite1->x, pSprite1->y, 0, pSprite1->x, pSprite1->y, pSprite1->ang, pSector->type == kSectorRotate); TranslateSector(i, 0, -65536, pSprite1->x, pSprite1->y, pSprite1->x, pSprite1->y, 0, pSprite1->x, pSprite1->y, pSprite1->ang, pSector->type == kSectorRotate);
for (int j = 0; j < pSector->wallnum; j++) for (int j = 0; j < pSector->wallnum; j++)
{ {
baseWall[pSector->wallptr+j].x = wall[pSector->wallptr+j].x; wall[pSector->wallptr + j].baseWall.x = wall[pSector->wallptr + j].x;
baseWall[pSector->wallptr+j].y = wall[pSector->wallptr+j].y; wall[pSector->wallptr + j].baseWall.y = wall[pSector->wallptr + j].y;
} }
BloodSectIterator it(i); BloodSectIterator it(i);
while (auto actor = it.Next()) while (auto actor = it.Next())

View file

@ -26,8 +26,6 @@ enum
{ {
kStatIgnited = 404, kStatIgnited = 404,
kMaxSprites = 4096, kMaxSprites = 4096,
kMaxSectors = 1024,
kMaxWalls = 8192,
kMaxVoxels = 4096, kMaxVoxels = 4096,
kMaxPalookups = 256, kMaxPalookups = 256,
kMaxStatus = 1024, kMaxStatus = 1024,

View file

@ -423,7 +423,7 @@ void UndoFlashes()
case 1: case 1:
{ {
assert(nIndex >= 0 && nIndex < kMaxWalls); assert(validWallIndex(nIndex));
pShade = &wall[nIndex].shade; pShade = &wall[nIndex].shade;
break; break;