components/prboom/p_doors.c
//
// EV_VerticalDoor
//
// Handle opening a door manually, no tag value
//
// Passed the line activating the door and the thing activating it
// Returns true if a thinker created
//
// jff 2/12/98 added int return value, fixed all returns
//
EV_VerticalDoor
Handle opening a door manually, no tag value

Passed the line activating the door and the thing activating it
Returns true if a thinker created

jff 2/12/98 added int return value, fixed all returns
EV_VerticalDoor Handle opening a door manually no tag value Passed the line activating the door and the thing activating it Returns true if a thinker created jff 2 / 12 / 98 added int return value fixed all returns
int EV_VerticalDoor
( line_t* line,
  mobj_t* thing )
{
  player_t* player;
  int   secnum;
  sector_t* sec;
  vldoor_t* door;
  player = thing->player;
  switch(line->special)
  {
    case 26: 
    case 32:
      if ( !player )
        return 0;
      if (!player->cards[it_bluecard] && !player->cards[it_blueskull])
      {
          player->message = s_PD_BLUEK;         
          S_StartSound(player->mo,sfx_oof);     
          return 0;
      }
      break;
    case 27: 
    case 34:
      if ( !player )
          return 0;
      if (!player->cards[it_yellowcard] && !player->cards[it_yellowskull])
      {
          player->message = s_PD_YELLOWK;       
          S_StartSound(player->mo,sfx_oof);     
          return 0;
      }
      break;
    case 28: 
    case 33:
      if ( !player )
          return 0;
      if (!player->cards[it_redcard] && !player->cards[it_redskull])
      {
          player->message = s_PD_REDK;          
          S_StartSound(player->mo,sfx_oof);     
          return 0;
      }
      break;
    default:
      break;
  }
  if (line->sidenum[1]==NO_INDEX)                     
  {
    S_StartSound(player->mo,sfx_oof);           
    return 0;
  }
  sec = sides[line->sidenum[1]].sector;
  secnum = sec-sectors;
  door = sec->ceilingdata;
  if (demo_compatibility) {
    if (!door) door = sec->floordata;
    if (!door) door = sec->lightingdata;
  }
  if (door &&
	  ((compatibility_level == prboom_4_compatibility) ||
	   (line->special == 1) || (line->special == 117) || (line->special == 26) || (line->special == 27) || (line->special == 28)
	  )
     ) {
    if (compatibility_level < prboom_4_compatibility || 
        door->thinker.function == T_VerticalDoor) {
      signed int outval = 0;
      if (door->thinker.function == T_VerticalDoor && door->direction == -1) {
        outval = 1; 
      } else if (player) {
        outval = -1; 
      }
      if (outval) {
        if (door->thinker.function == T_VerticalDoor) {
          door->direction = outval;
        } else if (door->thinker.function == T_PlatRaise) {
          plat_t* p = (plat_t*)door;
          p->wait = outval;
        } else {
          lprintf(LO_DEBUG, "EV_VerticalDoor: unknown thinker.function in thinker corruption emulation");
        }
        return 1;
      }
    }
    return 0;
  }
  switch(line->special)
  {
    case 117: 
    case 118: 
      S_StartSound((mobj_t *)&sec->soundorg,sfx_bdopn);
      break;
    default:  
      S_StartSound((mobj_t *)&sec->soundorg,sfx_doropn);
      break;
  }
  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;
  door->direction = 1;
  door->speed = VDOORSPEED;
  door->topwait = VDOORWAIT;
  door->line = line; 
  door->lighttag = comp[comp_doorlight] ? 0 : line->tag;
  switch(line->special)
  {
    case 1:
    case 26:
    case 27:
    case 28:
      door->type = normal;
      break;
    case 31:
    case 32:
    case 33:
    case 34:
      door->type = open;
      line->special = 0;
      break;
    case 117: 
      door->type = blazeRaise;
      door->speed = VDOORSPEED*4;
      break;
    case 118: 
      door->type = blazeOpen;
      line->special = 0;
      door->speed = VDOORSPEED*4;
      break;
    default:
      door->lighttag = 0;    10/98
      break;
  }
  door->topheight = P_FindLowestCeilingSurrounding(sec);
  door->topheight -= 4*FRACUNIT;
  return 1;
}
int EV_VerticalDoor ( line_t * line , mobj_t * thing ) { player_t * player ; int secnum ; sector_t * sec ; vldoor_t * door ; player = thing -> player ; switch ( line -> special ) { case 26 : case 32 : if ( ! player ) return 0 ; if ( ! player -> cards [ it_bluecard ] && ! player -> cards [ it_blueskull ] ) { player -> message = s_PD_BLUEK ; S_StartSound ( player -> mo , sfx_oof ) ; return 0 ; } break ; case 27 : case 34 : if ( ! player ) return 0 ; if ( ! player -> cards [ it_yellowcard ] && ! player -> cards [ it_yellowskull ] ) { player -> message = s_PD_YELLOWK ; S_StartSound ( player -> mo , sfx_oof ) ; return 0 ; } break ; case 28 : case 33 : if ( ! player ) return 0 ; if ( ! player -> cards [ it_redcard ] && ! player -> cards [ it_redskull ] ) { player -> message = s_PD_REDK ; S_StartSound ( player -> mo , sfx_oof ) ; return 0 ; } break ; default : break ; } if ( line -> sidenum [ 1 ] == NO_INDEX ) { S_StartSound ( player -> mo , sfx_oof ) ; return 0 ; } sec = sides [ line -> sidenum [ 1 ] ] . sector ; secnum = sec - sectors ; door = sec -> ceilingdata ; if ( demo_compatibility ) { if ( ! door ) door = sec -> floordata ; if ( ! door ) door = sec -> lightingdata ; } if ( door && ( ( compatibility_level == prboom_4_compatibility ) || ( line -> special == 1 ) || ( line -> special == 117 ) || ( line -> special == 26 ) || ( line -> special == 27 ) || ( line -> special == 28 ) ) ) { if ( compatibility_level < prboom_4_compatibility || door -> thinker . function == T_VerticalDoor ) { signed int outval = 0 ; if ( door -> thinker . function == T_VerticalDoor && door -> direction == -1 ) { outval = 1 ; } else if ( player ) { outval = -1 ; } if ( outval ) { if ( door -> thinker . function == T_VerticalDoor ) { door -> direction = outval ; } else if ( door -> thinker . function == T_PlatRaise ) { plat_t * p = ( plat_t * ) door ; p -> wait = outval ; } else { lprintf ( LO_DEBUG , " " ) ; } return 1 ; } } return 0 ; } switch ( line -> special ) { case 117 : case 118 : S_StartSound ( ( mobj_t * ) & sec -> soundorg , sfx_bdopn ) ; break ; default : S_StartSound ( ( mobj_t * ) & sec -> soundorg , sfx_doropn ) ; break ; } 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 ; door -> direction = 1 ; door -> speed = VDOORSPEED ; door -> topwait = VDOORWAIT ; door -> line = line ; door -> lighttag = comp [ comp_doorlight ] ? 0 : line -> tag ; switch ( line -> special ) { case 1 : case 26 : case 27 : case 28 : door -> type = normal ; break ; case 31 : case 32 : case 33 : case 34 : door -> type = open ; line -> special = 0 ; break ; case 117 : door -> type = blazeRaise ; door -> speed = VDOORSPEED * 4 ; break ; case 118 : door -> type = blazeOpen ; line -> special = 0 ; door -> speed = VDOORSPEED * 4 ; break ; default : door -> lighttag = 0 ; break ; } door -> topheight = P_FindLowestCeilingSurrounding ( sec ) ; door -> topheight -= 4 * FRACUNIT ; return 1 ; }
EV_VerticalDoor
Handle opening a door manually, no tag value
EV_VerticalDoor Handle opening a door manually no tag value
//  Check for locks // Blue Lock // Ty 03/27/98 - externalized // killough 3/20/98 // Yellow Lock // Ty 03/27/98 - externalized // killough 3/20/98 // Red Lock // Ty 03/27/98 - externalized // killough 3/20/98 // if the wrong side of door is pushed, give oof sound // killough // killough 3/20/98 // get the sector on the second side of activating linedef /* if door already has a thinker, use it
   * cph 2001/04/05 -
   * Ok, this is a disaster area. We're assuming that sec->ceilingdata
   *  is a vldoor_t! What if this door is controlled by both DR lines
   *  and by switches? I don't know how to fix that.
   * Secondly, original Doom didn't distinguish floor/lighting/ceiling
   *  actions, so we need to do the same in demo compatibility mode.
   */ /* If this is a repeatable line, and the door is already moving, then we can just reverse the current action. Note that in prboom 2.3.0 I erroneously removed the if-this-is-repeatable check, hence the prboom_4_compatibility clause below (foolishly assumed that already moving implies repeatable - but it could be moving due to another switch, e.g. lv19-509) */ /* For old demos we have to emulate the old buggy behavior and
     * mess up non-T_VerticalDoor actions.
     */ /* cph - we are writing outval to door->direction iff it is non-zero */ /* An already moving repeatable door which is being re-pressed, or a
       * monster is trying to open a closing door - so change direction
       * DEMOSYNC: we only read door->direction now if it really is a door.
       */ /* go back up */ /* go back down */ /* Write this to the thinker. In demo compatibility mode, we might be 
       *  overwriting a field of a non-vldoor_t thinker - we need to add any 
       *  other thinker types here if any demos depend on specific fields
       *  being corrupted by this.
       */ /* Either we're in prboom >=v2.3 and it's not a door, or it's a door but
     * we're a monster and don't want to shut it; exit with no action.
     */ // emit proper sound // blazing door raise // blazing door open // normal or locked door sound // new door thinker //jff 2/22/98 // jff 1/31/98 remember line that triggered us /* killough 10/98: use gradual lighting changes if nonzero tag given */ // set the type of door from the activating linedef type // blazing door raise // blazing door open // killough 10/98 // find the top and bottom of the movement range