mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
- deal with bad start sectors.
The engine will now try to find a proper sector in the map loader if there's a mismatch.
This commit is contained in:
parent
8575447e37
commit
17de3a08e8
5 changed files with 32 additions and 5 deletions
|
@ -414,6 +414,28 @@ void fixSectors()
|
|||
}
|
||||
}
|
||||
|
||||
void validateStartSector(const char* filename, const vec3_t& pos, int* cursectnum, unsigned numsectors)
|
||||
{
|
||||
|
||||
if ((unsigned)(*cursectnum) >= numsectors)
|
||||
{
|
||||
sectortype* sect = nullptr;
|
||||
updatesectorz(pos.X, pos.Y, pos.Z, §);
|
||||
if (!sect) updatesector(pos.X, pos.Y, §);
|
||||
if (sect)
|
||||
{
|
||||
Printf(PRINT_HIGH, "Error in map %s: Start sector %d out of range. Max. sector is %d\n", filename, *cursectnum, numsectors);
|
||||
*cursectnum = sectnum(sect);
|
||||
}
|
||||
else
|
||||
{
|
||||
I_Error("Unable to start map %s: Start sector %d out of range. Max. sector is %d. No valid location at start spot\n", filename, *cursectnum, numsectors);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void loadMap(const char* filename, int flags, vec3_t* pos, int16_t* ang, int* cursectnum, SpawnSpriteDef& sprites)
|
||||
{
|
||||
inputState.ClearAllInput();
|
||||
|
@ -507,6 +529,7 @@ void loadMap(const char* filename, int flags, vec3_t* pos, int16_t* ang, int* cu
|
|||
|
||||
wallbackup = wall;
|
||||
sectorbackup = sector;
|
||||
validateStartSector(filename, *pos, cursectnum, numsectors);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -648,3 +648,4 @@ void loadMap(const char *filename, int flags, vec3_t *pos, int16_t *ang, int *cu
|
|||
TArray<walltype> loadMapWalls(const char* filename);
|
||||
void loadMapBackup(const char* filename);
|
||||
void loadMapHack(const char* filename, const unsigned char*, SpawnSpriteDef& sprites);
|
||||
void validateStartSector(const char* filename, const vec3_t& pos, int* cursectnum, unsigned numsectors);
|
||||
|
|
|
@ -248,7 +248,9 @@ void StartLevel(MapRecord* level, bool newgame)
|
|||
#endif
|
||||
//drawLoadingScreen();
|
||||
BloodSpawnSpriteDef sprites;
|
||||
dbLoadMap(currentLevel->fileName, (int*)&startpos.X, (int*)&startpos.Y, (int*)&startpos.Z, &startang, &startsector, nullptr, sprites);
|
||||
int startsectno;
|
||||
dbLoadMap(currentLevel->fileName, (int*)&startpos.X, (int*)&startpos.Y, (int*)&startpos.Z, &startang, &startsectno, nullptr, sprites);
|
||||
startsector = §or[startsectno];
|
||||
SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name);
|
||||
STAT_NewLevel(currentLevel->fileName);
|
||||
wsrand(dbReadMapCRC(currentLevel->LabelName()));
|
||||
|
|
|
@ -129,7 +129,7 @@ unsigned int dbReadMapCRC(const char* pPath)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sectortype** ppSector, unsigned int* pCRC, BloodSpawnSpriteDef& sprites)
|
||||
void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int* cursectnum, unsigned int* pCRC, BloodSpawnSpriteDef& sprites)
|
||||
{
|
||||
const int nXSectorSize = 60;
|
||||
const int nXSpriteSize = 56;
|
||||
|
@ -221,7 +221,7 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sect
|
|||
#if 1 // bad, bad hack, just for making Polymost happy...
|
||||
PolymostAllocFakeSector();
|
||||
#endif
|
||||
* ppSector = mapHeader.sect >= 0 ? §or[mapHeader.sect] : nullptr;
|
||||
*cursectnum = mapHeader.sect;
|
||||
|
||||
if (encrypted)
|
||||
{
|
||||
|
@ -673,6 +673,7 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sect
|
|||
sectionGeometry.SetSize(sections.Size());
|
||||
wallbackup = wall;
|
||||
sectorbackup = sector;
|
||||
validateStartSector(mapname.GetChars(), { *pX, *pY, *pZ }, cursectnum, mapHeader.numsectors);
|
||||
}
|
||||
|
||||
|
||||
|
@ -687,6 +688,6 @@ END_BLD_NS
|
|||
void qloadboard(const char* filename, char flags, vec3_t* dapos, int16_t* daang)
|
||||
{
|
||||
Blood::BloodSpawnSpriteDef sprites;
|
||||
sectortype* sp;
|
||||
int sp;
|
||||
Blood::dbLoadMap(filename, &dapos->X, &dapos->Y, &dapos->Z, daang, &sp, nullptr, sprites);
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ DBloodActor* InsertSprite(sectortype* pSector, int nStat);
|
|||
int DeleteSprite(DBloodActor* actor);
|
||||
|
||||
unsigned int dbReadMapCRC(const char* pPath);
|
||||
void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sectortype** pSector, unsigned int* pCRC, BloodSpawnSpriteDef& sprites);
|
||||
void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int* pSector, unsigned int* pCRC, BloodSpawnSpriteDef& sprites);
|
||||
|
||||
|
||||
END_BLD_NS
|
||||
|
|
Loading…
Reference in a new issue