⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p_floor.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 3 页
字号:
    sec = &sectors[secnum];                  rtn = 1;    // handle trigger or numeric change type    switch(changetype)    {      case trigChangeOnly:        sec->floorpic = line->frontsector->floorpic;        sec->special = line->frontsector->special;        sec->oldspecial = line->frontsector->oldspecial;        break;      case numChangeOnly:        secm = P_FindModelFloorSector(sec->floorheight,secnum);        if (secm) // if no model, no change        {          sec->floorpic = secm->floorpic;          sec->special = secm->special;          sec->oldspecial = secm->oldspecial;        }        break;      default:        break;    }  }  return rtn;}//// BUILD A STAIRCASE!//// SoM: 3/6/2000: Use the Boom version of this function.int EV_BuildStairs( line_t*       line,  stair_e       type ){  int                   secnum;  int                   osecnum;  int                   height;  int                   i;  int                   newsecnum;  int                   texture;  int                   ok;  int                   rtn;      sector_t*             sec;  sector_t*             tsec;  floormove_t*  floor;      fixed_t               stairsize;  fixed_t               speed;  secnum = -1;  rtn = 0;  // start a stair at each sector tagged the same as the linedef  while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)  {    sec = &sectors[secnum];                  // don't start a stair if the first step's floor is already moving    if (P_SectorActive(floor_special,sec))      continue;          // create new floor thinker for first step    rtn = 1;    floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0);    P_AddThinker (&floor->thinker);    sec->floordata = floor;    floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor;    floor->direction = 1;    floor->sector = sec;    floor->type = buildStair;   //jff 3/31/98 do not leave uninited    // set up the speed and stepsize according to the stairs type    switch(type)    {      case build8:        speed = FLOORSPEED/4;        stairsize = 8*FRACUNIT;        if (boomsupport)          floor->crush = false; //jff 2/27/98 fix uninitialized crush field        break;      case turbo16:        speed = FLOORSPEED*4;        stairsize = 16*FRACUNIT;        if (boomsupport)          floor->crush = true;  //jff 2/27/98 fix uninitialized crush field        break;      // used by heretic      default:        speed = FLOORSPEED;        stairsize = type;        if (boomsupport)          floor->crush = true;  //jff 2/27/98 fix uninitialized crush field        break;    }    floor->speed = speed;    height = sec->floorheight + stairsize;    floor->floordestheight = height;                  texture = sec->floorpic;    osecnum = secnum;           //jff 3/4/98 preserve loop index          // Find next sector to raise    //   1. Find 2-sided line with same sector side[0] (lowest numbered)    //   2. Other side is the next sector to raise    //   3. Unless already moving, or different texture, then stop building    do    {      ok = 0;      for (i = 0;i < sec->linecount;i++)      {        if ( !((sec->lines[i])->flags & ML_TWOSIDED) )          continue;                                          tsec = (sec->lines[i])->frontsector;        newsecnum = tsec-sectors;                  if (secnum != newsecnum)          continue;        tsec = (sec->lines[i])->backsector;        if (!tsec) continue;     //jff 5/7/98 if no backside, continue        newsecnum = tsec - sectors;        // if sector's floor is different texture, look for another        if (tsec->floorpic != texture)          continue;        if (!boomsupport) // jff 6/19/98 prevent double stepsize          height += stairsize; // jff 6/28/98 change demo compatibility        // if sector's floor already moving, look for another        if (P_SectorActive(floor_special,tsec)) //jff 2/22/98          continue;                                          if (boomsupport) // jff 6/19/98 increase height AFTER continue          height += stairsize; // jff 6/28/98 change demo compatibility        sec = tsec;        secnum = newsecnum;        // create and initialize a thinker for the next step        floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0);        P_AddThinker (&floor->thinker);        sec->floordata = floor; //jff 2/22/98        floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor;        floor->direction = 1;        floor->sector = sec;        floor->speed = speed;        floor->floordestheight = height;        floor->type = buildStair; //jff 3/31/98 do not leave uninited        //jff 2/27/98 fix uninitialized crush field        if (boomsupport)          floor->crush = type==build8? false : true;        ok = 1;        break;      }    } while(ok);      // continue until no next step is found    secnum = osecnum; //jff 3/4/98 restore loop index  }  return rtn;}//SoM: 3/6/2000: boom donut function//// EV_DoDonut()//// Handle donut function: lower pillar, raise surrounding pool, both to height,// texture and type of the sector surrounding the pool.//// Passed the linedef that triggered the donut// Returns whether a thinker was created//int EV_DoDonut(line_t*  line){  sector_t* s1;  sector_t* s2;  sector_t* s3;  int       secnum;  int       rtn;  int       i;  floormove_t* floor;  secnum = -1;  rtn = 0;  // do function on all sectors with same tag as linedef  while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)  {    s1 = &sectors[secnum];                // s1 is pillar's sector                  // do not start the donut if the pillar is already moving    if (P_SectorActive(floor_special,s1)) //jff 2/22/98      continue;                          s2 = getNextSector(s1->lines[0],s1);  // s2 is pool's sector    if (!s2) continue;                    // note lowest numbered line around                                          // pillar must be two-sided     // do not start the donut if the pool is already moving    if (boomsupport && P_SectorActive(floor_special,s2))       continue;                           //jff 5/7/98                          // find a two sided line around the pool whose other side isn't the pillar    for (i = 0;i < s2->linecount;i++)    {      //jff 3/29/98 use true two-sidedness, not the flag      // killough 4/5/98: changed demo_compatibility to compatibility      if (!boomsupport)      {        if ((!s2->lines[i]->flags & ML_TWOSIDED) ||            (s2->lines[i]->backsector == s1))          continue;      }      else if (!s2->lines[i]->backsector || s2->lines[i]->backsector == s1)        continue;      rtn = 1; //jff 1/26/98 no donut action - no switch change on return      s3 = s2->lines[i]->backsector;      // s3 is model sector for changes              //  Spawn rising slime      floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0);      P_AddThinker (&floor->thinker);      s2->floordata = floor; //jff 2/22/98      floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor;      floor->type = donutRaise;      floor->crush = false;      floor->direction = 1;      floor->sector = s2;      floor->speed = FLOORSPEED / 2;      floor->texture = s3->floorpic;      floor->newspecial = 0;      floor->floordestheight = s3->floorheight;              //  Spawn lowering donut-hole pillar      floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0);      P_AddThinker (&floor->thinker);      s1->floordata = floor; //jff 2/22/98      floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor;      floor->type = lowerFloor;      floor->crush = false;      floor->direction = -1;      floor->sector = s1;      floor->speed = FLOORSPEED / 2;      floor->floordestheight = s3->floorheight;      break;    }  }  return rtn;}// SoM: Boom elevator support.//// EV_DoElevator//// Handle elevator linedef types//// Passed the linedef that triggered the elevator and the elevator action//// jff 2/22/98 new type to move floor and ceiling in parallel//int EV_DoElevator( line_t*       line,  elevator_e    elevtype ){  int                   secnum;  int                   rtn;  sector_t*             sec;  elevator_t*           elevator;  secnum = -1;  rtn = 0;  // act on all sectors with the same tag as the triggering linedef  while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)  {    sec = &sectors[secnum];                  // If either floor or ceiling is already activated, skip it    if (sec->floordata || sec->ceilingdata) //jff 2/22/98      continue;          // create and initialize new elevator thinker    rtn = 1;    elevator = Z_Malloc (sizeof(*elevator), PU_LEVSPEC, 0);    P_AddThinker (&elevator->thinker);    sec->floordata = elevator; //jff 2/22/98    sec->ceilingdata = elevator; //jff 2/22/98    elevator->thinker.function.acp1 = (actionf_p1) T_MoveElevator;    elevator->type = elevtype;    // set up the fields according to the type of elevator action    switch(elevtype)    {        // elevator down to next floor      case elevateDown:        elevator->direction = -1;        elevator->sector = sec;        elevator->speed = ELEVATORSPEED;        elevator->floordestheight =          P_FindNextLowestFloor(sec,sec->floorheight);        elevator->ceilingdestheight =          elevator->floordestheight + sec->ceilingheight - sec->floorheight;        break;        // elevator up to next floor      case elevateUp:        elevator->direction = 1;        elevator->sector = sec;        elevator->speed = ELEVATORSPEED;        elevator->floordestheight =          P_FindNextHighestFloor(sec,sec->floorheight);        elevator->ceilingdestheight =          elevator->floordestheight + sec->ceilingheight - sec->floorheight;        break;        // elevator to floor height of activating switch's front sector      case elevateCurrent:        elevator->sector = sec;        elevator->speed = ELEVATORSPEED;        elevator->floordestheight = line->frontsector->floorheight;        elevator->ceilingdestheight =          elevator->floordestheight + sec->ceilingheight - sec->floorheight;        elevator->direction =          elevator->floordestheight>sec->floorheight?  1 : -1;        break;      default:        break;    }  }  return rtn;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -