diff --git a/src/p_ceilng.c b/src/p_ceilng.c index c65156b6f..a6e8e8cda 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -398,8 +398,9 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type) INT32 secnum = -1; sector_t *sec; ceiling_t *ceiling; + TAG_ITER_C - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { sec = §ors[secnum]; @@ -618,8 +619,9 @@ INT32 EV_DoCrush(line_t *line, ceiling_e type) INT32 secnum = -1; sector_t *sec; ceiling_t *ceiling; + TAG_ITER_C - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { sec = §ors[secnum]; diff --git a/src/p_spec.c b/src/p_spec.c index c5186b531..1f9b6099b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2442,6 +2442,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { INT32 secnum = -1; mobj_t *bot = NULL; + TAG_ITER_C I_Assert(!mo || !P_MobjWasRemoved(mo)); // If mo is there, mo must be valid! @@ -2469,7 +2470,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) newceilinglightsec = line->frontsector->ceilinglightsec; // act on all sectors with the same tag as the triggering linedef - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { if (sectors[secnum].lightingdata) { @@ -2524,7 +2525,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 409: // Change tagged sectors' tag // (formerly "Change calling sectors' tag", but behavior was changed) { - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) P_ChangeSectorTag(secnum,(INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS)); break; } @@ -2534,7 +2535,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 411: // Stop floor/ceiling movement in tagged sector(s) - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { if (sectors[secnum].floordata) { @@ -2604,7 +2605,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } else { - if ((secnum = P_FindSectorFromLineTag(line, -1)) < 0) + if ((secnum = Tag_Iterate_Sectors(line->tag, 0)) < 0) return; dest = P_GetObjectTypeInSectorNum(MT_TELEPORTMAN, secnum); @@ -2719,7 +2720,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Additionally play the sound from tagged sectors' soundorgs sector_t *sec; - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { sec = §ors[secnum]; S_StartSound(&sec->soundorg, sfxnum); @@ -2834,7 +2835,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 416: // Spawn adjustable fire flicker - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2868,7 +2869,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 417: // Spawn adjustable glowing light - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2902,7 +2903,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 418: // Spawn adjustable strobe flash (unsynchronized) - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2936,7 +2937,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 419: // Spawn adjustable strobe flash (synchronized) - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { if (line->flags & ML_NOCLIMB && line->backsector) { @@ -2984,7 +2985,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 421: // Stop lighting effect in tagged sectors - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) if (sectors[secnum].lightingdata) { P_RemoveThinker(&((elevator_t *)sectors[secnum].lightingdata)->thinker); @@ -2999,7 +3000,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if ((!mo || !mo->player) && !titlemapinaction) // only players have views, and title screens return; - if ((secnum = P_FindSectorFromLineTag(line, -1)) < 0) + if ((secnum = Tag_Iterate_Sectors(line->tag, 0)) < 0) return; altview = P_GetObjectTypeInSectorNum(MT_ALTVIEWMAN, secnum); @@ -3318,7 +3319,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (line->sidenum[1] != 0xffff) state = (statenum_t)sides[line->sidenum[1]].toptexture; - while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + TAG_ITER_SECTORS(line->tag, secnum) { boolean tryagain; sec = sectors + secnum; @@ -3473,7 +3474,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Except it is activated by linedef executor, not level load // This could even override existing colormaps I believe // -- Monster Iestyn 14/06/18 - for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) + TAG_ITER_SECTORS(line->tag, secnum) { P_ResetColormapFader(§ors[secnum]); @@ -3801,7 +3802,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } case 455: // Fade colormap - for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) + TAG_ITER_SECTORS(line->tag, secnum) { extracolormap_t *source_exc, *dest_exc, *exc; INT32 speed = (INT32)((line->flags & ML_DONTPEGBOTTOM) || !sides[line->sidenum[0]].rowoffset) && line->sidenum[1] != 0xFFFF ? @@ -3890,7 +3891,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 456: // Stop fade colormap - for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) + TAG_ITER_SECTORS(line->tag, secnum) P_ResetColormapFader(§ors[secnum]); break; @@ -3904,7 +3905,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) boolean persist = (line->flags & ML_EFFECT2); mobj_t *anchormo; - if ((secnum = P_FindSectorFromLineTag(line, -1)) < 0) + if ((secnum = Tag_Iterate_Sectors(line->tag, 0)) < 0) return; anchormo = P_GetObjectTypeInSectorNum(MT_ANGLEMAN, secnum); @@ -6547,10 +6548,11 @@ void P_SpawnSpecials(boolean fromnetsave) INT32 s; size_t sec; ffloortype_e ffloorflags; + TAG_ITER_C case 1: // Definable gravity per sector sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) { sectors[s].gravity = §ors[sec].floorheight; // This allows it to change in realtime! @@ -6574,7 +6576,7 @@ void P_SpawnSpecials(boolean fromnetsave) case 5: // Change camera info sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_AddCameraScanner(§ors[sec], §ors[s], R_PointToAngle2(lines[i].v2->x, lines[i].v2->y, lines[i].v1->x, lines[i].v1->y)); break; @@ -6601,7 +6603,7 @@ void P_SpawnSpecials(boolean fromnetsave) P_ApplyFlatAlignment(lines + i, lines[i].frontsector, flatangle, xoffs, yoffs); else { - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0;) + TAG_ITER_SECTORS(lines[i].tag, s) P_ApplyFlatAlignment(lines + i, sectors + s, flatangle, xoffs, yoffs); } } @@ -6612,7 +6614,7 @@ void P_SpawnSpecials(boolean fromnetsave) break; case 8: // Sector Parameters - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) { if (lines[i].flags & ML_NOCLIMB) { @@ -6640,7 +6642,7 @@ void P_SpawnSpecials(boolean fromnetsave) case 10: // Vertical culling plane for sprites and FOFs sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) sectors[s].cullheight = &lines[i]; // This allows it to change in realtime! break; @@ -6701,19 +6703,18 @@ void P_SpawnSpecials(boolean fromnetsave) case 63: // support for drawn heights coming from different sector sec = sides[*lines[i].sidenum].sector-sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) sectors[s].heightsec = (INT32)sec; break; case 64: // Appearing/Disappearing FOF option if (lines[i].flags & ML_BLOCKMONSTERS) { // Find FOFs by control sector tag - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) for (j = 0; (unsigned)j < sectors[s].linecount; j++) if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) Add_MasterDisappearer(abs(lines[i].dx>>FRACBITS), abs(lines[i].dy>>FRACBITS), abs(sides[lines[i].sidenum[0]].sector->floorheight>>FRACBITS), (INT32)(sectors[s].lines[j]-lines), (INT32)i); } else // Find FOFs by effect sector tag { - TAG_ITER_C TAG_ITER_LINES((lines + i)->tag, s) { if ((size_t)s == i) @@ -6732,15 +6733,15 @@ void P_SpawnSpecials(boolean fromnetsave) break; case 66: // Displace floor by front sector - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_AddPlaneDisplaceThinker(pd_floor, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 67: // Displace ceiling by front sector - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_AddPlaneDisplaceThinker(pd_ceiling, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; case 68: // Displace both floor AND ceiling by front sector - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_AddPlaneDisplaceThinker(pd_both, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); break; @@ -7115,7 +7116,7 @@ void P_SpawnSpecials(boolean fromnetsave) case 251: // A THWOMP! sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) { P_AddThwompThinker(§ors[sec], §ors[s], &lines[i]); P_AddFakeFloor(§ors[s], §ors[sec], lines + i, @@ -7163,7 +7164,7 @@ void P_SpawnSpecials(boolean fromnetsave) sec = sides[*lines[i].sidenum].sector - sectors; // No longer totally disrupts netgames - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) EV_AddLaserThinker(§ors[s], §ors[sec], lines + i, secthinkers); break; @@ -7355,46 +7356,46 @@ void P_SpawnSpecials(boolean fromnetsave) case 600: // floor lighting independently (e.g. lava) sec = sides[*lines[i].sidenum].sector-sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) sectors[s].floorlightsec = (INT32)sec; break; case 601: // ceiling lighting independently sec = sides[*lines[i].sidenum].sector-sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) sectors[s].ceilinglightsec = (INT32)sec; break; case 602: // Adjustable pulsating light sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_SpawnAdjustableGlowingLight(§ors[sec], §ors[s], P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS); break; case 603: // Adjustable flickering light sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_SpawnAdjustableFireFlicker(§ors[sec], §ors[s], P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS); break; case 604: // Adjustable Blinking Light (unsynchronized) sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_SpawnAdjustableStrobeFlash(§ors[sec], §ors[s], abs(lines[i].dx)>>FRACBITS, abs(lines[i].dy)>>FRACBITS, false); break; case 605: // Adjustable Blinking Light (synchronized) sec = sides[*lines[i].sidenum].sector - sectors; - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) P_SpawnAdjustableStrobeFlash(§ors[sec], §ors[s], abs(lines[i].dx)>>FRACBITS, abs(lines[i].dy)>>FRACBITS, true); break; case 606: // HACK! Copy colormaps. Just plain colormaps. - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + TAG_ITER_SECTORS(lines[i].tag, s) sectors[s].extra_colormap = sectors[s].spawn_extra_colormap = sides[lines[i].sidenum[0]].colormap_data; break; @@ -7560,6 +7561,7 @@ void T_Scroll(scroll_t *s) size_t i; INT32 sect; ffloor_t *rover; + TAG_ITER_C case sc_side: // scroll wall texture side = sides + s->affectee; @@ -7596,7 +7598,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; @@ -7809,10 +7811,11 @@ static void P_SpawnScrollers(void) switch (special) { register INT32 s; + TAG_ITER_C case 513: // scroll effect ceiling case 533: // scroll and carry objects on ceiling - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Scroller(sc_ceiling, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB); if (special != 533) break; @@ -7821,13 +7824,13 @@ static void P_SpawnScrollers(void) case 523: // carry objects on ceiling dx = FixedMul(dx, CARRYFACTOR); dy = FixedMul(dy, CARRYFACTOR); - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Scroller(sc_carry_ceiling, dx, dy, control, s, accel, l->flags & ML_NOCLIMB); break; case 510: // scroll effect floor case 530: // scroll and carry objects on floor - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Scroller(sc_floor, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB); if (special != 530) break; @@ -7836,7 +7839,7 @@ static void P_SpawnScrollers(void) case 520: // carry objects on floor dx = FixedMul(dx, CARRYFACTOR); dy = FixedMul(dy, CARRYFACTOR); - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Scroller(sc_carry, dx, dy, control, s, accel, l->flags & ML_NOCLIMB); break; @@ -7844,7 +7847,6 @@ static void P_SpawnScrollers(void) // (same direction and speed as scrolling floors) case 502: { - TAG_ITER_C TAG_ITER_LINES(l->tag, s) if (s != (INT32)i) Add_Scroller(sc_side, dx, dy, control, lines[s].sidenum[0], accel, 0); @@ -7915,8 +7917,9 @@ void T_Disappear(disappear_t *d) { ffloor_t *rover; register INT32 s; + TAG_ITER_C - for (s = -1; (s = P_FindSectorFromLineTag(&lines[d->affectee], s)) >= 0 ;) + TAG_ITER_SECTORS(lines[d->affectee].tag, s) { for (rover = sectors[s].ffloors; rover; rover = rover->next) { @@ -8649,6 +8652,7 @@ static void P_SpawnFriction(void) fixed_t strength; // frontside texture offset controls magnitude fixed_t friction; // friction value to be applied during movement INT32 movefactor; // applied to each player move to simulate inertia + TAG_ITER_C for (i = 0; i < numlines; i++, l++) if (l->special == 540) @@ -8673,7 +8677,7 @@ static void P_SpawnFriction(void) else movefactor = FRACUNIT; - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Friction(friction, movefactor, s, -1); } } @@ -9203,20 +9207,21 @@ static void P_SpawnPushers(void) line_t *l = lines; register INT32 s; mobj_t *thing; + TAG_ITER_C for (i = 0; i < numlines; i++, l++) switch (l->special) { case 541: // wind - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Pusher(p_wind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 544: // current - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Pusher(p_current, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 547: // push/pull - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) { thing = P_GetPushThing(s); if (thing) // No MT_P* means no effect @@ -9224,19 +9229,19 @@ static void P_SpawnPushers(void) } break; case 545: // current up - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Pusher(p_upcurrent, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 546: // current down - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Pusher(p_downcurrent, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 542: // wind up - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Pusher(p_upwind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; case 543: // wind down - for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) + TAG_ITER_SECTORS(l->tag, s) Add_Pusher(p_downwind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break; }