diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 0367502d5..d37b48d38 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,8 @@ +June 14, 2008 (Changes by Graf Zahl) +- Fixed: The UDMF parser stored plane rotation angles as fixed_t, not angle_t. +- Grouped the sector plane texture transformation values into a separate + structure and replaced all access to them with wrapper functions. + June 12, 2008 - Add environment 255, 255 as a way to get the software underwater effect in any zone you want. diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 30db4eb06..ac337b7d3 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -376,10 +376,10 @@ static void LoadSectors (sectortype *bsec) sec->floorplane.ic = FRACUNIT; sprintf (tnam, "BTIL%04d", LittleShort(bsec->floorpicnum)); sec->floorpic = TexMan.GetTexture (tnam, FTexture::TEX_Build); - sec->floor_xscale = (bsec->floorstat & 8) ? FRACUNIT*2 : FRACUNIT; - sec->floor_yscale = (bsec->floorstat & 8) ? FRACUNIT*2 : FRACUNIT; - sec->floor_xoffs = (bsec->floorxpanning << FRACBITS) + (32 << FRACBITS); - sec->floor_yoffs = bsec->floorypanning << FRACBITS; + sec->SetXScale(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->SetYOffset(sector_t::floor, bsec->floorypanning << FRACBITS); sec->FloorLight = SHADE2LIGHT (bsec->floorshade); sec->FloorFlags = SECF_ABSLIGHTING; @@ -394,10 +394,10 @@ static void LoadSectors (sectortype *bsec) sky1texture = sky2texture = sec->ceilingpic; sec->ceilingpic = skyflatnum; } - sec->ceiling_xscale = (bsec->ceilingstat & 8) ? FRACUNIT*2 : FRACUNIT; - sec->ceiling_yscale = (bsec->ceilingstat & 8) ? FRACUNIT*2 : FRACUNIT; - sec->ceiling_xoffs = (bsec->ceilingxpanning << FRACBITS) + (32 << FRACBITS); - sec->ceiling_yoffs = bsec->ceilingypanning << FRACBITS; + sec->SetXScale(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->SetYOffset(sector_t::ceiling, bsec->ceilingypanning << FRACBITS); sec->CeilingLight = SHADE2LIGHT (bsec->ceilingshade); sec->CeilingFlags = SECF_ABSLIGHTING; @@ -414,30 +414,30 @@ static void LoadSectors (sectortype *bsec) if (bsec->floorstat & 4) { - sec->floor_angle = ANGLE_90; - sec->floor_xscale = -sec->floor_xscale; + sec->SetAngle(sector_t::floor, ANGLE_90); + sec->SetXScale(sector_t::floor, -sec->GetXScale(sector_t::floor)); } if (bsec->floorstat & 16) { - sec->floor_xscale = -sec->floor_xscale; + sec->SetXScale(sector_t::floor, -sec->GetXScale(sector_t::floor)); } if (bsec->floorstat & 32) { - sec->floor_yscale = -sec->floor_yscale; + sec->SetYScale(sector_t::floor, -sec->GetYScale(sector_t::floor)); } if (bsec->ceilingstat & 4) { - sec->ceiling_angle = ANGLE_90; - sec->floor_yscale = -sec->floor_yscale; + sec->SetAngle(sector_t::ceiling, ANGLE_90); + sec->SetYScale(sector_t::ceiling, -sec->GetYScale(sector_t::ceiling)); } if (bsec->ceilingstat & 16) { - sec->ceiling_xscale = -sec->ceiling_xscale; + sec->SetXScale(sector_t::ceiling, -sec->GetXScale(sector_t::ceiling)); } if (bsec->ceilingstat & 32) { - sec->ceiling_yscale = -sec->ceiling_yscale; + sec->SetYScale(sector_t::ceiling, -sec->GetYScale(sector_t::ceiling)); } } } @@ -512,7 +512,7 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec) } sides[i].TexelLength = walls[i].xrepeat * 8; - sides[i].Light = SHADE2LIGHT(walls[i].shade); + sides[i].SetLight(SHADE2LIGHT(walls[i].shade)); sides[i].Flags = WALLF_ABSLIGHTING; sides[i].RightSide = walls[i].point2; sides[walls[i].point2].LeftSide = i; diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 28d21c9eb..ce34fbeea 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -2160,8 +2160,8 @@ FUNC(LS_Sector_SetCeilingPanning) while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) { - sectors[secnum].ceiling_xoffs = xofs; - sectors[secnum].ceiling_yoffs = yofs; + sectors[secnum].SetXOffset(sector_t::ceiling, xofs); + sectors[secnum].SetYOffset(sector_t::ceiling, yofs); } return true; } @@ -2175,8 +2175,8 @@ FUNC(LS_Sector_SetFloorPanning) while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) { - sectors[secnum].floor_xoffs = xofs; - sectors[secnum].floor_yoffs = yofs; + sectors[secnum].SetXOffset(sector_t::floor, xofs); + sectors[secnum].SetYOffset(sector_t::floor, yofs); } return true; } @@ -2196,9 +2196,9 @@ FUNC(LS_Sector_SetCeilingScale) while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) { if (xscale) - sectors[secnum].ceiling_xscale = xscale; + sectors[secnum].SetXScale(sector_t::ceiling, arg1); if (yscale) - sectors[secnum].ceiling_yscale = yscale; + sectors[secnum].SetYScale(sector_t::ceiling, arg2); } return true; } @@ -2216,9 +2216,9 @@ FUNC(LS_Sector_SetFloorScale2) while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) { if (arg1) - sectors[secnum].floor_xscale = arg1; + sectors[secnum].SetXScale(sector_t::floor, arg1); if (arg2) - sectors[secnum].floor_yscale = arg2; + sectors[secnum].SetXScale(sector_t::floor, arg1); } return true; } @@ -2236,9 +2236,9 @@ FUNC(LS_Sector_SetCeilingScale2) while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) { if (arg1) - sectors[secnum].ceiling_xscale = arg1; + sectors[secnum].SetXScale(sector_t::ceiling, arg1); if (arg2) - sectors[secnum].ceiling_yscale = arg2; + sectors[secnum].SetXScale(sector_t::ceiling, arg1); } return true; } @@ -2258,9 +2258,9 @@ FUNC(LS_Sector_SetFloorScale) while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) { if (xscale) - sectors[secnum].floor_xscale = xscale; + sectors[secnum].SetXScale(sector_t::floor, arg1); if (yscale) - sectors[secnum].floor_yscale = yscale; + sectors[secnum].SetXScale(sector_t::floor, arg1); } return true; } @@ -2274,8 +2274,8 @@ FUNC(LS_Sector_SetRotation) while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0) { - sectors[secnum].floor_angle = floor; - sectors[secnum].ceiling_angle = ceiling; + sectors[secnum].SetAngle(sector_t::floor, floor); + sectors[secnum].SetAngle(sector_t::ceiling, ceiling); } return true; } diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 505f69290..529177f86 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -311,13 +311,8 @@ void P_SerializeWorld (FArchive &arc) << sec->stairlock << sec->prevsec << sec->nextsec - << sec->floor_xoffs << sec->floor_yoffs - << sec->ceiling_xoffs << sec->ceiling_yoffs - << sec->floor_xscale << sec->floor_yscale - << sec->ceiling_xscale << sec->ceiling_yscale - << sec->floor_angle << sec->ceiling_angle - << sec->base_ceiling_angle << sec->base_ceiling_yoffs - << sec->base_floor_angle << sec->base_floor_yoffs + << sec->planes[sector_t::floor] + << sec->planes[sector_t::ceiling] << sec->heightsec << sec->bottommap << sec->midmap << sec->topmap << sec->gravity @@ -428,6 +423,13 @@ FArchive &operator<< (FArchive &arc, side_t::part &p) return arc; } +FArchive &operator<< (FArchive &arc, sector_t::splane &p) +{ + arc << p.xform.xoffs << p.xform.yoffs << p.xform.xscale << p.xform.yscale + << p.xform.angle << p.xform.base_yoffs << p.xform.base_angle; + return arc; +} + // // Thinkers diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 51fffaa85..355e5d7f5 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1210,10 +1210,10 @@ void P_LoadSectors (MapData * map) ss->prevsec = -1; // stair retriggering until build completes // killough 3/7/98: - ss->floor_xscale = FRACUNIT; // [RH] floor and ceiling scaling - ss->floor_yscale = FRACUNIT; - ss->ceiling_xscale = FRACUNIT; - ss->ceiling_yscale = FRACUNIT; + ss->SetXScale(sector_t::floor, FRACUNIT); // [RH] floor and ceiling scaling + ss->SetYScale(sector_t::floor, FRACUNIT); + ss->SetXScale(sector_t::ceiling, FRACUNIT); + ss->SetYScale(sector_t::ceiling, FRACUNIT); ss->heightsec = NULL; // sector used to get floor and ceiling height // killough 3/7/98: end changes diff --git a/src/p_spec.cpp b/src/p_spec.cpp index cbf041ecb..35b028248 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -803,12 +803,12 @@ void DWallLightTransfer::DoTransfer (BYTE lightlevel, int target, BYTE flags) if (flags & WLF_SIDE1 && line->sidenum[0]!=NO_SIDE) { - sides[line->sidenum[0]].Light = lightlevel; + sides[line->sidenum[0]].SetLight(lightlevel); } if (flags & WLF_SIDE2 && line->sidenum[1]!=NO_SIDE) { - sides[line->sidenum[1]].Light = lightlevel; + sides[line->sidenum[1]].SetLight(lightlevel); } } } @@ -1150,13 +1150,13 @@ void DScroller::Tick () break; case sc_floor: // killough 3/7/98: Scroll floor texture - sectors[m_Affectee].floor_xoffs += dx; - sectors[m_Affectee].floor_yoffs += dy; + sectors[m_Affectee].AddXOffset(sector_t::floor, dx); + sectors[m_Affectee].AddYOffset(sector_t::floor, dy); break; case sc_ceiling: // killough 3/7/98: Scroll ceiling texture - sectors[m_Affectee].ceiling_xoffs += dx; - sectors[m_Affectee].ceiling_yoffs += dy; + sectors[m_Affectee].AddXOffset(sector_t::ceiling, dx); + sectors[m_Affectee].AddYOffset(sector_t::ceiling, dy); break; // [RH] Don't actually carry anything here. That happens later. diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index 855ec5335..92d4ed655 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -204,6 +204,11 @@ struct UDMFParser return FLOAT2FIXED(CheckFloat(key)); } + angle_t CheckAngle(const char *key) + { + return angle_t(CheckFloat(key) * ANGLE_90 / 90.); + } + bool CheckBool(const char *key) { if (sc.TokenType == TK_True) return true; @@ -724,7 +729,7 @@ struct UDMFParser break; case NAME_light: - sd->Light = CheckInt(key); + sd->SetLight(CheckInt(key)); break; case NAME_lightabsolute: @@ -767,10 +772,10 @@ struct UDMFParser memset(sec, 0, sizeof(*sec)); sec->lightlevel = 160; - sec->floor_xscale = FRACUNIT; // [RH] floor and ceiling scaling - sec->floor_yscale = FRACUNIT; - sec->ceiling_xscale = FRACUNIT; - sec->ceiling_yscale = FRACUNIT; + sec->SetXScale(sector_t::floor, FRACUNIT); // [RH] floor and ceiling scaling + sec->SetYScale(sector_t::floor, FRACUNIT); + sec->SetXScale(sector_t::ceiling, FRACUNIT); + sec->SetYScale(sector_t::ceiling, FRACUNIT); sec->oldspecial = !!(sec->special&SECRET_MASK); sec->thinglist = NULL; sec->touching_thinglist = NULL; // phares 3/14/98 @@ -835,43 +840,43 @@ struct UDMFParser if (namespace_bits & (Zd|Zdt)) switch(key) { case NAME_Xpanningfloor: - sec->floor_xoffs = CheckFixed(key); + sec->SetXOffset(sector_t::floor, CheckFixed(key)); break; case NAME_Ypanningfloor: - sec->floor_yoffs = CheckFixed(key); + sec->SetYOffset(sector_t::floor, CheckFixed(key)); break; case NAME_Xpanningceiling: - sec->ceiling_xoffs = CheckFixed(key); + sec->SetXOffset(sector_t::ceiling, CheckFixed(key)); break; case NAME_Ypanningceiling: - sec->ceiling_yoffs = CheckFixed(key); + sec->SetYOffset(sector_t::ceiling, CheckFixed(key)); break; case NAME_Xscalefloor: - sec->floor_xscale = CheckFixed(key); + sec->SetXScale(sector_t::floor, CheckFixed(key)); break; case NAME_Yscalefloor: - sec->floor_yscale = CheckFixed(key); + sec->SetYScale(sector_t::floor, CheckFixed(key)); break; case NAME_Xscaleceiling: - sec->ceiling_xscale = CheckFixed(key); + sec->SetXScale(sector_t::ceiling, CheckFixed(key)); break; case NAME_Yscaleceiling: - sec->ceiling_yscale = CheckFixed(key); + sec->SetYScale(sector_t::ceiling, CheckFixed(key)); break; case NAME_Rotationfloor: - sec->floor_angle = CheckFixed(key); + sec->SetAngle(sector_t::floor, CheckAngle(key)); break; case NAME_Rotationceiling: - sec->ceiling_angle = CheckFixed(key); + sec->SetAngle(sector_t::ceiling, CheckAngle(key)); break; case NAME_Lightfloor: diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 99721019c..c6113ff07 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -456,13 +456,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, if ((underwater && !back) || doorunderwater) { // head-below-floor hack tempsec->floorpic = diffTex ? sec->floorpic : s->floorpic; - tempsec->floor_xoffs = s->floor_xoffs; - tempsec->floor_yoffs = s->floor_yoffs; - tempsec->floor_xscale = s->floor_xscale; - tempsec->floor_yscale = s->floor_yscale; - tempsec->floor_angle = s->floor_angle; - tempsec->base_floor_angle = s->base_floor_angle; - tempsec->base_floor_yoffs = s->base_floor_yoffs; + tempsec->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform; tempsec->ceilingplane = s->floorplane; tempsec->ceilingplane.FlipVert (); @@ -473,24 +467,12 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, tempsec->floorplane.FlipVert (); tempsec->floorplane.ChangeHeight (+1); tempsec->ceilingpic = tempsec->floorpic; - tempsec->ceiling_xoffs = tempsec->floor_xoffs; - tempsec->ceiling_yoffs = tempsec->floor_yoffs; - tempsec->ceiling_xscale = tempsec->floor_xscale; - tempsec->ceiling_yscale = tempsec->floor_yscale; - tempsec->ceiling_angle = tempsec->floor_angle; - tempsec->base_ceiling_angle = tempsec->base_floor_angle; - tempsec->base_ceiling_yoffs = tempsec->base_floor_yoffs; + tempsec->planes[sector_t::ceiling].xform = tempsec->planes[sector_t::floor].xform; } else { tempsec->ceilingpic = diffTex ? s->floorpic : s->ceilingpic; - tempsec->ceiling_xoffs = s->ceiling_xoffs; - tempsec->ceiling_yoffs = s->ceiling_yoffs; - tempsec->ceiling_xscale = s->ceiling_xscale; - tempsec->ceiling_yscale = s->ceiling_yscale; - tempsec->ceiling_angle = s->ceiling_angle; - tempsec->base_ceiling_angle = s->base_ceiling_angle; - tempsec->base_ceiling_yoffs = s->base_ceiling_yoffs; + tempsec->planes[sector_t::ceiling].xform = s->planes[sector_t::ceiling].xform; } if (!(s->MoreFlags & SECF_NOFAKELIGHT)) @@ -521,23 +503,13 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, tempsec->ceilingpic = diffTex ? sec->ceilingpic : s->ceilingpic; tempsec->floorpic = s->ceilingpic; - tempsec->floor_xoffs = tempsec->ceiling_xoffs = s->ceiling_xoffs; - tempsec->floor_yoffs = tempsec->ceiling_yoffs = s->ceiling_yoffs; - tempsec->floor_xscale = tempsec->ceiling_xscale = s->ceiling_xscale; - tempsec->floor_yscale = tempsec->ceiling_yscale = s->ceiling_yscale; - tempsec->floor_angle = tempsec->ceiling_angle = s->ceiling_angle; - tempsec->base_floor_angle = tempsec->base_ceiling_angle = s->base_ceiling_angle; - tempsec->base_floor_yoffs = tempsec->base_ceiling_yoffs = s->base_ceiling_yoffs; + tempsec->planes[sector_t::ceiling].xform = tempsec->planes[sector_t::floor].xform = s->planes[sector_t::ceiling].xform; if (s->floorpic != skyflatnum) { tempsec->ceilingplane = sec->ceilingplane; tempsec->floorpic = s->floorpic; - tempsec->floor_xoffs = s->floor_xoffs; - tempsec->floor_yoffs = s->floor_yoffs; - tempsec->floor_xscale = s->floor_xscale; - tempsec->floor_yscale = s->floor_yscale; - tempsec->floor_angle = s->floor_angle; + tempsec->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform; } if (!(s->MoreFlags & SECF_NOFAKELIGHT)) @@ -782,10 +754,10 @@ void R_AddLine (seg_t *line) || curline->sidedef->GetTexture(side_t::mid) != 0 // killough 3/7/98: Take flats offsets into account: - || backsector->floor_xoffs != frontsector->floor_xoffs - || (backsector->floor_yoffs + backsector->base_floor_yoffs) != (frontsector->floor_yoffs + backsector->base_floor_yoffs) - || backsector->ceiling_xoffs != frontsector->ceiling_xoffs - || (backsector->ceiling_yoffs + backsector->base_ceiling_yoffs) != (frontsector->ceiling_yoffs + frontsector->base_ceiling_yoffs) + || backsector->GetXOffset(sector_t::floor) != frontsector->GetXOffset(sector_t::floor) + || backsector->GetYOffset(sector_t::floor) != frontsector->GetYOffset(sector_t::floor) + || backsector->GetXOffset(sector_t::ceiling) != frontsector->GetXOffset(sector_t::ceiling) + || backsector->GetYOffset(sector_t::ceiling) != frontsector->GetYOffset(sector_t::ceiling) || backsector->FloorLight != frontsector->FloorLight || backsector->CeilingLight != frontsector->CeilingLight @@ -796,14 +768,14 @@ void R_AddLine (seg_t *line) || backsector->ColorMap != frontsector->ColorMap // [RH] and scaling - || backsector->floor_xscale != frontsector->floor_xscale - || backsector->floor_yscale != frontsector->floor_yscale - || backsector->ceiling_xscale != frontsector->ceiling_xscale - || backsector->ceiling_yscale != frontsector->ceiling_yscale + || backsector->GetXScale(sector_t::floor) != frontsector->GetXScale(sector_t::floor) + || backsector->GetYScale(sector_t::floor) != frontsector->GetYScale(sector_t::floor) + || backsector->GetXScale(sector_t::ceiling) != frontsector->GetXScale(sector_t::ceiling) + || backsector->GetYScale(sector_t::ceiling) != frontsector->GetYScale(sector_t::ceiling) // [RH] and rotation - || (backsector->floor_angle + backsector->base_floor_angle) != (frontsector->floor_angle + frontsector->base_floor_angle) - || (backsector->ceiling_angle + backsector->base_ceiling_angle) != (frontsector->ceiling_angle + frontsector->base_ceiling_angle) + || backsector->GetAngle(sector_t::floor) != frontsector->GetAngle(sector_t::floor) + || backsector->GetAngle(sector_t::ceiling) != frontsector->GetAngle(sector_t::ceiling) ) { solid = false; @@ -1078,11 +1050,11 @@ void R_Subsector (subsector_t *sub) frontsector->sky & PL_SKYFLAT ? frontsector->sky : frontsector->ceilingpic, ceilinglightlevel + r_actualextralight, // killough 4/11/98 - frontsector->ceiling_xoffs, // killough 3/7/98 - frontsector->ceiling_yoffs + frontsector->base_ceiling_yoffs, - frontsector->ceiling_xscale, - frontsector->ceiling_yscale, - frontsector->ceiling_angle + frontsector->base_ceiling_angle, + frontsector->GetXOffset(sector_t::ceiling), // killough 3/7/98 + frontsector->GetYOffset(sector_t::ceiling), // killough 3/7/98 + frontsector->GetXScale(sector_t::ceiling), + frontsector->GetYScale(sector_t::ceiling), + frontsector->GetAngle(sector_t::ceiling), frontsector->CeilingSkyBox ) : NULL; @@ -1103,11 +1075,11 @@ void R_Subsector (subsector_t *sub) frontsector->sky & PL_SKYFLAT ? frontsector->sky : frontsector->floorpic, floorlightlevel + r_actualextralight, // killough 3/16/98 - frontsector->floor_xoffs, // killough 3/7/98 - frontsector->floor_yoffs + frontsector->base_floor_yoffs, - frontsector->floor_xscale, - frontsector->floor_yscale, - frontsector->floor_angle + frontsector->base_floor_angle, + frontsector->GetXOffset(sector_t::floor), // killough 3/7/98 + frontsector->GetYOffset(sector_t::floor), // killough 3/7/98 + frontsector->GetXScale(sector_t::floor), + frontsector->GetYScale(sector_t::floor), + frontsector->GetAngle(sector_t::floor), frontsector->FloorSkyBox ) : NULL; diff --git a/src/r_defs.h b/src/r_defs.h index d4a349aec..a04a33f88 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -319,6 +319,20 @@ struct extsector_t void Serialize(FArchive &arc); }; +struct FTransform +{ + // killough 3/7/98: floor and ceiling texture offsets + fixed_t xoffs, yoffs; + + // [RH] floor and ceiling texture scales + fixed_t xscale, yscale; + + // [RH] floor and ceiling texture rotation + angle_t angle; + + // base values + fixed_t base_angle, base_yoffs; +}; struct sector_t { @@ -347,6 +361,102 @@ struct sector_t DInterpolation *SetInterpolation(int position, bool attach); void StopInterpolation(int position); + enum + { + floor, + ceiling + }; + + struct splane + { + FTransform xform; + }; + + + splane planes[2]; + + void SetXOffset(int pos, fixed_t o) + { + planes[pos].xform.xoffs = o; + } + + void AddXOffset(int pos, fixed_t o) + { + planes[pos].xform.xoffs += o; + } + + fixed_t GetXOffset(int pos) const + { + return planes[pos].xform.xoffs; + } + + void SetYOffset(int pos, fixed_t o) + { + planes[pos].xform.yoffs = o; + } + + void AddYOffset(int pos, fixed_t o) + { + planes[pos].xform.yoffs += o; + } + + fixed_t GetYOffset(int pos, bool addbase = true) const + { + if (!addbase) + { + return planes[pos].xform.yoffs; + } + else + { + return planes[pos].xform.yoffs + planes[pos].xform.base_yoffs; + } + } + + void SetXScale(int pos, fixed_t o) + { + planes[pos].xform.xscale = o; + } + + fixed_t GetXScale(int pos) const + { + return planes[pos].xform.xscale; + } + + void SetYScale(int pos, fixed_t o) + { + planes[pos].xform.yscale = o; + } + + fixed_t GetYScale(int pos) const + { + return planes[pos].xform.yscale; + } + + void SetAngle(int pos, angle_t o) + { + planes[pos].xform.angle = o; + } + + angle_t GetAngle(int pos, bool addbase = true) const + { + if (!addbase) + { + return planes[pos].xform.angle; + } + else + { + return planes[pos].xform.angle + planes[pos].xform.base_angle; + } + } + + void SetBase(int pos, fixed_t y, angle_t o) + { + planes[pos].xform.base_yoffs = y; + planes[pos].xform.base_angle = o; + } + + + // Member variables fixed_t CenterFloor () const { return floorplane.ZatPoint (soundorg[0], soundorg[1]); } fixed_t CenterCeiling () const { return ceilingplane.ZatPoint (soundorg[0], soundorg[1]); } @@ -358,20 +468,6 @@ struct sector_t // [RH] give floor and ceiling even more properties FDynamicColormap *ColorMap; // [RH] Per-sector colormap - // killough 3/7/98: floor and ceiling texture offsets - fixed_t floor_xoffs, floor_yoffs; - fixed_t ceiling_xoffs, ceiling_yoffs; - - // [RH] floor and ceiling texture scales - fixed_t floor_xscale, floor_yscale; - fixed_t ceiling_xscale, ceiling_yscale; - - // [RH] floor and ceiling texture rotation - angle_t floor_angle, ceiling_angle; - - fixed_t base_ceiling_angle, base_ceiling_yoffs; - fixed_t base_floor_angle, base_floor_yoffs; - BYTE FloorLight, CeilingLight; BYTE FloorFlags, CeilingFlags; int floorpic, ceilingpic; @@ -456,6 +552,9 @@ struct sector_t extsector_t * e; // This stores data that requires construction/destruction. Such data must not be copied by R_FakeFlat. }; +FArchive &operator<< (FArchive &arc, sector_t::splane &p); + + struct ReverbContainer; struct zone_t { @@ -504,6 +603,11 @@ struct side_t int GetLightLevel (bool foggy, int baselight) const; + void SetLight(SWORD l) + { + Light = l; + } + int GetTexture(int which) const { return textures[which].texture; diff --git a/src/r_interpolate.cpp b/src/r_interpolate.cpp index 27cb1ffe8..f199a3ff3 100644 --- a/src/r_interpolate.cpp +++ b/src/r_interpolate.cpp @@ -583,16 +583,8 @@ void DSectorScrollInterpolation::Destroy() void DSectorScrollInterpolation::UpdateInterpolation() { - if (!ceiling) - { - oldx = sector->floor_xoffs; - oldy = sector->floor_yoffs; - } - else - { - oldx = sector->ceiling_xoffs; - oldy = sector->ceiling_yoffs; - } + oldx = sector->GetXOffset(ceiling); + oldy = sector->GetYOffset(ceiling, false); } //========================================================================== @@ -603,16 +595,8 @@ void DSectorScrollInterpolation::UpdateInterpolation() void DSectorScrollInterpolation::Restore() { - if (!ceiling) - { - sector->floor_xoffs = bakx; - sector->floor_yoffs = baky; - } - else - { - sector->ceiling_xoffs = bakx; - sector->ceiling_yoffs = baky; - } + sector->SetXOffset(ceiling, bakx); + sector->SetYOffset(ceiling, bakx); } //========================================================================== @@ -623,25 +607,11 @@ void DSectorScrollInterpolation::Restore() void DSectorScrollInterpolation::Interpolate(fixed_t smoothratio) { - fixed_t *px; - fixed_t *py; + bakx = sector->GetXOffset(ceiling); + baky = sector->GetYOffset(ceiling, false); - if (!ceiling) - { - px = §or->floor_xoffs; - py = §or->floor_yoffs; - } - else - { - px = §or->ceiling_xoffs; - py = §or->ceiling_yoffs; - } - - bakx = *px; - baky = *py; - - *px = oldx + FixedMul(bakx - oldx, smoothratio); - *py = oldy + FixedMul(baky - oldy, smoothratio); + sector->SetXOffset(ceiling, oldx + FixedMul(bakx - oldx, smoothratio)); + sector->SetYOffset(ceiling, oldy + FixedMul(baky - oldy, smoothratio)); } //========================================================================== diff --git a/src/r_plane.cpp b/src/r_plane.cpp index d34783f75..23317e1d3 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1683,16 +1683,6 @@ bool R_AlignFlat (int linenum, int side, int fc) dist = -dist; } - if (fc) - { - sec->base_ceiling_angle = 0-angle; - sec->base_ceiling_yoffs = dist & ((1<<(FRACBITS+8))-1); - } - else - { - sec->base_floor_angle = 0-angle; - sec->base_floor_yoffs = dist & ((1<<(FRACBITS+8))-1); - } - + sec->SetBase(fc, dist & ((1<<(FRACBITS+8))-1), 0-angle); return true; } diff --git a/src/r_polymost.cpp b/src/r_polymost.cpp index b18422494..0ce451bda 100644 --- a/src/r_polymost.cpp +++ b/src/r_polymost.cpp @@ -1300,11 +1300,11 @@ void RP_AddLine (seg_t *line) || curline->sidedef->GetTexture(side_t::mid) != 0 // killough 3/7/98: Take flats offsets into account: - || backsector->floor_xoffs != frontsector->floor_xoffs - || (backsector->floor_yoffs + backsector->base_floor_yoffs) != (frontsector->floor_yoffs + backsector->base_floor_yoffs) - || backsector->ceiling_xoffs != frontsector->ceiling_xoffs - || (backsector->ceiling_yoffs + backsector->base_ceiling_yoffs) != (frontsector->ceiling_yoffs + frontsector->base_ceiling_yoffs) - + || backsector->GetXOffset(sector_t::floor) != frontsector->GetXOffset(sector_t::floor) + || backsector->GetYOffset(sector_t::floor) != frontsector->GetYOffset(sector_t::floor) + || backsector->GetXOffset(sector_t::ceiling) != frontsector->GetXOffset(sector_t::ceiling) + || backsector->GetYOffset(sector_t::ceiling) != frontsector->GetYOffset(sector_t::ceiling) + || backsector->FloorLight != frontsector->FloorLight || backsector->CeilingLight != frontsector->CeilingLight || backsector->FloorFlags != frontsector->FloorFlags @@ -1314,14 +1314,14 @@ void RP_AddLine (seg_t *line) || backsector->ColorMap != frontsector->ColorMap // [RH] and scaling - || backsector->floor_xscale != frontsector->floor_xscale - || backsector->floor_yscale != frontsector->floor_yscale - || backsector->ceiling_xscale != frontsector->ceiling_xscale - || backsector->ceiling_yscale != frontsector->ceiling_yscale + || backsector->GetXScale(sector_t::floor) != frontsector->GetXScale(sector_t::floor) + || backsector->GetYScale(sector_t::floor) != frontsector->GetYScale(sector_t::floor) + || backsector->GetXScale(sector_t::ceiling) != frontsector->GetXScale(sector_t::ceiling) + || backsector->GetYScale(sector_t::ceiling) != frontsector->GetYScale(sector_t::ceiling) // [RH] and rotation - || (backsector->floor_angle + backsector->base_floor_angle) != (frontsector->floor_angle + frontsector->base_floor_angle) - || (backsector->ceiling_angle + backsector->base_ceiling_angle) != (frontsector->ceiling_angle + frontsector->base_ceiling_angle) + || backsector->GetAngle(sector_t::floor) != frontsector->GetAngle(sector_t::floor) + || backsector->GetAngle(sector_t::ceiling) != frontsector->GetAngle(sector_t::ceiling) ) { solid = false; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 6567e7249..2dd7f2aa9 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1268,8 +1268,8 @@ void R_NewWall (bool needlights) || backsector->floorpic != frontsector->floorpic // killough 3/7/98: Add checks for (x,y) offsets - || backsector->floor_xoffs != frontsector->floor_xoffs - || (backsector->floor_yoffs + backsector->base_floor_yoffs) != (frontsector->floor_yoffs + frontsector->base_floor_yoffs) + || backsector->GetXOffset(sector_t::floor) != frontsector->GetXOffset(sector_t::floor) + || backsector->GetYOffset(sector_t::floor) != frontsector->GetYOffset(sector_t::floor) // killough 4/15/98: prevent 2s normals // from bleeding through deep water @@ -1281,10 +1281,10 @@ void R_NewWall (bool needlights) // [RH] Add checks for colormaps || backsector->ColorMap != frontsector->ColorMap - || backsector->floor_xscale != frontsector->floor_xscale - || backsector->floor_yscale != frontsector->floor_yscale + || backsector->GetXScale(sector_t::floor) != frontsector->GetXScale(sector_t::floor) + || backsector->GetYScale(sector_t::floor) != frontsector->GetYScale(sector_t::floor) - || (backsector->floor_angle + backsector->base_floor_angle) != (frontsector->floor_angle + frontsector->base_floor_angle) + || backsector->GetAngle(sector_t::floor) != frontsector->GetAngle(sector_t::floor) || (sidedef->GetTexture(side_t::mid) && linedef->flags & (ML_CLIP_MIDTEX|ML_WRAP_MIDTEX)) ; @@ -1297,8 +1297,8 @@ void R_NewWall (bool needlights) || backsector->ceilingpic != frontsector->ceilingpic // killough 3/7/98: Add checks for (x,y) offsets - || backsector->ceiling_xoffs != frontsector->ceiling_xoffs - || (backsector->ceiling_yoffs + backsector->base_ceiling_yoffs) != (frontsector->ceiling_yoffs + frontsector->base_ceiling_yoffs) + || backsector->GetXOffset(sector_t::ceiling) != frontsector->GetXOffset(sector_t::ceiling) + || backsector->GetYOffset(sector_t::ceiling) != frontsector->GetYOffset(sector_t::ceiling) // killough 4/15/98: prevent 2s normals // from bleeding through fake ceilings @@ -1310,10 +1310,10 @@ void R_NewWall (bool needlights) // [RH] Add check for colormaps || backsector->ColorMap != frontsector->ColorMap - || backsector->ceiling_xscale != frontsector->ceiling_xscale - || backsector->ceiling_yscale != frontsector->ceiling_yscale + || backsector->GetXScale(sector_t::ceiling) != frontsector->GetXScale(sector_t::ceiling) + || backsector->GetYScale(sector_t::ceiling) != frontsector->GetYScale(sector_t::ceiling) - || (backsector->ceiling_angle + backsector->base_ceiling_angle) != (frontsector->ceiling_angle + frontsector->base_ceiling_angle) + || backsector->GetAngle(sector_t::ceiling) != frontsector->GetAngle(sector_t::ceiling) || (sidedef->GetTexture(side_t::mid) && linedef->flags & (ML_CLIP_MIDTEX|ML_WRAP_MIDTEX)) ); diff --git a/src/version.h b/src/version.h index b7b66e183..09edfb126 100644 --- a/src/version.h +++ b/src/version.h @@ -75,7 +75,7 @@ // SAVESIG should match SAVEVER. // MINSAVEVER is the minimum level snapshot version that can be loaded. -#define MINSAVEVER 1028 +#define MINSAVEVER 1033 #if SVN_REVISION_NUMBER < MINSAVEVER // Never write a savegame with a version lower than what we need