components/prboom/p_floor.c
//
// T_MovePlane()
//
// Move a plane (floor or ceiling) and check for crushing. Called
// every tick by all actions that move floors or ceilings.
//
// Passed the sector to move a plane in, the speed to move it at,
// the dest height it is to achieve, whether it crushes obstacles,
// whether it moves a floor or ceiling, and the direction up or down
// to move.
//
// Returns a result_e:
//  ok - plane moved normally, has not achieved destination yet
//  pastdest - plane moved normally and is now at destination height
//  crushed - plane encountered an obstacle, is holding until removed
//
T_MovePlane()
Move a plane (floor or ceiling) and check for crushing. Called
every tick by all actions that move floors or ceilings.

Passed the sector to move a plane in, the speed to move it at,
the dest height it is to achieve, whether it crushes obstacles,
whether it moves a floor or ceiling, and the direction up or down
to move.

Returns a result_e:
ok - plane moved normally, has not achieved destination yet
pastdest - plane moved normally and is now at destination height
crushed - plane encountered an obstacle, is holding until removed
T_MovePlane () Move a plane ( floor or ceiling ) and check for crushing . Called every tick by all actions that move floors or ceilings . Passed the sector to move a plane in the speed to move it at the dest height it is to achieve whether it crushes obstacles whether it moves a floor or ceiling and the direction up or down to move . Returns a result_e : ok - plane moved normally has not achieved destination yet pastdest - plane moved normally and is now at destination height crushed - plane encountered an obstacle is holding until removed
result_e T_MovePlane
( sector_t*     sector,
  fixed_t       speed,
  fixed_t       dest,
  boolean       crush,
  int           floorOrCeiling,
  int           direction )
{
  boolean       flag;
  fixed_t       lastpos;
  fixed_t       destheight; 
  switch(floorOrCeiling)
  {
    case 0:
      switch(direction)
      {
        case -1:
           down
          if (sector->floorheight - speed < dest)
          {
            lastpos = sector->floorheight;
            sector->floorheight = dest;
            flag = P_CheckSector(sector,crush); 
            if (flag == true)
            {
              sector->floorheight =lastpos;
              P_CheckSector(sector,crush);      
            }
            return pastdest;
          }
          else
          {
            lastpos = sector->floorheight;
            sector->floorheight -= speed;
            flag = P_CheckSector(sector,crush); 
      if ((flag == true) && comp[comp_floors]) {
        sector->floorheight = lastpos;
        P_ChangeSector(sector,crush);
        return crushed;
      }
          }
          break;
        case 1:
           up
          destheight = (comp[comp_floors] || dest<sector->ceilingheight)?
                          dest : sector->ceilingheight;
          if (sector->floorheight + speed > destheight)
          {
            lastpos = sector->floorheight;
            sector->floorheight = destheight;
            flag = P_CheckSector(sector,crush); 
            if (flag == true)
            {
              sector->floorheight = lastpos;
              P_CheckSector(sector,crush);      
            }
            return pastdest;
          }
          else
          {
            lastpos = sector->floorheight;
            sector->floorheight += speed;
            flag = P_CheckSector(sector,crush); 
            if (flag == true)
            {
              if (comp[comp_floors]) {
                if (crush == true)
                  return crushed;
              }
              sector->floorheight = lastpos;
              P_CheckSector(sector,crush);      
              return crushed;
            }
          }
          break;
      }
      break;
    case 1:
      switch(direction)
      {
        case -1:
           down
          destheight = (comp[comp_floors] || dest>sector->floorheight)?
                          dest : sector->floorheight;
          if (sector->ceilingheight - speed < destheight)
          {
            lastpos = sector->ceilingheight;
            sector->ceilingheight = destheight;
            flag = P_CheckSector(sector,crush); 
            if (flag == true)
            {
              sector->ceilingheight = lastpos;
              P_CheckSector(sector,crush);      
            }
            return pastdest;
          }
          else
          {
            lastpos = sector->ceilingheight;
            sector->ceilingheight -= speed;
            flag = P_CheckSector(sector,crush); 
            if (flag == true)
            {
              if (crush == true)
                return crushed;
              sector->ceilingheight = lastpos;
              P_CheckSector(sector,crush);      
              return crushed;
            }
          }
          break;
        case 1:
           up
          if (sector->ceilingheight + speed > dest)
          {
            lastpos = sector->ceilingheight;
            sector->ceilingheight = dest;
            flag = P_CheckSector(sector,crush); 
            if (flag == true)
            {
              sector->ceilingheight = lastpos;
              P_CheckSector(sector,crush);      
            }
            return pastdest;
          }
          else
          {
            lastpos = sector->ceilingheight;
            sector->ceilingheight += speed;
            flag = P_CheckSector(sector,crush); 
          }
          break;
      }
      break;
  }
  return ok;
}
result_e T_MovePlane ( sector_t * sector , fixed_t speed , fixed_t dest , boolean crush , int floorOrCeiling , int direction ) { boolean flag ; fixed_t lastpos ; fixed_t destheight ; switch ( floorOrCeiling ) { case 0 : switch ( direction ) { case -1 : if ( sector -> floorheight - speed < dest ) { lastpos = sector -> floorheight ; sector -> floorheight = dest ; flag = P_CheckSector ( sector , crush ) ; if ( flag == true ) { sector -> floorheight = lastpos ; P_CheckSector ( sector , crush ) ; } return pastdest ; } else { lastpos = sector -> floorheight ; sector -> floorheight -= speed ; flag = P_CheckSector ( sector , crush ) ; if ( ( flag == true ) && comp [ comp_floors ] ) { sector -> floorheight = lastpos ; P_ChangeSector ( sector , crush ) ; return crushed ; } } break ; case 1 : destheight = ( comp [ comp_floors ] || dest < sector -> ceilingheight ) ? dest : sector -> ceilingheight ; if ( sector -> floorheight + speed > destheight ) { lastpos = sector -> floorheight ; sector -> floorheight = destheight ; flag = P_CheckSector ( sector , crush ) ; if ( flag == true ) { sector -> floorheight = lastpos ; P_CheckSector ( sector , crush ) ; } return pastdest ; } else { lastpos = sector -> floorheight ; sector -> floorheight += speed ; flag = P_CheckSector ( sector , crush ) ; if ( flag == true ) { if ( comp [ comp_floors ] ) { if ( crush == true ) return crushed ; } sector -> floorheight = lastpos ; P_CheckSector ( sector , crush ) ; return crushed ; } } break ; } break ; case 1 : switch ( direction ) { case -1 : destheight = ( comp [ comp_floors ] || dest > sector -> floorheight ) ? dest : sector -> floorheight ; if ( sector -> ceilingheight - speed < destheight ) { lastpos = sector -> ceilingheight ; sector -> ceilingheight = destheight ; flag = P_CheckSector ( sector , crush ) ; if ( flag == true ) { sector -> ceilingheight = lastpos ; P_CheckSector ( sector , crush ) ; } return pastdest ; } else { lastpos = sector -> ceilingheight ; sector -> ceilingheight -= speed ; flag = P_CheckSector ( sector , crush ) ; if ( flag == true ) { if ( crush == true ) return crushed ; sector -> ceilingheight = lastpos ; P_CheckSector ( sector , crush ) ; return crushed ; } } break ; case 1 : if ( sector -> ceilingheight + speed > dest ) { lastpos = sector -> ceilingheight ; sector -> ceilingheight = dest ; flag = P_CheckSector ( sector , crush ) ; if ( flag == true ) { sector -> ceilingheight = lastpos ; P_CheckSector ( sector , crush ) ; } return pastdest ; } else { lastpos = sector -> ceilingheight ; sector -> ceilingheight += speed ; flag = P_CheckSector ( sector , crush ) ; } break ; } break ; } return ok ; }
T_MovePlane()
Move a plane (floor or ceiling) and check for crushing.
T_MovePlane () Move a plane ( floor or ceiling ) and check for crushing .
//jff 02/04/98 used to keep floors/ceilings // from moving thru each other // Moving a floor // Moving a floor down //jff 3/19/98 use faster chk //jff 3/19/98 use faster chk //jff 3/19/98 use faster chk /* cph - make more compatible with original Doom, by
       *  reintroducing this code. This means floors can't lower
       *  if objects are stuck in the ceiling */ // Moving a floor up // jff 02/04/98 keep floor from moving thru ceilings // jff 2/22/98 weaken check to demo_compatibility //jff 3/19/98 use faster chk //jff 3/19/98 use faster chk // crushing is possible //jff 3/19/98 use faster chk /* jff 1/25/98 fix floor crusher */ //jff 3/19/98 use faster chk // moving a ceiling // moving a ceiling down // jff 02/04/98 keep ceiling from moving thru floors // jff 2/22/98 weaken check to demo_compatibility //jff 3/19/98 use faster chk //jff 3/19/98 use faster chk // crushing is possible //jff 3/19/98 use faster chk //jff 3/19/98 use faster chk // moving a ceiling up //jff 3/19/98 use faster chk //jff 3/19/98 use faster chk //jff 3/19/98 use faster chk