- Put more floor/ceiling properties in sector_t into a substructure and

added wrapper functions.


SVN r1174 (trunk)
This commit is contained in:
Christoph Oelckers 2008-08-16 20:19:35 +00:00
parent fcdef6a0de
commit bc5d0c882b
29 changed files with 271 additions and 246 deletions

View file

@ -1,4 +1,6 @@
August 16, 2008 (Changes by Graf Zahl) August 16, 2008 (Changes by Graf Zahl)
- Put more floor/ceiling properties in sector_t into a substructure and
added wrapper functions.
- Fixed: A_Explode wants the distance parameter as an int, not a fixed_t. - Fixed: A_Explode wants the distance parameter as an int, not a fixed_t.
- some minor DECORATE fixes. - some minor DECORATE fixes.

View file

@ -186,7 +186,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
} }
else else
{ {
m_Sector->floortexz += move; m_Sector->ChangePlaneTexZ(sector_t::floor, move);
m_Sector->AdjustFloorClip (); m_Sector->AdjustFloorClip ();
} }
return pastdest; return pastdest;
@ -207,7 +207,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
} }
else else
{ {
m_Sector->floortexz += m_Sector->floorplane.HeightDiff (lastpos); m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff (lastpos));
m_Sector->AdjustFloorClip (); m_Sector->AdjustFloorClip ();
} }
} }
@ -244,7 +244,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
} }
else else
{ {
m_Sector->floortexz += move; m_Sector->ChangePlaneTexZ(sector_t::floor, move);
m_Sector->AdjustFloorClip (); m_Sector->AdjustFloorClip ();
} }
return pastdest; return pastdest;
@ -261,7 +261,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
{ {
if (crush >= 0 && !hexencrush) if (crush >= 0 && !hexencrush)
{ {
m_Sector->floortexz += m_Sector->floorplane.HeightDiff (lastpos); m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff (lastpos));
m_Sector->AdjustFloorClip (); m_Sector->AdjustFloorClip ();
return crushed; return crushed;
} }
@ -270,7 +270,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
MoveAttached(crush, -speed, 0, false); MoveAttached(crush, -speed, 0, false);
return crushed; return crushed;
} }
m_Sector->floortexz += m_Sector->floorplane.HeightDiff (lastpos); m_Sector->ChangePlaneTexZ(sector_t::floortexz, m_Sector->floorplane.HeightDiff (lastpos));
m_Sector->AdjustFloorClip (); m_Sector->AdjustFloorClip ();
} }
break; break;
@ -311,7 +311,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
} }
else else
{ {
m_Sector->ceilingtexz += move; m_Sector->ChangePlaneTexZ(sector_t::ceiling, move);
} }
return pastdest; return pastdest;
} }
@ -327,7 +327,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
{ {
if (crush >= 0 && !hexencrush) if (crush >= 0 && !hexencrush)
{ {
m_Sector->ceilingtexz += m_Sector->ceilingplane.HeightDiff (lastpos); m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
return crushed; return crushed;
} }
m_Sector->ceilingplane.d = lastpos; m_Sector->ceilingplane.d = lastpos;
@ -335,7 +335,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
MoveAttached(crush, speed, 1, false); MoveAttached(crush, speed, 1, false);
return crushed; return crushed;
} }
m_Sector->ceilingtexz += m_Sector->ceilingplane.HeightDiff (lastpos); m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
} }
break; break;
@ -359,7 +359,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
} }
else else
{ {
m_Sector->ceilingtexz += move; m_Sector->ChangePlaneTexZ(sector_t::ceiling, move);
} }
return pastdest; return pastdest;
} }
@ -377,7 +377,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
MoveAttached(crush, -speed, 1, false); MoveAttached(crush, -speed, 1, false);
return crushed; return crushed;
} }
m_Sector->ceilingtexz += m_Sector->ceilingplane.HeightDiff (lastpos); m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
} }
break; break;
} }

View file

@ -245,27 +245,27 @@ FTextureID DBaseDecal::StickToWall (side_t *wall, fixed_t x, fixed_t y)
{ {
RenderFlags |= RF_RELMID; RenderFlags |= RF_RELMID;
if (line->flags & ML_DONTPEGBOTTOM) if (line->flags & ML_DONTPEGBOTTOM)
Z -= front->floortexz; Z -= front->GetPlaneTexZ(sector_t::floor);
else else
Z -= front->ceilingtexz; Z -= front->GetPlaneTexZ(sector_t::ceiling);
tex = wall->GetTexture(side_t::mid); tex = wall->GetTexture(side_t::mid);
} }
else if (back->floorplane.ZatPoint (x, y) >= Z) else if (back->floorplane.ZatPoint (x, y) >= Z)
{ {
RenderFlags |= RF_RELLOWER|RF_CLIPLOWER; RenderFlags |= RF_RELLOWER|RF_CLIPLOWER;
if (line->flags & ML_DONTPEGBOTTOM) if (line->flags & ML_DONTPEGBOTTOM)
Z -= front->ceilingtexz; Z -= front->GetPlaneTexZ(sector_t::ceiling);
else else
Z -= back->floortexz; Z -= back->GetPlaneTexZ(sector_t::floor);
tex = wall->GetTexture(side_t::bottom); tex = wall->GetTexture(side_t::bottom);
} }
else else
{ {
RenderFlags |= RF_RELUPPER|RF_CLIPUPPER; RenderFlags |= RF_RELUPPER|RF_CLIPUPPER;
if (line->flags & ML_DONTPEGTOP) if (line->flags & ML_DONTPEGTOP)
Z -= front->ceilingtexz; Z -= front->GetPlaneTexZ(sector_t::ceiling);
else else
Z -= back->ceilingtexz; Z -= back->GetPlaneTexZ(sector_t::ceiling);
tex = wall->GetTexture(side_t::top); tex = wall->GetTexture(side_t::top);
} }
@ -301,29 +301,29 @@ fixed_t DBaseDecal::GetRealZ (const side_t *wall) const
case RF_RELUPPER: case RF_RELUPPER:
if (curline->linedef->flags & ML_DONTPEGTOP) if (curline->linedef->flags & ML_DONTPEGTOP)
{ {
return Z + front->ceilingtexz; return Z + front->GetPlaneTexZ(sector_t::ceiling);
} }
else else
{ {
return Z + back->ceilingtexz; return Z + back->GetPlaneTexZ(sector_t::ceiling);
} }
case RF_RELLOWER: case RF_RELLOWER:
if (curline->linedef->flags & ML_DONTPEGBOTTOM) if (curline->linedef->flags & ML_DONTPEGBOTTOM)
{ {
return Z + front->ceilingtexz; return Z + front->GetPlaneTexZ(sector_t::ceiling);
} }
else else
{ {
return Z + back->floortexz; return Z + back->GetPlaneTexZ(sector_t::floor);
} }
case RF_RELMID: case RF_RELMID:
if (curline->linedef->flags & ML_DONTPEGBOTTOM) if (curline->linedef->flags & ML_DONTPEGBOTTOM)
{ {
return Z + front->floortexz; return Z + front->GetPlaneTexZ(sector_t::floor);
} }
else else
{ {
return Z + front->ceilingtexz; return Z + front->GetPlaneTexZ(sector_t::ceiling);
} }
} }
} }

View file

@ -118,7 +118,7 @@ void DLightningThinker::LightningFlash ()
{ {
// allow combination of the lightning sector specials with bit masks // allow combination of the lightning sector specials with bit masks
int special = (tempSec->special&0xff); int special = (tempSec->special&0xff);
if (tempSec->ceilingpic == skyflatnum if (tempSec->GetTexture(sector_t::ceiling) == skyflatnum
|| special == Light_IndoorLightning1 || special == Light_IndoorLightning1
|| special == Light_IndoorLightning2 || special == Light_IndoorLightning2
|| special == Light_OutdoorLightning) || special == Light_OutdoorLightning)

View file

@ -231,14 +231,14 @@ bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, f
if(line->flags & ML_DONTPEGBOTTOM) if(line->flags & ML_DONTPEGBOTTOM)
{ {
*ptexbot = y_offset + *ptexbot = y_offset +
MAX<fixed_t>(line->frontsector->floortexz, line->backsector->floortexz); MAX<fixed_t>(line->frontsector->GetPlaneTexZ(sector_t::floor), line->backsector->GetPlaneTexZ(sector_t::floor));
*ptextop = *ptexbot + textureheight; *ptextop = *ptexbot + textureheight;
} }
else else
{ {
*ptextop = y_offset + *ptextop = y_offset +
MIN<fixed_t>(line->frontsector->ceilingtexz, line->backsector->ceilingtexz); MIN<fixed_t>(line->frontsector->GetPlaneTexZ(sector_t::ceiling), line->backsector->GetPlaneTexZ(sector_t::ceiling));
*ptexbot = *ptextop - textureheight; *ptexbot = *ptextop - textureheight;
} }

View file

@ -1898,18 +1898,8 @@ void DLevelScript::ChangeFlat (int tag, int name, bool floorOrCeiling)
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0)
{ {
if (floorOrCeiling == false) int pos = floorOrCeiling? sector_t::ceiling : sector_t::floor;
{ sectors[secnum].SetTexture(pos, flat);
if (sectors[secnum].floorpic != flat)
{
sectors[secnum].floorpic = flat;
sectors[secnum].AdjustFloorClip ();
}
}
else
{
sectors[secnum].ceilingpic = flat;
}
} }
} }
@ -2000,8 +1990,10 @@ void DLevelScript::ReplaceTextures (int fromnamei, int tonamei, int flags)
{ {
sector_t *sec = &sectors[i]; sector_t *sec = &sectors[i];
if (!(flags & NOT_FLOOR) && sec->floorpic == picnum1) sec->floorpic = picnum2; if (!(flags & NOT_FLOOR) && sec->GetTexture(sector_t::floor) == picnum1)
if (!(flags & NOT_CEILING) && sec->ceilingpic == picnum1) sec->ceilingpic = picnum2; sec->SetTexture(sector_t::floor, picnum2);
if (!(flags & NOT_CEILING) && sec->GetTexture(sector_t::ceiling) == picnum1)
sec->SetTexture(sector_t::ceiling, picnum2);
} }
} }
} }
@ -5321,7 +5313,7 @@ int DLevelScript::RunScript ()
if (actor != NULL) if (actor != NULL)
{ {
FTexture *tex = TexMan.FindTexture(FBehavior::StaticLookupString(STACK(1))); FTexture *tex = TexMan.FindTexture(FBehavior::StaticLookupString(STACK(1)));
STACK(2) = (tex == TexMan[actor->Sector->ceilingpic]); STACK(2) = (tex == TexMan[actor->Sector->GetTexture(sector_t::ceiling)]);
} }
else STACK(2)=0; else STACK(2)=0;
sp--; sp--;
@ -5334,7 +5326,7 @@ int DLevelScript::RunScript ()
if (actor != NULL) if (actor != NULL)
{ {
FTexture *tex = TexMan.FindTexture(FBehavior::StaticLookupString(STACK(1))); FTexture *tex = TexMan.FindTexture(FBehavior::StaticLookupString(STACK(1)));
STACK(2) = (tex == TexMan[actor->Sector->floorpic]); STACK(2) = (tex == TexMan[actor->Sector->GetTexture(sector_t::floor)]);
} }
else STACK(2)=0; else STACK(2)=0;
sp--; sp--;

View file

@ -369,38 +369,38 @@ static void LoadSectors (sectortype *bsec)
bsec->ceilingstat = WORD(bsec->ceilingstat); bsec->ceilingstat = WORD(bsec->ceilingstat);
bsec->floorstat = WORD(bsec->floorstat); bsec->floorstat = WORD(bsec->floorstat);
sec->floortexz = -(LittleLong(bsec->floorz) << 8); sec->SetPlaneTexZ(sector_t::floor, -(LittleLong(bsec->floorz) << 8));
sec->floorplane.d = -sec->floortexz; sec->floorplane.d = -sec->GetPlaneTexZ(sector_t::floor);
sec->floorplane.c = FRACUNIT; sec->floorplane.c = FRACUNIT;
sec->floorplane.ic = FRACUNIT; sec->floorplane.ic = FRACUNIT;
mysnprintf (tnam, countof(tnam), "BTIL%04d", LittleShort(bsec->floorpicnum)); mysnprintf (tnam, countof(tnam), "BTIL%04d", LittleShort(bsec->floorpicnum));
sec->floorpic = TexMan.GetTexture (tnam, FTexture::TEX_Build); sec->SetTexture(sector_t::floor, TexMan.GetTexture (tnam, FTexture::TEX_Build));
sec->SetXScale(sector_t::floor, (bsec->floorstat & 8) ? FRACUNIT*2 : FRACUNIT); sec->SetXScale(sector_t::floor, (bsec->floorstat & 8) ? FRACUNIT*2 : FRACUNIT);
sec->SetYScale(sector_t::floor, (bsec->floorstat & 8) ? FRACUNIT*2 : FRACUNIT); sec->SetYScale(sector_t::floor, (bsec->floorstat & 8) ? FRACUNIT*2 : FRACUNIT);
sec->SetXOffset(sector_t::floor, (bsec->floorxpanning << FRACBITS) + (32 << FRACBITS)); sec->SetXOffset(sector_t::floor, (bsec->floorxpanning << FRACBITS) + (32 << FRACBITS));
sec->SetYOffset(sector_t::floor, bsec->floorypanning << FRACBITS); sec->SetYOffset(sector_t::floor, bsec->floorypanning << FRACBITS);
sec->FloorLight = SHADE2LIGHT (bsec->floorshade); sec->SetPlaneLight(sector_t::floor, SHADE2LIGHT (bsec->floorshade));
sec->FloorFlags = SECF_ABSLIGHTING; sec->ChangeFlags(sector_t::floor, 0, SECF_ABSLIGHTING);
sec->ceilingtexz = -(LittleLong(bsec->ceilingz) << 8); sec->SetPlaneTexZ(sector_t::ceiling, -(LittleLong(bsec->ceilingz) << 8));
sec->ceilingplane.d = sec->ceilingtexz; sec->ceilingplane.d = sec->GetPlaneTexZ(sector_t::ceiling);
sec->ceilingplane.c = -FRACUNIT; sec->ceilingplane.c = -FRACUNIT;
sec->ceilingplane.ic = -FRACUNIT; sec->ceilingplane.ic = -FRACUNIT;
mysnprintf (tnam, countof(tnam), "BTIL%04d", LittleShort(bsec->ceilingpicnum)); mysnprintf (tnam, countof(tnam), "BTIL%04d", LittleShort(bsec->ceilingpicnum));
sec->ceilingpic = TexMan.GetTexture (tnam, FTexture::TEX_Build); sec->SetTexture(sector_t::ceiling, TexMan.GetTexture (tnam, FTexture::TEX_Build));
if (bsec->ceilingstat & 1) if (bsec->ceilingstat & 1)
{ {
sky1texture = sky2texture = sec->ceilingpic; sky1texture = sky2texture = sec->GetTexture(sector_t::ceiling);
sec->ceilingpic = skyflatnum; sec->SetTexture(sector_t::ceiling, skyflatnum);
} }
sec->SetXScale(sector_t::ceiling, (bsec->ceilingstat & 8) ? FRACUNIT*2 : FRACUNIT); sec->SetXScale(sector_t::ceiling, (bsec->ceilingstat & 8) ? FRACUNIT*2 : FRACUNIT);
sec->SetYScale(sector_t::ceiling, (bsec->ceilingstat & 8) ? FRACUNIT*2 : FRACUNIT); sec->SetYScale(sector_t::ceiling, (bsec->ceilingstat & 8) ? FRACUNIT*2 : FRACUNIT);
sec->SetXOffset(sector_t::ceiling, (bsec->ceilingxpanning << FRACBITS) + (32 << FRACBITS)); sec->SetXOffset(sector_t::ceiling, (bsec->ceilingxpanning << FRACBITS) + (32 << FRACBITS));
sec->SetYOffset(sector_t::ceiling, bsec->ceilingypanning << FRACBITS); sec->SetYOffset(sector_t::ceiling, bsec->ceilingypanning << FRACBITS);
sec->CeilingLight = SHADE2LIGHT (bsec->ceilingshade); sec->SetPlaneLight(sector_t::ceiling, SHADE2LIGHT (bsec->ceilingshade));
sec->CeilingFlags = SECF_ABSLIGHTING; sec->ChangeFlags(sector_t::ceiling, 0, SECF_ABSLIGHTING);
sec->lightlevel = (sec->FloorLight + sec->CeilingLight) / 2; sec->lightlevel = (sec->GetPlaneLight(sector_t::floor) + sec->GetPlaneLight(sector_t::ceiling)) / 2;
sec->seqType = -1; sec->seqType = -1;
sec->nextsec = -1; sec->nextsec = -1;

View file

@ -110,7 +110,7 @@ void DCeiling::Tick ()
m_Sector->special = m_NewSpecial; m_Sector->special = m_NewSpecial;
// fall through // fall through
case genCeilingChg: case genCeilingChg:
m_Sector->ceilingpic = m_Texture; m_Sector->SetTexture(sector_t::ceiling, m_Texture);
// fall through // fall through
default: default:
SN_StopSequence (m_Sector); SN_StopSequence (m_Sector);
@ -143,7 +143,7 @@ void DCeiling::Tick ()
m_Sector->special = m_NewSpecial; m_Sector->special = m_NewSpecial;
// fall through // fall through
case genCeilingChg: case genCeilingChg:
m_Sector->ceilingpic = m_Texture; m_Sector->SetTexture(sector_t::ceiling, m_Texture);
// fall through // fall through
default: default:
SN_StopSequence (m_Sector); SN_StopSequence (m_Sector);
@ -421,7 +421,7 @@ manual_ceiling:
sec->FindModelCeilingSector (targheight); sec->FindModelCeilingSector (targheight);
if (modelsec != NULL) if (modelsec != NULL)
{ {
ceiling->m_Texture = modelsec->ceilingpic; ceiling->m_Texture = modelsec->GetTexture(sector_t::ceiling);
switch (change & 3) switch (change & 3)
{ {
case 1: // type is zeroed case 1: // type is zeroed
@ -440,7 +440,7 @@ manual_ceiling:
} }
else if (line) // else if a trigger model change else if (line) // else if a trigger model change
{ {
ceiling->m_Texture = line->frontsector->ceilingpic; ceiling->m_Texture = line->frontsector->GetTexture(sector_t::ceiling);
switch (change & 3) switch (change & 3)
{ {
case 1: // type is zeroed case 1: // type is zeroed

View file

@ -180,8 +180,7 @@ void DFloor::Tick ()
m_Sector->special = (m_Sector->special & SECRET_MASK) | m_NewSpecial; m_Sector->special = (m_Sector->special & SECRET_MASK) | m_NewSpecial;
//fall thru //fall thru
case genFloorChg: case genFloorChg:
m_Sector->floorpic = m_Texture; m_Sector->SetTexture(sector_t::floor, m_Texture);
m_Sector->AdjustFloorClip ();
break; break;
default: default:
break; break;
@ -197,8 +196,7 @@ void DFloor::Tick ()
m_Sector->special = (m_Sector->special & SECRET_MASK) | m_NewSpecial; m_Sector->special = (m_Sector->special & SECRET_MASK) | m_NewSpecial;
//fall thru //fall thru
case genFloorChg: case genFloorChg:
m_Sector->floorpic = m_Texture; m_Sector->SetTexture(sector_t::floor, m_Texture);
m_Sector->AdjustFloorClip ();
break; break;
default: default:
break; break;
@ -299,7 +297,7 @@ void DElevator::Tick ()
void DFloor::SetFloorChangeType (sector_t *sec, int change) void DFloor::SetFloorChangeType (sector_t *sec, int change)
{ {
m_Texture = sec->floorpic; m_Texture = sec->GetTexture(sector_t::floor);
switch (change & 3) switch (change & 3)
{ {
@ -517,13 +515,9 @@ manual_floor:
floor->m_FloorDestDist = sec->floorplane.PointToDist (0, 0, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist (0, 0, newheight);
if (line != NULL) if (line != NULL)
{ {
FTextureID oldpic = sec->floorpic; FTextureID oldpic = sec->GetTexture(sector_t::floor);
sec->floorpic = line->frontsector->floorpic; sec->SetTexture(sector_t::floor, line->frontsector->GetTexture(sector_t::floor));
sec->special = (sec->special & SECRET_MASK) | (line->frontsector->special & ~SECRET_MASK); sec->special = (sec->special & SECRET_MASK) | (line->frontsector->special & ~SECRET_MASK);
if (oldpic != sec->floorpic)
{
sec->AdjustFloorClip ();
}
} }
else else
{ {
@ -535,7 +529,7 @@ manual_floor:
floor->m_Direction = -1; floor->m_Direction = -1;
newheight = sec->FindLowestFloorSurrounding (&spot); newheight = sec->FindLowestFloorSurrounding (&spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
floor->m_Texture = sec->floorpic; floor->m_Texture = sec->GetTexture(sector_t::floor);
// jff 1/24/98 make sure floor->m_NewSpecial gets initialized // jff 1/24/98 make sure floor->m_NewSpecial gets initialized
// in case no surrounding sector is at floordestheight // in case no surrounding sector is at floordestheight
// --> should not affect compatibility <-- // --> should not affect compatibility <--
@ -546,7 +540,7 @@ manual_floor:
modelsec = sec->FindModelFloorSector (newheight); modelsec = sec->FindModelFloorSector (newheight);
if (modelsec != NULL) if (modelsec != NULL)
{ {
floor->m_Texture = modelsec->floorpic; floor->m_Texture = modelsec->GetTexture(sector_t::floor);
floor->m_NewSpecial = modelsec->special & ~SECRET_MASK; floor->m_NewSpecial = modelsec->special & ~SECRET_MASK;
} }
break; break;
@ -659,14 +653,14 @@ bool EV_DoChange (line_t *line, EChange changetype, int tag)
rtn = true; rtn = true;
// handle trigger or numeric change type // handle trigger or numeric change type
FTextureID oldpic = sec->floorpic; FTextureID oldpic = sec->GetTexture(sector_t::floor);
switch(changetype) switch(changetype)
{ {
case trigChangeOnly: case trigChangeOnly:
if (line) if (line)
{ // [RH] if no line, no change { // [RH] if no line, no change
sec->floorpic = line->frontsector->floorpic; sec->SetTexture(sector_t::floor, line->frontsector->GetTexture(sector_t::floor));
sec->special = (sec->special & SECRET_MASK) | (line->frontsector->special & ~SECRET_MASK); sec->special = (sec->special & SECRET_MASK) | (line->frontsector->special & ~SECRET_MASK);
} }
break; break;
@ -674,18 +668,13 @@ bool EV_DoChange (line_t *line, EChange changetype, int tag)
secm = sec->FindModelFloorSector (sec->CenterFloor()); secm = sec->FindModelFloorSector (sec->CenterFloor());
if (secm) if (secm)
{ // if no model, no change { // if no model, no change
sec->floorpic = secm->floorpic; sec->SetTexture(sector_t::floor, secm->GetTexture(sector_t::floor));
sec->special = secm->special; sec->special = secm->special;
} }
break; break;
default: default:
break; break;
} }
if (oldpic != sec->floorpic)
{
sec->AdjustFloorClip ();
}
} }
return rtn; return rtn;
} }
@ -787,7 +776,7 @@ manual_stair:
height = sec->floorplane.ZatPoint (0, 0) + stairstep; height = sec->floorplane.ZatPoint (0, 0) + stairstep;
floor->m_FloorDestDist = sec->floorplane.PointToDist (0, 0, height); floor->m_FloorDestDist = sec->floorplane.PointToDist (0, 0, height);
texture = sec->floorpic; texture = sec->GetTexture(sector_t::floor);
osecnum = secnum; //jff 3/4/98 preserve loop index osecnum = secnum; //jff 3/4/98 preserve loop index
// Find next sector to raise // Find next sector to raise
@ -837,7 +826,7 @@ manual_stair:
if (!tsec) continue; //jff 5/7/98 if no backside, continue if (!tsec) continue; //jff 5/7/98 if no backside, continue
newsecnum = (int)(tsec - sectors); newsecnum = (int)(tsec - sectors);
if (!igntxt && tsec->floorpic != texture) if (!igntxt && tsec->GetTexture(sector_t::floor) != texture)
continue; continue;
height += stairstep; height += stairstep;
@ -954,7 +943,7 @@ bool EV_DoDonut (int tag, fixed_t pillarspeed, fixed_t slimespeed)
floor->m_Direction = 1; floor->m_Direction = 1;
floor->m_Sector = s2; floor->m_Sector = s2;
floor->m_Speed = slimespeed; floor->m_Speed = slimespeed;
floor->m_Texture = s3->floorpic; floor->m_Texture = s3->GetTexture(sector_t::floor);
floor->m_NewSpecial = 0; floor->m_NewSpecial = 0;
height = s3->FindHighestFloorPoint (&spot); height = s3->FindHighestFloorPoint (&spot);
floor->m_FloorDestDist = s2->floorplane.PointToDist (spot, height); floor->m_FloorDestDist = s2->floorplane.PointToDist (spot, height);
@ -1110,18 +1099,18 @@ void DWaggleBase::Destroy()
void DWaggleBase::DoWaggle (bool ceiling) void DWaggleBase::DoWaggle (bool ceiling)
{ {
secplane_t *plane; secplane_t *plane;
fixed_t *texz; int pos;
fixed_t dist; fixed_t dist;
if (ceiling) if (ceiling)
{ {
plane = &m_Sector->ceilingplane; plane = &m_Sector->ceilingplane;
texz = &m_Sector->ceilingtexz; pos = sector_t::ceiling;
} }
else else
{ {
plane = &m_Sector->floorplane; plane = &m_Sector->floorplane;
texz = &m_Sector->floortexz; pos = sector_t::floor;
} }
switch (m_State) switch (m_State)
@ -1138,7 +1127,7 @@ void DWaggleBase::DoWaggle (bool ceiling)
if ((m_Scale -= m_ScaleDelta) <= 0) if ((m_Scale -= m_ScaleDelta) <= 0)
{ // Remove { // Remove
dist = FixedMul (m_OriginalDist - plane->d, plane->ic); dist = FixedMul (m_OriginalDist - plane->d, plane->ic);
*texz -= plane->HeightDiff (m_OriginalDist); m_Sector->ChangePlaneTexZ(pos, -plane->HeightDiff (m_OriginalDist));
plane->d = m_OriginalDist; plane->d = m_OriginalDist;
P_ChangeSector (m_Sector, true, dist, ceiling, false); P_ChangeSector (m_Sector, true, dist, ceiling, false);
if (ceiling) if (ceiling)

View file

@ -92,14 +92,14 @@ bool sector_t::IsLinked(sector_t *other, bool ceiling) const
static bool MoveCeiling(sector_t *sector, int crush, fixed_t move) static bool MoveCeiling(sector_t *sector, int crush, fixed_t move)
{ {
sector->ceilingplane.ChangeHeight (move); sector->ceilingplane.ChangeHeight (move);
sector->ceilingtexz += move; sector->ChangePlaneTexZ(sector_t::ceiling, move);
if (P_ChangeSector(sector, crush, move, 1, true)) return false; if (P_ChangeSector(sector, crush, move, 1, true)) return false;
// Don't let the ceiling go below the floor // Don't let the ceiling go below the floor
if ((sector->ceilingplane.a | sector->ceilingplane.b | if ((sector->ceilingplane.a | sector->ceilingplane.b |
sector->floorplane.a | sector->floorplane.b) == 0 && sector->floorplane.a | sector->floorplane.b) == 0 &&
sector->floortexz > sector->ceilingtexz) return false; sector->GetPlaneTexZ(sector_t::floor) > sector->GetPlaneTexZ(sector_t::ceiling)) return false;
return true; return true;
} }
@ -107,14 +107,14 @@ static bool MoveCeiling(sector_t *sector, int crush, fixed_t move)
static bool MoveFloor(sector_t *sector, int crush, fixed_t move) static bool MoveFloor(sector_t *sector, int crush, fixed_t move)
{ {
sector->floorplane.ChangeHeight (move); sector->floorplane.ChangeHeight (move);
sector->floortexz += move; sector->ChangePlaneTexZ(sector_t::floortexz, move);
if (P_ChangeSector(sector, crush, move, 0, true)) return false; if (P_ChangeSector(sector, crush, move, 0, true)) return false;
// Don't let the floor go above the ceiling // Don't let the floor go above the ceiling
if ((sector->ceilingplane.a | sector->ceilingplane.b | if ((sector->ceilingplane.a | sector->ceilingplane.b |
sector->floorplane.a | sector->floorplane.b) == 0 && sector->floorplane.a | sector->floorplane.b) == 0 &&
sector->floortexz > sector->ceilingtexz) return false; sector->GetPlaneTexZ(sector_t::floor) > sector->GetPlaneTexZ(sector_t::ceiling)) return false;
return true; return true;
} }

View file

@ -180,9 +180,9 @@ void P_FindFloorCeiling (AActor *actor, bool onlymidtex)
tmf.thing = actor; tmf.thing = actor;
tmf.floorz = tmf.dropoffz = sec->floorplane.ZatPoint (tmf.x, tmf.y); tmf.floorz = tmf.dropoffz = sec->floorplane.ZatPoint (tmf.x, tmf.y);
tmf.ceilingz = sec->ceilingplane.ZatPoint (tmf.x, tmf.y); tmf.ceilingz = sec->ceilingplane.ZatPoint (tmf.x, tmf.y);
tmf.floorpic = sec->floorpic; tmf.floorpic = sec->GetTexture(sector_t::floor);
tmf.floorsector = sec; tmf.floorsector = sec;
tmf.ceilingpic = sec->ceilingpic; tmf.ceilingpic = sec->GetTexture(sector_t::ceiling);
tmf.ceilingsector = sec; tmf.ceilingsector = sec;
tmf.touchmidtex = false; tmf.touchmidtex = false;
validcount++; validcount++;
@ -239,9 +239,9 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr
tmf.z = z; tmf.z = z;
tmf.floorz = tmf.dropoffz = newsec->floorplane.ZatPoint (x, y); tmf.floorz = tmf.dropoffz = newsec->floorplane.ZatPoint (x, y);
tmf.ceilingz = newsec->ceilingplane.ZatPoint (x, y); tmf.ceilingz = newsec->ceilingplane.ZatPoint (x, y);
tmf.floorpic = newsec->floorpic; tmf.floorpic = newsec->GetTexture(sector_t::floor);
tmf.floorsector = newsec; tmf.floorsector = newsec;
tmf.ceilingpic = newsec->ceilingpic; tmf.ceilingpic = newsec->GetTexture(sector_t::ceiling);
tmf.ceilingsector = newsec; tmf.ceilingsector = newsec;
spechit.Clear (); spechit.Clear ();
@ -365,13 +365,13 @@ void P_PlayerStartStomp (AActor *actor)
inline fixed_t secfriction (const sector_t *sec) inline fixed_t secfriction (const sector_t *sec)
{ {
fixed_t friction = Terrains[TerrainTypes[sec->floorpic]].Friction; fixed_t friction = Terrains[TerrainTypes[sec->GetTexture(sector_t::floor)]].Friction;
return friction != 0 ? friction : sec->friction; return friction != 0 ? friction : sec->friction;
} }
inline fixed_t secmovefac (const sector_t *sec) inline fixed_t secmovefac (const sector_t *sec)
{ {
fixed_t movefactor = Terrains[TerrainTypes[sec->floorpic]].MoveFactor; fixed_t movefactor = Terrains[TerrainTypes[sec->GetTexture(sector_t::floor)]].MoveFactor;
return movefactor != 0 ? movefactor : sec->movefactor; return movefactor != 0 ? movefactor : sec->movefactor;
} }
@ -408,7 +408,7 @@ int P_GetFriction (const AActor *mo, int *frictionfactor)
{ {
sec = m->m_sector; sec = m->m_sector;
if (!(sec->special & FRICTION_MASK) && if (!(sec->special & FRICTION_MASK) &&
Terrains[TerrainTypes[sec->floorpic]].Friction == 0) Terrains[TerrainTypes[sec->GetTexture(sector_t::floor)]].Friction == 0)
{ {
continue; continue;
} }
@ -1025,9 +1025,9 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm)
// Any contacted lines the step closer together will adjust them. // Any contacted lines the step closer together will adjust them.
tm.floorz = tm.dropoffz = newsec->floorplane.ZatPoint (x, y); tm.floorz = tm.dropoffz = newsec->floorplane.ZatPoint (x, y);
tm.ceilingz = newsec->ceilingplane.ZatPoint (x, y); tm.ceilingz = newsec->ceilingplane.ZatPoint (x, y);
tm.floorpic = newsec->floorpic; tm.floorpic = newsec->GetTexture(sector_t::floor);
tm.floorsector = newsec; tm.floorsector = newsec;
tm.ceilingpic = newsec->ceilingpic; tm.ceilingpic = newsec->GetTexture(sector_t::ceiling);
tm.ceilingsector = newsec; tm.ceilingsector = newsec;
tm.touchmidtex = false; tm.touchmidtex = false;

View file

@ -157,7 +157,7 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef,
/*Printf ("]]]]]] %d %d\n", ff, bf);*/ /*Printf ("]]]]]] %d %d\n", ff, bf);*/
open.topsec = fc < bc? front : back; open.topsec = fc < bc? front : back;
open.ceilingpic = open.topsec->ceilingpic; open.ceilingpic = open.topsec->GetTexture(sector_t::ceiling);
open.top = fc < bc ? fc : bc; open.top = fc < bc ? fc : bc;
bool usefront; bool usefront;
@ -186,14 +186,14 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef,
{ {
open.bottom = ff; open.bottom = ff;
open.bottomsec = front; open.bottomsec = front;
open.floorpic = front->floorpic; open.floorpic = front->GetTexture(sector_t::floor);
open.lowfloor = bf; open.lowfloor = bf;
} }
else else
{ {
open.bottom = bf; open.bottom = bf;
open.bottomsec = back; open.bottomsec = back;
open.floorpic = back->floorpic; open.floorpic = back->GetTexture(sector_t::floor);
open.lowfloor = ff; open.lowfloor = ff;
} }

View file

@ -1635,7 +1635,7 @@ explode:
// explode a missile // explode a missile
if (tm.ceilingline && if (tm.ceilingline &&
tm.ceilingline->backsector && tm.ceilingline->backsector &&
tm.ceilingline->backsector->ceilingpic == skyflatnum && tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
mo->z >= tm.ceilingline->backsector->ceilingplane.ZatPoint (mo->x, mo->y) && //killough mo->z >= tm.ceilingline->backsector->ceilingplane.ZatPoint (mo->x, mo->y) && //killough
!(mo->flags3 & MF3_SKYEXPLODE)) !(mo->flags3 & MF3_SKYEXPLODE))
{ {
@ -3108,9 +3108,9 @@ AActor *AActor::StaticSpawn (const PClass *type, fixed_t ix, fixed_t iy, fixed_t
actor->floorz = actor->Sector->floorplane.ZatPoint (ix, iy); actor->floorz = actor->Sector->floorplane.ZatPoint (ix, iy);
actor->ceilingz = actor->Sector->ceilingplane.ZatPoint (ix, iy); actor->ceilingz = actor->Sector->ceilingplane.ZatPoint (ix, iy);
actor->floorsector = actor->Sector; actor->floorsector = actor->Sector;
actor->floorpic = actor->floorsector->floorpic; actor->floorpic = actor->floorsector->GetTexture(sector_t::floor);
actor->ceilingsector = actor->Sector; actor->ceilingsector = actor->Sector;
actor->ceilingpic = actor->ceilingsector->ceilingpic; actor->ceilingpic = actor->ceilingsector->GetTexture(sector_t::ceiling);
// Check if there's something solid to stand on between the current position and the // Check if there's something solid to stand on between the current position and the
// current sector's floor. // current sector's floor.
P_FindFloorCeiling(actor, true); P_FindFloorCeiling(actor, true);
@ -3124,9 +3124,9 @@ AActor *AActor::StaticSpawn (const PClass *type, fixed_t ix, fixed_t iy, fixed_t
actor->floorz = FIXED_MIN; actor->floorz = FIXED_MIN;
actor->dropoffz = FIXED_MIN; actor->dropoffz = FIXED_MIN;
actor->ceilingz = FIXED_MAX; actor->ceilingz = FIXED_MAX;
actor->floorpic = actor->Sector->floorpic; actor->floorpic = actor->Sector->GetTexture(sector_t::floor);
actor->floorsector = actor->Sector; actor->floorsector = actor->Sector;
actor->ceilingpic = actor->Sector->ceilingpic; actor->ceilingpic = actor->Sector->GetTexture(sector_t::ceiling);
actor->ceilingsector = actor->Sector; actor->ceilingsector = actor->Sector;
} }
@ -3363,7 +3363,7 @@ void AActor::AdjustFloorClip ()
m->m_sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) && m->m_sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) &&
m->m_sector->floorplane.ZatPoint (x, y) == z) m->m_sector->floorplane.ZatPoint (x, y) == z)
{ {
fixed_t clip = Terrains[TerrainTypes[m->m_sector->floorpic]].FootClip; fixed_t clip = Terrains[TerrainTypes[m->m_sector->GetTexture(sector_t::floor)]].FootClip;
if (clip < shallowestclip) if (clip < shallowestclip)
{ {
shallowestclip = clip; shallowestclip = clip;
@ -4182,7 +4182,7 @@ int P_GetThingFloorType (AActor *thing)
} }
else else
{ {
return TerrainTypes[thing->Sector->floorpic]; return TerrainTypes[thing->Sector->GetTexture(sector_t::floor)];
} }
} }
@ -4213,11 +4213,11 @@ bool P_HitWater (AActor * thing, sector_t * sec, fixed_t z)
(sec->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) || (sec->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) ||
!(sec->heightsec->MoreFlags & SECF_CLIPFAKEPLANES)) !(sec->heightsec->MoreFlags & SECF_CLIPFAKEPLANES))
{ {
terrainnum = TerrainTypes[sec->floorpic]; terrainnum = TerrainTypes[sec->GetTexture(sector_t::floor)];
} }
else else
{ {
terrainnum = TerrainTypes[sec->heightsec->floorpic]; terrainnum = TerrainTypes[sec->heightsec->GetTexture(sector_t::floor)];
} }
int splashnum = Terrains[terrainnum].Splash; int splashnum = Terrains[terrainnum].Splash;

View file

@ -261,7 +261,7 @@ manual_plat:
if (change) if (change)
{ {
if (line) if (line)
sec->floorpic = sides[line->sidenum[0]].sector->floorpic; sec->SetTexture(sector_t::floor, sides[line->sidenum[0]].sector->GetTexture(sector_t::floor));
if (change == 1) if (change == 1)
sec->special &= SECRET_MASK; // Stop damage and other stuff, if any sec->special &= SECRET_MASK; // Stop damage and other stuff, if any
} }

View file

@ -291,10 +291,6 @@ void P_SerializeWorld (FArchive &arc)
{ {
arc << sec->floorplane arc << sec->floorplane
<< sec->ceilingplane << sec->ceilingplane
<< sec->floortexz
<< sec->ceilingtexz
<< sec->floorpic
<< sec->ceilingpic
<< sec->lightlevel << sec->lightlevel
<< sec->special << sec->special
<< sec->tag << sec->tag
@ -317,10 +313,6 @@ void P_SerializeWorld (FArchive &arc)
<< sec->mod << sec->mod
<< sec->SoundTarget << sec->SoundTarget
<< sec->SecActTarget << sec->SecActTarget
<< sec->FloorLight
<< sec->CeilingLight
<< sec->FloorFlags
<< sec->CeilingFlags
<< sec->sky << sec->sky
<< sec->MoreFlags << sec->MoreFlags
<< sec->Flags << sec->Flags
@ -415,7 +407,8 @@ FArchive &operator<< (FArchive &arc, side_t::part &p)
FArchive &operator<< (FArchive &arc, sector_t::splane &p) FArchive &operator<< (FArchive &arc, sector_t::splane &p)
{ {
arc << p.xform.xoffs << p.xform.yoffs << p.xform.xscale << p.xform.yscale arc << p.xform.xoffs << p.xform.yoffs << p.xform.xscale << p.xform.yscale
<< p.xform.angle << p.xform.base_yoffs << p.xform.base_angle; << p.xform.angle << p.xform.base_yoffs << p.xform.base_angle
<< p.Flags << p.Light << p.Texture << p.TexZ;
return arc; return arc;
} }

View file

@ -63,7 +63,7 @@ fixed_t sector_t::FindLowestFloorSurrounding (vertex_t **v) const
fixed_t ofloor; fixed_t ofloor;
vertex_t *spot; vertex_t *spot;
if (linecount == 0) return floortexz; if (linecount == 0) return GetPlaneTexZ(sector_t::floor);
spot = lines[0]->v1; spot = lines[0]->v1;
floor = floorplane.ZatPoint (spot); floor = floorplane.ZatPoint (spot);
@ -270,7 +270,7 @@ fixed_t sector_t::FindNextLowestCeiling (vertex_t **v) const
int i; int i;
if (linecount == 0) return ceilingtexz; if (linecount == 0) return GetPlaneTexZ(sector_t::ceiling);
spot = lines[0]->v1; spot = lines[0]->v1;
height = ceilingplane.ZatPoint (spot); height = ceilingplane.ZatPoint (spot);

View file

@ -1186,18 +1186,18 @@ void P_LoadSectors (MapData * map)
{ {
ss->e = &sectors[0].e[i]; ss->e = &sectors[0].e[i];
if (!map->HasBehavior) ss->Flags |= SECF_FLOORDROP; if (!map->HasBehavior) ss->Flags |= SECF_FLOORDROP;
ss->floortexz = LittleShort(ms->floorheight)<<FRACBITS; ss->SetPlaneTexZ(sector_t::floor, LittleShort(ms->floorheight)<<FRACBITS);
ss->floorplane.d = -ss->floortexz; ss->floorplane.d = -ss->GetPlaneTexZ(sector_t::floor);
ss->floorplane.c = FRACUNIT; ss->floorplane.c = FRACUNIT;
ss->floorplane.ic = FRACUNIT; ss->floorplane.ic = FRACUNIT;
ss->ceilingtexz = LittleShort(ms->ceilingheight)<<FRACBITS; ss->SetPlaneTexZ(sector_t::ceiling, LittleShort(ms->ceilingheight)<<FRACBITS);
ss->ceilingplane.d = ss->ceilingtexz; ss->ceilingplane.d = ss->GetPlaneTexZ(sector_t::ceiling);
ss->ceilingplane.c = -FRACUNIT; ss->ceilingplane.c = -FRACUNIT;
ss->ceilingplane.ic = -FRACUNIT; ss->ceilingplane.ic = -FRACUNIT;
strncpy (fname, ms->floorpic, 8); strncpy (fname, ms->floorpic, 8);
ss->floorpic = TexMan.GetTexture (fname, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable); ss->SetTexture(sector_t::floor, TexMan.GetTexture (fname, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable));
strncpy (fname, ms->ceilingpic, 8); strncpy (fname, ms->ceilingpic, 8);
ss->ceilingpic = TexMan.GetTexture (fname, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable); ss->SetTexture(sector_t::ceiling, TexMan.GetTexture (fname, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable));
ss->lightlevel = clamp (LittleShort(ms->lightlevel), (short)0, (short)255); ss->lightlevel = clamp (LittleShort(ms->lightlevel), (short)0, (short)255);
if (map->HasBehavior) if (map->HasBehavior)
ss->special = LittleShort(ms->special); ss->special = LittleShort(ms->special);
@ -1225,7 +1225,7 @@ void P_LoadSectors (MapData * map)
// [RH] Sectors default to white light with the default fade. // [RH] Sectors default to white light with the default fade.
// If they are outside (have a sky ceiling), they use the outside fog. // If they are outside (have a sky ceiling), they use the outside fog.
if (level.outsidefog != 0xff000000 && (ss->ceilingpic == skyflatnum || (ss->special&0xff) == Sector_Outside)) if (level.outsidefog != 0xff000000 && (ss->GetTexture(sector_t::ceiling) == skyflatnum || (ss->special&0xff) == Sector_Outside))
{ {
if (fogMap == NULL) if (fogMap == NULL)
fogMap = GetSpecialLights (PalEntry (255,255,255), level.outsidefog, 0); fogMap = GetSpecialLights (PalEntry (255,255,255), level.outsidefog, 0);

View file

@ -209,7 +209,7 @@ void P_VavoomSlope(sector_t * sec, int id, fixed_t x, fixed_t y, fixed_t z, int
{ {
FVector3 v1, v2, cross; FVector3 v1, v2, cross;
secplane_t *srcplane = (which == 0) ? &sec->floorplane : &sec->ceilingplane; secplane_t *srcplane = (which == 0) ? &sec->floorplane : &sec->ceilingplane;
fixed_t srcheight = (which == 0) ? sec->floortexz : sec->ceilingtexz; fixed_t srcheight = (which == 0) ? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling);
v1[0] = FIXED2FLOAT (x - l->v2->x); v1[0] = FIXED2FLOAT (x - l->v2->x);
v1[1] = FIXED2FLOAT (y - l->v2->y); v1[1] = FIXED2FLOAT (y - l->v2->y);
@ -327,9 +327,9 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt)
fixed_t z3; fixed_t z3;
if (h1==NULL && h2==NULL && h3==NULL) continue; if (h1==NULL && h2==NULL && h3==NULL) continue;
vt1.Z = FIXED2FLOAT(h1? *h1 : j==0? sec->floortexz : sec->ceilingtexz); vt1.Z = FIXED2FLOAT(h1? *h1 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling));
vt2.Z = FIXED2FLOAT(h2? *h2 : j==0? sec->floortexz : sec->ceilingtexz); vt2.Z = FIXED2FLOAT(h2? *h2 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling));
z3 = h3? *h3 : j==0? sec->floortexz : sec->ceilingtexz; z3 = h3? *h3 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling);
vt3.Z = FIXED2FLOAT(z3); vt3.Z = FIXED2FLOAT(z3);
if (P_PointOnLineSide(vertexes[vi3].x, vertexes[vi3].y, sec->lines[0]) == 0) if (P_PointOnLineSide(vertexes[vi3].x, vertexes[vi3].y, sec->lines[0]) == 0)

View file

@ -684,12 +684,12 @@ DLightTransfer::DLightTransfer (sector_t *srcSec, int target, bool copyFloor)
if (copyFloor) if (copyFloor)
{ {
for (secnum = -1; (secnum = P_FindSectorFromTag (target, secnum)) >= 0; ) for (secnum = -1; (secnum = P_FindSectorFromTag (target, secnum)) >= 0; )
sectors[secnum].FloorFlags |= SECF_ABSLIGHTING; sectors[secnum].ChangeFlags(sector_t::floor, 0, SECF_ABSLIGHTING);
} }
else else
{ {
for (secnum = -1; (secnum = P_FindSectorFromTag (target, secnum)) >= 0; ) for (secnum = -1; (secnum = P_FindSectorFromTag (target, secnum)) >= 0; )
sectors[secnum].CeilingFlags |= SECF_ABSLIGHTING; sectors[secnum].ChangeFlags(sector_t::ceiling, 0, SECF_ABSLIGHTING);
} }
ChangeStatNum (STAT_LIGHTTRANSFER); ChangeStatNum (STAT_LIGHTTRANSFER);
} }
@ -712,12 +712,12 @@ void DLightTransfer::DoTransfer (BYTE level, int target, bool floor)
if (floor) if (floor)
{ {
for (secnum = -1; (secnum = P_FindSectorFromTag (target, secnum)) >= 0; ) for (secnum = -1; (secnum = P_FindSectorFromTag (target, secnum)) >= 0; )
sectors[secnum].FloorLight = level; sectors[secnum].SetPlaneLight(sector_t::floor, level);
} }
else else
{ {
for (secnum = -1; (secnum = P_FindSectorFromTag (target, secnum)) >= 0; ) for (secnum = -1; (secnum = P_FindSectorFromTag (target, secnum)) >= 0; )
sectors[secnum].CeilingLight = level; sectors[secnum].SetPlaneLight(sector_t::ceiling, level);
} }
} }

View file

@ -419,7 +419,7 @@ static bool EditTraceResult (DWORD flags, FTraceResults &res)
{ // Throw away sky hits { // Throw away sky hits
if (res.HitType == TRACE_HitFloor) if (res.HitType == TRACE_HitFloor)
{ {
if (res.Sector->floorpic == skyflatnum) if (res.Sector->GetTexture(sector_t::floor) == skyflatnum)
{ {
res.HitType = TRACE_HitNone; res.HitType = TRACE_HitNone;
return false; return false;
@ -427,7 +427,7 @@ static bool EditTraceResult (DWORD flags, FTraceResults &res)
} }
else if (res.HitType == TRACE_HitCeiling) else if (res.HitType == TRACE_HitCeiling)
{ {
if (res.Sector->ceilingpic == skyflatnum) if (res.Sector->GetTexture(sector_t::ceiling) == skyflatnum)
{ {
res.HitType = TRACE_HitNone; res.HitType = TRACE_HitNone;
return false; return false;
@ -436,8 +436,8 @@ static bool EditTraceResult (DWORD flags, FTraceResults &res)
else if (res.HitType == TRACE_HitWall) else if (res.HitType == TRACE_HitWall)
{ {
if (res.Tier == TIER_Upper && if (res.Tier == TIER_Upper &&
res.Line->frontsector->ceilingpic == skyflatnum && res.Line->frontsector->GetTexture(sector_t::ceiling) == skyflatnum &&
res.Line->backsector->ceilingpic == skyflatnum) res.Line->backsector->GetTexture(sector_t::ceiling) == skyflatnum)
{ {
res.HitType = TRACE_HitNone; res.HitType = TRACE_HitNone;
return false; return false;

View file

@ -800,19 +800,19 @@ struct UDMFParser
switch(key) switch(key)
{ {
case NAME_Heightfloor: case NAME_Heightfloor:
sec->floortexz = CheckInt(key) << FRACBITS; sec->SetPlaneTexZ(sector_t::floor, CheckInt(key) << FRACBITS);
break; break;
case NAME_Heightceiling: case NAME_Heightceiling:
sec->ceilingtexz = CheckInt(key) << FRACBITS; sec->SetPlaneTexZ(sector_t::ceiling, CheckInt(key) << FRACBITS);
break; break;
case NAME_Texturefloor: case NAME_Texturefloor:
sec->floorpic = TexMan.GetTexture (CheckString(key), FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable); sec->SetTexture(sector_t::floor, TexMan.GetTexture (CheckString(key), FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable));
break; break;
case NAME_Textureceiling: case NAME_Textureceiling:
sec->ceilingpic = TexMan.GetTexture (CheckString(key), FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable); sec->SetTexture(sector_t::ceiling, TexMan.GetTexture (CheckString(key), FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable));
break; break;
case NAME_Lightlevel: case NAME_Lightlevel:
@ -880,21 +880,21 @@ struct UDMFParser
break; break;
case NAME_Lightfloor: case NAME_Lightfloor:
sec->FloorLight = CheckInt(key); sec->SetPlaneLight(sector_t::floor, CheckInt(key));
break; break;
case NAME_Lightceiling: case NAME_Lightceiling:
sec->CeilingLight = CheckInt(key); sec->SetPlaneLight(sector_t::ceiling, CheckInt(key));
break; break;
case NAME_Lightfloorabsolute: case NAME_Lightfloorabsolute:
if (CheckBool(key)) sec->FloorFlags |= SECF_ABSLIGHTING; if (CheckBool(key)) sec->ChangeFlags(sector_t::floor, 0, SECF_ABSLIGHTING);
else sec->FloorFlags &= ~SECF_ABSLIGHTING; else sec->ChangeFlags(sector_t::floor, SECF_ABSLIGHTING, 0);
break; break;
case NAME_Lightceilingabsolute: case NAME_Lightceilingabsolute:
if (CheckBool(key)) sec->CeilingFlags |= SECF_ABSLIGHTING; if (CheckBool(key)) sec->ChangeFlags(sector_t::ceiling, 0, SECF_ABSLIGHTING);
else sec->CeilingFlags &= ~SECF_ABSLIGHTING; else sec->ChangeFlags(sector_t::ceiling, SECF_ABSLIGHTING, 0);
break; break;
case NAME_Gravity: case NAME_Gravity:
@ -932,16 +932,16 @@ struct UDMFParser
sc.MustGetToken(';'); sc.MustGetToken(';');
} }
sec->floorplane.d = -sec->floortexz; sec->floorplane.d = -sec->GetPlaneTexZ(sector_t::floor);
sec->floorplane.c = FRACUNIT; sec->floorplane.c = FRACUNIT;
sec->floorplane.ic = FRACUNIT; sec->floorplane.ic = FRACUNIT;
sec->ceilingplane.d = sec->ceilingtexz; sec->ceilingplane.d = sec->GetPlaneTexZ(sector_t::ceiling);
sec->ceilingplane.c = -FRACUNIT; sec->ceilingplane.c = -FRACUNIT;
sec->ceilingplane.ic = -FRACUNIT; sec->ceilingplane.ic = -FRACUNIT;
// [RH] Sectors default to white light with the default fade. // [RH] Sectors default to white light with the default fade.
// If they are outside (have a sky ceiling), they use the outside fog. // If they are outside (have a sky ceiling), they use the outside fog.
if (level.outsidefog != 0xff000000 && (sec->ceilingpic == skyflatnum || (sec->special&0xff) == Sector_Outside)) if (level.outsidefog != 0xff000000 && (sec->GetTexture(sector_t::ceiling) == skyflatnum || (sec->special&0xff) == Sector_Outside))
{ {
if (fogMap == NULL) if (fogMap == NULL)
fogMap = GetSpecialLights (PalEntry (255,255,255), level.outsidefog, 0); fogMap = GetSpecialLights (PalEntry (255,255,255), level.outsidefog, 0);

View file

@ -242,10 +242,10 @@ static int WriteSECTORS (FILE *file)
for (int i = 0; i < numsectors; ++i) for (int i = 0; i < numsectors; ++i)
{ {
ms.floorheight = LittleShort(short(sectors[i].floortexz >> FRACBITS)); ms.floorheight = LittleShort(short(sectors[i].GetPlaneTexZ(sector_t::floor) >> FRACBITS));
ms.ceilingheight = LittleShort(short(sectors[i].ceilingtexz >> FRACBITS)); ms.ceilingheight = LittleShort(short(sectors[i].GetPlaneTexZ(sector_t::ceiling) >> FRACBITS));
uppercopy (ms.floorpic, GetTextureName (sectors[i].floorpic)); uppercopy (ms.floorpic, GetTextureName (sectors[i].GetTexture(sector_t::floor)));
uppercopy (ms.ceilingpic, GetTextureName (sectors[i].ceilingpic)); uppercopy (ms.ceilingpic, GetTextureName (sectors[i].GetTexture(sector_t::ceiling)));
ms.lightlevel = LittleShort(sectors[i].lightlevel); ms.lightlevel = LittleShort(sectors[i].lightlevel);
ms.special = LittleShort(sectors[i].special); ms.special = LittleShort(sectors[i].special);
ms.tag = LittleShort(sectors[i].tag); ms.tag = LittleShort(sectors[i].tag);

View file

@ -269,25 +269,25 @@ void R_ClearClipSegs (short left, short right)
int GetFloorLight (const sector_t *sec) int GetFloorLight (const sector_t *sec)
{ {
if (sec->FloorFlags & SECF_ABSLIGHTING) if (sec->GetFlags(sector_t::floor) & SECF_ABSLIGHTING)
{ {
return sec->FloorLight; return sec->GetPlaneLight(sector_t::floor);
} }
else else
{ {
return clamp (sec->lightlevel + (SBYTE)sec->FloorLight, 0, 255); return clamp (sec->lightlevel + sec->GetPlaneLight(sector_t::floor), 0, 255);
} }
} }
int GetCeilingLight (const sector_t *sec) int GetCeilingLight (const sector_t *sec)
{ {
if (sec->CeilingFlags & SECF_ABSLIGHTING) if (sec->GetFlags(sector_t::ceiling) & SECF_ABSLIGHTING)
{ {
return sec->CeilingLight; return sec->GetPlaneLight(sector_t::ceiling);
} }
else else
{ {
return clamp (sec->lightlevel + (SBYTE)sec->CeilingLight, 0, 255); return clamp (sec->lightlevel + sec->GetPlaneLight(sector_t::ceiling), 0, 255);
} }
} }
@ -368,7 +368,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
{ {
if (CopyPlaneIfValid (&tempsec->floorplane, &s->floorplane, &sec->ceilingplane)) if (CopyPlaneIfValid (&tempsec->floorplane, &s->floorplane, &sec->ceilingplane))
{ {
tempsec->floorpic = s->floorpic; tempsec->SetTexture(sector_t::floor, s->GetTexture(sector_t::floor), false);
} }
else if (s->MoreFlags & SECF_FAKEFLOORONLY) else if (s->MoreFlags & SECF_FAKEFLOORONLY)
{ {
@ -406,7 +406,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
{ {
if (CopyPlaneIfValid (&tempsec->ceilingplane, &s->ceilingplane, &sec->floorplane)) if (CopyPlaneIfValid (&tempsec->ceilingplane, &s->ceilingplane, &sec->floorplane))
{ {
tempsec->ceilingpic = s->ceilingpic; tempsec->SetTexture(sector_t::ceiling, s->GetTexture(sector_t::ceiling), false);
} }
} }
else else
@ -456,23 +456,23 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
// killough 11/98: prevent sudden light changes from non-water sectors: // killough 11/98: prevent sudden light changes from non-water sectors:
if ((underwater && !back) || doorunderwater) if ((underwater && !back) || doorunderwater)
{ // head-below-floor hack { // head-below-floor hack
tempsec->floorpic = diffTex ? sec->floorpic : s->floorpic; tempsec->SetTexture(sector_t::floor, diffTex ? sec->GetTexture(sector_t::floor) : s->GetTexture(sector_t::floor), false);
tempsec->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform; tempsec->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform;
tempsec->ceilingplane = s->floorplane; tempsec->ceilingplane = s->floorplane;
tempsec->ceilingplane.FlipVert (); tempsec->ceilingplane.FlipVert ();
tempsec->ceilingplane.ChangeHeight (-1); tempsec->ceilingplane.ChangeHeight (-1);
if (s->ceilingpic == skyflatnum) if (s->GetTexture(sector_t::ceiling) == skyflatnum)
{ {
tempsec->floorplane = tempsec->ceilingplane; tempsec->floorplane = tempsec->ceilingplane;
tempsec->floorplane.FlipVert (); tempsec->floorplane.FlipVert ();
tempsec->floorplane.ChangeHeight (+1); tempsec->floorplane.ChangeHeight (+1);
tempsec->ceilingpic = tempsec->floorpic; tempsec->SetTexture(sector_t::ceiling, tempsec->GetTexture(sector_t::floor), false);
tempsec->planes[sector_t::ceiling].xform = tempsec->planes[sector_t::floor].xform; tempsec->planes[sector_t::ceiling].xform = tempsec->planes[sector_t::floor].xform;
} }
else else
{ {
tempsec->ceilingpic = diffTex ? s->floorpic : s->ceilingpic; tempsec->SetTexture(sector_t::ceiling, diffTex ? s->GetTexture(sector_t::floor) : s->GetTexture(sector_t::ceiling), false);
tempsec->planes[sector_t::ceiling].xform = s->planes[sector_t::ceiling].xform; tempsec->planes[sector_t::ceiling].xform = s->planes[sector_t::ceiling].xform;
} }
@ -502,14 +502,14 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
tempsec->ColorMap = s->ColorMap; tempsec->ColorMap = s->ColorMap;
tempsec->ColorMap = s->ColorMap; tempsec->ColorMap = s->ColorMap;
tempsec->ceilingpic = diffTex ? sec->ceilingpic : s->ceilingpic; tempsec->SetTexture(sector_t::ceiling, diffTex ? sec->GetTexture(sector_t::ceiling) : s->GetTexture(sector_t::ceiling), false);
tempsec->floorpic = s->ceilingpic; tempsec->SetTexture(sector_t::floor, s->GetTexture(sector_t::ceiling), false);
tempsec->planes[sector_t::ceiling].xform = tempsec->planes[sector_t::floor].xform = s->planes[sector_t::ceiling].xform; tempsec->planes[sector_t::ceiling].xform = tempsec->planes[sector_t::floor].xform = s->planes[sector_t::ceiling].xform;
if (s->floorpic != skyflatnum) if (s->GetTexture(sector_t::floor) != skyflatnum)
{ {
tempsec->ceilingplane = sec->ceilingplane; tempsec->ceilingplane = sec->ceilingplane;
tempsec->floorpic = s->floorpic; tempsec->SetTexture(sector_t::floor, s->GetTexture(sector_t::floor), false);
tempsec->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform; tempsec->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform;
} }
@ -723,7 +723,7 @@ void R_AddLine (seg_t *line)
} }
else if ( else if (
// properly render skies (consider door "open" if both ceilings are sky): // properly render skies (consider door "open" if both ceilings are sky):
(backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum) (backsector->GetTexture(sector_t::ceiling) != skyflatnum || frontsector->GetTexture(sector_t::ceiling) != skyflatnum)
// if door is closed because back is shut: // if door is closed because back is shut:
&& rw_backcz1 <= rw_backfz1 && rw_backcz2 <= rw_backfz2 && rw_backcz1 <= rw_backfz1 && rw_backcz2 <= rw_backfz2
@ -750,8 +750,8 @@ void R_AddLine (seg_t *line)
solid = false; solid = false;
} }
else if (backsector->lightlevel != frontsector->lightlevel else if (backsector->lightlevel != frontsector->lightlevel
|| backsector->floorpic != frontsector->floorpic || backsector->GetTexture(sector_t::floor) != frontsector->GetTexture(sector_t::floor)
|| backsector->ceilingpic != frontsector->ceilingpic || backsector->GetTexture(sector_t::ceiling) != frontsector->GetTexture(sector_t::ceiling)
|| curline->sidedef->GetTexture(side_t::mid).isValid() || curline->sidedef->GetTexture(side_t::mid).isValid()
// killough 3/7/98: Take flats offsets into account: // killough 3/7/98: Take flats offsets into account:
@ -760,10 +760,10 @@ void R_AddLine (seg_t *line)
|| backsector->GetXOffset(sector_t::ceiling) != frontsector->GetXOffset(sector_t::ceiling) || backsector->GetXOffset(sector_t::ceiling) != frontsector->GetXOffset(sector_t::ceiling)
|| backsector->GetYOffset(sector_t::ceiling) != frontsector->GetYOffset(sector_t::ceiling) || backsector->GetYOffset(sector_t::ceiling) != frontsector->GetYOffset(sector_t::ceiling)
|| backsector->FloorLight != frontsector->FloorLight || backsector->GetPlaneLight(sector_t::floor) != frontsector->GetPlaneLight(sector_t::floor)
|| backsector->CeilingLight != frontsector->CeilingLight || backsector->GetPlaneLight(sector_t::ceiling) != frontsector->GetPlaneLight(sector_t::ceiling)
|| backsector->FloorFlags != frontsector->FloorFlags || backsector->GetFlags(sector_t::floor) != frontsector->GetFlags(sector_t::floor)
|| backsector->CeilingFlags != frontsector->CeilingFlags || backsector->GetFlags(sector_t::ceiling) != frontsector->GetFlags(sector_t::ceiling)
// [RH] Also consider colormaps // [RH] Also consider colormaps
|| backsector->ColorMap != frontsector->ColorMap || backsector->ColorMap != frontsector->ColorMap
@ -1041,13 +1041,13 @@ void R_Subsector (subsector_t *sub)
r_actualextralight = foggy ? 0 : extralight << 4; r_actualextralight = foggy ? 0 : extralight << 4;
basecolormap = frontsector->ColorMap; basecolormap = frontsector->ColorMap;
ceilingplane = frontsector->ceilingplane.ZatPoint (viewx, viewy) > viewz || ceilingplane = frontsector->ceilingplane.ZatPoint (viewx, viewy) > viewz ||
frontsector->ceilingpic == skyflatnum || frontsector->GetTexture(sector_t::ceiling) == skyflatnum ||
(frontsector->CeilingSkyBox != NULL && frontsector->CeilingSkyBox->bAlways) || (frontsector->CeilingSkyBox != NULL && frontsector->CeilingSkyBox->bAlways) ||
(frontsector->heightsec && (frontsector->heightsec &&
!(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) && !(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) &&
frontsector->heightsec->floorpic == skyflatnum) ? frontsector->heightsec->GetTexture(sector_t::floor) == skyflatnum) ?
R_FindPlane(frontsector->ceilingplane, // killough 3/8/98 R_FindPlane(frontsector->ceilingplane, // killough 3/8/98
frontsector->ceilingpic, frontsector->GetTexture(sector_t::ceiling),
ceilinglightlevel + r_actualextralight, // killough 4/11/98 ceilinglightlevel + r_actualextralight, // killough 4/11/98
frontsector->GetXOffset(sector_t::ceiling), // killough 3/7/98 frontsector->GetXOffset(sector_t::ceiling), // killough 3/7/98
frontsector->GetYOffset(sector_t::ceiling), // killough 3/7/98 frontsector->GetYOffset(sector_t::ceiling), // killough 3/7/98
@ -1065,13 +1065,13 @@ void R_Subsector (subsector_t *sub)
// killough 3/16/98: add floorlightlevel // killough 3/16/98: add floorlightlevel
// killough 10/98: add support for skies transferred from sidedefs // killough 10/98: add support for skies transferred from sidedefs
floorplane = frontsector->floorplane.ZatPoint (viewx, viewy) < viewz || // killough 3/7/98 floorplane = frontsector->floorplane.ZatPoint (viewx, viewy) < viewz || // killough 3/7/98
frontsector->floorpic == skyflatnum || frontsector->GetTexture(sector_t::floor) == skyflatnum ||
(frontsector->FloorSkyBox != NULL && frontsector->FloorSkyBox->bAlways) || (frontsector->FloorSkyBox != NULL && frontsector->FloorSkyBox->bAlways) ||
(frontsector->heightsec && (frontsector->heightsec &&
!(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) && !(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) &&
frontsector->heightsec->ceilingpic == skyflatnum) ? frontsector->heightsec->GetTexture(sector_t::ceiling) == skyflatnum) ?
R_FindPlane(frontsector->floorplane, R_FindPlane(frontsector->floorplane,
frontsector->floorpic, frontsector->GetTexture(sector_t::floor),
floorlightlevel + r_actualextralight, // killough 3/16/98 floorlightlevel + r_actualextralight, // killough 3/16/98
frontsector->GetXOffset(sector_t::floor), // killough 3/7/98 frontsector->GetXOffset(sector_t::floor), // killough 3/7/98
frontsector->GetYOffset(sector_t::floor), // killough 3/7/98 frontsector->GetYOffset(sector_t::floor), // killough 3/7/98
@ -1087,7 +1087,7 @@ void R_Subsector (subsector_t *sub)
// lightlevels on floor & ceiling lightlevels in the surrounding area. // lightlevels on floor & ceiling lightlevels in the surrounding area.
// [RH] Handle sprite lighting like Duke 3D: If the ceiling is a sky, sprites are lit by // [RH] Handle sprite lighting like Duke 3D: If the ceiling is a sky, sprites are lit by
// it, otherwise they are lit by the floor. // it, otherwise they are lit by the floor.
R_AddSprites (sub->sector, frontsector->ceilingpic == skyflatnum ? R_AddSprites (sub->sector, frontsector->GetTexture(sector_t::ceiling) == skyflatnum ?
ceilinglightlevel : floorlightlevel, FakeSide); ceilinglightlevel : floorlightlevel, FakeSide);
// [RH] Add particles // [RH] Add particles

View file

@ -457,7 +457,8 @@ void R_PrecacheLevel (void)
for (i = numsectors - 1; i >= 0; i--) for (i = numsectors - 1; i >= 0; i--)
{ {
hitlist[sectors[i].floorpic.GetIndex()] = hitlist[sectors[i].ceilingpic.GetIndex()] |= 2; hitlist[sectors[i].GetTexture(sector_t::floor).GetIndex()] =
hitlist[sectors[i].GetTexture(sector_t::ceiling).GetIndex()] |= 2;
} }
for (i = numsides - 1; i >= 0; i--) for (i = numsides - 1; i >= 0; i--)

View file

@ -373,6 +373,10 @@ struct sector_t
struct splane struct splane
{ {
FTransform xform; FTransform xform;
int Flags;
int Light;
FTextureID Texture;
fixed_t TexZ;
}; };
@ -458,6 +462,53 @@ struct sector_t
planes[pos].xform.base_angle = o; planes[pos].xform.base_angle = o;
} }
int GetFlags(int pos) const
{
return planes[pos].Flags;
}
void ChangeFlags(int pos, int And, int Or)
{
planes[pos].Flags &= ~And;
planes[pos].Flags |= Or;
}
int GetPlaneLight(int pos) const
{
return planes[pos].Light;
}
void SetPlaneLight(int pos, int level)
{
planes[pos].Light = level;
}
FTextureID GetTexture(int pos) const
{
return planes[pos].Texture;
}
void SetTexture(int pos, FTextureID tex, bool floorclip = true)
{
FTextureID old = planes[pos].Texture;
planes[pos].Texture = tex;
if (floorclip && pos == floor && tex != old) AdjustFloorClip();
}
fixed_t GetPlaneTexZ(int pos) const
{
return planes[pos].TexZ;
}
void SetPlaneTexZ(int pos, fixed_t val)
{
planes[pos].TexZ = val;
}
void ChangePlaneTexZ(int pos, fixed_t val)
{
planes[pos].TexZ += val;
}
// Member variables // Member variables
@ -466,14 +517,10 @@ struct sector_t
// [RH] store floor and ceiling planes instead of heights // [RH] store floor and ceiling planes instead of heights
secplane_t floorplane, ceilingplane; secplane_t floorplane, ceilingplane;
fixed_t floortexz, ceilingtexz; // [RH] used for wall texture mapping
// [RH] give floor and ceiling even more properties // [RH] give floor and ceiling even more properties
FDynamicColormap *ColorMap; // [RH] Per-sector colormap FDynamicColormap *ColorMap; // [RH] Per-sector colormap
BYTE FloorLight, CeilingLight;
BYTE FloorFlags, CeilingFlags;
FTextureID floorpic, ceilingpic;
BYTE lightlevel; BYTE lightlevel;
TObjPtr<AActor> SoundTarget; TObjPtr<AActor> SoundTarget;

View file

@ -429,12 +429,12 @@ void DSectorPlaneInterpolation::UpdateInterpolation()
if (!ceiling) if (!ceiling)
{ {
oldheight = sector->floorplane.d; oldheight = sector->floorplane.d;
oldtexz = sector->floortexz; oldtexz = sector->GetPlaneTexZ(sector_t::floor);
} }
else else
{ {
oldheight = sector->ceilingplane.d; oldheight = sector->ceilingplane.d;
oldtexz = sector->ceilingtexz; oldtexz = sector->GetPlaneTexZ(sector_t::ceiling);
} }
} }
@ -449,12 +449,12 @@ void DSectorPlaneInterpolation::Restore()
if (!ceiling) if (!ceiling)
{ {
sector->floorplane.d = bakheight; sector->floorplane.d = bakheight;
sector->floortexz = baktexz; sector->SetPlaneTexZ(sector_t::floor, baktexz);
} }
else else
{ {
sector->ceilingplane.d = bakheight; sector->ceilingplane.d = bakheight;
sector->ceilingtexz = baktexz; sector->GetPlaneTexZ(sector_t::ceiling, baktexz?;
} }
} }
@ -467,24 +467,25 @@ void DSectorPlaneInterpolation::Restore()
void DSectorPlaneInterpolation::Interpolate(fixed_t smoothratio) void DSectorPlaneInterpolation::Interpolate(fixed_t smoothratio)
{ {
fixed_t *pheight; fixed_t *pheight;
int pos;
fixed_t *ptexz; fixed_t *ptexz;
if (!ceiling) if (!ceiling)
{ {
pheight = &sector->floorplane.d; pheight = &sector->floorplane.d;
ptexz = &sector->floortexz; pos = sector_t::floor;
} }
else else
{ {
pheight = &sector->ceilingplane.d; pheight = &sector->ceilingplane.d;
ptexz = &sector->ceilingtexz; pos = sector_t::ceiling;
} }
bakheight = *pheight; bakheight = *pheight;
baktexz = *ptexz; baktexz = sector->GetPlaneTexZ(pos);
*pheight = oldheight + FixedMul(bakheight - oldheight, smoothratio); *pheight = oldheight + FixedMul(bakheight - oldheight, smoothratio);
*ptexz = oldtexz + FixedMul(baktexz - oldtexz, smoothratio); sector->SetPlaneTexZ(pos, oldtexz + FixedMul(baktexz - oldtexz, smoothratio));
} }
//========================================================================== //==========================================================================

View file

@ -1267,8 +1267,8 @@ void RP_AddLine (seg_t *line)
solid = true; solid = true;
} }
else if ( else if (
(backsector->ceilingpic != skyflatnum || (backsector->GetTexture(sector_t::ceiling) != skyflatnum ||
frontsector->ceilingpic != skyflatnum) frontsector->GetTexture(sector_t::ceiling) != skyflatnum)
// if door is closed because back is shut: // if door is closed because back is shut:
&& bcz0 <= bfz0 && bcz1 <= bfz1 && bcz0 <= bfz0 && bcz1 <= bfz1
@ -1296,8 +1296,8 @@ void RP_AddLine (seg_t *line)
solid = false; solid = false;
} }
else if (backsector->lightlevel != frontsector->lightlevel else if (backsector->lightlevel != frontsector->lightlevel
|| backsector->floorpic != frontsector->floorpic || backsector->GetTexture(sector_t::floor) != frontsector->GetTexture(sector_t::floor)
|| backsector->ceilingpic != frontsector->ceilingpic || backsector->GetTexture(sector_t::ceiling) != frontsector->GetTexture(sector_t::ceiling)
|| curline->sidedef->GetTexture(side_t::mid).isValid() || curline->sidedef->GetTexture(side_t::mid).isValid()
// killough 3/7/98: Take flats offsets into account: // killough 3/7/98: Take flats offsets into account:
@ -1306,10 +1306,10 @@ void RP_AddLine (seg_t *line)
|| backsector->GetXOffset(sector_t::ceiling) != frontsector->GetXOffset(sector_t::ceiling) || backsector->GetXOffset(sector_t::ceiling) != frontsector->GetXOffset(sector_t::ceiling)
|| backsector->GetYOffset(sector_t::ceiling) != frontsector->GetYOffset(sector_t::ceiling) || backsector->GetYOffset(sector_t::ceiling) != frontsector->GetYOffset(sector_t::ceiling)
|| backsector->FloorLight != frontsector->FloorLight || backsector->GetPlaneLight(sector_t::floor) != frontsector->GetPlaneLight(sector_t::floor)
|| backsector->CeilingLight != frontsector->CeilingLight || backsector->GetPlaneLight(sector_t::ceiling) != frontsector->GetPlaneLight(sector_t::ceiling)
|| backsector->FloorFlags != frontsector->FloorFlags || backsector->GetFlags(sector_t::floor) != frontsector->GetFlags(sector_t::floor)
|| backsector->CeilingFlags != frontsector->CeilingFlags || backsector->GetFlags(sector_t::ceiling) != frontsector->GetFlags(sector_t::ceiling)
// [RH] Also consider colormaps // [RH] Also consider colormaps
|| backsector->ColorMap != frontsector->ColorMap || backsector->ColorMap != frontsector->ColorMap

View file

@ -144,7 +144,7 @@ inline bool IsFogBoundary (sector_t *front, sector_t *back)
{ {
return r_fogboundary && !fixedcolormap && front->ColorMap->Fade && return r_fogboundary && !fixedcolormap && front->ColorMap->Fade &&
front->ColorMap->Fade != back->ColorMap->Fade && front->ColorMap->Fade != back->ColorMap->Fade &&
(front->ceilingpic != skyflatnum || back->ceilingpic != skyflatnum); (front->GetTexture(sector_t::ceiling) != skyflatnum || back->GetTexture(sector_t::ceiling) != skyflatnum);
} }
//============================================================================= //=============================================================================
@ -255,11 +255,11 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2)
texheight = tex->GetScaledHeight() << FRACBITS; texheight = tex->GetScaledHeight() << FRACBITS;
if (curline->linedef->flags & ML_DONTPEGBOTTOM) if (curline->linedef->flags & ML_DONTPEGBOTTOM)
{ {
dc_texturemid = MAX (frontsector->floortexz, backsector->floortexz) + texheight; dc_texturemid = MAX (frontsector->GetPlaneTexZ(sector_t::floor), backsector->GetPlaneTexZ(sector_t::floor)) + texheight;
} }
else else
{ {
dc_texturemid = MIN (frontsector->ceilingtexz, backsector->ceilingtexz); dc_texturemid = MIN (frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling));
} }
{ // encapsilate the lifetime of rowoffset { // encapsilate the lifetime of rowoffset
@ -1198,11 +1198,11 @@ void R_NewWall (bool needlights)
rowoffset = sidedef->GetTextureYOffset(side_t::mid); rowoffset = sidedef->GetTextureYOffset(side_t::mid);
if (linedef->flags & ML_DONTPEGBOTTOM) if (linedef->flags & ML_DONTPEGBOTTOM)
{ // bottom of texture at bottom { // bottom of texture at bottom
rw_midtexturemid = frontsector->floortexz + (midtexture->GetHeight() << FRACBITS); rw_midtexturemid = frontsector->GetPlaneTexZ(sector_t::floor) + (midtexture->GetHeight() << FRACBITS);
} }
else else
{ // top of texture at top { // top of texture at top
rw_midtexturemid = frontsector->ceilingtexz; rw_midtexturemid = frontsector->GetPlaneTexZ(sector_t::ceiling);
if (rowoffset < 0 && midtexture != NULL) if (rowoffset < 0 && midtexture != NULL)
{ {
rowoffset += midtexture->GetHeight() << FRACBITS; rowoffset += midtexture->GetHeight() << FRACBITS;
@ -1230,10 +1230,10 @@ void R_NewWall (bool needlights)
{ // two-sided line { // two-sided line
// hack to allow height changes in outdoor areas // hack to allow height changes in outdoor areas
rw_frontlowertop = frontsector->ceilingtexz; rw_frontlowertop = frontsector->GetPlaneTexZ(sector_t::ceiling);
if (frontsector->ceilingpic == skyflatnum && if (frontsector->GetTexture(sector_t::ceiling) == skyflatnum &&
backsector->ceilingpic == skyflatnum) backsector->GetTexture(sector_t::ceiling) == skyflatnum)
{ {
if (rw_havehigh) if (rw_havehigh)
{ // front ceiling is above back ceiling { // front ceiling is above back ceiling
@ -1251,7 +1251,7 @@ void R_NewWall (bool needlights)
} }
// Putting sky ceilings on the front and back of a line alters the way unpegged // Putting sky ceilings on the front and back of a line alters the way unpegged
// positioning works. // positioning works.
rw_frontlowertop = backsector->ceilingtexz; rw_frontlowertop = backsector->GetPlaneTexZ(sector_t::ceiling);
} }
if ((rw_backcz1 <= rw_frontfz1 && rw_backcz2 <= rw_frontfz2) || if ((rw_backcz1 <= rw_frontfz1 && rw_backcz2 <= rw_frontfz2) ||
@ -1265,7 +1265,7 @@ void R_NewWall (bool needlights)
markfloor = rw_mustmarkfloor markfloor = rw_mustmarkfloor
|| backsector->floorplane != frontsector->floorplane || backsector->floorplane != frontsector->floorplane
|| backsector->lightlevel != frontsector->lightlevel || backsector->lightlevel != frontsector->lightlevel
|| backsector->floorpic != frontsector->floorpic || backsector->GetTexture(sector_t::floor) != frontsector->GetTexture(sector_t::floor)
// killough 3/7/98: Add checks for (x,y) offsets // killough 3/7/98: Add checks for (x,y) offsets
|| backsector->GetXOffset(sector_t::floor) != frontsector->GetXOffset(sector_t::floor) || backsector->GetXOffset(sector_t::floor) != frontsector->GetXOffset(sector_t::floor)
@ -1275,8 +1275,8 @@ void R_NewWall (bool needlights)
// from bleeding through deep water // from bleeding through deep water
|| frontsector->heightsec || frontsector->heightsec
|| backsector->FloorLight != frontsector->FloorLight || backsector->GetPlaneLight(sector_t::floor) != frontsector->GetPlaneLight(sector_t::floor)
|| backsector->FloorFlags != frontsector->FloorFlags || backsector->GetFlags(sector_t::floor) != frontsector->GetFlags(sector_t::floor)
// [RH] Add checks for colormaps // [RH] Add checks for colormaps
|| backsector->ColorMap != frontsector->ColorMap || backsector->ColorMap != frontsector->ColorMap
@ -1289,12 +1289,12 @@ void R_NewWall (bool needlights)
|| (sidedef->GetTexture(side_t::mid).isValid() && linedef->flags & (ML_CLIP_MIDTEX|ML_WRAP_MIDTEX)) || (sidedef->GetTexture(side_t::mid).isValid() && linedef->flags & (ML_CLIP_MIDTEX|ML_WRAP_MIDTEX))
; ;
markceiling = (frontsector->ceilingpic != skyflatnum || markceiling = (frontsector->GetTexture(sector_t::ceiling) != skyflatnum ||
backsector->ceilingpic != skyflatnum) && backsector->GetTexture(sector_t::ceiling) != skyflatnum) &&
(rw_mustmarkceiling (rw_mustmarkceiling
|| backsector->ceilingplane != frontsector->ceilingplane || backsector->ceilingplane != frontsector->ceilingplane
|| backsector->lightlevel != frontsector->lightlevel || backsector->lightlevel != frontsector->lightlevel
|| backsector->ceilingpic != frontsector->ceilingpic || backsector->GetTexture(sector_t::ceiling) != frontsector->GetTexture(sector_t::ceiling)
// killough 3/7/98: Add checks for (x,y) offsets // killough 3/7/98: Add checks for (x,y) offsets
|| backsector->GetXOffset(sector_t::ceiling) != frontsector->GetXOffset(sector_t::ceiling) || backsector->GetXOffset(sector_t::ceiling) != frontsector->GetXOffset(sector_t::ceiling)
@ -1302,10 +1302,10 @@ void R_NewWall (bool needlights)
// killough 4/15/98: prevent 2s normals // killough 4/15/98: prevent 2s normals
// from bleeding through fake ceilings // from bleeding through fake ceilings
|| (frontsector->heightsec && frontsector->ceilingpic != skyflatnum) || (frontsector->heightsec && frontsector->GetTexture(sector_t::ceiling) != skyflatnum)
|| backsector->CeilingLight != frontsector->CeilingLight || backsector->GetPlaneLight(sector_t::ceiling) != frontsector->GetPlaneLight(sector_t::ceiling)
|| backsector->CeilingFlags != frontsector->CeilingFlags || backsector->GetFlags(sector_t::ceiling) != frontsector->GetFlags(sector_t::ceiling)
// [RH] Add check for colormaps // [RH] Add check for colormaps
|| backsector->ColorMap != frontsector->ColorMap || backsector->ColorMap != frontsector->ColorMap
@ -1328,7 +1328,7 @@ void R_NewWall (bool needlights)
rowoffset = sidedef->GetTextureYOffset(side_t::top); rowoffset = sidedef->GetTextureYOffset(side_t::top);
if (linedef->flags & ML_DONTPEGTOP) if (linedef->flags & ML_DONTPEGTOP)
{ // top of texture at top { // top of texture at top
rw_toptexturemid = MulScale16 (frontsector->ceilingtexz - viewz, scale); rw_toptexturemid = MulScale16 (frontsector->GetPlaneTexZ(sector_t::ceiling) - viewz, scale);
if (rowoffset < 0 && toptexture != NULL) if (rowoffset < 0 && toptexture != NULL)
{ {
rowoffset += toptexture->GetHeight() << FRACBITS; rowoffset += toptexture->GetHeight() << FRACBITS;
@ -1336,7 +1336,7 @@ void R_NewWall (bool needlights)
} }
else else
{ // bottom of texture at bottom { // bottom of texture at bottom
rw_toptexturemid = MulScale16 (backsector->ceilingtexz - viewz, scale) + (toptexture->GetHeight() << FRACBITS); rw_toptexturemid = MulScale16 (backsector->GetPlaneTexZ(sector_t::ceiling) - viewz, scale) + (toptexture->GetHeight() << FRACBITS);
} }
if (toptexture->bWorldPanning) if (toptexture->bWorldPanning)
{ {
@ -1359,7 +1359,7 @@ void R_NewWall (bool needlights)
} }
else else
{ // top of texture at top { // top of texture at top
rw_bottomtexturemid = backsector->floortexz; rw_bottomtexturemid = backsector->GetPlaneTexZ(sector_t::floor);
if (rowoffset < 0 && bottomtexture != NULL) if (rowoffset < 0 && bottomtexture != NULL)
{ {
rowoffset += bottomtexture->GetHeight() << FRACBITS; rowoffset += bottomtexture->GetHeight() << FRACBITS;
@ -1388,7 +1388,7 @@ void R_NewWall (bool needlights)
if (frontsector->floorplane.ZatPoint (viewx, viewy) >= viewz) // above view plane if (frontsector->floorplane.ZatPoint (viewx, viewy) >= viewz) // above view plane
markfloor = false; markfloor = false;
if (frontsector->ceilingplane.ZatPoint (viewx, viewy) <= viewz && if (frontsector->ceilingplane.ZatPoint (viewx, viewy) <= viewz &&
frontsector->ceilingpic != skyflatnum) // below view plane frontsector->GetTexture(sector_t::ceiling) != skyflatnum) // below view plane
markceiling = false; markceiling = false;
} }
@ -2145,31 +2145,31 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
case RF_RELUPPER: case RF_RELUPPER:
if (curline->linedef->flags & ML_DONTPEGTOP) if (curline->linedef->flags & ML_DONTPEGTOP)
{ {
zpos = decal->Z + front->ceilingtexz; zpos = decal->Z + front->GetPlaneTexZ(sector_t::ceiling);
} }
else else
{ {
zpos = decal->Z + back->ceilingtexz; zpos = decal->Z + back->GetPlaneTexZ(sector_t::ceiling);
} }
break; break;
case RF_RELLOWER: case RF_RELLOWER:
if (curline->linedef->flags & ML_DONTPEGBOTTOM) if (curline->linedef->flags & ML_DONTPEGBOTTOM)
{ {
zpos = decal->Z + front->ceilingtexz; zpos = decal->Z + front->GetPlaneTexZ(sector_t::ceiling);
} }
else else
{ {
zpos = decal->Z + back->floortexz; zpos = decal->Z + back->GetPlaneTexZ(sector_t::floor);
} }
break; break;
case RF_RELMID: case RF_RELMID:
if (curline->linedef->flags & ML_DONTPEGBOTTOM) if (curline->linedef->flags & ML_DONTPEGBOTTOM)
{ {
zpos = decal->Z + front->floortexz; zpos = decal->Z + front->GetPlaneTexZ(sector_t::floor);
} }
else else
{ {
zpos = decal->Z + front->ceilingtexz; zpos = decal->Z + front->GetPlaneTexZ(sector_t::ceiling);
} }
} }

View file

@ -2381,24 +2381,24 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade,
{ {
topplane = &sector->ceilingplane; topplane = &sector->ceilingplane;
botplane = &heightsec->ceilingplane; botplane = &heightsec->ceilingplane;
toppic = sector->ceilingpic; toppic = sector->GetTexture(sector_t::ceiling);
botpic = heightsec->ceilingpic; botpic = heightsec->GetTexture(sector_t::ceiling);
map = heightsec->ColorMap->Maps; map = heightsec->ColorMap->Maps;
} }
else if (fakeside == FAKED_BelowFloor) else if (fakeside == FAKED_BelowFloor)
{ {
topplane = &heightsec->floorplane; topplane = &heightsec->floorplane;
botplane = &sector->floorplane; botplane = &sector->floorplane;
toppic = heightsec->floorpic; toppic = heightsec->GetTexture(sector_t::floor);
botpic = sector->floorpic; botpic = sector->GetTexture(sector_t::floor);
map = heightsec->ColorMap->Maps; map = heightsec->ColorMap->Maps;
} }
else else
{ {
topplane = &heightsec->ceilingplane; topplane = &heightsec->ceilingplane;
botplane = &heightsec->floorplane; botplane = &heightsec->floorplane;
toppic = heightsec->ceilingpic; toppic = heightsec->GetTexture(sector_t::ceiling);
botpic = heightsec->floorpic; botpic = heightsec->GetTexture(sector_t::floor);
map = sector->ColorMap->Maps; map = sector->ColorMap->Maps;
} }
} }
@ -2406,8 +2406,8 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade,
{ {
topplane = &sector->ceilingplane; topplane = &sector->ceilingplane;
botplane = &sector->floorplane; botplane = &sector->floorplane;
toppic = sector->ceilingpic; toppic = sector->GetTexture(sector_t::ceiling);
botpic = sector->floorpic; botpic = sector->GetTexture(sector_t::floor);
map = sector->ColorMap->Maps; map = sector->ColorMap->Maps;
} }