Commit 2c8a99f2 by Nev3r

Add a level parameter to the iterators to account for nesting, and thus avoid variable shadowing.

parent a8f55407
......@@ -395,9 +395,9 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type)
sector_t *sec;
ceiling_t *ceiling;
mtag_t tag = Tag_FGet(&line->tags);
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
TAG_ITER_SECTORS(tag, secnum)
TAG_ITER_SECTORS(0, tag, secnum)
{
sec = &sectors[secnum];
......@@ -617,9 +617,9 @@ INT32 EV_DoCrush(line_t *line, ceiling_e type)
sector_t *sec;
ceiling_t *ceiling;
mtag_t tag = Tag_FGet(&line->tags);
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
TAG_ITER_SECTORS(tag, secnum)
TAG_ITER_SECTORS(0, tag, secnum)
{
sec = &sectors[secnum];
......
......@@ -635,7 +635,7 @@ void T_BounceCheese(bouncecheese_t *bouncer)
boolean remove;
INT32 i;
mtag_t tag = Tag_FGet(&bouncer->sourceline->tags);
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
if (bouncer->sector->crumblestate == CRUMBLE_RESTORE || bouncer->sector->crumblestate == CRUMBLE_WAIT
|| bouncer->sector->crumblestate == CRUMBLE_ACTIVATED) // Oops! Crumbler says to remove yourself!
......@@ -650,7 +650,7 @@ void T_BounceCheese(bouncecheese_t *bouncer)
}
// You can use multiple target sectors, but at your own risk!!!
TAG_ITER_SECTORS(tag, i)
TAG_ITER_SECTORS(0, tag, i)
{
actionsector = &sectors[i];
actionsector->moved = true;
......@@ -775,7 +775,7 @@ void T_StartCrumble(crumble_t *crumble)
sector_t *sector;
INT32 i;
mtag_t tag = Tag_FGet(&crumble->sourceline->tags);
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
// Once done, the no-return thinker just sits there,
// constantly 'returning'... kind of an oxymoron, isn't it?
......@@ -804,7 +804,7 @@ void T_StartCrumble(crumble_t *crumble)
}
else if (++crumble->timer == 0) // Reposition back to original spot
{
TAG_ITER_SECTORS(tag, i)
TAG_ITER_SECTORS(0, tag, i)
{
sector = &sectors[i];
......@@ -840,7 +840,7 @@ void T_StartCrumble(crumble_t *crumble)
// Flash to indicate that the platform is about to return.
if (crumble->timer > -224 && (leveltime % ((abs(crumble->timer)/8) + 1) == 0))
{
TAG_ITER_SECTORS(tag, i)
TAG_ITER_SECTORS(0, tag, i)
{
sector = &sectors[i];
......@@ -932,7 +932,7 @@ void T_StartCrumble(crumble_t *crumble)
P_RemoveThinker(&crumble->thinker);
}
TAG_ITER_SECTORS(tag, i)
TAG_ITER_SECTORS(0, tag, i)
{
sector = &sectors[i];
sector->moved = true;
......@@ -948,7 +948,7 @@ void T_StartCrumble(crumble_t *crumble)
void T_MarioBlock(mariothink_t *block)
{
INT32 i;
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
T_MovePlane
(
......@@ -983,7 +983,7 @@ void T_MarioBlock(mariothink_t *block)
block->sector->ceilspeed = 0;
block->direction = 0;
}
TAG_ITER_SECTORS((INT16)block->tag, i)
TAG_ITER_SECTORS(0, (INT16)block->tag, i)
P_RecalcPrecipInSector(&sectors[i]);
}
......@@ -1295,9 +1295,9 @@ void T_NoEnemiesSector(noenemies_t *nobaddies)
INT32 secnum = -1;
boolean FOFsector = false;
mtag_t tag = Tag_FGet(&nobaddies->sourceline->tags);
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
TAG_ITER_SECTORS(tag, secnum)
TAG_ITER_SECTORS(0, tag, secnum)
{
sec = &sectors[secnum];
......@@ -1308,14 +1308,14 @@ void T_NoEnemiesSector(noenemies_t *nobaddies)
{
INT32 targetsecnum = -1;
mtag_t tag2 = Tag_FGet(&sec->lines[i]->tags);
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(1);
if (sec->lines[i]->special < 100 || sec->lines[i]->special >= 300)
continue;
FOFsector = true;
TAG_ITER_SECTORS(tag2, targetsecnum)
TAG_ITER_SECTORS(1, tag2, targetsecnum)
{
if (T_SectorHasEnemies(&sectors[targetsecnum]))
return;
......@@ -1402,7 +1402,7 @@ void T_EachTimeThinker(eachtime_t *eachtime)
fixed_t bottomheight, topheight;
ffloor_t *rover;
mtag_t tag = Tag_FGet(&eachtime->sourceline->tags);
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
for (i = 0; i < MAXPLAYERS; i++)
{
......@@ -1412,7 +1412,7 @@ void T_EachTimeThinker(eachtime_t *eachtime)
eachtime->playersOnArea[i] = false;
}
TAG_ITER_SECTORS(tag, secnum)
TAG_ITER_SECTORS(0, tag, secnum)
{
sec = &sectors[secnum];
......@@ -1430,14 +1430,14 @@ void T_EachTimeThinker(eachtime_t *eachtime)
{
INT32 targetsecnum = -1;
mtag_t tag2 = Tag_FGet(&sec->lines[i]->tags);
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(1);
if (sec->lines[i]->special < 100 || sec->lines[i]->special >= 300)
continue;
FOFsector = true;
TAG_ITER_SECTORS(tag2, targetsecnum)
TAG_ITER_SECTORS(1, tag2, targetsecnum)
{
targetsec = &sectors[targetsecnum];
......@@ -1572,12 +1572,12 @@ void T_RaiseSector(raise_t *raise)
INT32 direction;
result_e res = 0;
mtag_t tag = raise->tag;
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
if (raise->sector->crumblestate >= CRUMBLE_FALL || raise->sector->ceilingdata)
return;
TAG_ITER_SECTORS(tag, i)
TAG_ITER_SECTORS(0, tag, i)
{
sector = &sectors[i];
......@@ -1704,7 +1704,7 @@ void T_RaiseSector(raise_t *raise)
raise->sector->ceilspeed = 42;
raise->sector->floorspeed = speed*direction;
TAG_ITER_SECTORS(tag, i)
TAG_ITER_SECTORS(0, tag, i)
P_RecalcPrecipInSector(&sectors[i]);
}
......@@ -1822,9 +1822,9 @@ void EV_DoFloor(line_t *line, floor_e floortype)
sector_t *sec;
floormove_t *dofloor;
mtag_t tag = Tag_FGet(&line->tags);
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
TAG_ITER_SECTORS(tag, secnum)
TAG_ITER_SECTORS(0, tag, secnum)
{
sec = &sectors[secnum];
......@@ -2039,10 +2039,10 @@ void EV_DoElevator(line_t *line, elevator_e elevtype, boolean customspeed)
sector_t *sec;
elevator_t *elevator;
mtag_t tag = Tag_FGet(&line->tags);
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
// act on all sectors with the same tag as the triggering linedef
TAG_ITER_SECTORS(tag, secnum)
TAG_ITER_SECTORS(0, tag, secnum)
{
sec = &sectors[secnum];
......@@ -2339,7 +2339,7 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating,
sector_t *foundsec;
INT32 i;
mtag_t tag = Tag_FGet(&rover->master->tags);
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
// If floor is already activated, skip it
if (sec->floordata)
......@@ -2382,7 +2382,7 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating,
crumble->sector->crumblestate = CRUMBLE_ACTIVATED;
TAG_ITER_SECTORS(tag, i)
TAG_ITER_SECTORS(0, tag, i)
{
foundsec = &sectors[i];
......
......@@ -374,10 +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_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
// search all sectors for ones with tag
TAG_ITER_SECTORS(tag, i)
TAG_ITER_SECTORS(0, tag, i)
{
if (!force && ticbased // always let speed fader execute
&& sectors[i].lightingdata
......
......@@ -4631,9 +4631,9 @@ static boolean P_Boss4MoveCage(mobj_t *mobj, fixed_t delta)
INT32 snum;
sector_t *sector;
boolean gotcage = false;
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
TAG_ITER_SECTORS(tag, snum)
TAG_ITER_SECTORS(0, tag, snum)
{
sector = &sectors[snum];
sector->floorheight += delta;
......@@ -4717,9 +4717,9 @@ static void P_Boss4DestroyCage(mobj_t *mobj)
size_t a;
sector_t *sector, *rsec;
ffloor_t *rover;
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
TAG_ITER_SECTORS(tag, snum)
TAG_ITER_SECTORS(0, tag, snum)
{
sector = &sectors[snum];
......
......@@ -2971,9 +2971,9 @@ static void P_ConvertBinaryMap(void)
INT32 check = -1;
INT32 paramline = -1;
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
TAG_ITER_LINES(tag, check)
TAG_ITER_LINES(0, tag, check)
{
if (lines[check].special == 22)
{
......@@ -3188,11 +3188,11 @@ static void P_ConvertBinaryMap(void)
INT32 firstline = -1;
mtag_t tag = mapthings[i].angle;
TAG_ITER_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
Tag_FSet(&mapthings[i].tags, tag);
TAG_ITER_LINES(tag, check)
TAG_ITER_LINES(0, tag, check)
{
if (lines[check].special == 20)
{
......
......@@ -546,11 +546,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_DECLARECOUNTER;
TAG_ITER_DECLARECOUNTER(0);
if (!tag || *secslope)
return false;
TAG_ITER_SECTORS(tag, i)
TAG_ITER_SECTORS(0, tag, i)
{
pslope_t *srcslope = ceiling ? sectors[i].c_slope : sectors[i].f_slope;
if (srcslope)
......
......@@ -62,13 +62,13 @@ INT32 Tag_FindLineSpecial(const INT16 special, const mtag_t tag);
INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start);
// Use this macro to declare the iterator position variable.
#define TAG_ITER_DECLARECOUNTER size_t tag_iterator_pos
#define TAG_ITER_DECLARECOUNTER(level) size_t ICNT_##level
#define TAG_ITER(fn, tag, id) for(tag_iterator_pos = 0; (id = fn(tag, tag_iterator_pos)) >= 0; tag_iterator_pos++)
#define TAG_ITER(level, fn, tag, id) for(ICNT_##level = 0; (id = fn(tag, ICNT_##level)) >= 0; ICNT_##level++)
// Use these macros as wrappers for the taglist iterations.
#define TAG_ITER_SECTORS(tag, id) TAG_ITER(Tag_Iterate_Sectors, tag, id)
#define TAG_ITER_LINES(tag, id) TAG_ITER(Tag_Iterate_Lines, tag, id)
#define TAG_ITER_THINGS(tag, id) TAG_ITER(Tag_Iterate_Things, tag, id)
#define TAG_ITER_SECTORS(level, tag, id) TAG_ITER(level, Tag_Iterate_Sectors, tag, id)
#define TAG_ITER_LINES(level, tag, id) TAG_ITER(level, Tag_Iterate_Lines, tag, id)
#define TAG_ITER_THINGS(level, tag, id) TAG_ITER(level, Tag_Iterate_Things, tag, id)
#endif //__R_TAGLIST__
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment