mirror of
https://github.com/DrBeef/Raze.git
synced 2025-04-01 21:50:51 +00:00
- migrated Blood's xsector and got rid of the static global array.
This commit is contained in:
parent
993821b75f
commit
e034635e12
4 changed files with 9 additions and 46 deletions
|
@ -152,8 +152,8 @@ struct sectortype
|
|||
|
||||
|
||||
// These will unfortunately have to be within the base struct to refactor Blood properly. They can later be removed again, once everything is done.
|
||||
Blood::XSECTOR& xs() const;
|
||||
bool hasX() const { return extra > 0; } // 0 is invalid!
|
||||
Blood::XSECTOR& xs() const { return *_xs; }
|
||||
bool hasX() const { return _xs != nullptr; } // 0 is invalid!
|
||||
void allocX();
|
||||
|
||||
// same for SW
|
||||
|
|
|
@ -44,11 +44,6 @@ DBloodActor bloodActors[kMaxSprites];
|
|||
bool gModernMap = false;
|
||||
unsigned int gStatCount[kMaxStatus + 1];
|
||||
|
||||
XSECTOR xsector[kMaxXSectors];
|
||||
int XSectorsUsed;
|
||||
|
||||
|
||||
|
||||
int gVisibility;
|
||||
|
||||
void dbCrypt(char *pPtr, int nLength, int nKey)
|
||||
|
@ -248,21 +243,8 @@ void InitFreeList(unsigned short* pList, int nCount)
|
|||
}
|
||||
|
||||
|
||||
unsigned int dbInsertXSector(int nSector)
|
||||
{
|
||||
int nXSector = XSectorsUsed++;
|
||||
if (nXSector >= kMaxXSectors)
|
||||
{
|
||||
I_Error("Out of free XSectors");
|
||||
}
|
||||
memset(&xsector[nXSector], 0, sizeof(XSECTOR));
|
||||
sector[nSector].extra = nXSector;
|
||||
return nXSector;
|
||||
}
|
||||
|
||||
void dbInit(void)
|
||||
{
|
||||
XSectorsUsed = 1; // 0 is not usable because it's the default for 'extra' and some code actually uses it to clobber the contents in here. :(
|
||||
initspritelists();
|
||||
for (int i = 0; i < kMaxSprites; i++)
|
||||
{
|
||||
|
@ -573,12 +555,11 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int*
|
|||
pSector->exflags = 0;
|
||||
pSector->fogpal = 0;
|
||||
|
||||
if (sector[i].extra > 0)
|
||||
if (pSector->extra > 0)
|
||||
{
|
||||
char pBuffer[nXSectorSize];
|
||||
int nXSector = dbInsertXSector(i);
|
||||
XSECTOR* pXSector = &xsector[nXSector];
|
||||
memset(pXSector, 0, sizeof(XSECTOR));
|
||||
pSector->allocX();
|
||||
XSECTOR* pXSector = &pSector->xs();
|
||||
int nCount;
|
||||
if (!encrypted)
|
||||
{
|
||||
|
@ -934,9 +915,9 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int*
|
|||
for (int i = 0; i < numsectors; i++)
|
||||
{
|
||||
sectortype* pSector = §or[i];
|
||||
if (pSector->extra > 0)
|
||||
if (pSector->hasX())
|
||||
{
|
||||
XSECTOR* pXSector = &xsector[pSector->extra];
|
||||
XSECTOR* pXSector = &pSector->xs();
|
||||
pXSector->busyTimeB = pXSector->busyTimeA;
|
||||
if (pXSector->busyTimeA > 0)
|
||||
{
|
||||
|
@ -958,9 +939,9 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int*
|
|||
for (int i = 0; i < numsectors; i++)
|
||||
{
|
||||
sectortype* pSector = §or[i];
|
||||
if (pSector->extra > 0)
|
||||
if (pSector->hasX())
|
||||
{
|
||||
XSECTOR* pXSector = &xsector[pSector->extra];
|
||||
XSECTOR* pXSector = &pSector->xs();
|
||||
pXSector->freq >>= 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,12 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
kMaxXSectors = 512
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
kAttrMove = 0x0001, // is affected by movement physics
|
||||
|
@ -85,16 +79,12 @@ extern unsigned int gStatCount[kMaxStatus + 1];;
|
|||
extern bool drawtile2048, encrypted;
|
||||
extern MAPHEADER2 byte_19AE44;
|
||||
|
||||
extern XSECTOR xsector[kMaxXSectors];
|
||||
|
||||
extern int gVisibility;
|
||||
extern int gMapRev, gMattId, gSkyCount;
|
||||
extern const char *gItemText[];
|
||||
extern const char *gAmmoText[];
|
||||
extern const char *gWeaponText[];
|
||||
|
||||
extern int XSectorsUsed;
|
||||
|
||||
static inline int GetWallType(int nWall)
|
||||
{
|
||||
return wall[nWall].type;
|
||||
|
@ -145,9 +135,3 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int*
|
|||
|
||||
|
||||
END_BLD_NS
|
||||
|
||||
// refactoring aids.
|
||||
inline Blood::XSECTOR& sectortype::xs() const
|
||||
{
|
||||
return Blood::xsector[extra];
|
||||
}
|
||||
|
|
|
@ -713,7 +713,6 @@ void SerializeState(FSerializer& arc)
|
|||
.Array("basewall", baseWall, numwalls)
|
||||
("hitinfo", gHitInfo)
|
||||
.Array("statcount", gStatCount, kMaxStatus + 1)
|
||||
("xsectorsused", XSectorsUsed)
|
||||
("fogmode", gFogMode)
|
||||
#ifdef NOONE_EXTENSIONS
|
||||
("modern", gModernMap)
|
||||
|
@ -727,7 +726,6 @@ void SerializeState(FSerializer& arc)
|
|||
("numtiles", pSky->lognumtiles)
|
||||
("gameoptions", gGameOptions)
|
||||
|
||||
.Array("xsector", xsector, XSectorsUsed)
|
||||
.SparseArray("actors", bloodActors, kMaxSprites, activeSprites);
|
||||
|
||||
arc.EndObject();
|
||||
|
|
Loading…
Reference in a new issue