Replaces P_FindSectorFromTag() occurrences with its corresponding macro and vanishes it from existence.

This commit is contained in:
Nev3r 2020-04-14 23:33:56 +02:00
parent 25102ab4af
commit d518703334
5 changed files with 27 additions and 75 deletions

View file

@ -687,6 +687,7 @@ void T_BounceCheese(levelspecthink_t *bouncer)
fixed_t floorheight;
sector_t *actionsector;
INT32 i;
TAG_ITER_C
if (bouncer->sector->crumblestate == 4 || bouncer->sector->crumblestate == 1
|| bouncer->sector->crumblestate == 2) // Oops! Crumbler says to remove yourself!
@ -701,7 +702,7 @@ void T_BounceCheese(levelspecthink_t *bouncer)
}
// You can use multiple target sectors, but at your own risk!!!
for (i = -1; (i = P_FindSectorFromTag(bouncer->sourceline->tag, i)) >= 0 ;)
TAG_ITER_SECTORS(bouncer->sourceline->tag, i)
{
actionsector = &sectors[i];
actionsector->moved = true;
@ -844,6 +845,7 @@ void T_StartCrumble(elevator_t *elevator)
ffloor_t *rover;
sector_t *sector;
INT32 i;
TAG_ITER_C
// Once done, the no-return thinker just sits there,
// constantly 'returning'... kind of an oxymoron, isn't it?
@ -873,7 +875,7 @@ void T_StartCrumble(elevator_t *elevator)
}
else if (++elevator->distance == 0) // Reposition back to original spot
{
for (i = -1; (i = P_FindSectorFromTag(elevator->sourceline->tag, i)) >= 0 ;)
TAG_ITER_SECTORS(elevator->sourceline->tag, i)
{
sector = &sectors[i];
@ -904,7 +906,7 @@ void T_StartCrumble(elevator_t *elevator)
// Flash to indicate that the platform is about to return.
if (elevator->distance > -224 && (leveltime % ((abs(elevator->distance)/8) + 1) == 0))
{
for (i = -1; (i = P_FindSectorFromTag(elevator->sourceline->tag, i)) >= 0 ;)
TAG_ITER_SECTORS(elevator->sourceline->tag, i)
{
sector = &sectors[i];
@ -1000,7 +1002,7 @@ void T_StartCrumble(elevator_t *elevator)
P_RemoveThinker(&elevator->thinker);
}
for (i = -1; (i = P_FindSectorFromTag(elevator->sourceline->tag, i)) >= 0 ;)
TAG_ITER_SECTORS(elevator->sourceline->tag, i)
{
sector = &sectors[i];
sector->moved = true;
@ -1016,6 +1018,7 @@ void T_StartCrumble(elevator_t *elevator)
void T_MarioBlock(levelspecthink_t *block)
{
INT32 i;
TAG_ITER_C
#define speed vars[1]
#define direction vars[2]
@ -1057,8 +1060,7 @@ void T_MarioBlock(levelspecthink_t *block)
block->sector->ceilspeed = 0;
block->direction = 0;
}
for (i = -1; (i = P_FindSectorFromTag((INT16)block->vars[0], i)) >= 0 ;)
TAG_ITER_SECTORS((INT16)block->vars[0], i)
P_RecalcPrecipInSector(&sectors[i]);
#undef speed
@ -1151,9 +1153,7 @@ void T_FloatSector(levelspecthink_t *floater)
// Just find the first sector with the tag.
// Doesn't work with multiple sectors that have different floor/ceiling heights.
secnum = P_FindSectorFromTag((INT16)floater->vars[0], -1);
if (secnum > 0)
if ((secnum = Tag_Iterate_Sectors((INT16)floater->vars[0], 0)) >= 0)
actionsector = &sectors[secnum];
else
actionsector = NULL;
@ -1288,9 +1288,7 @@ void T_ThwompSector(levelspecthink_t *thwomp)
// Just find the first sector with the tag.
// Doesn't work with multiple sectors that have different floor/ceiling heights.
secnum = P_FindSectorFromTag((INT16)thwomp->vars[0], -1);
if (secnum > 0)
if ((secnum = Tag_Iterate_Sectors((INT16)thwomp->vars[0], 0)) >= 0)
{
actionsector = &sectors[secnum];
@ -1860,11 +1858,12 @@ void T_RaiseSector(levelspecthink_t *raise)
boolean playeronme = false, active = false;
fixed_t ceilingdestination, floordestination;
result_e res = 0;
TAG_ITER_C
if (raise->sector->crumblestate >= 3 || raise->sector->ceilingdata)
return;
for (i = -1; (i = P_FindSectorFromTag(raise->sourceline->tag, i)) >= 0 ;)
TAG_ITER_SECTORS(raise->sourceline->tag, i)
{
sector = &sectors[i];
@ -2057,7 +2056,7 @@ void T_RaiseSector(levelspecthink_t *raise)
raise->sector->ceilspeed = 42;
raise->sector->floorspeed = raise->vars[3]*raise->vars[8];
for (i = -1; (i = P_FindSectorFromTag(raise->sourceline->tag, i)) >= 0 ;)
TAG_ITER_SECTORS(raise->sourceline->tag, i)
P_RecalcPrecipInSector(&sectors[i]);
}
@ -2726,6 +2725,7 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating,
elevator_t *elevator;
sector_t *foundsec;
INT32 i;
TAG_ITER_C
// If floor is already activated, skip it
if (sec->floordata)
@ -2778,7 +2778,7 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating,
elevator->sector->crumblestate = 2;
for (i = -1; (i = P_FindSectorFromTag(elevator->sourceline->tag, i)) >= 0 ;)
TAG_ITER_SECTORS(elevator->sourceline->tag, i)
{
foundsec = &sectors[i];

View file

@ -374,8 +374,10 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean
void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean force)
{
INT32 i;
TAG_ITER_C
// search all sectors for ones with tag
for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0 ;)
TAG_ITER_SECTORS(tag, i)
{
if (!force && ticbased // always let speed fader execute
&& sectors[i].lightingdata

View file

@ -549,11 +549,11 @@ static boolean P_SetSlopeFromTag(sector_t *sec, INT32 tag, boolean ceiling)
{
INT32 i;
pslope_t **secslope = ceiling ? &sec->c_slope : &sec->f_slope;
TAG_ITER_C
if (!tag || *secslope)
return false;
for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0;)
TAG_ITER_SECTORS(tag, i)
{
pslope_t *srcslope = ceiling ? sectors[i].c_slope : sectors[i].f_slope;
if (srcslope)

View file

@ -988,54 +988,6 @@ static sector_t *P_FindModelCeilingSector(fixed_t ceildestheight, INT32 secnum)
}
#endif
/** Searches the tag lists for the next sector with a given tag.
*
* \param tag Tag number to look for.
* \param start -1 to start anew, or the result of a previous call to keep
* searching.
* \return Number of the next tagged sector found.
*/
INT32 P_FindSectorFromTag(INT16 tag, INT32 start)
{
if (tag == -1)
{
start++;
if (start >= (INT32)numsectors)
return -1;
return start;
}
#if 0
INT32 tpos = 0;
if (tags_sectors[tag])
{
// Resume previous position.
if (start != -1)
for (; tpos < tags_sectors[(UINT16)tag]->count;)
if (start == tags_sectors[(UINT16)tag]->elements[tpos++])
break;
if (tpos >= tags_sectors[(UINT16)tag]->count)
return -1;
return tags_sectors[(UINT16)tag]->elements[tpos++];
}
return -1;
#else
else
{
start = start >= 0 ? sectors[start].nexttag :
sectors[(unsigned)tag % numsectors].firsttag;
while (start >= 0 && sectors[start].tag != tag)
start = sectors[start].nexttag;
return start;
}
#endif
}
//
// P_FindSpecialLineFromTag
//
@ -3181,7 +3133,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
ffloor_t *rover; // FOF that we are going to crumble
boolean foundrover = false; // for debug, "Can't find a FOF" message
for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;)
TAG_ITER_SECTORS(sectag, secnum)
{
sec = sectors + secnum;
@ -3365,7 +3317,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
boolean foundrover = false; // for debug, "Can't find a FOF" message
ffloortype_e oldflags; // store FOF's old flags
for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;)
TAG_ITER_SECTORS(sectag, secnum)
{
sec = sectors + secnum;
@ -3423,7 +3375,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
if (line->flags & ML_NOCLIMB) // don't respawn!
respawn = false;
for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;)
TAG_ITER_SECTORS(sectag, secnum)
{
sec = sectors + secnum;
@ -3608,7 +3560,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
ffloor_t *rover; // FOF that we are going to operate
boolean foundrover = false; // for debug, "Can't find a FOF" message
for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;)
TAG_ITER_SECTORS(sectag, secnum)
{
sec = sectors + secnum;
@ -3672,7 +3624,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
boolean foundrover = false; // for debug, "Can't find a FOF" message
size_t j = 0; // sec->ffloors is saved as ffloor #0, ss->ffloors->next is #1, etc
for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;)
TAG_ITER_SECTORS(sectag, secnum)
{
sec = sectors + secnum;
@ -3757,7 +3709,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
ffloor_t *rover; // FOF that we are going to operate
boolean foundrover = false; // for debug, "Can't find a FOF" message
for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;)
TAG_ITER_SECTORS(sectag, secnum)
{
sec = sectors + secnum;
@ -7617,8 +7569,7 @@ void T_Scroll(scroll_t *s)
if (!is3dblock)
continue;
for (sect = -1; (sect = P_FindSectorFromTag(line->tag, sect)) >= 0 ;)
TAG_ITER_SECTORS(line->tag, sect)
{
sector_t *psec;
psec = sectors + sect;

View file

@ -55,7 +55,6 @@ fixed_t P_FindNextLowestFloor(sector_t *sec, fixed_t currentheight);
fixed_t P_FindLowestCeilingSurrounding(sector_t *sec);
fixed_t P_FindHighestCeilingSurrounding(sector_t *sec);
INT32 P_FindSectorFromTag(INT16 tag, INT32 start);
INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start);
INT32 P_FindMinSurroundingLight(sector_t *sector, INT32 max);