mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
- preparations in the map loader for dynamically sized data storage.
This also consolidates these parts for Blood with the other games.
This commit is contained in:
parent
33a3e0d8bf
commit
7126aa22f4
4 changed files with 47 additions and 16 deletions
|
@ -377,6 +377,7 @@ int32_t engineInit(void);
|
|||
void engineUnInit(void);
|
||||
void initspritelists(void);
|
||||
|
||||
void allocateMapArrays(int numsprites);
|
||||
void ValidateSprite(spritetype& spr);
|
||||
void engineLoadBoard(const char *filename, int flags, vec3_t *dapos, int16_t *daang, int *dacursectnum);
|
||||
void loadMapBackup(const char* filename);
|
||||
|
|
|
@ -46,6 +46,18 @@
|
|||
#include "render.h"
|
||||
#include "hw_sections.h"
|
||||
|
||||
// needed for skipping over to get the map size first.
|
||||
enum
|
||||
{
|
||||
sectorsize5 = 37,
|
||||
sectorsize6 = 37,
|
||||
sectorsize7 = 40,
|
||||
wallsize5 = 35,
|
||||
wallsize6 = 32,
|
||||
wallsize7 = 32,
|
||||
};
|
||||
|
||||
|
||||
static void ReadSectorV7(FileReader& fr, sectortype& sect)
|
||||
{
|
||||
sect.wallptr = fr.ReadInt16();
|
||||
|
@ -375,12 +387,23 @@ static void insertAllSprites(const char* filename, const vec3_t* pos, int* curse
|
|||
|
||||
void addBlockingPairs();
|
||||
|
||||
void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang, int* cursectnum)
|
||||
// allocates global map storage. Blood will also call this.
|
||||
void allocateMapArrays(int numsprites)
|
||||
{
|
||||
inputState.ClearAllInput();
|
||||
|
||||
memset(sector, 0, sizeof(*sector) * MAXSECTORS);
|
||||
memset(wall, 0, sizeof(*wall) * MAXWALLS);
|
||||
memset(sprite, 0, sizeof(*sector) * MAXSPRITES);
|
||||
memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
|
||||
memset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES + MAXUNIQHUDID));
|
||||
|
||||
ClearAutomap();
|
||||
Polymost::Polymost_prepare_loadboard();
|
||||
}
|
||||
|
||||
void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang, int* cursectnum)
|
||||
{
|
||||
inputState.ClearAllInput();
|
||||
|
||||
FileReader fr = fileSystem.OpenFileReader(filename);
|
||||
if (!fr.isOpen()) I_Error("Unable to open map %s", filename);
|
||||
|
@ -390,20 +413,31 @@ void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang,
|
|||
I_Error("%s: Invalid map format, expcted 5-9, got %d", filename, mapversion);
|
||||
}
|
||||
|
||||
memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
|
||||
memset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES + MAXUNIQHUDID));
|
||||
initspritelists();
|
||||
ClearAutomap();
|
||||
Polymost::Polymost_prepare_loadboard();
|
||||
|
||||
pos->x = fr.ReadInt32();
|
||||
pos->y = fr.ReadInt32();
|
||||
pos->z = fr.ReadInt32();
|
||||
*ang = fr.ReadInt16() & 2047;
|
||||
*cursectnum = fr.ReadUInt16();
|
||||
|
||||
// Get the basics out before loading the data so that we can set up the global storage.
|
||||
numsectors = fr.ReadUInt16();
|
||||
if ((unsigned)numsectors > MAXSECTORS) I_Error("%s: Invalid map, too many sectors", filename);
|
||||
auto sectorpos = fr.Tell();
|
||||
fr.Seek((mapversion == 5 ? sectorsize5 : mapversion == 6 ? sectorsize6 : sectorsize7) * numsectors, FileReader::SeekCur);
|
||||
numwalls = fr.ReadUInt16();
|
||||
if ((unsigned)numwalls > MAXWALLS) I_Error("%s: Invalid map, too many walls", filename);
|
||||
auto wallpos = fr.Tell();
|
||||
fr.Seek((mapversion == 5 ? wallsize5 : mapversion == 6 ? wallsize6 : wallsize7)* numwalls, FileReader::SeekCur);
|
||||
int numsprites = fr.ReadUInt16();
|
||||
if ((unsigned)numsprites > MAXSPRITES) I_Error("%s: Invalid map, too many sprites", filename);
|
||||
auto spritepos = fr.Tell();
|
||||
|
||||
// Now that we know the map's size, set up the globals.
|
||||
initspritelists(); // may not be used in Blood!
|
||||
allocateMapArrays(numsprites);
|
||||
|
||||
// Now load the actual data.
|
||||
fr.Seek(sectorpos, FileReader::SeekSet);
|
||||
for (int i = 0; i < numsectors; i++)
|
||||
{
|
||||
switch (mapversion)
|
||||
|
@ -414,8 +448,7 @@ void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang,
|
|||
}
|
||||
}
|
||||
|
||||
numwalls = fr.ReadUInt16();
|
||||
if ((unsigned)numwalls > MAXWALLS) I_Error("%s: Invalid map, too many walls", filename);
|
||||
fr.Seek(wallpos, FileReader::SeekSet);
|
||||
for (int i = 0; i < numwalls; i++)
|
||||
{
|
||||
switch (mapversion)
|
||||
|
@ -426,8 +459,7 @@ void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang,
|
|||
}
|
||||
}
|
||||
|
||||
int numsprites = fr.ReadUInt16();
|
||||
if ((unsigned)numsprites > MAXSPRITES) I_Error("%s: Invalid map, too many sprites", filename);
|
||||
fr.Seek(spritepos, FileReader::SeekSet);
|
||||
for (int i = 0; i < numsprites; i++)
|
||||
{
|
||||
switch (mapversion)
|
||||
|
|
|
@ -503,9 +503,6 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, int
|
|||
gModernMap = false;
|
||||
#endif
|
||||
|
||||
memset(sector, 0, sizeof(sector));
|
||||
memset(wall, 0, sizeof(wall));
|
||||
memset(sprite, 0, sizeof(sprite));
|
||||
memset(xsprite, 0, sizeof(xsprite));
|
||||
|
||||
#ifdef NOONE_EXTENSIONS
|
||||
|
@ -595,6 +592,7 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, int
|
|||
gMapRev = mapHeader.revision;
|
||||
numsectors = mapHeader.numsectors;
|
||||
numwalls = mapHeader.numwalls;
|
||||
allocateMapArrays(mapHeader.numsprites);
|
||||
dbInit();
|
||||
if (encrypted)
|
||||
{
|
||||
|
|
|
@ -979,7 +979,7 @@ static void lotsofpopcorn(DDukeActor *actor, walltype* wal, int n)
|
|||
|
||||
void checkhitwall_r(DDukeActor* spr, walltype* wal, int x, int y, int z, int atwith)
|
||||
{
|
||||
int j, i;
|
||||
int j;
|
||||
int sn = -1, darkestwall;
|
||||
spritetype* s;
|
||||
|
||||
|
|
Loading…
Reference in a new issue