示例#1
0
文件: spec.c 项目: Almamu/doom3do
Fixed P_FindNextHighestFloor(sector_t *sec,Fixed currentheight)
{
	Word i;
	line_t **check;
	sector_t *other;
	Fixed height;		/* Value to return */

	height = 0x7FFFFFFF;		/* Init to the maximum Fixed */
	i = sec->linecount;			/* Any lines? */
	if (i) {
		check = sec->lines;		/* Init line pointer */
		do {
			other = getNextSector(check[0],sec);	/* Connecting sector? */
			if (other) {
				if (other->floorheight>currentheight) {	/* Higher than current? */
					if (other->floorheight<height) {	/* Lower than result? */
						height = other->floorheight;	/* Change result */
					}
				}
			}
			++check;
		} while (--i);
	}
    return height;		/* Return the answer */
}
示例#2
0
文件: p_lights.c 项目: jezze/doom
int EV_TurnTagLightsOff(line_t *line)
{

    int j;

    for (j = -1; (j = P_FindSectorFromLineTag(line,j)) >= 0;)
    {

        sector_t *sector = sectors + j, *tsec;
        int i, min = sector->lightlevel;

        for (i = 0;i < sector->linecount; i++)
        {

            if ((tsec = getNextSector(sector->lines[i], sector)) && tsec->lightlevel < min)
                min = tsec->lightlevel;

        }

        sector->lightlevel = min;

    }

    return 1;

}
示例#3
0
文件: p_lights.c 项目: smokhov/atsm
//
// TURN LINE'S TAG LIGHTS ON
//
void EV_LightTurnOn(line_t *line, int bright)
{
    int		i;
    int		j;
    sector_t	*sector;
    sector_t	*temp;
    line_t	*templine;

    for (i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;)
    {
        sector = sectors + i;
        // bright = 0 means to search
        // for highest light level
        // surrounding sector
        if (!bright)
        {
            for (j = 0; j < sector->linecount; j++)
            {
                templine = sector->lines[j];
                temp = getNextSector(templine, sector);

                if (!temp)
                    continue;

                if (temp->lightlevel > bright)
                    bright = temp->lightlevel;
            }
        }
        sector-> lightlevel = bright;
    }
}
示例#4
0
// killough 10/98:
//
// EV_LightTurnOnPartway()
//
// Turn sectors tagged to line lights on to specified or max neighbor level
//
// Passed the activating line's tag, and a light level fraction between 
// 0 and 1. Sets the light to min on 0, max on 1, and interpolates in-
// between. Used for doors with gradual lighting effects.
//
// haleyjd 02/28/05: changed to take a tag instead of a line.
//
// Returns true
//
int EV_LightTurnOnPartway(int tag, fixed_t level)
{
   int i;
   
   if(level < 0)          // clip at extremes 
      level = 0;
   if(level > FRACUNIT)
      level = FRACUNIT;

   // search all sectors for ones with same tag as activating line
   for(i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0;)
   {
      sector_t *temp, *sector = sectors + i;
      int j, bright = 0, min = sector->lightlevel;

      for(j = 0; j < sector->linecount; ++j)
      {
         if((temp = getNextSector(sector->lines[j], sector)))
         {
            if(temp->lightlevel > bright)
               bright = temp->lightlevel;
            if(temp->lightlevel < min)
               min = temp->lightlevel;
         }
      }

      sector->lightlevel =   // Set level in-between extremes
         (level * bright + (FRACUNIT - level) * min) >> FRACBITS;
   }
   return 1;
}
示例#5
0
文件: p_lights.c 项目: smokhov/atsm
//
// TURN LINE'S TAG LIGHTS OFF
//
void EV_TurnTagLightsOff(line_t *line)
{
    int			i;
    int			j;
    int			min;
    sector_t		*sector;
    sector_t		*tsec;
    line_t		*templine;

    for (j = -1; (j = P_FindSectorFromLineTag(line, j)) >= 0;)
    {
        sector = sectors + j;
        min = sector->lightlevel;
        for (i = 0; i < sector->linecount; i++)
        {
            templine = sector->lines[i];
            tsec = getNextSector(templine, sector);
            if (!tsec)
                continue;
            if (tsec->lightlevel < min)
                min = tsec->lightlevel;
        }
        sector->lightlevel = min;
    }
}
示例#6
0
void EV_LightTurnOnPartway (int tag, fixed_t frac)
{
	int i;

	frac = clamp<fixed_t> (frac, 0, FRACUNIT);

	// Search all sectors for ones with same tag as activating line
	i = -1;
	while ((i = P_FindSectorFromTag (tag, i)) >= 0)
	{
		sector_t *temp, *sector = sectors + i;
		int j, bright = 0, min = sector->lightlevel;

		for (j = 0; j < sector->linecount; ++j)
		{
			if ((temp = getNextSector (sector->lines[j], sector)) != NULL)
			{
				if (temp->lightlevel > bright)
				{
					bright = temp->lightlevel;
				}
				if (temp->lightlevel < min)
				{
					min = temp->lightlevel;
				}
			}
		}
		sector->SetLightLevel(DMulScale16 (frac, bright, FRACUNIT-frac, min));
	}
}
示例#7
0
void EV_TurnTagLightsOff (int tag)
{
	int i;
	int secnum;

	// [RH] Don't do a linear search
	for (secnum = -1; (secnum = P_FindSectorFromTag (tag, secnum)) >= 0; ) 
	{
		sector_t *sector = sectors + secnum;
		int min = sector->lightlevel;

		for (i = 0; i < sector->linecount; i++)
		{
			sector_t *tsec = getNextSector (sector->lines[i],sector);
			if (!tsec)
				continue;
			if (tsec->lightlevel < min)
				min = tsec->lightlevel;
		}
		sector->SetLightLevel(min);

		// [BC] Flag the sector as having its light level altered. That way, when clients
		// connect, we can tell them about the updated light level.
		sector->bLightChange = true;

		// [BC] If we're the server, tell clients about the light level change.
		if ( NETWORK_GetState( ) == NETSTATE_SERVER )
			SERVERCOMMANDS_SetSectorLightLevel( secnum );
	}
}
示例#8
0
文件: p_lights.c 项目: hexameron/DOOM
//
// EV_LightTurnOn()
//
// Turn sectors tagged to line lights on to specified or max neighbor level
//
// Passed the activating line, and a level to set the light to
// If level passed is 0, the maximum neighbor lighting is used
// Returns true
//
// jff 2/12/98 added int return value, fixed return
//
int EV_LightTurnOn(line_t *line, int bright)
{
  int i;

  // search all sectors for ones with same tag as activating line

  // killough 10/98: replace inefficient search with fast search
  for (i = -1; (i = P_FindSectorFromLineTag(line,i)) >= 0;)
    {
      sector_t *temp, *sector = sectors+i;
      int j, tbright = bright; //jff 5/17/98 search for maximum PER sector

      // bright = 0 means to search for highest light level surrounding sector

      if (!bright)
	for (j = 0;j < sector->linecount; j++)
	  if ((temp = getNextSector(sector->lines[j],sector)) &&
	      temp->lightlevel > tbright)
	    tbright = temp->lightlevel;

      sector->lightlevel = tbright;
      
      //jff 5/17/98 unless compatibility optioned 
      //then maximum near ANY tagged sector
      if (compatibility)
	bright = tbright;
    }
  return 1;
}
示例#9
0
//
// Special Stuff that can not be categorized
//
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;
    while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
    {
	s1 = &sectors[secnum];
		
	// ALREADY MOVING?  IF SO, KEEP GOING...
	if (s1->specialdata)
	    continue;
			
	rtn = 1;
	s2 = getNextSector(s1->lines[0],s1);
	for (i = 0;i < s2->linecount;i++)
	{
		//isn't this always false?
	    /*if ((!s2->lines[i]->flags & ML_TWOSIDED) ||
		(s2->lines[i]->backsector == s1))
		continue;*/
	    s3 = s2->lines[i]->backsector;
	    
	    //	Spawn rising slime
	    floor = (floormove_t*)malloc (sizeof(*floor));
	    P_AddThinker (&floor->thinker);
	    s2->specialdata = floor;
	    floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor;
	    floor->type = donutRaise;
	    floor->crush = false;
	    floor->direction = Direction::UP;
	    floor->sector = s2;
	    floor->speed = FLOORSPEED / 2;
	    floor->texture = s3->floorpic;
	    floor->newspecial = 0;
	    floor->floordestheight = s3->floorheight;
	    
	    //	Spawn lowering donut-hole
	    floor = (floormove_t*)malloc (sizeof(*floor));
	    P_AddThinker (&floor->thinker);
	    s1->specialdata = floor;
	    floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor;
	    floor->type = lowerFloor;
	    floor->crush = false;
	    floor->direction = Direction::DOWN;
	    floor->sector = s1;
	    floor->speed = FLOORSPEED / 2;
	    floor->floordestheight = s3->floorheight;
	    break;
	}
    }
    return rtn;
}
示例#10
0
//
// TURN LINE'S TAG LIGHTS ON
// [RH] Takes a tag instead of a line
//
void EV_LightTurnOn (int tag, int bright)
{
	int secnum = -1;

	// [RH] Don't do a linear search
	while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) 
	{
		sector_t *sector = sectors + secnum;

		// bright = -1 means to search ([RH] Not 0)
		// for highest light level
		// surrounding sector
		if (bright < 0)
		{
			int j;

			bright = 0;
			for (j = 0; j < sector->linecount; j++)
			{
				sector_t *temp = getNextSector (sector->lines[j], sector);

				if (!temp)
					continue;

				if (temp->lightlevel > bright)
					bright = temp->lightlevel;
			}
		}
		sector->lightlevel = CLIPLIGHT(bright);
	}
}
示例#11
0
//==================================================================
//
//      TURN LINE'S TAG LIGHTS ON
//
//==================================================================
void EV_LightTurnOn(line_t * line, int bright)
{
    int i;
    int j;
    sector_t *sector;
    sector_t *temp;
    line_t *templine;

    sector = sectors;

    for (i = 0; i < numsectors; i++, sector++)
        if (sector->tag == line->tag)
        {
            //
            // bright = 0 means to search for highest
            // light level surrounding sector
            //
            if (!bright)
            {
                for (j = 0; j < sector->linecount; j++)
                {
                    templine = sector->lines[j];
                    temp = getNextSector(templine, sector);
                    if (!temp)
                        continue;
                    if (temp->lightlevel > bright)
                        bright = temp->lightlevel;
                }
            }
            sector->lightlevel = bright;
        }
}
示例#12
0
//
// TURN LINE'S TAG LIGHTS OFF
//
// [STRIFE] Verified unmodified
//
void EV_TurnTagLightsOff(line_t* line)
{
    int             i;
    int             j;
    int             min;
    sector_t*       sector;
    sector_t*       tsec;
    line_t*         templine;

    sector = sectors;

    for (j = 0;j < numsectors; j++, sector++)
    {
        if (sector->tag == line->tag)
        {
            min = sector->lightlevel;
            for (i = 0;i < sector->linecount; i++)
            {
                templine = sector->lines[i];
                tsec = getNextSector(templine,sector);
                if (!tsec)
                    continue;
                if (tsec->lightlevel < min)
                    min = tsec->lightlevel;
            }
            sector->lightlevel = min;
        }
    }
}
示例#13
0
文件: p_lights.c 项目: jezze/doom
int EV_LightTurnOn(line_t *line, int bright)
{

    int i;

    for (i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;)
    {

        sector_t *temp, *sector = sectors + i;
        int j, tbright = bright;

        if (!bright)
        {

            for (j = 0;j < sector->linecount; j++)
            {

                if ((temp = getNextSector(sector->lines[j],sector)) && temp->lightlevel > tbright)
                    tbright = temp->lightlevel;

            }

            sector->lightlevel = tbright;

        }

    }

    return 1;

}
示例#14
0
//==================================================================
//
//	FIND NEXT HIGHEST FLOOR IN SURROUNDING SECTORS
//
//==================================================================
fixed_t	P_FindNextHighestFloor(sector_t *sec,int currentheight)
{
	int			i;
	int			h;
	int			min;
	line_t		*check;
	sector_t	*other;
	fixed_t		height = currentheight;
	fixed_t		heightlist[20];		// 20 adjoining sectors max!
	
	heightlist[0] = 0;
	for (i =0,h = 0 ;i < sec->linecount ; i++)
	{
		check = sec->lines[i];
		other = getNextSector(check,sec);
		if (!other)
			continue;
		if (other->floorheight > height)
			heightlist[h++] = other->floorheight;
	}
	
	//
	// Find lowest height in list
	//
	min = heightlist[0];
	for (i = 1;i < h;i++)
		if (heightlist[i] < min)
			min = heightlist[i];
			
	return min;
}
示例#15
0
//
// P_FindNextHighestFloor()
//
// Passed a sector and a floor height, returns the fixed point value
// of the smallest floor height in a surrounding sector larger than
// the floor height passed. If no such height exists the floorheight
// passed is returned.
//
// 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;
		}
	/* cph - my guess at doom v1.2 - 1.4beta compatibility here.
	* If there are no higher neighbouring sectors, Heretic just returned
	* heightlist[0] (local variable), i.e. noise off the stack. 0 is right for
	* RETURN01 E1M2, so let's take that. */
	return currentheight;
}
示例#16
0
int
P_FindNextHighestFloor
( sector_t*	sec,
  int		currentheight )
{
    int			i;
    int			h;
    int			min;
    line_t*		check;
    sector_t*		other;
    int		height = currentheight;

    
    int		heightlist[MAX_ADJOINING_SECTORS];		

    for (i=0, h=0 ;i < sec->linecount ; i++)
    {
	check = sec->lines[i];
	other = getNextSector(check,sec);

	if (!other)
	    continue;
	
	if (other->floorheight > height)
	    heightlist[h++] = other->floorheight;

	// Check for overflow. Exit.
	if ( h >= MAX_ADJOINING_SECTORS )
	{
	    fprintf( stderr,
		     "Sector with more than 20 adjoining sectors\n" );
	    break;
	}
    }
    
    // Find lowest height in list
    if (!h)
	return currentheight;
		
    min = heightlist[0];
    
    // Range checking? 
    for (i = 1;i < h;i++)
	if (heightlist[i] < min)
	    min = heightlist[i];
			
    return min;
}
示例#17
0
文件: p_spec.c 项目: japeq/nios-doom
fixed_t P_FindNextHighestFloor(sector_t * sec, int currentheight) {
	int i;
	int h;
	int min;
	line_t *check;
	sector_t *other;
	fixed_t height = currentheight;
	fixed_t heightlist[MAX_ADJOINING_SECTORS + 2];

	for (i = 0, h = 0; i < sec->linecount; i++) {
		check = sec->lines[i];
		other = getNextSector(check, sec);

		if (!other)
			continue;

		if (other->floorheight > height) {
			// Emulation of memory (stack) overflow
			if (h == MAX_ADJOINING_SECTORS + 1) {
				height = other->floorheight;
			} else if (h == MAX_ADJOINING_SECTORS + 2) {
				// Fatal overflow: game crashes at 22 textures
				I_Error
				    ("Sector with more than 22 adjoining sectors. "
				     "Vanilla will crash here");
			}

			heightlist[h++] = other->floorheight;
		}
	}

	// Find lowest height in list
	if (!h) {
		return currentheight;
	}

	min = heightlist[0];

	// Range checking? 
	for (i = 1; i < h; i++) {
		if (heightlist[i] < min) {
			min = heightlist[i];
		}
	}

	return min;
}
/** This function steers towards a given angle. It also takes a plunger
 ** attached to this kart into account by modifying the actual steer angle
 *  somewhat to simulate driving without seeing.
 */
float AIBaseLapController::steerToAngle(const unsigned int sector,
                                     const float add_angle)
{
    float angle = QuadGraph::get()->getAngleToNext(sector,
                                                   getNextSector(sector));

    //Desired angle minus current angle equals how many angles to turn
    float steer_angle = angle - m_kart->getHeading();

    if(m_kart->getBlockedByPlungerTime()>0)
        steer_angle += add_angle*0.2f;
    else
        steer_angle += add_angle;
    steer_angle = normalizeAngle( steer_angle );

    return steer_angle;
}   // steerToAngle
示例#19
0
//
// Find minimum light from an adjacent sector
//
int sector_t::FindMinSurroundingLight (int min) const
{
	int 		i;
	line_t* 	line;
	sector_t*	check;
		
	for (i = 0; i < linecount; i++)
	{
		line = lines[i];
		if (NULL != (check = getNextSector (line, this)) &&
			check->lightlevel < min)
		{
			min = check->lightlevel;
		}
	}
	return min;
}
示例#20
0
void EV_LightTurnOn (int tag, int bright)
{
	int secnum = -1;

	// [RH] Don't do a linear search
	while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0) 
	{
		sector_t *sector = sectors + secnum;
		int tbright = bright; //jff 5/17/98 search for maximum PER sector

		// bright = -1 means to search ([RH] Not 0)
		// for highest light level
		// surrounding sector
		if (bright < 0)
		{
			int j;

			for (j = 0; j < sector->linecount; j++)
			{
				sector_t *temp = getNextSector (sector->lines[j], sector);

				if (!temp)
					continue;

				if (temp->lightlevel > tbright)
					tbright = temp->lightlevel;
			}
		}
		sector->SetLightLevel(tbright);

		//jff 5/17/98 unless compatibility optioned
		//then maximum near ANY tagged sector
		if (i_compatflags & COMPATF_LIGHT)
		{
			bright = tbright;
		}

		// [BC] Flag the sector as having its light level altered. That way, when clients
		// connect, we can tell them about the updated light level.
		sector->bLightChange = true;

		// [BC] If we're the server, tell clients about the light level change.
		if ( NETWORK_GetState( ) == NETSTATE_SERVER )
			SERVERCOMMANDS_SetSectorLightLevel( secnum );
	}
}
示例#21
0
//
// 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.
//
// jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this
//
fixed_t sector_t::FindNextLowestFloor (vertex_t **v) const
{
	fixed_t height;
	fixed_t heightdiff;
	fixed_t ofloor, floor;
	sector_t *other;
	vertex_t *spot;
	line_t *check;
	int i;

	if (linecount == 0) return GetPlaneTexZ(sector_t::floor);

	spot = lines[0]->v1;
	height = floorplane.ZatPoint (spot);
	heightdiff = FIXED_MAX;

	for (i = 0; i < linecount; i++)
	{
		check = lines[i];
		if (NULL != (other = getNextSector (check, this)))
		{
			if (other - sectors == 6)
				other = other;
			ofloor = other->floorplane.ZatPoint (check->v1);
			floor = floorplane.ZatPoint (check->v1);
			if (ofloor < floor && floor - ofloor < heightdiff && !IsLinked(other, false))
			{
				heightdiff = floor - ofloor;
				height = ofloor;
				spot = check->v1;
			}
			ofloor = other->floorplane.ZatPoint (check->v2);
			floor = floorplane.ZatPoint (check->v2);
			if (ofloor < floor && floor - ofloor < heightdiff && !IsLinked(other, false))
			{
				heightdiff = floor - ofloor;
				height = ofloor;
				spot = check->v2;
			}
		}
	}
	if (v != NULL)
		*v = spot;
	return height;
}
示例#22
0
// [RH]
// P_NextSpecialSector()
//
// Returns the next special sector attached to this sector
// with a certain special.
sector_t *sector_t::NextSpecialSector (int type, sector_t *nogood) const
{
	sector_t *tsec;
	int i;

	for (i = 0; i < linecount; i++)
	{
		line_t *ln = lines[i];

		if (NULL != (tsec = getNextSector (ln, this)) &&
			tsec != nogood &&
			(tsec->special & 0x00ff) == type)
		{
			return tsec;
		}
	}
	return NULL;
}
示例#23
0
//==================================================================
//
//	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;
	
	for (i=0 ;i < sec->linecount ; i++)
	{
		check = sec->lines[i];
		other = getNextSector(check,sec);
		if (!other)
			continue;
		if (other->ceilingheight > height)
			height = other->ceilingheight;
	}
	return height;
}
示例#24
0
//==================================================================
//
//	FIND HIGHEST FLOOR HEIGHT IN SURROUNDING SECTORS
//
//==================================================================
fixed_t	P_FindHighestFloorSurrounding(sector_t *sec)
{
	int			i;
	line_t		*check;
	sector_t	*other;
	fixed_t		floor = -500*FRACUNIT;
	
	for (i=0 ;i < sec->linecount ; i++)
	{
		check = sec->lines[i];
		other = getNextSector(check,sec);
		if (!other)
			continue;			
		if (other->floorheight > floor)
			floor = other->floorheight;
	}
	return floor;
}
示例#25
0
//
// 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.
//
// jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this
//
fixed_t sector_t::FindNextLowestCeiling (vertex_t **v) const
{
	fixed_t height;
	fixed_t heightdiff;
	fixed_t oceil, ceil;
	sector_t *other;
	vertex_t *spot;
	line_t *check;
	int i;


	if (linecount == 0) return GetPlaneTexZ(sector_t::ceiling);

	spot = lines[0]->v1;
	height = ceilingplane.ZatPoint (spot);
	heightdiff = FIXED_MAX;

	for (i = 0; i < linecount; i++)
	{
		check = lines[i];
		if (NULL != (other = getNextSector (check, this)))
		{
			oceil = other->ceilingplane.ZatPoint (check->v1);
			ceil = ceilingplane.ZatPoint (check->v1);
			if (oceil < ceil && ceil - oceil < heightdiff && !IsLinked(other, true))
			{
				heightdiff = ceil - oceil;
				height = oceil;
				spot = check->v1;
			}
			oceil = other->ceilingplane.ZatPoint (check->v2);
			ceil = ceilingplane.ZatPoint (check->v2);
			if (oceil < ceil && ceil - oceil < heightdiff && !IsLinked(other, true))
			{
				heightdiff = ceil - oceil;
				height = oceil;
				spot = check->v2;
			}
		}
	}
	if (v != NULL)
		*v = spot;
	return height;
}
示例#26
0
//
// 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
//
// jff 02/03/98 Add routine to find numeric model ceiling
//  around a sector specified by sector number
//  used only from generalized ceiling types
// jff 3/14/98 change first parameter to plain height to allow call
//  from routine not using ceiling_t
//
sector_t *sector_t::FindModelCeilingSector (fixed_t floordestheight) const
{
	int i;
	sector_t *sec;

	//jff 5/23/98 don't disturb sec->linecount while searching
	// but allow early exit in old demos
	for (i = 0; i < linecount; i++)
	{
		sec = getNextSector (lines[i], this);
		if (sec != NULL &&
			(sec->ceilingplane.ZatPoint (lines[i]->v1) == floordestheight ||
			 sec->ceilingplane.ZatPoint (lines[i]->v2) == floordestheight))
		{
			return sec;
		}
	}
	return NULL;
}
示例#27
0
//==================================================================
//
//	Find minimum light from an adjacent sector
//
//==================================================================
int	P_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;
}
示例#28
0
文件: p_lights.c 项目: hexameron/DOOM
//
// EV_TurnTagLightsOff()
//
// Turn line's tagged sector's lights to min adjacent neighbor level
//
// Passed the line that activated the lights being turned off
// Returns true
//
// jff 2/12/98 added int return value, fixed return
//
int EV_TurnTagLightsOff(line_t* line)
{
  int j;
  
  // search sectors for those with same tag as activating line

  // killough 10/98: replaced inefficient search with fast search
  for (j = -1; (j = P_FindSectorFromLineTag(line,j)) >= 0;)
    {
      sector_t *sector = sectors + j, *tsec;
      int i, min = sector->lightlevel;
      // find min neighbor light level
      for (i = 0;i < sector->linecount; i++)
	if ((tsec = getNextSector(sector->lines[i], sector)) &&
	    tsec->lightlevel < min)
	  min = tsec->lightlevel;
      sector->lightlevel = min;
    }
  return 1;
}
示例#29
0
//
// P_FindLowestFloorSurrounding()
// FIND LOWEST FLOOR HEIGHT IN SURROUNDING SECTORS
//
int	P_FindLowestFloorSurrounding(sector_t* sec)
{
    int			i;
    line_t*		check;
    sector_t*		other;
    int		floor = sec->floorheight;
	
    for (i=0 ;i < sec->linecount ; i++)
    {
	check = sec->lines[i];
	other = getNextSector(check,sec);

	if (!other)
	    continue;
	
	if (other->floorheight < floor)
	    floor = other->floorheight;
    }
    return floor;
}
示例#30
0
// int EV_LightTurnOnPartway(line_t *line, fixed_t level)
int EV_LightTurnOnPartway(int tag, int level)
{
    int i;

    if (level < 0)          // clip at extremes
    {
        level = 0;
    }
    if (level > FRACUNIT)
    {
        level = FRACUNIT;
    }

    // search all sectors for ones with same tag as activating line
    // for (i = -1; (i = P_FindSectorFromLineTag(line,i)) >= 0;)
    for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0;)
    {
        sector_t *temp, *sector = sectors+i;
        int j;
        int bright = 0;
        int min = sector->lightlevel;
        for (j = 0; j < sector->linecount; j++)
        {
            if ((temp = getNextSector(sector->lines[j], sector)))
            {
                if (temp->lightlevel > bright)
                {
                    bright = temp->lightlevel;
                }
                if (temp->lightlevel < min)
                {
                    min = temp->lightlevel;
                }
            }
        }
        // Set level in-between extremes
        sector->lightlevel =
            (level * bright + (FRACUNIT-level) * min) >> FRACBITS;
    }
    return 1;
}