components/prboom/p_floor.c
//
// EV_DoElevator
//
// Handle elevator linedef types
//
// Passed the linedef that triggered the elevator and the elevator action
//
// jff 2/22/98 new type to move floor and ceiling in parallel
//
EV_DoElevator
Handle elevator linedef types

Passed the linedef that triggered the elevator and the elevator action

jff 2/22/98 new type to move floor and ceiling in parallel
EV_DoElevator Handle elevator linedef types Passed the linedef that triggered the elevator and the elevator action jff 2 / 22 / 98 new type to move floor and ceiling in parallel
int EV_DoElevator
( line_t*       line,
  elevator_e    elevtype )
{
  int                   secnum;
  int                   rtn;
  sector_t*             sec;
  elevator_t*           elevator;
  secnum = -1;
  rtn = 0;
  while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
  {
    sec = &sectors[secnum];
    if (sec->floordata || sec->ceilingdata) 
      continue;
    rtn = 1;
    elevator = Z_Malloc (sizeof(*elevator), PU_LEVSPEC, 0);
    memset(elevator, 0, sizeof(*elevator));
    P_AddThinker (&elevator->thinker);
    sec->floordata = elevator; 
    sec->ceilingdata = elevator; 
    elevator->thinker.function = T_MoveElevator;
    elevator->type = elevtype;
    switch(elevtype)
    {
      case elevateDown:
        elevator->direction = -1;
        elevator->sector = sec;
        elevator->speed = ELEVATORSPEED;
        elevator->floordestheight =
          P_FindNextLowestFloor(sec,sec->floorheight);
        elevator->ceilingdestheight =
          elevator->floordestheight + sec->ceilingheight - sec->floorheight;
        break;
      case elevateUp:
        elevator->direction = 1;
        elevator->sector = sec;
        elevator->speed = ELEVATORSPEED;
        elevator->floordestheight =
          P_FindNextHighestFloor(sec,sec->floorheight);
        elevator->ceilingdestheight =
          elevator->floordestheight + sec->ceilingheight - sec->floorheight;
        break;
      case elevateCurrent:
        elevator->sector = sec;
        elevator->speed = ELEVATORSPEED;
        elevator->floordestheight = line->frontsector->floorheight;
        elevator->ceilingdestheight =
          elevator->floordestheight + sec->ceilingheight - sec->floorheight;
        elevator->direction =
          elevator->floordestheight>sec->floorheight?  1 : -1;
        break;
      default:
        break;
    }
  }
  return rtn;
}
int EV_DoElevator ( line_t * line , elevator_e elevtype ) { int secnum ; int rtn ; sector_t * sec ; elevator_t * elevator ; secnum = -1 ; rtn = 0 ; while ( ( secnum = P_FindSectorFromLineTag ( line , secnum ) ) >= 0 ) { sec = & sectors [ secnum ] ; if ( sec -> floordata || sec -> ceilingdata ) continue ; rtn = 1 ; elevator = Z_Malloc ( sizeof ( * elevator ) , PU_LEVSPEC , 0 ) ; memset ( elevator , 0 , sizeof ( * elevator ) ) ; P_AddThinker ( & elevator -> thinker ) ; sec -> floordata = elevator ; sec -> ceilingdata = elevator ; elevator -> thinker . function = T_MoveElevator ; elevator -> type = elevtype ; switch ( elevtype ) { case elevateDown : elevator -> direction = -1 ; elevator -> sector = sec ; elevator -> speed = ELEVATORSPEED ; elevator -> floordestheight = P_FindNextLowestFloor ( sec , sec -> floorheight ) ; elevator -> ceilingdestheight = elevator -> floordestheight + sec -> ceilingheight - sec -> floorheight ; break ; case elevateUp : elevator -> direction = 1 ; elevator -> sector = sec ; elevator -> speed = ELEVATORSPEED ; elevator -> floordestheight = P_FindNextHighestFloor ( sec , sec -> floorheight ) ; elevator -> ceilingdestheight = elevator -> floordestheight + sec -> ceilingheight - sec -> floorheight ; break ; case elevateCurrent : elevator -> sector = sec ; elevator -> speed = ELEVATORSPEED ; elevator -> floordestheight = line -> frontsector -> floorheight ; elevator -> ceilingdestheight = elevator -> floordestheight + sec -> ceilingheight - sec -> floorheight ; elevator -> direction = elevator -> floordestheight > sec -> floorheight ? 1 : -1 ; break ; default : break ; } } return rtn ; }
EV_DoElevator
Handle elevator linedef types
EV_DoElevator Handle elevator linedef types
// act on all sectors with the same tag as the triggering linedef // If either floor or ceiling is already activated, skip it //jff 2/22/98 // create and initialize new elevator thinker //jff 2/22/98 //jff 2/22/98 // set up the fields according to the type of elevator action // elevator down to next floor // elevator up to next floor // elevator to floor height of activating switch's front sector