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

📄 p_spec.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 5 页
字号:
          foundsector = 1;    }    return floor;}//// P_FindNextHighestFloor// FIND NEXT HIGHEST FLOOR IN SURROUNDING SECTORS// SoM: 3/7/2000: Use Lee Killough's version insted.// Rewritten by Lee Killough to avoid fixed array and to be faster//fixed_t P_FindNextHighestFloor(sector_t *sec, int currentheight){  sector_t *other;  int i;  for (i=0 ;i < sec->linecount ; i++)    if ((other = getNextSector(sec->lines[i],sec)) &&         other->floorheight > currentheight)    {      int height = other->floorheight;      while (++i < sec->linecount)        if ((other = getNextSector(sec->lines[i],sec)) &&            other->floorheight < height &&            other->floorheight > currentheight)          height = other->floorheight;      return height;    }  return currentheight;}////////////////////////////////////////////////////// SoM: Start new Boom functions////////////////////////////////////////////////////// P_FindNextLowestFloor()//// Passed a sector and a floor height, returns the fixed point value// of the largest floor height in a surrounding sector smaller than// the floor height passed. If no such height exists the floorheight// passed is returned.////fixed_t P_FindNextLowestFloor(sector_t *sec, int currentheight){  sector_t *other;  int i;  for (i=0 ;i < sec->linecount ; i++)    if ((other = getNextSector(sec->lines[i],sec)) &&         other->floorheight < currentheight)    {      int height = other->floorheight;      while (++i < sec->linecount)        if ((other = getNextSector(sec->lines[i],sec)) &&            other->floorheight > height &&            other->floorheight < currentheight)          height = other->floorheight;      return height;    }  return currentheight;}//// P_FindNextLowestCeiling()//// Passed a sector and a ceiling height, returns the fixed point value// of the largest ceiling height in a surrounding sector smaller than// the ceiling height passed. If no such height exists the ceiling height// passed is returned.////fixed_t P_FindNextLowestCeiling(sector_t *sec, int currentheight){  sector_t *other;  int i;  for (i=0 ;i < sec->linecount ; i++)    if ((other = getNextSector(sec->lines[i],sec)) &&        other->ceilingheight < currentheight)    {      int height = other->ceilingheight;      while (++i < sec->linecount)        if ((other = getNextSector(sec->lines[i],sec)) &&            other->ceilingheight > height &&            other->ceilingheight < currentheight)          height = other->ceilingheight;      return height;    }  return currentheight;}//// P_FindNextHighestCeiling()//// Passed a sector and a ceiling height, returns the fixed point value// of the smallest ceiling height in a surrounding sector larger than// the ceiling height passed. If no such height exists the ceiling height// passed is returned.////fixed_t P_FindNextHighestCeiling(sector_t *sec, int currentheight){  sector_t *other;  int i;  for (i=0 ;i < sec->linecount ; i++)    if ((other = getNextSector(sec->lines[i],sec)) &&         other->ceilingheight > currentheight)    {      int height = other->ceilingheight;      while (++i < sec->linecount)        if ((other = getNextSector(sec->lines[i],sec)) &&            other->ceilingheight < height &&            other->ceilingheight > currentheight)          height = other->ceilingheight;      return height;    }  return currentheight;}////////////////////////////// End New Boom functions//////////////////////////////// FIND LOWEST CEILING IN THE SURROUNDING SECTORS//fixed_tP_FindLowestCeilingSurrounding(sector_t* sec){    int                 i;    line_t*             check;    sector_t*           other;    fixed_t             height = MAXINT;    int                 foundsector = 0;    if (boomsupport) height = 32000*FRACUNIT; //SoM: 3/7/2000: Remove ovf                                                  for (i=0 ;i < sec->linecount ; i++)    {        check = sec->lines[i];        other = getNextSector(check,sec);        if (!other)            continue;        if (other->ceilingheight < height || !foundsector)            height = other->ceilingheight;        if(!foundsector)          foundsector = 1;    }    return height;}//// FIND HIGHEST CEILING IN THE SURROUNDING SECTORS//fixed_t P_FindHighestCeilingSurrounding(sector_t* sec){    int         i;    line_t*     check;    sector_t*   other;    fixed_t     height = 0;    int         foundsector = 0;    for (i=0 ;i < sec->linecount ; i++)    {        check = sec->lines[i];        other = getNextSector(check,sec);        if (!other)            continue;        if (other->ceilingheight > height || !foundsector)            height = other->ceilingheight;        if(!foundsector)          foundsector = 1;    }    return height;}//SoM: 3/7/2000: UTILS.....//// P_FindShortestTextureAround()//// Passed a sector number, returns the shortest lower texture on a// linedef bounding the sector.////fixed_t P_FindShortestTextureAround(int secnum){  int minsize = MAXINT;  side_t*     side;  int i;  sector_t *sec = &sectors[secnum];  if (boomsupport)    minsize = 32000<<FRACBITS;  for (i = 0; i < sec->linecount; i++)  {    if (twoSided(secnum, i))    {      side = getSide(secnum,i,0);      if (side->bottomtexture > 0)        if (textureheight[side->bottomtexture] < minsize)          minsize = textureheight[side->bottomtexture];      side = getSide(secnum,i,1);      if (side->bottomtexture > 0)        if (textureheight[side->bottomtexture] < minsize)          minsize = textureheight[side->bottomtexture];    }  }  return minsize;}//SoM: 3/7/2000: Stuff.... (can you tell I'm getting tired? It's 12:30!)//// P_FindShortestUpperAround()//// Passed a sector number, returns the shortest upper texture on a// linedef bounding the sector.////fixed_t P_FindShortestUpperAround(int secnum){  int minsize = MAXINT;  side_t*     side;  int i;  sector_t *sec = &sectors[secnum];  if (boomsupport)    minsize = 32000<<FRACBITS;  for (i = 0; i < sec->linecount; i++)  {    if (twoSided(secnum, i))    {      side = getSide(secnum,i,0);      if (side->toptexture > 0)        if (textureheight[side->toptexture] < minsize)          minsize = textureheight[side->toptexture];      side = getSide(secnum,i,1);      if (side->toptexture > 0)        if (textureheight[side->toptexture] < minsize)          minsize = textureheight[side->toptexture];    }  }  return minsize;}//SoM: 3/7/2000//// P_FindModelFloorSector()//// Passed a floor height and a sector number, return a pointer to a// a sector with that floor height across the lowest numbered two sided// line surrounding the sector.//// Note: If no sector at that height bounds the sector passed, return NULL////sector_t *P_FindModelFloorSector(fixed_t floordestheight,int secnum){  int i;  sector_t *sec=NULL;  int linecount;  sec = &sectors[secnum];  linecount = sec->linecount;  for (i = 0; i < (!boomsupport && sec->linecount<linecount?                   sec->linecount : linecount); i++)  {    if ( twoSided(secnum, i) )    {      if (getSide(secnum,i,0)->sector-sectors == secnum)          sec = getSector(secnum,i,1);      else          sec = getSector(secnum,i,0);      if (sec->floorheight == floordestheight)        return sec;    }  }  return NULL;}//SoM: 3/7/2000: Last one...//// P_FindModelCeilingSector()//// Passed a ceiling height and a sector number, return a pointer to a// a sector with that ceiling height across the lowest numbered two sided// line surrounding the sector.//// Note: If no sector at that height bounds the sector passed, return NULL////sector_t *P_FindModelCeilingSector(fixed_t ceildestheight,int secnum){  int i;  sector_t *sec=NULL;  int linecount;  sec = &sectors[secnum];  linecount = sec->linecount;  for (i = 0; i < (!boomsupport && sec->linecount<linecount?                   sec->linecount : linecount); i++)  {    if ( twoSided(secnum, i) )    {      if (getSide(secnum,i,0)->sector-sectors == secnum)          sec = getSector(secnum,i,1);      else          sec = getSector(secnum,i,0);      if (sec->ceilingheight == ceildestheight)        return sec;    }  }  return NULL;}//// RETURN NEXT SECTOR # THAT LINE TAG REFERS TO////SoM: 3/7/2000: Killough wrote this to improve the process.intP_FindSectorFromLineTag( line_t*       line,  int           start ){  start = start >= 0 ? sectors[start].nexttag :    sectors[(unsigned) line->tag % (unsigned) numsectors].firsttag;  while (start >= 0 && sectors[start].tag != line->tag)    start = sectors[start].nexttag;  return start;}//// P_FindSectorFromTag// Used by FraggleScriptintP_FindSectorFromTag( int           tag,  int           start ){  start = start >= 0 ? sectors[start].nexttag :    sectors[(unsigned) tag % (unsigned) numsectors].firsttag;  while (start >= 0 && sectors[start].tag != tag)    start = sectors[start].nexttag;  return start;}//SoM: 3/7/2000: More boom specific stuff...// killough 4/16/98: Same thing, only for linedefsint P_FindLineFromLineTag(const line_t *line, int start){  start = start >= 0 ? lines[start].nexttag :    lines[(unsigned) line->tag % (unsigned) numlines].firsttag;  while (start >= 0 && lines[start].tag != line->tag)    start = lines[start].nexttag;  return start;}//SoM: 3/7/2000: Oh joy!// Hash the sector tags across the sectors and linedefs.static void P_InitTagLists(void){  register int i;  for (i=numsectors; --i>=0; )    sectors[i].firsttag = -1;  for (i=numsectors; --i>=0; )    {      int j = (unsigned) sectors[i].tag % (unsigned) numsectors;      sectors[i].nexttag = sectors[j].firsttag;      sectors[j].firsttag = i;    }  for (i=numlines; --i>=0; )    lines[i].firsttag = -1;  for (i=numlines; --i>=0; )    {      int j = (unsigned) lines[i].tag % (unsigned) numlines;      lines[i].nexttag = lines[j].firsttag;      lines[j].firsttag = i;    }}//// Find minimum light from an adjacent sector//intP_FindMinSurroundingLight( sector_t*     sector,  int           max ){    int         i;    int         min;    line_t*     line;    sector_t*   check;    min = max;    for (i=0 ; i < sector->linecount ; i++)    {        line = sector->lines[i];        check = getNextSector(line,sector);        if (!check)            continue;        if (check->lightlevel < min)            min = check->lightlevel;    }    return min;}//SoM: 3/7/2000//// P_CanUnlockGenDoor()//// Passed a generalized locked door linedef and a player, returns whether// the player has the keys necessary to unlock that door.//// Note: The linedef passed MUST be a generalized locked door type//       or results are undefined.////boolean P_CanUnlockGenDoor( line_t* line, player_t* player){  // does this line special distinguish between skulls and keys?  int skulliscard = (line->special & LockedNKeys)>>LockedNKeysShift;  // determine for each case of lock type if player's keys are adequate  switch((line->special & LockedKey)>>LockedKeyShift)  {    case AnyKey_:      if      (        !(player->cards & it_redcard) &&        !(player->cards & it_redskull) &&        !(player->cards & it_bluecard) &&        !(player->cards & it_blueskull) &&        !(player->cards & it_yellowcard) &&        !(player->cards & it_yellowskull)      )      {        player->message = PD_ANY;#ifdef HW3SOUND        S_StartScreamSound(player->mo, sfx_oof);#else        S_StartSound(player->mo,sfx_oof);#endif        return false;      }      break;    case RCard:      if      (        !(player->cards & it_redcard) &&        (!skulliscard || !(player->cards & it_redskull))      )      {        player->message = skulliscard? PD_REDK : PD_REDC;#ifdef HW3SOUND        S_StartScreamSound(player->mo, sfx_oof);#else        S_StartSound(player->mo,sfx_oof);#endif        return false;      }      break;    case BCard:

⌨️ 快捷键说明

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