components/prboom/r_bsp.c
//
// killough 3/7/98: Hack floor/ceiling heights for deep water etc.
//
// If player's view height is underneath fake floor, lower the
// drawn ceiling to be just under the floor height, and replace
// the drawn floor and ceiling textures, and light level, with
// the control sector's.
//
// Similar for ceiling, only reflected.
//
// killough 4/11/98, 4/13/98: fix bugs, add 'back' parameter
//
killough 3/7/98: Hack floor/ceiling heights for deep water etc.
If player's view height is underneath fake floor, lower the
drawn ceiling to be just under the floor height, and replace
the drawn floor and ceiling textures, and light level, with
the control sector's.

Similar for ceiling, only reflected.


killough 3 / 7 / 98 : Hack floor / ceiling heights for deep water etc . If player ' s view height is underneath fake floor lower the drawn ceiling to be just under the floor height and replace the drawn floor and ceiling textures and light level with the control sector ' s . Similar for ceiling only reflected .
sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
                     int *floorlightlevel, int *ceilinglightlevel,
                     boolean back)
{
  if (floorlightlevel)
    *floorlightlevel = sec->floorlightsec == -1 ?
      sec->lightlevel : sectors[sec->floorlightsec].lightlevel;
  if (ceilinglightlevel)
    *ceilinglightlevel = sec->ceilinglightsec == -1 ? 
      sec->lightlevel : sectors[sec->ceilinglightsec].lightlevel;
  if (sec->heightsec != -1)
    {
      const sector_t *s = &sectors[sec->heightsec];
      int heightsec = viewplayer->mo->subsector->sector->heightsec;
      int underwater = heightsec!=-1 && viewz<=sectors[heightsec].floorheight;
      *tempsec = *sec;
      tempsec->floorheight   = s->floorheight;
      tempsec->ceilingheight = s->ceilingheight;
      if (underwater && (tempsec->  floorheight = sec->floorheight,
                          tempsec->ceilingheight = s->floorheight-1, !back))
        {                   
          tempsec->floorpic    = s->floorpic;
          tempsec->floor_xoffs = s->floor_xoffs;
          tempsec->floor_yoffs = s->floor_yoffs;
          if (underwater) {
            if (s->ceilingpic == skyflatnum) {
		tempsec->floorheight   = tempsec->ceilingheight+1;
		tempsec->ceilingpic    = tempsec->floorpic;
                tempsec->ceiling_xoffs = tempsec->floor_xoffs;
                tempsec->ceiling_yoffs = tempsec->floor_yoffs;
	    } else {
		tempsec->ceilingpic    = s->ceilingpic;
		tempsec->ceiling_xoffs = s->ceiling_xoffs;
		tempsec->ceiling_yoffs = s->ceiling_yoffs;
	    }
	  }
          tempsec->lightlevel  = s->lightlevel;
          if (floorlightlevel)
            *floorlightlevel = s->floorlightsec == -1 ? s->lightlevel :
            sectors[s->floorlightsec].lightlevel; 
          if (ceilinglightlevel)
            *ceilinglightlevel = s->ceilinglightsec == -1 ? s->lightlevel :
            sectors[s->ceilinglightsec].lightlevel; 
        }
      else
        if (heightsec != -1 && viewz >= sectors[heightsec].ceilingheight &&
            sec->ceilingheight > s->ceilingheight)
          {   
            tempsec->ceilingheight = s->ceilingheight;
            tempsec->floorheight   = s->ceilingheight + 1;
            tempsec->floorpic    = tempsec->ceilingpic    = s->ceilingpic;
            tempsec->floor_xoffs = tempsec->ceiling_xoffs = s->ceiling_xoffs;
            tempsec->floor_yoffs = tempsec->ceiling_yoffs = s->ceiling_yoffs;
            if (s->floorpic != skyflatnum)
              {
                tempsec->ceilingheight = sec->ceilingheight;
                tempsec->floorpic      = s->floorpic;
                tempsec->floor_xoffs   = s->floor_xoffs;
                tempsec->floor_yoffs   = s->floor_yoffs;
              }
            tempsec->lightlevel  = s->lightlevel;
            if (floorlightlevel)
              *floorlightlevel = s->floorlightsec == -1 ? s->lightlevel :
              sectors[s->floorlightsec].lightlevel; 
            if (ceilinglightlevel)
              *ceilinglightlevel = s->ceilinglightsec == -1 ? s->lightlevel :
              sectors[s->ceilinglightsec].lightlevel; 
          }
      sec = tempsec;               
    }
  return sec;
}
sector_t * R_FakeFlat ( sector_t * sec , sector_t * tempsec , int * floorlightlevel , int * ceilinglightlevel , boolean back ) { if ( floorlightlevel ) * floorlightlevel = sec -> floorlightsec == -1 ? sec -> lightlevel : sectors [ sec -> floorlightsec ] . lightlevel ; if ( ceilinglightlevel ) * ceilinglightlevel = sec -> ceilinglightsec == -1 ? sec -> lightlevel : sectors [ sec -> ceilinglightsec ] . lightlevel ; if ( sec -> heightsec != -1 ) { const sector_t * s = & sectors [ sec -> heightsec ] ; int heightsec = viewplayer -> mo -> subsector -> sector -> heightsec ; int underwater = heightsec != -1 && viewz <= sectors [ heightsec ] . floorheight ; * tempsec = * sec ; tempsec -> floorheight = s -> floorheight ; tempsec -> ceilingheight = s -> ceilingheight ; if ( underwater && ( tempsec -> floorheight = sec -> floorheight , tempsec -> ceilingheight = s -> floorheight - 1 , ! back ) ) { tempsec -> floorpic = s -> floorpic ; tempsec -> floor_xoffs = s -> floor_xoffs ; tempsec -> floor_yoffs = s -> floor_yoffs ; if ( underwater ) { if ( s -> ceilingpic == skyflatnum ) { tempsec -> floorheight = tempsec -> ceilingheight + 1 ; tempsec -> ceilingpic = tempsec -> floorpic ; tempsec -> ceiling_xoffs = tempsec -> floor_xoffs ; tempsec -> ceiling_yoffs = tempsec -> floor_yoffs ; } else { tempsec -> ceilingpic = s -> ceilingpic ; tempsec -> ceiling_xoffs = s -> ceiling_xoffs ; tempsec -> ceiling_yoffs = s -> ceiling_yoffs ; } } tempsec -> lightlevel = s -> lightlevel ; if ( floorlightlevel ) * floorlightlevel = s -> floorlightsec == -1 ? s -> lightlevel : sectors [ s -> floorlightsec ] . lightlevel ; if ( ceilinglightlevel ) * ceilinglightlevel = s -> ceilinglightsec == -1 ? s -> lightlevel : sectors [ s -> ceilinglightsec ] . lightlevel ; } else if ( heightsec != -1 && viewz >= sectors [ heightsec ] . ceilingheight && sec -> ceilingheight > s -> ceilingheight ) { tempsec -> ceilingheight = s -> ceilingheight ; tempsec -> floorheight = s -> ceilingheight + 1 ; tempsec -> floorpic = tempsec -> ceilingpic = s -> ceilingpic ; tempsec -> floor_xoffs = tempsec -> ceiling_xoffs = s -> ceiling_xoffs ; tempsec -> floor_yoffs = tempsec -> ceiling_yoffs = s -> ceiling_yoffs ; if ( s -> floorpic != skyflatnum ) { tempsec -> ceilingheight = sec -> ceilingheight ; tempsec -> floorpic = s -> floorpic ; tempsec -> floor_xoffs = s -> floor_xoffs ; tempsec -> floor_yoffs = s -> floor_yoffs ; } tempsec -> lightlevel = s -> lightlevel ; if ( floorlightlevel ) * floorlightlevel = s -> floorlightsec == -1 ? s -> lightlevel : sectors [ s -> floorlightsec ] . lightlevel ; if ( ceilinglightlevel ) * ceilinglightlevel = s -> ceilinglightsec == -1 ? s -> lightlevel : sectors [ s -> ceilinglightsec ] . lightlevel ; } sec = tempsec ; } return sec ; }
killough 3/7/98: Hack floor/ceiling heights for deep water etc.
killough 3 / 7 / 98 : Hack floor / ceiling heights for deep water etc .
// killough 4/11/98 // Replace sector being drawn, with a copy to be hacked // Replace floor and ceiling height with other sector's heights. // killough 11/98: prevent sudden light changes from non-water sectors: // head-below-floor hack // killough 3/16/98 // killough 4/11/98 // Above-ceiling hack // killough 3/16/98 // killough 4/11/98 // Use other sector