- made wall flags type safe

This commit is contained in:
Christoph Oelckers 2021-12-18 15:36:50 +01:00
parent 1e30f461e6
commit 8f012d1beb
8 changed files with 20 additions and 18 deletions

View file

@ -451,7 +451,7 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
int const initialsectnum = *sectnum; int const initialsectnum = *sectnum;
int32_t const dawalclipmask = (cliptype & 65535); // CLIPMASK0 = 0x00010001 int32_t const dawalclipmask = (cliptype & 65535); // CLIPMASK0 = 0x00010001 (in desperate need of getting fixed!)
int32_t const dasprclipmask = (cliptype >> 16); // CLIPMASK1 = 0x01000040 int32_t const dasprclipmask = (cliptype >> 16); // CLIPMASK1 = 0x01000040
vec2_t const move = { xvect, yvect }; vec2_t const move = { xvect, yvect };
@ -514,7 +514,7 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
int clipyou = 0; int clipyou = 0;
if (wal->nextsector < 0 || (wal->cstat&dawalclipmask)) if (wal->nextsector < 0 || (wal->cstat & EWallFlags::FromInt(dawalclipmask)))
{ {
clipyou = 1; clipyou = 1;
} }
@ -879,7 +879,7 @@ int pushmove_(vec3_t *const vect, int *const sectnum,
if (clipinsidebox(&vect->vec2, i, walldist-4) == 1) if (clipinsidebox(&vect->vec2, i, walldist-4) == 1)
{ {
int j = 0; int j = 0;
if (wal->nextsector < 0 || wal->cstat&dawalclipmask) j = 1; if (wal->nextsector < 0 || wal->cstat & EWallFlags::FromInt(dawalclipmask)) j = 1;
else else
{ {
int32_t daz2; int32_t daz2;
@ -1005,7 +1005,7 @@ void getzrange(const vec3_t& pos, sectortype* sect, int32_t* ceilz, CollisionBas
if (da.x >= da.y) if (da.x >= da.y)
continue; continue;
if (wal.cstat&dawalclipmask) continue; // XXX? if (wal.cstat & EWallFlags::FromInt(dawalclipmask)) continue; // XXX?
if (((nextsect->ceilingstat & CSTAT_SECTOR_SKY) == 0) && (pos.z <= nextsect->ceilingz+(3<<8))) continue; if (((nextsect->ceilingstat & CSTAT_SECTOR_SKY) == 0) && (pos.z <= nextsect->ceilingz+(3<<8))) continue;
if (((nextsect->floorstat & CSTAT_SECTOR_SKY) == 0) && (pos.z >= nextsect->floorz-(3<<8))) continue; if (((nextsect->floorstat & CSTAT_SECTOR_SKY) == 0) && (pos.z >= nextsect->floorz-(3<<8))) continue;
@ -1297,7 +1297,7 @@ int hitscan(const vec3_t& start, const sectortype* startsect, const vec3_t& dire
if (!curspr) if (!curspr)
{ {
if ((!wal->twoSided()) || (wal->cstat&dawalclipmask)) if ((!wal->twoSided()) || (wal->cstat & EWallFlags::FromInt(dawalclipmask)))
{ {
hit_set(&hitinfo, sec, wal, nullptr, intx, inty, intz); hit_set(&hitinfo, sec, wal, nullptr, intx, inty, intz);
continue; continue;

View file

@ -221,7 +221,7 @@ static int32_t LoadMapHack(const char *filename, SpawnSpriteDef& sprites)
{ {
if (currentwall != -1 && validateWall()) if (currentwall != -1 && validateWall())
{ {
wall[currentwall].cstat &= ~sc.Number; wall[currentwall].cstat &= EWallFlags::FromInt(~sc.Number);
} }
else if (currentsprite != -1 && validateSprite()) else if (currentsprite != -1 && validateSprite())
{ {
@ -235,7 +235,7 @@ static int32_t LoadMapHack(const char *filename, SpawnSpriteDef& sprites)
{ {
if (currentwall != -1 && validateWall()) if (currentwall != -1 && validateWall())
{ {
wall[currentwall].cstat |= sc.Number; wall[currentwall].cstat |= EWallFlags::FromInt(sc.Number);
} }
else if (currentsprite != -1 && validateSprite()) else if (currentsprite != -1 && validateSprite())
{ {

View file

@ -184,7 +184,7 @@ static void ReadWallV7(FileReader& fr, walltype& wall)
wall.point2 = fr.ReadInt16(); wall.point2 = fr.ReadInt16();
wall.nextwall = fr.ReadInt16(); wall.nextwall = fr.ReadInt16();
wall.nextsector = fr.ReadInt16(); wall.nextsector = fr.ReadInt16();
wall.cstat = fr.ReadUInt16(); wall.cstat = EWallFlags::FromInt(fr.ReadUInt16());
wall.picnum = fr.ReadInt16(); wall.picnum = fr.ReadInt16();
wall.overpicnum = fr.ReadInt16(); wall.overpicnum = fr.ReadInt16();
wall.shade = fr.ReadInt8(); wall.shade = fr.ReadInt8();
@ -209,7 +209,7 @@ static void ReadWallV6(FileReader& fr, walltype& wall)
wall.overpicnum = fr.ReadInt16(); wall.overpicnum = fr.ReadInt16();
wall.shade = fr.ReadInt8(); wall.shade = fr.ReadInt8();
wall.pal = fr.ReadUInt8(); wall.pal = fr.ReadUInt8();
wall.cstat = fr.ReadUInt16(); wall.cstat = EWallFlags::FromInt(fr.ReadUInt16());
wall.xrepeat = fr.ReadUInt8(); wall.xrepeat = fr.ReadUInt8();
wall.yrepeat = fr.ReadUInt8(); wall.yrepeat = fr.ReadUInt8();
wall.xpan_ = fr.ReadUInt8(); wall.xpan_ = fr.ReadUInt8();
@ -227,7 +227,7 @@ static void ReadWallV5(FileReader& fr, walltype& wall)
wall.picnum = fr.ReadInt16(); wall.picnum = fr.ReadInt16();
wall.overpicnum = fr.ReadInt16(); wall.overpicnum = fr.ReadInt16();
wall.shade = fr.ReadInt8(); wall.shade = fr.ReadInt8();
wall.cstat = fr.ReadUInt16(); wall.cstat = EWallFlags::FromInt(fr.ReadUInt16());
wall.xrepeat = fr.ReadUInt8(); wall.xrepeat = fr.ReadUInt8();
wall.yrepeat = fr.ReadUInt8(); wall.yrepeat = fr.ReadUInt8();
wall.xpan_ = fr.ReadUInt8(); wall.xpan_ = fr.ReadUInt8();

View file

@ -116,6 +116,9 @@ enum EWallBits // names are from Shadow Warrior
}; };
typedef TFlags<EWallBits, uint16_t> EWallFlags;
DEFINE_TFLAGS_OPERATORS(EWallFlags)
enum ESpriteBits // names mostly from SW. enum ESpriteBits // names mostly from SW.
{ {
CSTAT_SPRITE_BLOCK = 1, // bit 0: 1 = Blocking sprite (use with clipmove, getzrange) "B" CSTAT_SPRITE_BLOCK = 1, // bit 0: 1 = Blocking sprite (use with clipmove, getzrange) "B"
@ -312,7 +315,7 @@ struct walltype
float xpan_; float xpan_;
float ypan_; float ypan_;
uint16_t cstat; EWallFlags cstat;
int16_t picnum; int16_t picnum;
int16_t overpicnum; int16_t overpicnum;
union { int16_t lotag, type; }; // type is for Blood union { int16_t lotag, type; }; // type is for Blood

View file

@ -5384,7 +5384,7 @@ int MoveMissile(DBloodActor* actor)
if (pXWall->triggerVector) if (pXWall->triggerVector)
{ {
trTriggerWall(pWall, kCmdWallImpact); trTriggerWall(pWall, kCmdWallImpact);
if (!(pWall->cstat & 64)) if (!(pWall->cstat & CSTAT_WALL_BLOCK_HITSCAN))
{ {
cliptype = -1; cliptype = -1;
if (i-- > 0) if (i-- > 0)
@ -6814,8 +6814,7 @@ bool actCheckRespawn(DBloodActor* actor)
bool actCanSplatWall(walltype* pWall) bool actCanSplatWall(walltype* pWall)
{ {
if (pWall->cstat & 16384) return 0; if (pWall->cstat & (CSTAT_WALL_MOVE_MASK)) return 0;
if (pWall->cstat & 32768) return 0;
int nType = pWall->type; int nType = pWall->type;
if (nType >= kWallBase && nType < kWallMax) return 0; if (nType >= kWallBase && nType < kWallMax) return 0;

View file

@ -445,8 +445,8 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, sect
pWall->point2 = LittleShort(load.point2); pWall->point2 = LittleShort(load.point2);
pWall->nextwall = LittleShort(load.nextwall); pWall->nextwall = LittleShort(load.nextwall);
pWall->nextsector = LittleShort(load.nextsector); pWall->nextsector = LittleShort(load.nextsector);
pWall->cstat = LittleShort(load.cstat); pWall->cstat = EWallFlags::FromInt(LittleShort(load.cstat));
pWall->picnum = LittleShort(load.picnum); pWall->picnum = EWallFlags::FromInt(LittleShort(load.picnum));
pWall->overpicnum = LittleShort(load.overpicnum); pWall->overpicnum = LittleShort(load.overpicnum);
pWall->type = LittleShort(load.type); pWall->type = LittleShort(load.type);
pWall->hitag = LittleShort(load.hitag); pWall->hitag = LittleShort(load.hitag);

View file

@ -3782,7 +3782,7 @@ bool condCheckMixed(DBloodActor* aCond, const EVENT& event, int cmpOp, bool PUSH
case 25: return condCmp(pObj->picnum, arg1, arg2, cmpOp); case 25: return condCmp(pObj->picnum, arg1, arg2, cmpOp);
case 26: return condCmp(pObj->pal, arg1, arg2, cmpOp); case 26: return condCmp(pObj->pal, arg1, arg2, cmpOp);
case 27: return condCmp(pObj->shade, arg1, arg2, cmpOp); case 27: return condCmp(pObj->shade, arg1, arg2, cmpOp);
case 28: return (pObj->cstat & arg1); case 28: return (pObj->cstat & EWallFlags::FromInt(arg1));
case 29: return (pObj->hitag & arg1); case 29: return (pObj->hitag & arg1);
case 30: return condCmp(pObj->xrepeat, arg1, arg2, cmpOp); case 30: return condCmp(pObj->xrepeat, arg1, arg2, cmpOp);
case 31: return condCmp(pObj->xpan(), arg1, arg2, cmpOp); case 31: return condCmp(pObj->xpan(), arg1, arg2, cmpOp);

View file

@ -979,7 +979,7 @@ void DoWall(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, i
if (!bSet) SetGameVarID(lVar2, wallp->nextsector, sActor, sPlayer); if (!bSet) SetGameVarID(lVar2, wallp->nextsector, sActor, sPlayer);
break; break;
case WALL_CSTAT: case WALL_CSTAT:
if (bSet) wallp->cstat = lValue; if (bSet) wallp->cstat = EWallFlags::FromInt(lValue);
else SetGameVarID(lVar2, wallp->cstat, sActor, sPlayer); else SetGameVarID(lVar2, wallp->cstat, sActor, sPlayer);
break; break;
case WALL_PICNUM: case WALL_PICNUM: