components/prboom/p_genlin.c
//
// EV_DoGenLift()
//
// Handle generalized lift types
//
// Passed the linedef activating the lift
// Returns true if a thinker is created
//
EV_DoGenLift()
Handle generalized lift types

Passed the linedef activating the lift
Returns true if a thinker is created
EV_DoGenLift () Handle generalized lift types Passed the linedef activating the lift Returns true if a thinker is created
int EV_DoGenLift
( line_t*       line )
{
  plat_t*         plat;
  int             secnum;
  int             rtn;
  boolean         manual;
  sector_t*       sec;
  unsigned        value = (unsigned)line->special - GenLiftBase;
  int Targ = (value & LiftTarget) >> LiftTargetShift;
  int Dely = (value & LiftDelay) >> LiftDelayShift;
  int Sped = (value & LiftSpeed) >> LiftSpeedShift;
  int Trig = (value & TriggerType) >> TriggerTypeShift;
  secnum = -1;
  rtn = 0;
  if (Targ==LnF2HnF)
    P_ActivateInStasis(line->tag);
  manual = false;
  if (Trig==PushOnce || Trig==PushMany)
  {
    if (!(sec = line->backsector))
      return rtn;
    secnum = sec-sectors;
    manual = true;
    goto manual_lift;
  }
  while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
  {
    sec = &sectors[secnum];
manual_lift:
    if (P_SectorActive(floor_special,sec))
    {
      if (!manual)
        continue;
      else
        return rtn;
    }
    rtn = 1;
    plat = Z_Malloc( sizeof(*plat), PU_LEVSPEC, 0);
    memset(plat, 0, sizeof(*plat));
    P_AddThinker(&plat->thinker);
    plat->sector = sec;
    plat->sector->floordata = plat;
    plat->thinker.function = T_PlatRaise;
    plat->crush = false;
    plat->tag = line->tag;
    plat->type = genLift;
    plat->high = sec->floorheight;
    plat->status = down;
    switch(Targ)
    {
      case F2LnF:
        plat->low = P_FindLowestFloorSurrounding(sec);
        if (plat->low > sec->floorheight)
          plat->low = sec->floorheight;
        break;
      case F2NnF:
        plat->low = P_FindNextLowestFloor(sec,sec->floorheight);
        break;
      case F2LnC:
        plat->low = P_FindLowestCeilingSurrounding(sec);
        if (plat->low > sec->floorheight)
          plat->low = sec->floorheight;
        break;
      case LnF2HnF:
        plat->type = genPerpetual;
        plat->low = P_FindLowestFloorSurrounding(sec);
        if (plat->low > sec->floorheight)
          plat->low = sec->floorheight;
        plat->high = P_FindHighestFloorSurrounding(sec);
        if (plat->high < sec->floorheight)
          plat->high = sec->floorheight;
        plat->status = P_Random(pr_genlift)&1;
        break;
      default:
        break;
    }
    switch(Sped)
    {
      case SpeedSlow:
        plat->speed = PLATSPEED * 2;
        break;
      case SpeedNormal:
        plat->speed = PLATSPEED * 4;
        break;
      case SpeedFast:
        plat->speed = PLATSPEED * 8;
        break;
      case SpeedTurbo:
        plat->speed = PLATSPEED * 16;
        break;
      default:
        break;
    }
    switch(Dely)
    {
      case 0:
        plat->wait = 1*35;
        break;
      case 1:
        plat->wait = PLATWAIT*35;
        break;
      case 2:
        plat->wait = 5*35;
        break;
      case 3:
        plat->wait = 10*35;
        break;
    }
    S_StartSound((mobj_t *)&sec->soundorg,sfx_pstart);
    P_AddActivePlat(plat); 
    if (manual)
      return rtn;
  }
  return rtn;
}
int EV_DoGenLift ( line_t * line ) { plat_t * plat ; int secnum ; int rtn ; boolean manual ; sector_t * sec ; unsigned value = ( unsigned ) line -> special - GenLiftBase ; int Targ = ( value & LiftTarget ) >> LiftTargetShift ; int Dely = ( value & LiftDelay ) >> LiftDelayShift ; int Sped = ( value & LiftSpeed ) >> LiftSpeedShift ; int Trig = ( value & TriggerType ) >> TriggerTypeShift ; secnum = -1 ; rtn = 0 ; if ( Targ == LnF2HnF ) P_ActivateInStasis ( line -> tag ) ; manual = false ; if ( Trig == PushOnce || Trig == PushMany ) { if ( ! ( sec = line -> backsector ) ) return rtn ; secnum = sec - sectors ; manual = true ; goto manual_lift ; } while ( ( secnum = P_FindSectorFromLineTag ( line , secnum ) ) >= 0 ) { sec = & sectors [ secnum ] ; manual_lift : if ( P_SectorActive ( floor_special , sec ) ) { if ( ! manual ) continue ; else return rtn ; } rtn = 1 ; plat = Z_Malloc ( sizeof ( * plat ) , PU_LEVSPEC , 0 ) ; memset ( plat , 0 , sizeof ( * plat ) ) ; P_AddThinker ( & plat -> thinker ) ; plat -> sector = sec ; plat -> sector -> floordata = plat ; plat -> thinker . function = T_PlatRaise ; plat -> crush = false ; plat -> tag = line -> tag ; plat -> type = genLift ; plat -> high = sec -> floorheight ; plat -> status = down ; switch ( Targ ) { case F2LnF : plat -> low = P_FindLowestFloorSurrounding ( sec ) ; if ( plat -> low > sec -> floorheight ) plat -> low = sec -> floorheight ; break ; case F2NnF : plat -> low = P_FindNextLowestFloor ( sec , sec -> floorheight ) ; break ; case F2LnC : plat -> low = P_FindLowestCeilingSurrounding ( sec ) ; if ( plat -> low > sec -> floorheight ) plat -> low = sec -> floorheight ; break ; case LnF2HnF : plat -> type = genPerpetual ; plat -> low = P_FindLowestFloorSurrounding ( sec ) ; if ( plat -> low > sec -> floorheight ) plat -> low = sec -> floorheight ; plat -> high = P_FindHighestFloorSurrounding ( sec ) ; if ( plat -> high < sec -> floorheight ) plat -> high = sec -> floorheight ; plat -> status = P_Random ( pr_genlift ) & 1 ; break ; default : break ; } switch ( Sped ) { case SpeedSlow : plat -> speed = PLATSPEED * 2 ; break ; case SpeedNormal : plat -> speed = PLATSPEED * 4 ; break ; case SpeedFast : plat -> speed = PLATSPEED * 8 ; break ; case SpeedTurbo : plat -> speed = PLATSPEED * 16 ; break ; default : break ; } switch ( Dely ) { case 0 : plat -> wait = 1 * 35 ; break ; case 1 : plat -> wait = PLATWAIT * 35 ; break ; case 2 : plat -> wait = 5 * 35 ; break ; case 3 : plat -> wait = 10 * 35 ; break ; } S_StartSound ( ( mobj_t * ) & sec -> soundorg , sfx_pstart ) ; P_AddActivePlat ( plat ) ; if ( manual ) return rtn ; } return rtn ; }
EV_DoGenLift()
Handle generalized lift types
EV_DoGenLift () Handle generalized lift types
// parse the bit fields in the line's special type // Activate all <type> plats that are in_stasis // 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 // Setup the plat thinker // setup the target destination height // setup the speed of motion // setup the delay time before the floor returns // add this plat to the list of active plats