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

Passed the linedef activating the crusher
Returns true if a thinker created
EV_DoGenCrusher () Handle generalized crusher types Passed the linedef activating the crusher Returns true if a thinker created
int EV_DoGenCrusher
( line_t*       line )
{
  int                   secnum;
  int                   rtn;
  boolean               manual;
  sector_t*             sec;
  ceiling_t*            ceiling;
  unsigned              value = (unsigned)line->special - GenCrusherBase;
  int Slnt = (value & CrusherSilent) >> CrusherSilentShift;
  int Sped = (value & CrusherSpeed) >> CrusherSpeedShift;
  int Trig = (value & TriggerType) >> TriggerTypeShift;
  rtn = P_ActivateInStasisCeiling(line);
  manual = false;
  if (Trig==PushOnce || Trig==PushMany)
  {
    if (!(sec = line->backsector))
      return rtn;
    secnum = sec-sectors;
    manual = true;
    goto manual_crusher;
  }
  secnum = -1;
  while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
  {
    sec = &sectors[secnum];
manual_crusher:
    if (P_SectorActive(ceiling_special,sec)) 
    {
      if (!manual)
        continue;
      else
        return rtn;
    }
    rtn = 1;
    ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVSPEC, 0);
    memset(ceiling, 0, sizeof(*ceiling));
    P_AddThinker (&ceiling->thinker);
    sec->ceilingdata = ceiling; 
    ceiling->thinker.function = T_MoveCeiling;
    ceiling->crush = true;
    ceiling->direction = -1;
    ceiling->sector = sec;
    ceiling->texture = sec->ceilingpic;
    ceiling->newspecial = sec->special;
    ceiling->tag = sec->tag;
    ceiling->type = Slnt? genSilentCrusher : genCrusher;
    ceiling->topheight = sec->ceilingheight;
    ceiling->bottomheight = sec->floorheight + (8*FRACUNIT);
    switch (Sped)
    {
      case SpeedSlow:
        ceiling->speed = CEILSPEED;
        break;
      case SpeedNormal:
        ceiling->speed = CEILSPEED*2;
        break;
      case SpeedFast:
        ceiling->speed = CEILSPEED*4;
        break;
      case SpeedTurbo:
        ceiling->speed = CEILSPEED*8;
        break;
      default:
        break;
    }
    ceiling->oldspeed=ceiling->speed;
    P_AddActiveCeiling(ceiling);  
    if (manual) return rtn;
  }
  return rtn;
}
int EV_DoGenCrusher ( line_t * line ) { int secnum ; int rtn ; boolean manual ; sector_t * sec ; ceiling_t * ceiling ; unsigned value = ( unsigned ) line -> special - GenCrusherBase ; int Slnt = ( value & CrusherSilent ) >> CrusherSilentShift ; int Sped = ( value & CrusherSpeed ) >> CrusherSpeedShift ; int Trig = ( value & TriggerType ) >> TriggerTypeShift ; rtn = P_ActivateInStasisCeiling ( line ) ; manual = false ; if ( Trig == PushOnce || Trig == PushMany ) { if ( ! ( sec = line -> backsector ) ) return rtn ; secnum = sec - sectors ; manual = true ; goto manual_crusher ; } secnum = -1 ; while ( ( secnum = P_FindSectorFromLineTag ( line , secnum ) ) >= 0 ) { sec = & sectors [ secnum ] ; manual_crusher : if ( P_SectorActive ( ceiling_special , sec ) ) { if ( ! manual ) continue ; else return rtn ; } rtn = 1 ; ceiling = Z_Malloc ( sizeof ( * ceiling ) , PU_LEVSPEC , 0 ) ; memset ( ceiling , 0 , sizeof ( * ceiling ) ) ; P_AddThinker ( & ceiling -> thinker ) ; sec -> ceilingdata = ceiling ; ceiling -> thinker . function = T_MoveCeiling ; ceiling -> crush = true ; ceiling -> direction = -1 ; ceiling -> sector = sec ; ceiling -> texture = sec -> ceilingpic ; ceiling -> newspecial = sec -> special ; ceiling -> tag = sec -> tag ; ceiling -> type = Slnt ? genSilentCrusher : genCrusher ; ceiling -> topheight = sec -> ceilingheight ; ceiling -> bottomheight = sec -> floorheight + ( 8 * FRACUNIT ) ; switch ( Sped ) { case SpeedSlow : ceiling -> speed = CEILSPEED ; break ; case SpeedNormal : ceiling -> speed = CEILSPEED * 2 ; break ; case SpeedFast : ceiling -> speed = CEILSPEED * 4 ; break ; case SpeedTurbo : ceiling -> speed = CEILSPEED * 8 ; break ; default : break ; } ceiling -> oldspeed = ceiling -> speed ; P_AddActiveCeiling ( ceiling ) ; if ( manual ) return rtn ; } return rtn ; }
EV_DoGenCrusher()
Handle generalized crusher types
EV_DoGenCrusher () Handle generalized crusher types
// parse the bit fields in the line's special type //jff 2/22/98  Reactivate in-stasis ceilings...for certain types. //jff 4/5/98 return if activated // 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 ceiling already moving //jff 2/22/98 // new ceiling thinker //jff 2/22/98 // setup ceiling motion speed // add to list of active ceilings