components/prboom/p_genlin.c
//
// EV_DoGenFloor()
//
// Handle generalized floor types
//
// Passed the line activating the generalized floor function
// Returns true if a thinker is created
//
// jff 02/04/98 Added this routine (and file) to handle generalized
// floor movers using bit fields in the line special type.
//
EV_DoGenFloor()
Handle generalized floor types

Passed the line activating the generalized floor function
Returns true if a thinker is created

jff 02/04/98 Added this routine (and file) to handle generalized
floor movers using bit fields in the line special type.
EV_DoGenFloor () Handle generalized floor types Passed the line activating the generalized floor function Returns true if a thinker is created jff 02 / 04 / 98 Added this routine ( and file ) to handle generalized floor movers using bit fields in the line special type .
int EV_DoGenFloor
( line_t*       line )
{
  int                   secnum;
  int                   rtn;
  boolean               manual;
  sector_t*             sec;
  floormove_t*          floor;
  unsigned              value = (unsigned)line->special - GenFloorBase;
  int Crsh = (value & FloorCrush) >> FloorCrushShift;
  int ChgT = (value & FloorChange) >> FloorChangeShift;
  int Targ = (value & FloorTarget) >> FloorTargetShift;
  int Dirn = (value & FloorDirection) >> FloorDirectionShift;
  int ChgM = (value & FloorModel) >> FloorModelShift;
  int Sped = (value & FloorSpeed) >> FloorSpeedShift;
  int Trig = (value & TriggerType) >> TriggerTypeShift;
  rtn = 0;
  manual = false;
  if (Trig==PushOnce || Trig==PushMany)
  {
    if (!(sec = line->backsector))
      return rtn;
    secnum = sec-sectors;
    manual = true;
    goto manual_floor;
  }
  secnum = -1;
  while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
  {
    sec = &sectors[secnum];
manual_floor:
    if (P_SectorActive(floor_special,sec))
    {
      if (!manual)
        continue;
      else
        return rtn;
    }
    rtn = 1;
    floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0);
    memset(floor, 0, sizeof(*floor));
    P_AddThinker (&floor->thinker);
    sec->floordata = floor;
    floor->thinker.function = T_MoveFloor;
    floor->crush = Crsh;
    floor->direction = Dirn? 1 : -1;
    floor->sector = sec;
    floor->texture = sec->floorpic;
    floor->newspecial = sec->special;
    floor->oldspecial = sec->oldspecial;
    floor->type = genFloor;
    switch (Sped)
    {
      case SpeedSlow:
        floor->speed = FLOORSPEED;
        break;
      case SpeedNormal:
        floor->speed = FLOORSPEED*2;
        break;
      case SpeedFast:
        floor->speed = FLOORSPEED*4;
        break;
      case SpeedTurbo:
        floor->speed = FLOORSPEED*8;
        break;
      default:
        break;
    }
    switch(Targ)
    {
      case FtoHnF:
        floor->floordestheight = P_FindHighestFloorSurrounding(sec);
        break;
      case FtoLnF:
        floor->floordestheight = P_FindLowestFloorSurrounding(sec);
        break;
      case FtoNnF:
        floor->floordestheight = Dirn?
          P_FindNextHighestFloor(sec,sec->floorheight) :
          P_FindNextLowestFloor(sec,sec->floorheight);
        break;
      case FtoLnC:
        floor->floordestheight = P_FindLowestCeilingSurrounding(sec);
        break;
      case FtoC:
        floor->floordestheight = sec->ceilingheight;
        break;
      case FbyST:
        floor->floordestheight = (floor->sector->floorheight>>FRACBITS) +
          floor->direction * (P_FindShortestTextureAround(secnum)>>FRACBITS);
        if (floor->floordestheight>32000)  
          floor->floordestheight=32000;    
        if (floor->floordestheight<-32000)
          floor->floordestheight=-32000;
        floor->floordestheight<<=FRACBITS;
        break;
      case Fby24:
        floor->floordestheight = floor->sector->floorheight +
          floor->direction * 24*FRACUNIT;
        break;
      case Fby32:
        floor->floordestheight = floor->sector->floorheight +
          floor->direction * 32*FRACUNIT;
        break;
      default:
        break;
    }
    if (ChgT)   
    {
      if (ChgM) 
      {
        sector_t *sec;
        sec = (Targ==FtoLnC || Targ==FtoC)?
          P_FindModelCeilingSector(floor->floordestheight,secnum) :
          P_FindModelFloorSector(floor->floordestheight,secnum);
        if (sec)
        {
          floor->texture = sec->floorpic;
          switch(ChgT)
          {
            case FChgZero:  
              floor->newspecial = 0;
              floor->oldspecial = 0;
              floor->type = genFloorChg0;
              break;
            case FChgTyp:   
              floor->newspecial = sec->special;
              floor->oldspecial = sec->oldspecial;
              floor->type = genFloorChgT;
              break;
            case FChgTxt:   
              floor->type = genFloorChg;
              break;
            default:
              break;
          }
        }
      }
      else     
      {
        floor->texture = line->frontsector->floorpic;
        switch (ChgT)
        {
          case FChgZero:    
            floor->newspecial = 0;
            floor->oldspecial = 0;
            floor->type = genFloorChg0;
            break;
          case FChgTyp:     
            floor->newspecial = line->frontsector->special;
            floor->oldspecial = line->frontsector->oldspecial;
            floor->type = genFloorChgT;
            break;
          case FChgTxt:     
            floor->type = genFloorChg;
          default:
            break;
        }
      }
    }
    if (manual) return rtn;
  }
  return rtn;
}
int EV_DoGenFloor ( line_t * line ) { int secnum ; int rtn ; boolean manual ; sector_t * sec ; floormove_t * floor ; unsigned value = ( unsigned ) line -> special - GenFloorBase ; int Crsh = ( value & FloorCrush ) >> FloorCrushShift ; int ChgT = ( value & FloorChange ) >> FloorChangeShift ; int Targ = ( value & FloorTarget ) >> FloorTargetShift ; int Dirn = ( value & FloorDirection ) >> FloorDirectionShift ; int ChgM = ( value & FloorModel ) >> FloorModelShift ; int Sped = ( value & FloorSpeed ) >> FloorSpeedShift ; int Trig = ( value & TriggerType ) >> TriggerTypeShift ; rtn = 0 ; manual = false ; if ( Trig == PushOnce || Trig == PushMany ) { if ( ! ( sec = line -> backsector ) ) return rtn ; secnum = sec - sectors ; manual = true ; goto manual_floor ; } secnum = -1 ; while ( ( secnum = P_FindSectorFromLineTag ( line , secnum ) ) >= 0 ) { sec = & sectors [ secnum ] ; manual_floor : if ( P_SectorActive ( floor_special , sec ) ) { if ( ! manual ) continue ; else return rtn ; } rtn = 1 ; floor = Z_Malloc ( sizeof ( * floor ) , PU_LEVSPEC , 0 ) ; memset ( floor , 0 , sizeof ( * floor ) ) ; P_AddThinker ( & floor -> thinker ) ; sec -> floordata = floor ; floor -> thinker . function = T_MoveFloor ; floor -> crush = Crsh ; floor -> direction = Dirn ? 1 : -1 ; floor -> sector = sec ; floor -> texture = sec -> floorpic ; floor -> newspecial = sec -> special ; floor -> oldspecial = sec -> oldspecial ; floor -> type = genFloor ; switch ( Sped ) { case SpeedSlow : floor -> speed = FLOORSPEED ; break ; case SpeedNormal : floor -> speed = FLOORSPEED * 2 ; break ; case SpeedFast : floor -> speed = FLOORSPEED * 4 ; break ; case SpeedTurbo : floor -> speed = FLOORSPEED * 8 ; break ; default : break ; } switch ( Targ ) { case FtoHnF : floor -> floordestheight = P_FindHighestFloorSurrounding ( sec ) ; break ; case FtoLnF : floor -> floordestheight = P_FindLowestFloorSurrounding ( sec ) ; break ; case FtoNnF : floor -> floordestheight = Dirn ? P_FindNextHighestFloor ( sec , sec -> floorheight ) : P_FindNextLowestFloor ( sec , sec -> floorheight ) ; break ; case FtoLnC : floor -> floordestheight = P_FindLowestCeilingSurrounding ( sec ) ; break ; case FtoC : floor -> floordestheight = sec -> ceilingheight ; break ; case FbyST : floor -> floordestheight = ( floor -> sector -> floorheight >> FRACBITS ) + floor -> direction * ( P_FindShortestTextureAround ( secnum ) >> FRACBITS ) ; if ( floor -> floordestheight > 32000 ) floor -> floordestheight = 32000 ; if ( floor -> floordestheight < -32000 ) floor -> floordestheight = -32000 ; floor -> floordestheight <<= FRACBITS ; break ; case Fby24 : floor -> floordestheight = floor -> sector -> floorheight + floor -> direction * 24 * FRACUNIT ; break ; case Fby32 : floor -> floordestheight = floor -> sector -> floorheight + floor -> direction * 32 * FRACUNIT ; break ; default : break ; } if ( ChgT ) { if ( ChgM ) { sector_t * sec ; sec = ( Targ == FtoLnC || Targ == FtoC ) ? P_FindModelCeilingSector ( floor -> floordestheight , secnum ) : P_FindModelFloorSector ( floor -> floordestheight , secnum ) ; if ( sec ) { floor -> texture = sec -> floorpic ; switch ( ChgT ) { case FChgZero : floor -> newspecial = 0 ; floor -> oldspecial = 0 ; floor -> type = genFloorChg0 ; break ; case FChgTyp : floor -> newspecial = sec -> special ; floor -> oldspecial = sec -> oldspecial ; floor -> type = genFloorChgT ; break ; case FChgTxt : floor -> type = genFloorChg ; break ; default : break ; } } } else { floor -> texture = line -> frontsector -> floorpic ; switch ( ChgT ) { case FChgZero : floor -> newspecial = 0 ; floor -> oldspecial = 0 ; floor -> type = genFloorChg0 ; break ; case FChgTyp : floor -> newspecial = line -> frontsector -> special ; floor -> oldspecial = line -> frontsector -> oldspecial ; floor -> type = genFloorChgT ; break ; case FChgTxt : floor -> type = genFloorChg ; default : break ; } } } if ( manual ) return rtn ; } return rtn ; }
EV_DoGenFloor()
Handle generalized floor types
EV_DoGenFloor () Handle generalized floor types
// parse the bit fields in the line's special type // check if a manual trigger, if so do just the sector on the backside // if not manual do all sectors tagged the same as the line // Do not start another function if floor already moving // new floor thinker //jff 3/14/98 transfer old special field too // set the speed of motion // set the destination height //jff 3/13/98 prevent overflow // wraparound in floor height // set texture/type change properties // if a texture change is indicated // if a numeric model change //jff 5/23/98 find model with ceiling at target height if target //is a ceiling type // zero type //jff 3/14/98 change old field too // copy type //jff 3/14/98 change old field too // leave type be // else if a trigger model change // zero type //jff 3/14/98 change old field too // copy type //jff 3/14/98 change old field too // leave type be