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

Passed the linedef activating the generalized door
Returns true if a thinker created
EV_DoGenDoor () Handle generalized door types Passed the linedef activating the generalized door Returns true if a thinker created
int EV_DoGenDoor
( line_t* line )
{
  int   secnum,rtn;
  sector_t* sec;
  boolean   manual;
  vldoor_t* door;
  unsigned  value = (unsigned)line->special - GenDoorBase;
  int Dely = (value & DoorDelay) >> DoorDelayShift;
  int Kind = (value & DoorKind) >> DoorKindShift;
  int Sped = (value & DoorSpeed) >> DoorSpeedShift;
  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_door;
  }
  secnum = -1;
  rtn = 0;
  while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
  {
    sec = &sectors[secnum];
manual_door:
    if (P_SectorActive(ceiling_special,sec)) 
    {
      if (!manual)
        continue;
      else
        return rtn;
    }
    rtn = 1;
    door = Z_Malloc (sizeof(*door), PU_LEVSPEC, 0);
    memset(door, 0, sizeof(*door));
    P_AddThinker (&door->thinker);
    sec->ceilingdata = door; 
    door->thinker.function = T_VerticalDoor;
    door->sector = sec;
    switch(Dely)
    {
      default:
      case 0:
        door->topwait = 35;
        break;
      case 1:
        door->topwait = VDOORWAIT;
        break;
      case 2:
        door->topwait = 2*VDOORWAIT;
        break;
      case 3:
        door->topwait = 7*VDOORWAIT;
        break;
    }
    switch(Sped)
    {
      default:
      case SpeedSlow:
        door->speed = VDOORSPEED;
        break;
      case SpeedNormal:
        door->speed = VDOORSPEED*2;
        break;
      case SpeedFast:
        door->speed = VDOORSPEED*4;
        break;
      case SpeedTurbo:
        door->speed = VDOORSPEED*8;
        break;
    }
    door->line = line; 
    door->lighttag = !comp[comp_doorlight] &&
      (line->special&6) == 6 &&
      line->special > GenLockedBase ? line->tag : 0;
    switch(Kind)
    {
      case OdCDoor:
        door->direction = 1;
        door->topheight = P_FindLowestCeilingSurrounding(sec);
        door->topheight -= 4*FRACUNIT;
        if (door->topheight != sec->ceilingheight)
          S_StartSound((mobj_t *)&door->sector->soundorg,Sped>=SpeedFast || comp[comp_sound] ? sfx_bdopn : sfx_doropn);
        door->type = Sped>=SpeedFast? genBlazeRaise : genRaise;
        break;
      case ODoor:
        door->direction = 1;
        door->topheight = P_FindLowestCeilingSurrounding(sec);
        door->topheight -= 4*FRACUNIT;
        if (door->topheight != sec->ceilingheight)
          S_StartSound((mobj_t *)&door->sector->soundorg,Sped>=SpeedFast || comp[comp_sound] ? sfx_bdopn : sfx_doropn);
        door->type = Sped>=SpeedFast? genBlazeOpen : genOpen;
        break;
      case CdODoor:
        door->topheight = sec->ceilingheight;
        door->direction = -1;
        S_StartSound((mobj_t *)&door->sector->soundorg,Sped>=SpeedFast && !comp[comp_sound] ? sfx_bdcls : sfx_dorcls);
        door->type = Sped>=SpeedFast? genBlazeCdO : genCdO;
        break;
      case CDoor:
        door->topheight = P_FindLowestCeilingSurrounding(sec);
        door->topheight -= 4*FRACUNIT;
        door->direction = -1;
        S_StartSound((mobj_t *)&door->sector->soundorg,Sped>=SpeedFast && !comp[comp_sound] ? sfx_bdcls : sfx_dorcls);
        door->type = Sped>=SpeedFast? genBlazeClose : genClose;
        break;
      default:
        break;
    }
    if (manual)
      return rtn;
  }
  return rtn;
}
int EV_DoGenDoor ( line_t * line ) { int secnum , rtn ; sector_t * sec ; boolean manual ; vldoor_t * door ; unsigned value = ( unsigned ) line -> special - GenDoorBase ; int Dely = ( value & DoorDelay ) >> DoorDelayShift ; int Kind = ( value & DoorKind ) >> DoorKindShift ; int Sped = ( value & DoorSpeed ) >> DoorSpeedShift ; 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_door ; } secnum = -1 ; rtn = 0 ; while ( ( secnum = P_FindSectorFromLineTag ( line , secnum ) ) >= 0 ) { sec = & sectors [ secnum ] ; manual_door : if ( P_SectorActive ( ceiling_special , sec ) ) { if ( ! manual ) continue ; else return rtn ; } rtn = 1 ; door = Z_Malloc ( sizeof ( * door ) , PU_LEVSPEC , 0 ) ; memset ( door , 0 , sizeof ( * door ) ) ; P_AddThinker ( & door -> thinker ) ; sec -> ceilingdata = door ; door -> thinker . function = T_VerticalDoor ; door -> sector = sec ; switch ( Dely ) { default : case 0 : door -> topwait = 35 ; break ; case 1 : door -> topwait = VDOORWAIT ; break ; case 2 : door -> topwait = 2 * VDOORWAIT ; break ; case 3 : door -> topwait = 7 * VDOORWAIT ; break ; } switch ( Sped ) { default : case SpeedSlow : door -> speed = VDOORSPEED ; break ; case SpeedNormal : door -> speed = VDOORSPEED * 2 ; break ; case SpeedFast : door -> speed = VDOORSPEED * 4 ; break ; case SpeedTurbo : door -> speed = VDOORSPEED * 8 ; break ; } door -> line = line ; door -> lighttag = ! comp [ comp_doorlight ] && ( line -> special & 6 ) == 6 && line -> special > GenLockedBase ? line -> tag : 0 ; switch ( Kind ) { case OdCDoor : door -> direction = 1 ; door -> topheight = P_FindLowestCeilingSurrounding ( sec ) ; door -> topheight -= 4 * FRACUNIT ; if ( door -> topheight != sec -> ceilingheight ) S_StartSound ( ( mobj_t * ) & door -> sector -> soundorg , Sped >= SpeedFast || comp [ comp_sound ] ? sfx_bdopn : sfx_doropn ) ; door -> type = Sped >= SpeedFast ? genBlazeRaise : genRaise ; break ; case ODoor : door -> direction = 1 ; door -> topheight = P_FindLowestCeilingSurrounding ( sec ) ; door -> topheight -= 4 * FRACUNIT ; if ( door -> topheight != sec -> ceilingheight ) S_StartSound ( ( mobj_t * ) & door -> sector -> soundorg , Sped >= SpeedFast || comp [ comp_sound ] ? sfx_bdopn : sfx_doropn ) ; door -> type = Sped >= SpeedFast ? genBlazeOpen : genOpen ; break ; case CdODoor : door -> topheight = sec -> ceilingheight ; door -> direction = -1 ; S_StartSound ( ( mobj_t * ) & door -> sector -> soundorg , Sped >= SpeedFast && ! comp [ comp_sound ] ? sfx_bdcls : sfx_dorcls ) ; door -> type = Sped >= SpeedFast ? genBlazeCdO : genCdO ; break ; case CDoor : door -> topheight = P_FindLowestCeilingSurrounding ( sec ) ; door -> topheight -= 4 * FRACUNIT ; door -> direction = -1 ; S_StartSound ( ( mobj_t * ) & door -> sector -> soundorg , Sped >= SpeedFast && ! comp [ comp_sound ] ? sfx_bdcls : sfx_dorcls ) ; door -> type = Sped >= SpeedFast ? genBlazeClose : genClose ; break ; default : break ; } if ( manual ) return rtn ; } return rtn ; }
EV_DoGenDoor()
Handle generalized door types
EV_DoGenDoor () Handle generalized door 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 ceiling already moving //jff 2/22/98 // new door thinker //jff 2/22/98 // setup delay for door remaining open/closed // setup speed of door motion // jff 1/31/98 remember line that triggered us /* killough 10/98: implement gradual lighting */ // set kind of door, whether it opens then close, opens, closes etc. // assign target heights accordingly