- overpicnum lightening.

Especially make sure that it is never set to tile 0. There seems to have been some undefined behavior here treating 0 as 'no texture', but doing so inconsistently.
This commit is contained in:
Christoph Oelckers 2022-12-10 00:56:40 +01:00
parent 837e4d1438
commit 8c41294cb0
10 changed files with 24 additions and 17 deletions

View file

@ -193,7 +193,9 @@ static void ReadWallV7(FileReader& fr, walltype& wall)
wall.nextsector = fr.ReadInt16();
wall.cstat = EWallFlags::FromInt(fr.ReadUInt16());
wall.wallpicnum = fr.ReadInt16();
wall.overpicnum = fr.ReadInt16();
int overpicnum = fr.ReadInt16();
if (overpicnum == 0) overpicnum = -1;
wall.overpicnum = overpicnum;
wall.shade = fr.ReadInt8();
wall.pal = fr.ReadUInt8();
wall.xrepeat = fr.ReadUInt8();
@ -214,7 +216,9 @@ static void ReadWallV6(FileReader& fr, walltype& wall)
wall.nextsector = fr.ReadInt16();
wall.nextwall = fr.ReadInt16();
wall.wallpicnum = fr.ReadInt16();
wall.overpicnum = fr.ReadInt16();
int overpicnum = fr.ReadInt16();
if (overpicnum == 0) overpicnum = -1;
wall.overpicnum = overpicnum;
wall.shade = fr.ReadInt8();
wall.pal = fr.ReadUInt8();
wall.cstat = EWallFlags::FromInt(fr.ReadUInt16());
@ -234,7 +238,9 @@ static void ReadWallV5(FileReader& fr, walltype& wall)
wall.setPosFromMap(x, y);
wall.point2 = fr.ReadInt16();
wall.wallpicnum = fr.ReadInt16();
wall.overpicnum = fr.ReadInt16();
int overpicnum = fr.ReadInt16();
if (overpicnum == 0) overpicnum = -1;
wall.overpicnum = overpicnum;
wall.shade = fr.ReadInt8();
wall.cstat = EWallFlags::FromInt(fr.ReadUInt16());
wall.xrepeat = fr.ReadUInt8();

View file

@ -403,6 +403,7 @@ void dbLoadMap(const char* pPath, DVector3& pos, short* pAngle, sectortype** cur
pWall->nextsector = LittleShort(load.nextsector);
pWall->cstat = EWallFlags::FromInt(LittleShort(load.cstat));
pWall->setwalltexture(tileGetTextureID(LittleShort(load.picnum)));
if (load.overpic == 0) load.overpic = -1;
pWall->setovertexture(tileGetTextureID(LittleShort(load.overpic)));
pWall->type = LittleShort(load.type);
pWall->hitag = LittleShort(load.hitag);

View file

@ -2142,7 +2142,7 @@ DDukeActor* ifhitsectors(sectortype* sect)
//
//---------------------------------------------------------------------------
void handle_se19(DDukeActor *actor, int BIGFORCE)
void handle_se19(DDukeActor *actor)
{
auto sc = actor->sector();
int sh = actor->spr.hitag;
@ -2152,16 +2152,17 @@ void handle_se19(DDukeActor *actor, int BIGFORCE)
if (actor->temp_data[0] == 1)
{
actor->temp_data[0]++;
auto bigforce = TexMan.CheckForTexture("BIGFORCE", ETextureType::Any);
for (auto& wal : sc->walls)
{
if (wal.overpicnum == BIGFORCE)
if (wal.overtexture() == bigforce)
{
wal.cstat &= (CSTAT_WALL_TRANSLUCENT | CSTAT_WALL_1WAY | CSTAT_WALL_XFLIP | CSTAT_WALL_ALIGN_BOTTOM | CSTAT_WALL_BOTTOM_SWAP);
wal.overpicnum = 0;
wal.setovertexture(FNullTextureID());
auto nextwal = wal.nextWall();
if (nextwal != nullptr)
{
nextwal->overpicnum = 0;
nextwal->setovertexture(FNullTextureID());
nextwal->cstat &= (CSTAT_WALL_TRANSLUCENT | CSTAT_WALL_1WAY | CSTAT_WALL_XFLIP | CSTAT_WALL_ALIGN_BOTTOM | CSTAT_WALL_BOTTOM_SWAP);
}
}

View file

@ -1413,7 +1413,7 @@ void moveeffectors_d(void) //STATNUM 3
break;
case SE_19_EXPLOSION_LOWERS_CEILING:
handle_se19(act, DTILE_BIGFORCE);
handle_se19(act);
break;
case SE_20_STRETCH_BRIDGE:

View file

@ -1311,7 +1311,7 @@ void moveeffectors_r(void) //STATNUM 3
break;
case SE_19_EXPLOSION_LOWERS_CEILING:
handle_se19(act, RTILE_BIGFORCE);
handle_se19(act);
break;
case SE_20_STRETCH_BRIDGE:

View file

@ -63,7 +63,7 @@ void handle_se15(DDukeActor* i);
void handle_se16(DDukeActor* i);
void handle_se17(DDukeActor* i);
void handle_se18(DDukeActor* i, bool morecheck);
void handle_se19(DDukeActor* i, int BIGFORCE);
void handle_se19(DDukeActor* i);
void handle_se20(DDukeActor* i);
void handle_se21(DDukeActor* i);
void handle_se22(DDukeActor* i);

View file

@ -2002,7 +2002,7 @@ int operateTripbomb(int snum)
if (hit.hitWall != nullptr && hit.hitSector->lotag > 2)
return 0;
if (hit.hitWall != nullptr && hit.hitWall->overpicnum >= 0)
if (hit.hitWall != nullptr)
if (hit.hitWall->overpicnum == DTILE_BIGFORCE)
return 0;

View file

@ -611,17 +611,17 @@ int AutoBreakWall(walltype* wallp, const DVector3& hit_pos, DAngle ang, int type
}
// change the wall
if (wallp->overpicnum > 0 && (wallp->cstat & CSTAT_WALL_MASKED))
if (wallp->overtexture().isValid() && (wallp->cstat & CSTAT_WALL_MASKED))
{
if (break_info->breaknum == -1)
{
wallp->cstat &= ~(CSTAT_WALL_MASKED|CSTAT_WALL_1WAY|CSTAT_WALL_BLOCK_HITSCAN|CSTAT_WALL_BLOCK);
wallp->overpicnum = 0;
wallp->setovertexture(FNullTextureID());
if (wallp->twoSided())
{
nwp = wallp->nextWall();
nwp->cstat &= ~(CSTAT_WALL_MASKED|CSTAT_WALL_1WAY|CSTAT_WALL_BLOCK_HITSCAN|CSTAT_WALL_BLOCK);
nwp->overpicnum = 0;
nwp->setovertexture(FNullTextureID());
}
}
else

View file

@ -63,7 +63,6 @@ void CopySectorWalls(sectortype* dest_sect, sectortype* src_sect)
dwall->xrepeat = swall->xrepeat;
dwall->yrepeat = swall->yrepeat;
dwall->overpicnum = swall->overpicnum;
dwall->pal = swall->pal;
dwall->cstat = swall->cstat;
dwall->shade = swall->shade;

View file

@ -279,7 +279,7 @@ void JS_InitMirrors(void)
if (mirrorcnt >= MAXMIRRORS)
{
Printf("MAXMIRRORS reached! Skipping mirror wall\n");
wal.overpicnum = legacyTileNum(sec->ceilingtexture);
wal.setovertexture(sec->ceilingtexture);
continue;
}
@ -372,7 +372,7 @@ void JS_InitMirrors(void)
mirrorcnt++;
}
else
wal.overpicnum = legacyTileNum(sec->ceilingtexture);
wal.setovertexture(sec->ceilingtexture);
}
}
} // InitMirrors