components/prboom/p_ceilng.c
//
// EV_DoCeiling
//
// Move a ceiling up/down or start a crusher
//
// Passed the linedef activating the function and the type of function desired
// returns true if a thinker started
//
EV_DoCeiling
Move a ceiling up/down or start a crusher

Passed the linedef activating the function and the type of function desired
returns true if a thinker started
EV_DoCeiling Move a ceiling up / down or start a crusher Passed the linedef activating the function and the type of function desired returns true if a thinker started
int EV_DoCeiling
( line_t* line,
  ceiling_e type )
{
  int   secnum;
  int   rtn;
  sector_t* sec;
  ceiling_t*  ceiling;
  secnum = -1;
  rtn = 0;
  switch(type)
  {
    case fastCrushAndRaise:
    case silentCrushAndRaise:
    case crushAndRaise:
      rtn = P_ActivateInStasisCeiling(line);
    default:
      break;
  }
  while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
  {
    sec = &sectors[secnum];
    if (P_SectorActive(ceiling_special,sec))  
      continue;
    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->sector = sec;
    ceiling->crush = false;
    switch(type)
    {
      case fastCrushAndRaise:
        ceiling->crush = true;
        ceiling->topheight = sec->ceilingheight;
        ceiling->bottomheight = sec->floorheight + (8*FRACUNIT);
        ceiling->direction = -1;
        ceiling->speed = CEILSPEED * 2;
        break;
      case silentCrushAndRaise:
      case crushAndRaise:
        ceiling->crush = true;
        ceiling->topheight = sec->ceilingheight;
      case lowerAndCrush:
      case lowerToFloor:
        ceiling->bottomheight = sec->floorheight;
        if (type != lowerToFloor)
          ceiling->bottomheight += 8*FRACUNIT;
        ceiling->direction = -1;
        ceiling->speed = CEILSPEED;
        break;
      case raiseToHighest:
        ceiling->topheight = P_FindHighestCeilingSurrounding(sec);
        ceiling->direction = 1;
        ceiling->speed = CEILSPEED;
        break;
      case lowerToLowest:
        ceiling->bottomheight = P_FindLowestCeilingSurrounding(sec);
        ceiling->direction = -1;
        ceiling->speed = CEILSPEED;
        break;
      case lowerToMaxFloor:
        ceiling->bottomheight = P_FindHighestFloorSurrounding(sec);
        ceiling->direction = -1;
        ceiling->speed = CEILSPEED;
        break;
      default:
        break;
    }
    ceiling->tag = sec->tag;
    ceiling->type = type;
    P_AddActiveCeiling(ceiling);
  }
  return rtn;
}
int EV_DoCeiling ( line_t * line , ceiling_e type ) { int secnum ; int rtn ; sector_t * sec ; ceiling_t * ceiling ; secnum = -1 ; rtn = 0 ; switch ( type ) { case fastCrushAndRaise : case silentCrushAndRaise : case crushAndRaise : rtn = P_ActivateInStasisCeiling ( line ) ; default : break ; } while ( ( secnum = P_FindSectorFromLineTag ( line , secnum ) ) >= 0 ) { sec = & sectors [ secnum ] ; if ( P_SectorActive ( ceiling_special , sec ) ) continue ; 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 -> sector = sec ; ceiling -> crush = false ; switch ( type ) { case fastCrushAndRaise : ceiling -> crush = true ; ceiling -> topheight = sec -> ceilingheight ; ceiling -> bottomheight = sec -> floorheight + ( 8 * FRACUNIT ) ; ceiling -> direction = -1 ; ceiling -> speed = CEILSPEED * 2 ; break ; case silentCrushAndRaise : case crushAndRaise : ceiling -> crush = true ; ceiling -> topheight = sec -> ceilingheight ; case lowerAndCrush : case lowerToFloor : ceiling -> bottomheight = sec -> floorheight ; if ( type != lowerToFloor ) ceiling -> bottomheight += 8 * FRACUNIT ; ceiling -> direction = -1 ; ceiling -> speed = CEILSPEED ; break ; case raiseToHighest : ceiling -> topheight = P_FindHighestCeilingSurrounding ( sec ) ; ceiling -> direction = 1 ; ceiling -> speed = CEILSPEED ; break ; case lowerToLowest : ceiling -> bottomheight = P_FindLowestCeilingSurrounding ( sec ) ; ceiling -> direction = -1 ; ceiling -> speed = CEILSPEED ; break ; case lowerToMaxFloor : ceiling -> bottomheight = P_FindHighestFloorSurrounding ( sec ) ; ceiling -> direction = -1 ; ceiling -> speed = CEILSPEED ; break ; default : break ; } ceiling -> tag = sec -> tag ; ceiling -> type = type ; P_AddActiveCeiling ( ceiling ) ; } return rtn ; }
EV_DoCeiling
Move a ceiling up/down or start a crusher
EV_DoCeiling Move a ceiling up / down or start a crusher
// Reactivate in-stasis ceilings...for certain types. // This restarts a crusher after it has been stopped //jff 4/5/98 return if activated // affects all sectors with the same tag as the linedef // if ceiling already moving, don't start a second function on it //jff 2/22/98 // create a new ceiling thinker //jff 2/22/98 // setup ceiling structure according to type of function // add the ceiling to the active list