mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- changed map loader to work without relying on spritetype::sectnum.
All access to this field is done through access functions now.
This commit is contained in:
parent
8ee5d1b0d7
commit
2d913982da
7 changed files with 37 additions and 23 deletions
|
@ -324,7 +324,7 @@ struct SpawnSpriteDef
|
|||
void insertAllSprites(SpawnSpriteDef& sprites);
|
||||
|
||||
void allocateMapArrays(int numsprites);
|
||||
void ValidateSprite(spritetype& spr, int index);
|
||||
void ValidateSprite(spritetype& spr, int secno, int index);
|
||||
void engineLoadBoard(const char *filename, int flags, vec3_t *dapos, int16_t *daang, int *dacursectnum, SpawnSpriteDef& sprites);
|
||||
void loadMapBackup(const char* filename);
|
||||
void G_LoadMapHack(const char* filename, const unsigned char*, SpawnSpriteDef& sprites);
|
||||
|
@ -614,12 +614,23 @@ inline sectortype* spritetypebase::sector() const
|
|||
return !validSectorIndex(sectnum)? nullptr : &::sector[sectnum];
|
||||
}
|
||||
|
||||
inline int spritetypebase::sectno() const
|
||||
{
|
||||
return sectnum;
|
||||
}
|
||||
|
||||
inline void spritetypebase::setsector(sectortype* sect)
|
||||
{
|
||||
// place for asserts.
|
||||
sectnum = sect? ::sector.IndexOf(sect) : -1;
|
||||
}
|
||||
|
||||
inline void spritetypebase::setsector(int sec)
|
||||
{
|
||||
// place for asserts.
|
||||
sectnum = validSectorIndex(sec)? sec : -1;
|
||||
}
|
||||
|
||||
inline bool spritetypebase::insector() const
|
||||
{
|
||||
return validSectorIndex(sectnum);
|
||||
|
|
|
@ -408,8 +408,10 @@ struct spritetypebase
|
|||
}
|
||||
|
||||
sectortype* sector() const;
|
||||
int sectno() const;
|
||||
bool insector() const;
|
||||
void setsector(sectortype*);
|
||||
void setsector(int);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ class TObjPtr
|
|||
public:
|
||||
TObjPtr() = default;
|
||||
|
||||
TObjPtr(const TObjPtr<T> &q) = delete;
|
||||
TObjPtr(const TObjPtr<T> &q) = default;
|
||||
|
||||
TObjPtr(T q) noexcept
|
||||
: pp(q)
|
||||
|
|
|
@ -257,7 +257,7 @@ static void AddSectHead(DCoreActor *actor, sectortype* sect)
|
|||
else sect->lastEntry = actor;
|
||||
sect->firstEntry = actor;
|
||||
assert(ValidateSectList(sect));
|
||||
actor->s().sectnum = sectnum(sect);
|
||||
actor->s().setsector(sect);
|
||||
actor->link_sector = sect;
|
||||
GC::WriteBarrier(actor);
|
||||
GC::WriteBarrier(head);
|
||||
|
|
|
@ -160,7 +160,7 @@ static int32_t LoadMapHack(const char *filename, SpawnSpriteDef& sprites)
|
|||
{
|
||||
if (currentsprite != -1 && validateSprite())
|
||||
{
|
||||
sprites.sprites[currentsprite].sectnum = sc.Number;
|
||||
sprites.sprites[currentsprite].setsector(sc.Number);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ static void SetWallPalV5()
|
|||
}
|
||||
}
|
||||
|
||||
void ValidateSprite(spritetype& spr, int index)
|
||||
void ValidateSprite(spritetype& spr, int sectnum, int index)
|
||||
{
|
||||
bool bugged = false;
|
||||
if ((unsigned)spr.statnum >= MAXSTATUS)
|
||||
|
@ -250,27 +250,27 @@ void ValidateSprite(spritetype& spr, int index)
|
|||
Printf("Sprite #%d (%d,%d) has invalid picnum %d.\n", index, spr.x, spr.y, spr.picnum);
|
||||
bugged = true;
|
||||
}
|
||||
else if (!validSectorIndex(spr.sectnum))
|
||||
else if (!validSectorIndex(sectnum))
|
||||
{
|
||||
int sectnum = -1;
|
||||
sectnum = -1;
|
||||
updatesector(spr.x, spr.y, §num);
|
||||
bugged = sectnum < 0;
|
||||
|
||||
if (!DPrintf(DMSG_WARNING, "Sprite #%d (%d,%d) with invalid sector %d was corrected to sector %d\n", index, spr.x, spr.y, spr.sectnum, sectnum))
|
||||
if (!DPrintf(DMSG_WARNING, "Sprite #%d (%d,%d) with invalid sector %d was corrected to sector %d\n", index, spr.x, spr.y, sectnum, sectnum))
|
||||
{
|
||||
if (bugged) Printf("Sprite #%d (%d,%d) with invalid sector %d\n", index, spr.x, spr.y, spr.sectnum);
|
||||
if (bugged) Printf("Sprite #%d (%d,%d) with invalid sector %d\n", index, spr.x, spr.y, sectnum);
|
||||
}
|
||||
spr.sectnum = sectnum;
|
||||
}
|
||||
if (bugged)
|
||||
{
|
||||
spr.clear();
|
||||
spr.statnum = MAXSTATUS;
|
||||
spr.sectnum = MAXSECTORS;
|
||||
sectnum = -1;
|
||||
}
|
||||
spr.setsector(sectnum);
|
||||
}
|
||||
|
||||
static void ReadSpriteV7(FileReader& fr, spritetype& spr)
|
||||
static void ReadSpriteV7(FileReader& fr, spritetype& spr, int& secno)
|
||||
{
|
||||
spr.pos.x = fr.ReadInt32();
|
||||
spr.pos.y = fr.ReadInt32();
|
||||
|
@ -285,7 +285,7 @@ static void ReadSpriteV7(FileReader& fr, spritetype& spr)
|
|||
spr.yrepeat = fr.ReadUInt8();
|
||||
spr.xoffset = fr.ReadInt8();
|
||||
spr.yoffset = fr.ReadInt8();
|
||||
spr.sectnum = fr.ReadInt16();
|
||||
secno = fr.ReadInt16();
|
||||
spr.statnum = fr.ReadInt16();
|
||||
spr.ang = fr.ReadInt16();
|
||||
spr.owner = fr.ReadInt16();
|
||||
|
@ -298,7 +298,7 @@ static void ReadSpriteV7(FileReader& fr, spritetype& spr)
|
|||
spr.detail = 0;
|
||||
}
|
||||
|
||||
static void ReadSpriteV6(FileReader& fr, spritetype& spr)
|
||||
static void ReadSpriteV6(FileReader& fr, spritetype& spr, int& secno)
|
||||
{
|
||||
spr.pos.x = fr.ReadInt32();
|
||||
spr.pos.y = fr.ReadInt32();
|
||||
|
@ -317,7 +317,7 @@ static void ReadSpriteV6(FileReader& fr, spritetype& spr)
|
|||
spr.yvel = fr.ReadInt16();
|
||||
spr.zvel = fr.ReadInt16();
|
||||
spr.owner = fr.ReadInt16();
|
||||
spr.sectnum = fr.ReadInt16();
|
||||
secno = fr.ReadInt16();
|
||||
spr.statnum = fr.ReadInt16();
|
||||
spr.lotag = fr.ReadInt16();
|
||||
spr.hitag = fr.ReadInt16();
|
||||
|
@ -326,7 +326,7 @@ static void ReadSpriteV6(FileReader& fr, spritetype& spr)
|
|||
spr.detail = 0;
|
||||
}
|
||||
|
||||
static void ReadSpriteV5(FileReader& fr, spritetype& spr)
|
||||
static void ReadSpriteV5(FileReader& fr, spritetype& spr, int& secno)
|
||||
{
|
||||
spr.pos.x = fr.ReadInt32();
|
||||
spr.pos.y = fr.ReadInt32();
|
||||
|
@ -341,7 +341,7 @@ static void ReadSpriteV5(FileReader& fr, spritetype& spr)
|
|||
spr.yvel = fr.ReadInt16();
|
||||
spr.zvel = fr.ReadInt16();
|
||||
spr.owner = fr.ReadInt16();
|
||||
spr.sectnum = fr.ReadInt16();
|
||||
secno = fr.ReadInt16();
|
||||
spr.statnum = fr.ReadInt16();
|
||||
spr.lotag = fr.ReadInt16();
|
||||
spr.hitag = fr.ReadInt16();
|
||||
|
@ -446,13 +446,14 @@ void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang,
|
|||
fr.Seek(spritepos, FileReader::SeekSet);
|
||||
for (int i = 0; i < numsprites; i++)
|
||||
{
|
||||
int secno = -1;
|
||||
switch (mapversion)
|
||||
{
|
||||
case 5: ReadSpriteV5(fr, sprites.sprites[i]); break;
|
||||
case 6: ReadSpriteV6(fr, sprites.sprites[i]); break;
|
||||
default: ReadSpriteV7(fr, sprites.sprites[i]); break;
|
||||
case 5: ReadSpriteV5(fr, sprites.sprites[i], secno); break;
|
||||
case 6: ReadSpriteV6(fr, sprites.sprites[i], secno); break;
|
||||
default: ReadSpriteV7(fr, sprites.sprites[i], secno); break;
|
||||
}
|
||||
ValidateSprite(sprites.sprites[i], i);
|
||||
ValidateSprite(sprites.sprites[i], secno, i);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -532,7 +532,7 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sect
|
|||
pSprite->z = LittleLong(load.z);
|
||||
pSprite->cstat = LittleShort(load.cstat);
|
||||
pSprite->picnum = LittleShort(load.picnum);
|
||||
pSprite->sectnum = LittleShort(load.sectnum);
|
||||
int secno = LittleShort(load.sectnum);
|
||||
pSprite->statnum = LittleShort(load.statnum);
|
||||
pSprite->ang = LittleShort(load.ang);
|
||||
pSprite->owner = LittleShort(load.owner);
|
||||
|
@ -552,7 +552,7 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sect
|
|||
pSprite->shade = load.shade;
|
||||
pSprite->blend = 0;
|
||||
pSprite->time = i;
|
||||
ValidateSprite(*pSprite, i);
|
||||
ValidateSprite(*pSprite, secno, i);
|
||||
|
||||
if (pSprite->extra > 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue