- moved the tag manager into FLevelLocals.

This also involves deprecating the old creation functions because they do not have a proper level context.
This commit is contained in:
Christoph Oelckers 2019-01-08 23:39:48 +01:00
parent e91971964f
commit 6b9641d673
32 changed files with 207 additions and 189 deletions

View file

@ -306,7 +306,7 @@ class FSSectorTagIterator : public FSectorTagIterator
{ {
public: public:
FSSectorTagIterator(FLevelLocals *Level, int tag) FSSectorTagIterator(FLevelLocals *Level, int tag)
: FSectorTagIterator(tag) : FSectorTagIterator(Level->tagManager, tag)
{ {
if (tag < 0) if (tag < 0)
{ {
@ -1150,7 +1150,7 @@ void FParser::SF_ObjSector(void)
} }
t_return.type = svt_int; t_return.type = svt_int;
t_return.value.i = mo ? tagManager.GetFirstSectorTag(mo->Sector) : 0; // nullptr check t_return.value.i = mo ? Level->tagManager.GetFirstSectorTag(mo->Sector) : 0; // nullptr check
} }
//========================================================================== //==========================================================================
@ -1859,7 +1859,7 @@ void FParser::SF_FadeLight(void)
destlevel = intvalue(t_argv[1]); destlevel = intvalue(t_argv[1]);
speed = t_argc>2 ? intvalue(t_argv[2]) : 1; speed = t_argc>2 ? intvalue(t_argv[2]) : 1;
FSectorTagIterator it(sectag); FSectorTagIterator it(Level->tagManager, sectag);
while ((i = it.Next()) >= 0) while ((i = it.Next()) >= 0)
{ {
if (!Level->sectors[i].lightingdata) Create<DLightLevel>(&Level->sectors[i],destlevel,speed); if (!Level->sectors[i].lightingdata) Create<DLightLevel>(&Level->sectors[i],destlevel,speed);
@ -2157,7 +2157,7 @@ void FParser::SF_SetLineBlocking(void)
{ {
blocking=blocks[blocking]; blocking=blocks[blocking];
int tag=intvalue(t_argv[0]); int tag=intvalue(t_argv[0]);
FLineIdIterator itr(tag); FLineIdIterator itr(Level->tagManager, tag);
int i; int i;
while ((i = itr.Next()) >= 0) while ((i = itr.Next()) >= 0)
{ {
@ -2180,7 +2180,7 @@ void FParser::SF_SetLineMonsterBlocking(void)
int blocking = intvalue(t_argv[1]) ? (int)ML_BLOCKMONSTERS : 0; int blocking = intvalue(t_argv[1]) ? (int)ML_BLOCKMONSTERS : 0;
int tag=intvalue(t_argv[0]); int tag=intvalue(t_argv[0]);
FLineIdIterator itr(tag); FLineIdIterator itr(Level->tagManager, tag);
int i; int i;
while ((i = itr.Next()) >= 0) while ((i = itr.Next()) >= 0)
{ {
@ -2237,7 +2237,7 @@ void FParser::SF_SetLineTexture(void)
texture = stringvalue(t_argv[3]); texture = stringvalue(t_argv[3]);
texturenum = TexMan.GetTextureID(texture, ETextureType::Wall, FTextureManager::TEXMAN_Overridable); texturenum = TexMan.GetTextureID(texture, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
FLineIdIterator itr(tag); FLineIdIterator itr(Level->tagManager, tag);
while ((i = itr.Next()) >= 0) while ((i = itr.Next()) >= 0)
{ {
// bad sidedef, Hexen just SEGV'd here! // bad sidedef, Hexen just SEGV'd here!
@ -2257,7 +2257,7 @@ void FParser::SF_SetLineTexture(void)
int sections = intvalue(t_argv[3]); int sections = intvalue(t_argv[3]);
// set all sectors with tag // set all sectors with tag
FLineIdIterator itr(tag); FLineIdIterator itr(Level->tagManager, tag);
while ((i = itr.Next()) >= 0) while ((i = itr.Next()) >= 0)
{ {
side_t *sided = Level->lines[i].sidedef[side]; side_t *sided = Level->lines[i].sidedef[side];
@ -3792,7 +3792,7 @@ void FParser::SF_KillInSector()
while ((mo=it.Next())) while ((mo=it.Next()))
{ {
if (mo->flags3&MF3_ISMONSTER && tagManager.SectorHasTag(mo->Sector, tag)) P_DamageMobj(mo, NULL, NULL, 1000000, NAME_Massacre); if (mo->flags3&MF3_ISMONSTER && Level->tagManager.SectorHasTag(mo->Sector, tag)) P_DamageMobj(mo, NULL, NULL, 1000000, NAME_Massacre);
} }
} }
} }
@ -3814,7 +3814,7 @@ void FParser::SF_SetLineTrigger()
id=intvalue(t_argv[0]); id=intvalue(t_argv[0]);
spec=intvalue(t_argv[1]); spec=intvalue(t_argv[1]);
if (t_argc>2) tag=intvalue(t_argv[2]); if (t_argc>2) tag=intvalue(t_argv[2]);
FLineIdIterator itr(id); FLineIdIterator itr(Level->tagManager, id);
while ((i = itr.Next()) >= 0) while ((i = itr.Next()) >= 0)
{ {
maplinedef_t mld; maplinedef_t mld;

View file

@ -458,7 +458,7 @@ bool DFraggleThinker::wait_finished(DRunningScript *script)
case wt_tagwait: case wt_tagwait:
{ {
int secnum; int secnum;
FSectorTagIterator itr(script->wait_data); FSectorTagIterator itr(Level->tagManager, script->wait_data);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
sector_t *sec = &Level->sectors[secnum]; sector_t *sec = &Level->sectors[secnum];

View file

@ -44,6 +44,7 @@
#include "p_local.h" #include "p_local.h"
#include "po_man.h" #include "po_man.h"
#include "p_acs.h" #include "p_acs.h"
#include "p_tags.h"
#include "p_destructible.h" #include "p_destructible.h"
#include "r_data/r_sections.h" #include "r_data/r_sections.h"
#include "r_data/r_canvastexture.h" #include "r_data/r_canvastexture.h"
@ -70,6 +71,7 @@ struct FLevelData
TArray<uint8_t> rejectmatrix; TArray<uint8_t> rejectmatrix;
TArray<zone_t> Zones; TArray<zone_t> Zones;
TArray<FPolyObj> Polyobjects; TArray<FPolyObj> Polyobjects;
FTagManager tagManager;
TArray<FSectorPortal> sectorPortals; TArray<FSectorPortal> sectorPortals;
TArray<FLinePortal> linePortals; TArray<FLinePortal> linePortals;

View file

@ -394,7 +394,7 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, ClearSectorTags)
{ {
PARAM_SELF_PROLOGUE(DLevelCompatibility); PARAM_SELF_PROLOGUE(DLevelCompatibility);
PARAM_INT(sector); PARAM_INT(sector);
tagManager.RemoveSectorTags(sector); self->Level->tagManager.RemoveSectorTags(sector);
return 0; return 0;
} }
@ -406,7 +406,7 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, AddSectorTag)
if ((unsigned)sector < self->Level->sectors.Size()) if ((unsigned)sector < self->Level->sectors.Size())
{ {
tagManager.AddSectorTag(sector, tag); self->Level->tagManager.AddSectorTag(sector, tag);
} }
return 0; return 0;
} }

View file

@ -583,7 +583,7 @@ void MapLoader::ProcessEDLinedef(line_t *ld, int recordnum)
ld->flags = (ld->flags&~fmask) | eld->flags; ld->flags = (ld->flags&~fmask) | eld->flags;
ld->setAlpha(eld->alpha); ld->setAlpha(eld->alpha);
memcpy(ld->args, eld->args, sizeof(ld->args)); memcpy(ld->args, eld->args, sizeof(ld->args));
tagManager.AddLineID(Index(ld), eld->tag); Level->tagManager.AddLineID(Index(ld), eld->tag);
} }
void MapLoader::ProcessEDSector(sector_t *sec, int recordnum) void MapLoader::ProcessEDSector(sector_t *sec, int recordnum)

View file

@ -1040,7 +1040,7 @@ void MapLoader::LoadSectors (MapData *map, FMissingTextureTracker &missingtex)
ss->special = LittleShort(ms->special); ss->special = LittleShort(ms->special);
else // [RH] Translate to new sector special else // [RH] Translate to new sector special
ss->special = P_TranslateSectorSpecial (LittleShort(ms->special)); ss->special = P_TranslateSectorSpecial (LittleShort(ms->special));
tagManager.AddSectorTag(i, LittleShort(ms->tag)); Level->tagManager.AddSectorTag(i, LittleShort(ms->tag));
ss->thinglist = nullptr; ss->thinglist = nullptr;
ss->touching_thinglist = nullptr; // phares 3/14/98 ss->touching_thinglist = nullptr; // phares 3/14/98
ss->sectorportal_thinglist = nullptr; ss->sectorportal_thinglist = nullptr;
@ -1461,7 +1461,7 @@ void MapLoader::SetLineID (int i, line_t *ld)
} }
if (setid != -1) if (setid != -1)
{ {
tagManager.AddLineID(i, setid); Level->tagManager.AddLineID(i, setid);
} }
} }
} }
@ -1555,7 +1555,7 @@ void MapLoader::FinishLoadingLineDef(line_t *ld, int alpha)
{ {
for (unsigned j = 0; j < Level->lines.Size(); j++) for (unsigned j = 0; j < Level->lines.Size(); j++)
{ {
if (tagManager.LineHasID(j, ld->args[0])) if (Level->tagManager.LineHasID(j, ld->args[0]))
{ {
Level->lines[j].alpha = dalpha; Level->lines[j].alpha = dalpha;
if (additive) if (additive)
@ -1685,7 +1685,7 @@ void MapLoader::LoadLineDefs (MapData * map)
// do not assign the tag for Extradata lines. // do not assign the tag for Extradata lines.
if (ld->special != Static_Init || (ld->args[1] != Init_EDLine && ld->args[1] != Init_EDSector)) if (ld->special != Static_Init || (ld->args[1] != Init_EDLine && ld->args[1] != Init_EDSector))
{ {
tagManager.AddLineID(i, mld->tag); Level->tagManager.AddLineID(i, mld->tag);
} }
#ifndef NO_EDATA #ifndef NO_EDATA
if (ld->special == Static_Init && ld->args[1] == Init_EDLine) if (ld->special == Static_Init && ld->args[1] == Init_EDLine)
@ -2059,7 +2059,7 @@ void MapLoader::ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec
{ {
for (unsigned s = 0; s < Level->sectors.Size(); s++) for (unsigned s = 0; s < Level->sectors.Size(); s++)
{ {
if (tagManager.SectorHasTag(s, tag)) if (Level->tagManager.SectorHasTag(s, tag))
{ {
if (colorgood) if (colorgood)
{ {
@ -2685,9 +2685,9 @@ void MapLoader::GroupLines (bool buildmap)
{ {
if (sector->Lines.Count == 0) if (sector->Lines.Count == 0)
{ {
Printf ("Sector %i (tag %i) has no lines\n", i, tagManager.GetFirstSectorTag(Index(sector))); Printf ("Sector %i (tag %i) has no lines\n", i, Level->tagManager.GetFirstSectorTag(Index(sector)));
// 0 the sector's tag so that no specials can use it // 0 the sector's tag so that no specials can use it
tagManager.RemoveSectorTags(i); Level->tagManager.RemoveSectorTags(i);
} }
else else
{ {
@ -2742,7 +2742,7 @@ void MapLoader::GroupLines (bool buildmap)
} }
// killough 1/30/98: Create xref tables for tags // killough 1/30/98: Create xref tables for tags
tagManager.HashTags(); Level->tagManager.HashTags();
if (!buildmap) if (!buildmap)
{ {

View file

@ -53,7 +53,7 @@ void MapLoader::SlopeLineToPoint (int lineid, const DVector3 &pos, bool slopeCei
{ {
int linenum; int linenum;
FLineIdIterator itr(lineid); FLineIdIterator itr(Level->tagManager, lineid);
while ((linenum = itr.Next()) >= 0) while ((linenum = itr.Next()) >= 0)
{ {
const line_t *line = &Level->lines[linenum]; const line_t *line = &Level->lines[linenum];
@ -123,7 +123,7 @@ void MapLoader::CopyPlane (int tag, sector_t *dest, bool copyCeil)
sector_t *source; sector_t *source;
int secnum; int secnum;
secnum = P_FindFirstSectorFromTag (tag); secnum = Level->tagManager.FindFirstSectorFromTag (tag);
if (secnum == -1) if (secnum == -1)
{ {
return; return;

View file

@ -856,7 +856,7 @@ public:
case NAME_Id: case NAME_Id:
lineid = CheckInt(key); lineid = CheckInt(key);
tagManager.AddLineID(index, lineid); Level->tagManager.AddLineID(index, lineid);
continue; continue;
case NAME_Sidefront: case NAME_Sidefront:
@ -1127,7 +1127,7 @@ public:
// scan the string as long as valid numbers can be found // scan the string as long as valid numbers can be found
while (sc.CheckNumber()) while (sc.CheckNumber())
{ {
if (sc.Number != 0) tagManager.AddLineID(index, sc.Number); if (sc.Number != 0) Level->tagManager.AddLineID(index, sc.Number);
} }
} }
@ -1513,7 +1513,7 @@ public:
continue; continue;
case NAME_Id: case NAME_Id:
tagManager.AddSectorTag(index, CheckInt(key)); Level->tagManager.AddSectorTag(index, CheckInt(key));
continue; continue;
default: default:
@ -1908,7 +1908,7 @@ public:
// scan the string as long as valid numbers can be found // scan the string as long as valid numbers can be found
while (sc.CheckNumber()) while (sc.CheckNumber())
{ {
if (sc.Number != 0) tagManager.AddSectorTag(index, sc.Number); if (sc.Number != 0) Level->tagManager.AddSectorTag(index, sc.Number);
} }
} }

View file

@ -213,7 +213,7 @@ static int P_Set3DFloor(line_t * line, int param, int param2, int alpha)
sector_t * sec = line->frontsector, *ss; sector_t * sec = line->frontsector, *ss;
auto Level = sec->Level; auto Level = sec->Level;
FSectorTagIterator itr(tag); FSectorTagIterator itr(Level->tagManager, tag);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
{ {
ss = &Level->sectors[s]; ss = &Level->sectors[s];
@ -905,7 +905,7 @@ void P_Spawn3DFloors (FLevelLocals *Level)
{ {
if (line.args[1]&8) if (line.args[1]&8)
{ {
tagManager.AddLineID(line.Index(), line.args[4]); Level->tagManager.AddLineID(line.Index(), line.args[4]);
} }
else else
{ {

View file

@ -150,7 +150,7 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c
if (tag == 0) if (tag == 0)
{ {
FLineIdIterator itr(lineid); FLineIdIterator itr(Level->tagManager, lineid);
int line; int line;
while ((line = itr.Next()) >= 0) while ((line = itr.Next()) >= 0)
{ {
@ -166,13 +166,13 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c
} }
else else
{ {
FSectorTagIterator it(tag); FSectorTagIterator it(Level->tagManager, tag);
int sec; int sec;
while ((sec = it.Next()) >= 0) while ((sec = it.Next()) >= 0)
{ {
for (auto ln : Level->sectors[sec].Lines) for (auto ln : Level->sectors[sec].Lines)
{ {
if (lineid != 0 && !tagManager.LineHasID(ln, lineid)) continue; if (lineid != 0 && !Level->tagManager.LineHasID(ln, lineid)) continue;
if (ln->frontsector == NULL || ln->backsector == NULL || !(ln->flags & ML_3DMIDTEX)) if (ln->frontsector == NULL || ln->backsector == NULL || !(ln->flags & ML_3DMIDTEX))
{ {

View file

@ -1853,7 +1853,7 @@ DPlaneWatcher::DPlaneWatcher (FLevelLocals *Level, AActor *it, line_t *line, int
Args[2] = arg2; Args[2] = arg2;
Args[3] = arg3; Args[3] = arg3;
Args[4] = arg4; Args[4] = arg4;
secnum = P_FindFirstSectorFromTag (tag); secnum = Level->tagManager.FindFirstSectorFromTag (tag);
if (secnum >= 0) if (secnum >= 0)
{ {
secplane_t plane; secplane_t plane;
@ -3625,7 +3625,7 @@ do_count:
if (actor->health > 0 && if (actor->health > 0 &&
(kind == NULL || actor->IsA (kind))) (kind == NULL || actor->IsA (kind)))
{ {
if (tag == -1 || tagManager.SectorHasTag(actor->Sector, tag)) if (tag == -1 || Level->tagManager.SectorHasTag(actor->Sector, tag))
{ {
// Don't count items in somebody's inventory // Don't count items in somebody's inventory
if (actor->IsMapActor()) if (actor->IsMapActor())
@ -3644,7 +3644,7 @@ do_count:
if (actor->health > 0 && if (actor->health > 0 &&
(kind == NULL || actor->IsA (kind))) (kind == NULL || actor->IsA (kind)))
{ {
if (tag == -1 || tagManager.SectorHasTag(actor->Sector, tag)) if (tag == -1 || Level->tagManager.SectorHasTag(actor->Sector, tag))
{ {
// Don't count items in somebody's inventory // Don't count items in somebody's inventory
if (actor->IsMapActor()) if (actor->IsMapActor())
@ -3680,7 +3680,7 @@ void DLevelScript::ChangeFlat (int tag, int name, bool floorOrCeiling)
flat = TexMan.GetTextureID(flatname, ETextureType::Flat, FTextureManager::TEXMAN_Overridable); flat = TexMan.GetTextureID(flatname, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
FSectorTagIterator it(tag); FSectorTagIterator it(Level->tagManager, tag);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
int pos = floorOrCeiling? sector_t::ceiling : sector_t::floor; int pos = floorOrCeiling? sector_t::ceiling : sector_t::floor;
@ -3712,7 +3712,7 @@ void DLevelScript::SetLineTexture (int lineid, int side, int position, int name)
texture = TexMan.GetTextureID(texname, ETextureType::Wall, FTextureManager::TEXMAN_Overridable); texture = TexMan.GetTextureID(texname, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
FLineIdIterator itr(lineid); FLineIdIterator itr(Level->tagManager, lineid);
while ((linenum = itr.Next()) >= 0) while ((linenum = itr.Next()) >= 0)
{ {
side_t *sidedef; side_t *sidedef;
@ -4819,7 +4819,7 @@ int DLevelScript::SideFromID(int id, int side)
} }
else else
{ {
int line = P_FindFirstLineFromID(id); int line = Level->tagManager.FindFirstLineFromID(id);
if (line == -1) return -1; if (line == -1) return -1;
if (Level->lines[line].sidedef[side] == NULL) return -1; if (Level->lines[line].sidedef[side] == NULL) return -1;
return Level->lines[line].sidedef[side]->UDMFIndex; return Level->lines[line].sidedef[side]->UDMFIndex;
@ -4835,7 +4835,7 @@ int DLevelScript::LineFromID(int id)
} }
else else
{ {
return P_FindFirstLineFromID(id); return Level->tagManager.FindFirstLineFromID(id);
} }
} }
@ -5322,10 +5322,10 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args)
return 0; // Not implemented yet return 0; // Not implemented yet
case ACSF_GetSectorUDMFInt: case ACSF_GetSectorUDMFInt:
return GetUDMFInt(UDMF_Sector, P_FindFirstSectorFromTag(args[0]), Level->Behaviors.LookupString(args[1])); return GetUDMFInt(UDMF_Sector, Level->tagManager.FindFirstSectorFromTag(args[0]), Level->Behaviors.LookupString(args[1]));
case ACSF_GetSectorUDMFFixed: case ACSF_GetSectorUDMFFixed:
return DoubleToACS(GetUDMFFloat(UDMF_Sector, P_FindFirstSectorFromTag(args[0]), Level->Behaviors.LookupString(args[1]))); return DoubleToACS(GetUDMFFloat(UDMF_Sector, Level->tagManager.FindFirstSectorFromTag(args[0]), Level->Behaviors.LookupString(args[1])));
case ACSF_GetSideUDMFInt: case ACSF_GetSideUDMFInt:
return GetUDMFInt(UDMF_Side, SideFromID(args[0], args[1]), Level->Behaviors.LookupString(args[2])); return GetUDMFInt(UDMF_Side, SideFromID(args[0], args[1]), Level->Behaviors.LookupString(args[2]));
@ -5657,7 +5657,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args)
int space = args[2] < CHAN_FLOOR || args[2] > CHAN_INTERIOR ? CHAN_FULLHEIGHT : args[2]; int space = args[2] < CHAN_FLOOR || args[2] > CHAN_INTERIOR ? CHAN_FULLHEIGHT : args[2];
if (seqname != NULL) if (seqname != NULL)
{ {
FSectorTagIterator it(args[0]); FSectorTagIterator it(Level->tagManager, args[0]);
int s; int s;
while ((s = it.Next()) >= 0) while ((s = it.Next()) >= 0)
{ {
@ -6205,7 +6205,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
if (argCount >= 2) if (argCount >= 2)
{ {
int line; int line;
FLineIdIterator itr(args[0]); FLineIdIterator itr(Level->tagManager, args[0]);
while ((line = itr.Next()) >= 0) while ((line = itr.Next()) >= 0)
{ {
Level->lines[line].activation = args[1]; Level->lines[line].activation = args[1];
@ -6216,7 +6216,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
case ACSF_GetLineActivation: case ACSF_GetLineActivation:
if (argCount > 0) if (argCount > 0)
{ {
int line = P_FindFirstLineFromID(args[0]); int line = Level->tagManager.FindFirstLineFromID(args[0]);
return line >= 0 ? Level->lines[line].activation : 0; return line >= 0 ? Level->lines[line].activation : 0;
} }
break; break;
@ -6429,7 +6429,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
case ACSF_SetSectorDamage: case ACSF_SetSectorDamage:
if (argCount >= 2) if (argCount >= 2)
{ {
FSectorTagIterator it(args[0]); FSectorTagIterator it(Level->tagManager, args[0]);
int s; int s;
while ((s = it.Next()) >= 0) while ((s = it.Next()) >= 0)
{ {
@ -6449,7 +6449,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
if (args[1] == sector_t::floor || args[1] == sector_t::ceiling) if (args[1] == sector_t::floor || args[1] == sector_t::ceiling)
{ {
int terrain = P_FindTerrain(Level->Behaviors.LookupString(args[2])); int terrain = P_FindTerrain(Level->Behaviors.LookupString(args[2]));
FSectorTagIterator it(args[0]); FSectorTagIterator it(Level->tagManager, args[0]);
int s; int s;
while ((s = it.Next()) >= 0) while ((s = it.Next()) >= 0)
{ {
@ -6590,7 +6590,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
float height = float(args[5]); float height = float(args[5]);
if (args[2] == -1) color = -1; if (args[2] == -1) color = -1;
FSectorTagIterator it(args[0]); FSectorTagIterator it(Level->tagManager, args[0]);
int s; int s;
while ((s = it.Next()) >= 0) while ((s = it.Next()) >= 0)
{ {
@ -6602,7 +6602,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
case ACSF_SetFogDensity: case ACSF_SetFogDensity:
{ {
FSectorTagIterator it(args[0]); FSectorTagIterator it(Level->tagManager, args[0]);
int s; int s;
int d = clamp(args[1]/2, 0, 255); int d = clamp(args[1]/2, 0, 255);
while ((s = it.Next()) >= 0) while ((s = it.Next()) >= 0)
@ -6662,7 +6662,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
case ACSF_GetSectorHealth: case ACSF_GetSectorHealth:
{ {
int part = args[1]; int part = args[1];
FSectorTagIterator it(args[0]); FSectorTagIterator it(Level->tagManager, args[0]);
int s = it.Next(); int s = it.Next();
if (s < 0) if (s < 0)
return 0; return 0;
@ -6688,7 +6688,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
case ACSF_GetLineHealth: case ACSF_GetLineHealth:
{ {
FLineIdIterator it(args[0]); FLineIdIterator it(Level->tagManager, args[0]);
int l = it.Next(); int l = it.Next();
if (l < 0) if (l < 0)
return 0; return 0;
@ -6705,7 +6705,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
case ACSF_GetLineX: case ACSF_GetLineX:
case ACSF_GetLineY: case ACSF_GetLineY:
{ {
FLineIdIterator it(args[0]); FLineIdIterator it(Level->tagManager, args[0]);
int lineno = it.Next(); int lineno = it.Next();
if (lineno < 0) return 0; if (lineno < 0) return 0;
DVector2 delta = Level->lines[lineno].Delta(); DVector2 delta = Level->lines[lineno].Delta();
@ -6821,7 +6821,7 @@ int DLevelScript::RunScript ()
// state running // state running
{ {
int secnum; int secnum;
FSectorTagIterator it(statedata); FSectorTagIterator it(Level->tagManager, statedata);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
if (Level->sectors[secnum].floordata || Level->sectors[secnum].ceilingdata) if (Level->sectors[secnum].floordata || Level->sectors[secnum].ceilingdata)
@ -8930,7 +8930,7 @@ scriptwait:
{ {
int lineno; int lineno;
FLineIdIterator itr(STACK(2)); FLineIdIterator itr(Level->tagManager, STACK(2));
while ((lineno = itr.Next()) >= 0) while ((lineno = itr.Next()) >= 0)
{ {
auto &line = Level->lines[lineno]; auto &line = Level->lines[lineno];
@ -8967,7 +8967,7 @@ scriptwait:
{ {
int line; int line;
FLineIdIterator itr(STACK(2)); FLineIdIterator itr(Level->tagManager, STACK(2));
while ((line = itr.Next()) >= 0) while ((line = itr.Next()) >= 0)
{ {
if (STACK(1)) if (STACK(1))
@ -8993,7 +8993,7 @@ scriptwait:
arg0 = -FName(Level->Behaviors.LookupString(arg0)); arg0 = -FName(Level->Behaviors.LookupString(arg0));
} }
FLineIdIterator itr(STACK(7)); FLineIdIterator itr(Level->tagManager, STACK(7));
while ((linenum = itr.Next()) >= 0) while ((linenum = itr.Next()) >= 0)
{ {
line_t *line = &Level->lines[linenum]; line_t *line = &Level->lines[linenum];
@ -9467,7 +9467,7 @@ scriptwait:
double z = 0; double z = 0;
if (tag != 0) if (tag != 0)
secnum = P_FindFirstSectorFromTag (tag); secnum = Level->tagManager.FindFirstSectorFromTag (tag);
else else
secnum = P_PointInSector (x, y)->sectornum; secnum = P_PointInSector (x, y)->sectornum;
@ -9489,7 +9489,7 @@ scriptwait:
case PCD_GETSECTORLIGHTLEVEL: case PCD_GETSECTORLIGHTLEVEL:
{ {
int secnum = P_FindFirstSectorFromTag (STACK(1)); int secnum = Level->tagManager.FindFirstSectorFromTag (STACK(1));
int z = -1; int z = -1;
if (secnum >= 0) if (secnum >= 0)

View file

@ -4832,7 +4832,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain)
} }
else if (sec->special == Scroll_StrifeCurrent) else if (sec->special == Scroll_StrifeCurrent)
{ {
int anglespeed = tagManager.GetFirstSectorTag(sec) - 100; int anglespeed = self->Level->tagManager.GetFirstSectorTag(sec) - 100;
double speed = (anglespeed % 10) / 16.; double speed = (anglespeed % 10) / 16.;
DAngle an = (anglespeed / 10) * (360 / 8.); DAngle an = (anglespeed / 10) * (360 / 8.);
self->Thrust(an, speed); self->Thrust(an, speed);

View file

@ -520,7 +520,7 @@ bool EV_DoCeiling (FLevelLocals *Level, DCeiling::ECeiling type, line_t *line,
} }
// affects all sectors with the same tag as the linedef // affects all sectors with the same tag as the linedef
FSectorTagIterator it(tag); FSectorTagIterator it(Level->tagManager, tag);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
rtn |= P_CreateCeiling(&Level->sectors[secnum], type, line, tag, speed, speed2, height, crush, silent, change, hexencrush); rtn |= P_CreateCeiling(&Level->sectors[secnum], type, line, tag, speed, speed2, height, crush, silent, change, hexencrush);
@ -592,7 +592,7 @@ bool EV_CeilingCrushStop (FLevelLocals *Level, int tag, bool remove)
bool EV_StopCeiling(FLevelLocals *Level, int tag, line_t *line) bool EV_StopCeiling(FLevelLocals *Level, int tag, line_t *line)
{ {
int sec; int sec;
FSectorTagIterator it(tag, line); FSectorTagIterator it(Level->tagManager, tag, line);
while ((sec = it.Next()) >= 0) while ((sec = it.Next()) >= 0)
{ {
if (Level->sectors[sec].ceilingdata) if (Level->sectors[sec].ceilingdata)

View file

@ -490,7 +490,7 @@ bool EV_DoDoor (FLevelLocals *Level, DDoor::EVlDoor type, line_t *line, AActor *
else else
{ // [RH] Remote door { // [RH] Remote door
FSectorTagIterator it(tag); FSectorTagIterator it(Level->tagManager, tag);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
sec = &Level->sectors[secnum]; sec = &Level->sectors[secnum];
@ -787,7 +787,7 @@ bool EV_SlidingDoor (FLevelLocals *Level, line_t *line, AActor *actor, int tag,
return false; return false;
} }
FSectorTagIterator it(tag); FSectorTagIterator it(Level->tagManager, tag);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
sec = &Level->sectors[secnum]; sec = &Level->sectors[secnum];

View file

@ -532,7 +532,7 @@ bool EV_DoFloor (FLevelLocals *Level, DFloor::EFloor floortype, line_t *line, in
bool rtn = false; bool rtn = false;
// check if a manual trigger; if so do just the sector on the backside // check if a manual trigger; if so do just the sector on the backside
FSectorTagIterator it(tag, line); FSectorTagIterator it(Level->tagManager, tag, line);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
rtn |= P_CreateFloor(&Level->sectors[secnum], floortype, line, speed, height, crush, change, hexencrush, hereticlower); rtn |= P_CreateFloor(&Level->sectors[secnum], floortype, line, speed, height, crush, change, hexencrush, hereticlower);
@ -551,7 +551,7 @@ bool EV_DoFloor (FLevelLocals *Level, DFloor::EFloor floortype, line_t *line, in
bool EV_FloorCrushStop (FLevelLocals *Level, int tag, line_t *line) bool EV_FloorCrushStop (FLevelLocals *Level, int tag, line_t *line)
{ {
int secnum; int secnum;
FSectorTagIterator it(tag, line); FSectorTagIterator it(Level->tagManager, tag, line);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
sector_t *sec = &Level->sectors[secnum]; sector_t *sec = &Level->sectors[secnum];
@ -571,7 +571,7 @@ bool EV_FloorCrushStop (FLevelLocals *Level, int tag, line_t *line)
bool EV_StopFloor(FLevelLocals *Level, int tag, line_t *line) bool EV_StopFloor(FLevelLocals *Level, int tag, line_t *line)
{ {
int sec; int sec;
FSectorTagIterator it(tag, line); FSectorTagIterator it(Level->tagManager, tag, line);
while ((sec = it.Next()) >= 0) while ((sec = it.Next()) >= 0)
{ {
if (Level->sectors[sec].floordata) if (Level->sectors[sec].floordata)
@ -619,7 +619,7 @@ bool EV_BuildStairs (FLevelLocals *Level, int tag, DFloor::EStair type, line_t *
persteptime = int(stairsize / speed); persteptime = int(stairsize / speed);
// check if a manual trigger, if so do just the sector on the backside // check if a manual trigger, if so do just the sector on the backside
FSectorTagIterator itr(tag, line); FSectorTagIterator itr(Level->tagManager, tag, line);
// The compatibility mode doesn't work with a hashing algorithm. // The compatibility mode doesn't work with a hashing algorithm.
// It needs the original linear search method. This was broken in Boom. // It needs the original linear search method. This was broken in Boom.
bool compatible = tag != 0 && (i_compatflags & COMPATF_STAIRINDEX); bool compatible = tag != 0 && (i_compatflags & COMPATF_STAIRINDEX);
@ -794,7 +794,7 @@ bool EV_DoDonut (FLevelLocals *Level, int tag, line_t *line, double pillarspeed,
rtn = false; rtn = false;
FSectorTagIterator itr(tag, line); FSectorTagIterator itr(Level->tagManager, tag, line);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
s1 = &Level->sectors[secnum]; // s1 is pillar's sector s1 = &Level->sectors[secnum]; // s1 is pillar's sector
@ -1011,7 +1011,7 @@ bool EV_DoElevator (FLevelLocals *Level, line_t *line, DElevator::EElevator elev
secnum = -1; secnum = -1;
rtn = false; rtn = false;
FSectorTagIterator itr(tag, line); FSectorTagIterator itr(Level->tagManager, tag, line);
// act on all sectors with the same tag as the triggering linedef // act on all sectors with the same tag as the triggering linedef
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
@ -1106,7 +1106,7 @@ bool EV_DoChange (FLevelLocals *Level, line_t *line, EChange changetype, int tag
rtn = false; rtn = false;
// change all sectors with the same tag as the linedef // change all sectors with the same tag as the linedef
FSectorTagIterator it(tag); FSectorTagIterator it(Level->tagManager, tag);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
sec = &Level->sectors[secnum]; sec = &Level->sectors[secnum];
@ -1320,7 +1320,7 @@ bool EV_StartWaggle (FLevelLocals *Level, int tag, line_t *line, int height, int
retCode = false; retCode = false;
FSectorTagIterator itr(tag, line); FSectorTagIterator itr(Level->tagManager, tag, line);
while ((sectorIndex = itr.Next()) >= 0) while ((sectorIndex = itr.Next()) >= 0)
{ {

View file

@ -326,7 +326,7 @@ DFlicker::DFlicker (sector_t *sector, int upper, int lower)
void EV_StartLightFlickering (FLevelLocals *Level, int tag, int upper, int lower) void EV_StartLightFlickering (FLevelLocals *Level, int tag, int upper, int lower)
{ {
int secnum; int secnum;
FSectorTagIterator it(tag); FSectorTagIterator it(Level->tagManager, tag);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
Create<DFlicker> (&Level->sectors[secnum], upper, lower); Create<DFlicker> (&Level->sectors[secnum], upper, lower);
@ -503,7 +503,7 @@ DStrobe::DStrobe (sector_t *sector, int utics, int ltics, bool inSync)
void EV_StartLightStrobing (FLevelLocals *Level, int tag, int upper, int lower, int utics, int ltics) void EV_StartLightStrobing (FLevelLocals *Level, int tag, int upper, int lower, int utics, int ltics)
{ {
int secnum; int secnum;
FSectorTagIterator it(tag); FSectorTagIterator it(Level->tagManager, tag);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
sector_t *sec = &Level->sectors[secnum]; sector_t *sec = &Level->sectors[secnum];
@ -517,7 +517,7 @@ void EV_StartLightStrobing (FLevelLocals *Level, int tag, int upper, int lower,
void EV_StartLightStrobing (FLevelLocals *Level, int tag, int utics, int ltics) void EV_StartLightStrobing (FLevelLocals *Level, int tag, int utics, int ltics)
{ {
int secnum; int secnum;
FSectorTagIterator it(tag); FSectorTagIterator it(Level->tagManager, tag);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
sector_t *sec = &Level->sectors[secnum]; sector_t *sec = &Level->sectors[secnum];
@ -539,7 +539,7 @@ void EV_StartLightStrobing (FLevelLocals *Level, int tag, int utics, int ltics)
void EV_TurnTagLightsOff (FLevelLocals *Level, int tag) void EV_TurnTagLightsOff (FLevelLocals *Level, int tag)
{ {
int secnum; int secnum;
FSectorTagIterator it(tag); FSectorTagIterator it(Level->tagManager, tag);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
sector_t *sector = &Level->sectors[secnum]; sector_t *sector = &Level->sectors[secnum];
@ -568,7 +568,7 @@ void EV_TurnTagLightsOff (FLevelLocals *Level, int tag)
void EV_LightTurnOn (FLevelLocals *Level, int tag, int bright) void EV_LightTurnOn (FLevelLocals *Level, int tag, int bright)
{ {
int secnum; int secnum;
FSectorTagIterator it(tag); FSectorTagIterator it(Level->tagManager, tag);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
sector_t *sector = &Level->sectors[secnum]; sector_t *sector = &Level->sectors[secnum];
@ -621,7 +621,7 @@ void EV_LightTurnOnPartway (FLevelLocals *Level, int tag, double frac)
// Search all sectors for ones with same tag as activating line // Search all sectors for ones with same tag as activating line
int secnum; int secnum;
FSectorTagIterator it(tag); FSectorTagIterator it(Level->tagManager, tag);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
sector_t *temp, *sector = &Level->sectors[secnum]; sector_t *temp, *sector = &Level->sectors[secnum];
@ -657,7 +657,7 @@ void EV_LightTurnOnPartway (FLevelLocals *Level, int tag, double frac)
void EV_LightChange (FLevelLocals *Level, int tag, int value) void EV_LightChange (FLevelLocals *Level, int tag, int value)
{ {
int secnum; int secnum;
FSectorTagIterator it(tag); FSectorTagIterator it(Level->tagManager, tag);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
Level->sectors[secnum].SetLightLevel(Level->sectors[secnum].lightlevel + value); Level->sectors[secnum].SetLightLevel(Level->sectors[secnum].lightlevel + value);
@ -823,7 +823,7 @@ void EV_StartLightGlowing (FLevelLocals *Level, int tag, int upper, int lower, i
lower = temp; lower = temp;
} }
FSectorTagIterator it(tag); FSectorTagIterator it(Level->tagManager, tag);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
sector_t *sec = &Level->sectors[secnum]; sector_t *sec = &Level->sectors[secnum];
@ -843,7 +843,7 @@ void EV_StartLightGlowing (FLevelLocals *Level, int tag, int upper, int lower, i
void EV_StartLightFading (FLevelLocals *Level, int tag, int value, int tics) void EV_StartLightFading (FLevelLocals *Level, int tag, int value, int tics)
{ {
int secnum; int secnum;
FSectorTagIterator it(tag); FSectorTagIterator it(Level->tagManager, tag);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
sector_t *sec = &Level->sectors[secnum]; sector_t *sec = &Level->sectors[secnum];
@ -989,7 +989,7 @@ void EV_StopLightEffect (FLevelLocals *Level, int tag)
while ((effect = iterator.Next()) != NULL) while ((effect = iterator.Next()) != NULL)
{ {
if (tagManager.SectorHasTag(effect->GetSector(), tag)) if (Level->tagManager.SectorHasTag(effect->GetSector(), tag))
{ {
effect->Destroy(); effect->Destroy();
} }

View file

@ -284,11 +284,11 @@ static void AddSingleSector(extsector_t::linked::plane &scrollplane, sector_t *s
// //
//============================================================================ //============================================================================
static void RemoveTaggedSectors(extsector_t::linked::plane &scrollplane, int tag) static void RemoveTaggedSectors(FLevelLocals *Level, extsector_t::linked::plane &scrollplane, int tag)
{ {
for(int i = scrollplane.Sectors.Size()-1; i>=0; i--) for(int i = scrollplane.Sectors.Size()-1; i>=0; i--)
{ {
if (tagManager.SectorHasTag(scrollplane.Sectors[i].Sector, tag)) if (Level->tagManager.SectorHasTag(scrollplane.Sectors[i].Sector, tag))
{ {
scrollplane.Sectors.Delete(i); scrollplane.Sectors.Delete(i);
} }
@ -328,7 +328,7 @@ bool P_AddSectorLinks(sector_t *control, int tag, INTBOOL ceiling, int movetype)
if (movetype > 0) if (movetype > 0)
{ {
int sec; int sec;
FSectorTagIterator itr(tag); FSectorTagIterator itr(Level->tagManager, tag);
while ((sec = itr.Next()) >= 0) while ((sec = itr.Next()) >= 0)
{ {
// Don't attach to self (but allow attaching to this sector's oposite plane. // Don't attach to self (but allow attaching to this sector's oposite plane.
@ -342,7 +342,7 @@ bool P_AddSectorLinks(sector_t *control, int tag, INTBOOL ceiling, int movetype)
} }
else else
{ {
RemoveTaggedSectors(scrollplane, tag); RemoveTaggedSectors(Level, scrollplane, tag);
} }
return true; return true;
} }
@ -362,7 +362,7 @@ void P_AddSectorLinksByID(sector_t *control, int id, INTBOOL ceiling)
extsector_t::linked::plane &scrollplane = ceiling? control->e->Linked.Ceiling : control->e->Linked.Floor; extsector_t::linked::plane &scrollplane = ceiling? control->e->Linked.Ceiling : control->e->Linked.Floor;
auto Level = control->Level; auto Level = control->Level;
FLineIdIterator itr(id); FLineIdIterator itr(Level->tagManager, id);
int line; int line;
while ((line = itr.Next()) >= 0) while ((line = itr.Next()) >= 0)
{ {

View file

@ -1520,7 +1520,7 @@ FUNC(LS_Thing_Destroy)
while (actor) while (actor)
{ {
AActor *temp = iterator.Next (); AActor *temp = iterator.Next ();
if (actor->flags & MF_SHOOTABLE && tagManager.SectorHasTag(actor->Sector, arg2)) if (actor->flags & MF_SHOOTABLE && Level->tagManager.SectorHasTag(actor->Sector, arg2))
P_DamageMobj (actor, NULL, it, arg1 ? TELEFRAG_DAMAGE : actor->health, NAME_None); P_DamageMobj (actor, NULL, it, arg1 ? TELEFRAG_DAMAGE : actor->health, NAME_None);
actor = temp; actor = temp;
} }
@ -1533,7 +1533,7 @@ FUNC(LS_Thing_Destroy)
while (actor) while (actor)
{ {
AActor *temp = iterator.Next (); AActor *temp = iterator.Next ();
if (actor->flags & MF_SHOOTABLE && (arg2 == 0 || tagManager.SectorHasTag(actor->Sector, arg2))) if (actor->flags & MF_SHOOTABLE && (arg2 == 0 || Level->tagManager.SectorHasTag(actor->Sector, arg2)))
P_DamageMobj (actor, NULL, it, arg1 ? TELEFRAG_DAMAGE : actor->health, NAME_None); P_DamageMobj (actor, NULL, it, arg1 ? TELEFRAG_DAMAGE : actor->health, NAME_None);
actor = temp; actor = temp;
} }
@ -2194,7 +2194,7 @@ FUNC(LS_Sector_ChangeSound)
return false; return false;
rtn = false; rtn = false;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
while ((secNum = itr.Next()) >= 0) while ((secNum = itr.Next()) >= 0)
{ {
Level->sectors[secNum].seqType = arg1; Level->sectors[secNum].seqType = arg1;
@ -2213,7 +2213,7 @@ FUNC(LS_Sector_ChangeFlags)
return false; return false;
rtn = false; rtn = false;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
// exclude protected flags // exclude protected flags
arg1 &= ~SECF_NOMODIFY; arg1 &= ~SECF_NOMODIFY;
arg2 &= ~SECF_NOMODIFY; arg2 &= ~SECF_NOMODIFY;
@ -2262,7 +2262,7 @@ FUNC(LS_Sector_SetTranslucent)
if (arg0 != 0) if (arg0 != 0)
{ {
int secnum; int secnum;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
Level->sectors[secnum].SetAlpha(arg1, clamp(arg2, 0, 255) / 255.); Level->sectors[secnum].SetAlpha(arg1, clamp(arg2, 0, 255) / 255.);
@ -2278,7 +2278,7 @@ FUNC(LS_Sector_SetLink)
{ {
if (arg0 != 0) // control tag == 0 is for static initialization and must not be handled here if (arg0 != 0) // control tag == 0 is for static initialization and must not be handled here
{ {
int control = P_FindFirstSectorFromTag(arg0); int control = Level->tagManager.FindFirstSectorFromTag(arg0);
if (control >= 0) if (control >= 0)
{ {
return P_AddSectorLinks(&Level->sectors[control], arg1, arg2, arg3); return P_AddSectorLinks(&Level->sectors[control], arg1, arg2, arg3);
@ -2379,7 +2379,7 @@ FUNC(LS_Sector_SetDamage)
// problems by adding an unwanted constructor. // problems by adding an unwanted constructor.
// Since it doesn't really matter whether the type is translated // Since it doesn't really matter whether the type is translated
// here or in P_PlayerInSpecialSector I think it's the best solution. // here or in P_PlayerInSpecialSector I think it's the best solution.
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
int secnum; int secnum;
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
@ -2418,7 +2418,7 @@ FUNC(LS_Sector_SetGravity)
arg2 = 99; arg2 = 99;
gravity = (double)arg1 + (double)arg2 * 0.01; gravity = (double)arg1 + (double)arg2 * 0.01;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
int secnum; int secnum;
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
Level->sectors[secnum].gravity = gravity; Level->sectors[secnum].gravity = gravity;
@ -2429,7 +2429,7 @@ FUNC(LS_Sector_SetGravity)
FUNC(LS_Sector_SetColor) FUNC(LS_Sector_SetColor)
// Sector_SetColor (tag, r, g, b, desaturate) // Sector_SetColor (tag, r, g, b, desaturate)
{ {
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
int secnum; int secnum;
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
@ -2442,7 +2442,7 @@ FUNC(LS_Sector_SetColor)
FUNC(LS_Sector_SetFade) FUNC(LS_Sector_SetFade)
// Sector_SetFade (tag, r, g, b) // Sector_SetFade (tag, r, g, b)
{ {
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
int secnum; int secnum;
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
@ -2457,7 +2457,7 @@ FUNC(LS_Sector_SetCeilingPanning)
double xofs = arg1 + arg2 / 100.; double xofs = arg1 + arg2 / 100.;
double yofs = arg3 + arg4 / 100.; double yofs = arg3 + arg4 / 100.;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
int secnum; int secnum;
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
@ -2473,7 +2473,7 @@ FUNC(LS_Sector_SetFloorPanning)
double xofs = arg1 + arg2 / 100.; double xofs = arg1 + arg2 / 100.;
double yofs = arg3 + arg4 / 100.; double yofs = arg3 + arg4 / 100.;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
int secnum; int secnum;
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
@ -2494,7 +2494,7 @@ FUNC(LS_Sector_SetFloorScale)
if (yscale) if (yscale)
yscale = 1. / yscale; yscale = 1. / yscale;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
int secnum; int secnum;
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
@ -2517,7 +2517,7 @@ FUNC(LS_Sector_SetCeilingScale)
if (yscale) if (yscale)
yscale = 1. / yscale; yscale = 1. / yscale;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
int secnum; int secnum;
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
@ -2539,7 +2539,7 @@ FUNC(LS_Sector_SetFloorScale2)
if (yscale) if (yscale)
yscale = 1. / yscale; yscale = 1. / yscale;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
int secnum; int secnum;
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
@ -2561,7 +2561,7 @@ FUNC(LS_Sector_SetCeilingScale2)
if (yscale) if (yscale)
yscale = 1. / yscale; yscale = 1. / yscale;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
int secnum; int secnum;
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
@ -2579,7 +2579,7 @@ FUNC(LS_Sector_SetRotation)
DAngle ceiling = (double)arg2; DAngle ceiling = (double)arg2;
DAngle floor = (double)arg1; DAngle floor = (double)arg1;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
int secnum; int secnum;
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
@ -2594,7 +2594,7 @@ FUNC(LS_Line_AlignCeiling)
{ {
bool ret = 0; bool ret = 0;
FLineIdIterator itr(arg0); FLineIdIterator itr(Level->tagManager, arg0);
int line; int line;
while ((line = itr.Next()) >= 0) while ((line = itr.Next()) >= 0)
{ {
@ -2608,7 +2608,7 @@ FUNC(LS_Line_AlignFloor)
{ {
bool ret = 0; bool ret = 0;
FLineIdIterator itr(arg0); FLineIdIterator itr(Level->tagManager, arg0);
int line; int line;
while ((line = itr.Next()) >= 0) while ((line = itr.Next()) >= 0)
{ {
@ -2627,7 +2627,7 @@ FUNC(LS_Line_SetTextureOffset)
if (arg0 == 0 || arg3 < 0 || arg3 > 1) if (arg0 == 0 || arg3 < 0 || arg3 > 1)
return false; return false;
FLineIdIterator itr(arg0); FLineIdIterator itr(Level->tagManager, arg0);
int line; int line;
while ((line = itr.Next()) >= 0) while ((line = itr.Next()) >= 0)
{ {
@ -2682,7 +2682,7 @@ FUNC(LS_Line_SetTextureScale)
if (arg0 == 0 || arg3 < 0 || arg3 > 1) if (arg0 == 0 || arg3 < 0 || arg3 > 1)
return false; return false;
FLineIdIterator itr(arg0); FLineIdIterator itr(Level->tagManager, arg0);
int line; int line;
while ((line = itr.Next()) >= 0) while ((line = itr.Next()) >= 0)
{ {
@ -2756,7 +2756,7 @@ FUNC(LS_Line_SetBlocking)
if (arg2 & 1) clearflags |= flagtrans[i]; if (arg2 & 1) clearflags |= flagtrans[i];
} }
FLineIdIterator itr(arg0); FLineIdIterator itr(Level->tagManager, arg0);
int line; int line;
while ((line = itr.Next()) >= 0) while ((line = itr.Next()) >= 0)
{ {
@ -2788,7 +2788,7 @@ FUNC(LS_Line_SetAutomapFlags)
if (arg2 & 1) clearflags |= flagtrans[i]; if (arg2 & 1) clearflags |= flagtrans[i];
} }
FLineIdIterator itr(arg0); FLineIdIterator itr(Level->tagManager, arg0);
int line; int line;
while ((line = itr.Next()) >= 0) while ((line = itr.Next()) >= 0)
{ {
@ -2803,7 +2803,7 @@ FUNC(LS_Line_SetAutomapStyle)
{ {
if (arg1 < AMLS_COUNT && arg1 >= 0) if (arg1 < AMLS_COUNT && arg1 >= 0)
{ {
FLineIdIterator itr(arg0); FLineIdIterator itr(Level->tagManager, arg0);
int line; int line;
while ((line = itr.Next()) >= 0) while ((line = itr.Next()) >= 0)
{ {
@ -3103,7 +3103,7 @@ FUNC(LS_SetPlayerProperty)
FUNC(LS_TranslucentLine) FUNC(LS_TranslucentLine)
// TranslucentLine (id, amount, type) // TranslucentLine (id, amount, type)
{ {
FLineIdIterator itr(arg0); FLineIdIterator itr(Level->tagManager, arg0);
int linenum; int linenum;
while ((linenum = itr.Next()) >= 0) while ((linenum = itr.Next()) >= 0)
{ {
@ -3233,7 +3233,7 @@ FUNC(LS_ClearForceField)
{ {
bool rtn = false; bool rtn = false;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
int secnum; int secnum;
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
@ -3409,7 +3409,7 @@ FUNC(LS_Sector_SetPlaneReflection)
// Sector_SetPlaneReflection (tag, floor, ceiling) // Sector_SetPlaneReflection (tag, floor, ceiling)
{ {
int secnum; int secnum;
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
@ -3450,7 +3450,7 @@ FUNC(LS_Sector_SetFloorGlow)
int secnum; int secnum;
PalEntry color(arg2, arg3, arg4); PalEntry color(arg2, arg3, arg4);
if (arg1 < 0) color = -1; // negative height invalidates the glow. if (arg1 < 0) color = -1; // negative height invalidates the glow.
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
@ -3467,7 +3467,7 @@ FUNC(LS_Sector_SetCeilingGlow)
int secnum; int secnum;
PalEntry color(arg2, arg3, arg4); PalEntry color(arg2, arg3, arg4);
if (arg1 < 0) color = -1; // negative height invalidates the glow. if (arg1 < 0) color = -1; // negative height invalidates the glow.
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
@ -3481,7 +3481,7 @@ FUNC(LS_Sector_SetCeilingGlow)
FUNC(LS_Line_SetHealth) FUNC(LS_Line_SetHealth)
// Line_SetHealth(id, health) // Line_SetHealth(id, health)
{ {
FLineIdIterator itr(arg0); FLineIdIterator itr(Level->tagManager, arg0);
int l; int l;
if (arg1 < 0) if (arg1 < 0)
@ -3500,7 +3500,7 @@ FUNC(LS_Line_SetHealth)
FUNC(LS_Sector_SetHealth) FUNC(LS_Sector_SetHealth)
// Sector_SetHealth(id, part, health) // Sector_SetHealth(id, part, health)
{ {
FSectorTagIterator itr(arg0); FSectorTagIterator itr(Level->tagManager, arg0);
int s; int s;
if (arg2 < 0) if (arg2 < 0)

View file

@ -3792,7 +3792,7 @@ void AActor::Tick ()
} }
else if (scrolltype == Scroll_StrifeCurrent) else if (scrolltype == Scroll_StrifeCurrent)
{ // Strife scroll special { // Strife scroll special
int anglespeed = tagManager.GetFirstSectorTag(sec) - 100; int anglespeed = Level->tagManager.GetFirstSectorTag(sec) - 100;
double carryspeed = (anglespeed % 10) / (16 * CARRYFACTOR); double carryspeed = (anglespeed % 10) / (16 * CARRYFACTOR);
DAngle angle = ((anglespeed / 10) * 45.); DAngle angle = ((anglespeed / 10) * 45.);
scrollv += angle.ToVector(carryspeed); scrollv += angle.ToVector(carryspeed);

View file

@ -218,7 +218,7 @@ bool EV_DoPillar (FLevelLocals *Level, DPillar::EPillar type, line_t *line, int
bool rtn = false; bool rtn = false;
// check if a manual trigger; if so do just the sector on the backside // check if a manual trigger; if so do just the sector on the backside
FSectorTagIterator itr(tag, line); FSectorTagIterator itr(Level->tagManager, tag, line);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
sec = &Level->sectors[secnum]; sec = &Level->sectors[secnum];

View file

@ -244,7 +244,7 @@ bool EV_DoPlat (FLevelLocals *Level, int tag, line_t *line, DPlat::EPlatType typ
// [RH] If tag is zero, use the sector on the back side // [RH] If tag is zero, use the sector on the back side
// of the activating line (if any). // of the activating line (if any).
FSectorTagIterator itr(tag, line); FSectorTagIterator itr(Level->tagManager, tag, line);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
sec = &Level->sectors[secnum]; sec = &Level->sectors[secnum];

View file

@ -173,7 +173,7 @@ DPusher::DPusher (DPusher::EPusher type, line_t *l, int magnitude, int angle, AA
int DPusher::CheckForSectorMatch (EPusher type, int tag) int DPusher::CheckForSectorMatch (EPusher type, int tag)
{ {
if (m_Type == type && tagManager.SectorHasTag(m_Affectee, tag)) if (m_Type == type && Level->tagManager.SectorHasTag(m_Affectee, tag))
return m_Affectee->Index(); return m_Affectee->Index();
else else
return -1; return -1;
@ -368,7 +368,7 @@ void P_SpawnPushers (FLevelLocals *Level)
{ {
case Sector_SetWind: // wind case Sector_SetWind: // wind
{ {
FSectorTagIterator itr(l->args[0]); FSectorTagIterator itr(Level->tagManager, l->args[0]);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
Create<DPusher>(DPusher::p_wind, l->args[3] ? l : nullptr, l->args[1], l->args[2], nullptr, &Level->sectors[s]); Create<DPusher>(DPusher::p_wind, l->args[3] ? l : nullptr, l->args[1], l->args[2], nullptr, &Level->sectors[s]);
l->special = 0; l->special = 0;
@ -377,7 +377,7 @@ void P_SpawnPushers (FLevelLocals *Level)
case Sector_SetCurrent: // current case Sector_SetCurrent: // current
{ {
FSectorTagIterator itr(l->args[0]); FSectorTagIterator itr(Level->tagManager, l->args[0]);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
Create<DPusher>(DPusher::p_current, l->args[3] ? l : nullptr, l->args[1], l->args[2], nullptr, &Level->sectors[s]); Create<DPusher>(DPusher::p_current, l->args[3] ? l : nullptr, l->args[1], l->args[2], nullptr, &Level->sectors[s]);
l->special = 0; l->special = 0;
@ -386,7 +386,7 @@ void P_SpawnPushers (FLevelLocals *Level)
case PointPush_SetForce: // push/pull case PointPush_SetForce: // push/pull
if (l->args[0]) { // [RH] Find thing by sector if (l->args[0]) { // [RH] Find thing by sector
FSectorTagIterator itr(l->args[0]); FSectorTagIterator itr(Level->tagManager, l->args[0]);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
{ {
AActor *thing = P_GetPushThing (&Level->sectors[s]); AActor *thing = P_GetPushThing (&Level->sectors[s]);
@ -439,7 +439,7 @@ void AdjustPusher (FLevelLocals *Level, int tag, int magnitude, int angle, bool
int secnum; int secnum;
// Now create pushers for any sectors that don't already have them. // Now create pushers for any sectors that don't already have them.
FSectorTagIterator itr(tag); FSectorTagIterator itr(Level->tagManager, tag);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
unsigned int i; unsigned int i;

View file

@ -432,7 +432,7 @@ void P_SpawnScrollers(FLevelLocals *Level)
if (line.special == Sector_CopyScroller) if (line.special == Sector_CopyScroller)
{ {
// don't allow copying the scroller if the sector has the same tag as it would just duplicate it. // don't allow copying the scroller if the sector has the same tag as it would just duplicate it.
if (!tagManager.SectorHasTag(line.frontsector, line.args[0])) if (!Level->tagManager.SectorHasTag(line.frontsector, line.args[0]))
{ {
copyscrollers.Push(line.Index()); copyscrollers.Push(line.Index());
} }
@ -510,7 +510,7 @@ void P_SpawnScrollers(FLevelLocals *Level)
case Scroll_Ceiling: case Scroll_Ceiling:
{ {
FSectorTagIterator itr(l->args[0]); FSectorTagIterator itr(Level->tagManager, l->args[0]);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
{ {
Create<DScroller>(EScroll::sc_ceiling, -dx, dy, control, &Level->sectors[s], nullptr, accel); Create<DScroller>(EScroll::sc_ceiling, -dx, dy, control, &Level->sectors[s], nullptr, accel);
@ -530,7 +530,7 @@ void P_SpawnScrollers(FLevelLocals *Level)
case Scroll_Floor: case Scroll_Floor:
if (l->args[2] != 1) if (l->args[2] != 1)
{ // scroll the floor texture { // scroll the floor texture
FSectorTagIterator itr(l->args[0]); FSectorTagIterator itr(Level->tagManager, l->args[0]);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
{ {
Create<DScroller> (EScroll::sc_floor, -dx, dy, control, &Level->sectors[s], nullptr, accel); Create<DScroller> (EScroll::sc_floor, -dx, dy, control, &Level->sectors[s], nullptr, accel);
@ -548,7 +548,7 @@ void P_SpawnScrollers(FLevelLocals *Level)
if (l->args[2] > 0) if (l->args[2] > 0)
{ // carry objects on the floor { // carry objects on the floor
FSectorTagIterator itr(l->args[0]); FSectorTagIterator itr(Level->tagManager, l->args[0]);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
{ {
Create<DScroller> (EScroll::sc_carry, dx, dy, control, &Level->sectors[s], nullptr, accel); Create<DScroller> (EScroll::sc_carry, dx, dy, control, &Level->sectors[s], nullptr, accel);
@ -569,7 +569,7 @@ void P_SpawnScrollers(FLevelLocals *Level)
// (same direction and speed as scrolling floors) // (same direction and speed as scrolling floors)
case Scroll_Texture_Model: case Scroll_Texture_Model:
{ {
FLineIdIterator itr(l->args[0]); FLineIdIterator itr(Level->tagManager, l->args[0]);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
{ {
if (s != (int)i) if (s != (int)i)
@ -647,7 +647,7 @@ void SetWallScroller (FLevelLocals *Level, int id, int sidechoice, double dx, do
{ {
auto wall = scroller->GetWall (); auto wall = scroller->GetWall ();
if (wall != nullptr && tagManager.LineHasID(wall->linedef, id) && wall->linedef->sidedef[sidechoice] == wall && Where == scroller->GetScrollParts()) if (wall != nullptr && Level->tagManager.LineHasID(wall->linedef, id) && wall->linedef->sidedef[sidechoice] == wall && Where == scroller->GetScrollParts())
{ {
scroller->Destroy (); scroller->Destroy ();
} }
@ -668,7 +668,7 @@ void SetWallScroller (FLevelLocals *Level, int id, int sidechoice, double dx, do
if (wall != nullptr) if (wall != nullptr)
{ {
auto line = wall->linedef; auto line = wall->linedef;
if (tagManager.LineHasID(line, id) && line->sidedef[sidechoice] == wall && Where == scroll->GetScrollParts()) if (Level->tagManager.LineHasID(line, id) && line->sidedef[sidechoice] == wall && Where == scroll->GetScrollParts())
{ {
scroll->SetRate(dx, dy); scroll->SetRate(dx, dy);
Collection.Push(scroll); Collection.Push(scroll);
@ -681,7 +681,7 @@ void SetWallScroller (FLevelLocals *Level, int id, int sidechoice, double dx, do
int linenum; int linenum;
// Now create scrollers for any walls that don't already have them. // Now create scrollers for any walls that don't already have them.
FLineIdIterator itr(id); FLineIdIterator itr(Level->tagManager, id);
while ((linenum = itr.Next()) >= 0) while ((linenum = itr.Next()) >= 0)
{ {
side_t *side = Level->lines[linenum].sidedef[sidechoice]; side_t *side = Level->lines[linenum].sidedef[sidechoice];
@ -712,7 +712,7 @@ void SetScroller (FLevelLocals *Level, int tag, EScroll type, double dx, double
{ {
if (scroller->IsType (type)) if (scroller->IsType (type))
{ {
if (tagManager.SectorHasTag(scroller->GetSector(), tag)) if (Level->tagManager.SectorHasTag(scroller->GetSector(), tag))
{ {
i++; i++;
scroller->SetRate (dx, dy); scroller->SetRate (dx, dy);
@ -726,7 +726,7 @@ void SetScroller (FLevelLocals *Level, int tag, EScroll type, double dx, double
} }
// Need to create scrollers for the sector(s) // Need to create scrollers for the sector(s)
FSectorTagIterator itr(tag); FSectorTagIterator itr(Level->tagManager, tag);
while ((i = itr.Next()) >= 0) while ((i = itr.Next()) >= 0)
{ {
Create<DScroller> (type, dx, dy, nullptr, &Level->sectors[i], nullptr, 0); Create<DScroller> (type, dx, dy, nullptr, &Level->sectors[i], nullptr, 0);

View file

@ -273,6 +273,10 @@ void FLevelLocals::ClearLevelData()
} }
ClearPortals(); ClearPortals();
tagManager.Clear();
Behaviors.UnloadModules();
SpotState = nullptr; SpotState = nullptr;
ACSThinker = nullptr; ACSThinker = nullptr;
FraggleScriptThinker = nullptr; FraggleScriptThinker = nullptr;
@ -339,9 +343,6 @@ void P_FreeLevelData ()
level.ClearAllSubsectorLinks(); // can't be done as part of the polyobj deletion process. level.ClearAllSubsectorLinks(); // can't be done as part of the polyobj deletion process.
SN_StopAllSequences (); SN_StopAllSequences ();
DThinker::DestroyAllThinkers (); DThinker::DestroyAllThinkers ();
tagManager.Clear();
level.Behaviors.UnloadModules ();
P_FreeStrifeConversations (); P_FreeStrifeConversations ();
level.ClearLevelData(); level.ClearLevelData();

View file

@ -165,6 +165,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe
INTBOOL repeat; INTBOOL repeat;
INTBOOL buttonSuccess; INTBOOL buttonSuccess;
uint8_t special; uint8_t special;
auto Level = line->GetLevel();
if (!P_TestActivateLine (line, mo, side, activationType, optpos)) if (!P_TestActivateLine (line, mo, side, activationType, optpos))
{ {
@ -209,9 +210,9 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe
!repeat && // only non-repeatable triggers !repeat && // only non-repeatable triggers
(special<Generic_Floor || special>Generic_Crusher) && // not for Boom's generalized linedefs (special<Generic_Floor || special>Generic_Crusher) && // not for Boom's generalized linedefs
special && // not for lines without a special special && // not for lines without a special
tagManager.LineHasID(line, line->args[0]) && // Safety check: exclude edited UDMF linedefs or ones that don't map the tag to args[0] Level->tagManager.LineHasID(line, line->args[0]) && // Safety check: exclude edited UDMF linedefs or ones that don't map the tag to args[0]
line->args[0] && // only if there's a tag (which is stored in the first arg) line->args[0] && // only if there's a tag (which is stored in the first arg)
P_FindFirstSectorFromTag (line->args[0]) == -1) // only if no sector is tagged to this linedef Level->tagManager.FindFirstSectorFromTag (line->args[0]) == -1) // only if no sector is tagged to this linedef
{ {
P_ChangeSwitchTexture (line->sidedef[0], repeat, special); P_ChangeSwitchTexture (line->sidedef[0], repeat, special);
line->special = 0; line->special = 0;
@ -523,7 +524,7 @@ static void DoSectorDamage(AActor *actor, sector_t *sec, int amount, FName type,
void P_SectorDamage(FLevelLocals *Level, int tag, int amount, FName type, PClassActor *protectClass, int flags) void P_SectorDamage(FLevelLocals *Level, int tag, int amount, FName type, PClassActor *protectClass, int flags)
{ {
FSectorTagIterator itr(tag); FSectorTagIterator itr(Level->tagManager, tag);
int secnum; int secnum;
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
@ -733,13 +734,13 @@ DLightTransfer::DLightTransfer (sector_t *srcSec, int target, bool copyFloor)
auto Level = Source->Level; auto Level = Source->Level;
if (copyFloor) if (copyFloor)
{ {
FSectorTagIterator itr(target); FSectorTagIterator itr(Level->tagManager, target);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
Level->sectors[secnum].ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING); Level->sectors[secnum].ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING);
} }
else else
{ {
FSectorTagIterator itr(target); FSectorTagIterator itr(Level->tagManager, target);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
Level->sectors[secnum].ChangeFlags(sector_t::ceiling, 0, PLANEF_ABSLIGHTING); Level->sectors[secnum].ChangeFlags(sector_t::ceiling, 0, PLANEF_ABSLIGHTING);
} }
@ -764,13 +765,13 @@ void DLightTransfer::DoTransfer (int llevel, int target, bool floor)
auto Level = Source->Level; auto Level = Source->Level;
if (floor) if (floor)
{ {
FSectorTagIterator itr(target); FSectorTagIterator itr(Level->tagManager, target);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
Level->sectors[secnum].SetPlaneLight(sector_t::floor, llevel); Level->sectors[secnum].SetPlaneLight(sector_t::floor, llevel);
} }
else else
{ {
FSectorTagIterator itr(target); FSectorTagIterator itr(Level->tagManager, target);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
Level->sectors[secnum].SetPlaneLight(sector_t::ceiling, llevel); Level->sectors[secnum].SetPlaneLight(sector_t::ceiling, llevel);
} }
@ -832,7 +833,7 @@ DWallLightTransfer::DWallLightTransfer (sector_t *srcSec, int target, uint8_t fl
wallflags = WALLF_ABSLIGHTING | WALLF_NOFAKECONTRAST; wallflags = WALLF_ABSLIGHTING | WALLF_NOFAKECONTRAST;
} }
FLineIdIterator itr(target); FLineIdIterator itr(Level->tagManager, target);
auto Level = Source->Level; auto Level = Source->Level;
while ((linenum = itr.Next()) >= 0) while ((linenum = itr.Next()) >= 0)
{ {
@ -865,7 +866,7 @@ void DWallLightTransfer::DoTransfer (short lightlevel, int target, uint8_t flags
int linenum; int linenum;
auto Level = Source->Level; auto Level = Source->Level;
FLineIdIterator itr(target); FLineIdIterator itr(Level->tagManager, target);
while ((linenum = itr.Next()) >= 0) while ((linenum = itr.Next()) >= 0)
{ {
line_t *line = &Level->lines[linenum]; line_t *line = &Level->lines[linenum];
@ -999,7 +1000,7 @@ static void SetPortal(sector_t *sector, int plane, unsigned pnum, double alpha)
static void CopyPortal(FLevelLocals *Level, int sectortag, int plane, unsigned pnum, double alpha, bool tolines) static void CopyPortal(FLevelLocals *Level, int sectortag, int plane, unsigned pnum, double alpha, bool tolines)
{ {
int s; int s;
FSectorTagIterator itr(sectortag); FSectorTagIterator itr(Level->tagManager, sectortag);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
{ {
SetPortal(&Level->sectors[s], plane, pnum, alpha); SetPortal(&Level->sectors[s], plane, pnum, alpha);
@ -1020,7 +1021,7 @@ static void CopyPortal(FLevelLocals *Level, int sectortag, int plane, unsigned p
} }
else else
{ {
FSectorTagIterator itr(line.args[0]); FSectorTagIterator itr(Level->tagManager, line.args[0]);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
{ {
SetPortal(&Level->sectors[s], plane, pnum, alpha); SetPortal(&Level->sectors[s], plane, pnum, alpha);
@ -1037,7 +1038,7 @@ static void CopyPortal(FLevelLocals *Level, int sectortag, int plane, unsigned p
} }
else else
{ {
FLineIdIterator itr(line.args[0]); FLineIdIterator itr(Level->tagManager, line.args[0]);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
{ {
Level->lines[s].portaltransferred = pnum; Level->lines[s].portaltransferred = pnum;
@ -1350,7 +1351,7 @@ void P_SpawnSpecials (MapLoader *ml)
{ {
sec->MoreFlags |= SECMF_NOFAKELIGHT; sec->MoreFlags |= SECMF_NOFAKELIGHT;
} }
FSectorTagIterator itr(line.args[0]); FSectorTagIterator itr(Level->tagManager, line.args[0]);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
{ {
Level->sectors[s].heightsec = sec; Level->sectors[s].heightsec = sec;
@ -1426,7 +1427,7 @@ void P_SpawnSpecials (MapLoader *ml)
case Init_Gravity: case Init_Gravity:
{ {
double grav = line.Delta().Length() / 100.; double grav = line.Delta().Length() / 100.;
FSectorTagIterator itr(line.args[0]); FSectorTagIterator itr(Level->tagManager, line.args[0]);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
Level->sectors[s].gravity = grav; Level->sectors[s].gravity = grav;
} }
@ -1438,7 +1439,7 @@ void P_SpawnSpecials (MapLoader *ml)
case Init_Damage: case Init_Damage:
{ {
int damage = int(line.Delta().Length()); int damage = int(line.Delta().Length());
FSectorTagIterator itr(line.args[0]); FSectorTagIterator itr(Level->tagManager, line.args[0]);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
{ {
sector_t *sec = &Level->sectors[s]; sector_t *sec = &Level->sectors[s];
@ -1479,7 +1480,7 @@ void P_SpawnSpecials (MapLoader *ml)
case Init_TransferSky: case Init_TransferSky:
{ {
FSectorTagIterator itr(line.args[0]); FSectorTagIterator itr(Level->tagManager, line.args[0]);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
Level->sectors[s].sky = (line.Index() + 1) | PL_SKYFLAT; Level->sectors[s].sky = (line.Index() + 1) | PL_SKYFLAT;
break; break;
@ -1587,7 +1588,7 @@ void P_SetSectorFriction (FLevelLocals *Level, int tag, int amount, bool alterFl
// higher friction value actually means 'less friction'. // higher friction value actually means 'less friction'.
movefactor = FrictionToMoveFactor(friction); movefactor = FrictionToMoveFactor(friction);
FSectorTagIterator itr(tag); FSectorTagIterator itr(Level->tagManager, tag);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
{ {
// killough 8/28/98: // killough 8/28/98:

View file

@ -68,17 +68,20 @@ public:
void RemoveSectorTags(int sect); void RemoveSectorTags(int sect);
void DumpTags(); void DumpTags();
};
extern FTagManager tagManager; int FindFirstSectorFromTag(int tag);
int FindFirstLineFromID(int tag);
};
class FSectorTagIterator class FSectorTagIterator
{ {
protected: protected:
int searchtag; int searchtag;
int start; int start;
FTagManager &tagManager;
FSectorTagIterator() FSectorTagIterator(FTagManager &manager) : tagManager(manager)
{ {
// For DSectorTagIterator // For DSectorTagIterator
} }
@ -104,13 +107,13 @@ protected:
} }
public: public:
FSectorTagIterator(int tag) FSectorTagIterator(FTagManager &manager, int tag) : tagManager(manager)
{ {
Init(tag); Init(tag);
} }
// Special constructor for actions that treat tag 0 as 'back of activation line' // Special constructor for actions that treat tag 0 as 'back of activation line'
FSectorTagIterator(int tag, line_t *line) FSectorTagIterator(FTagManager &manager, int tag, line_t *line) : tagManager(manager)
{ {
Init(tag, line); Init(tag, line);
} }
@ -124,9 +127,10 @@ class FLineIdIterator
protected: protected:
int searchtag; int searchtag;
int start; int start;
FTagManager &tagManager;
public: public:
FLineIdIterator(int id) FLineIdIterator(FTagManager &manager, int id) : tagManager(manager)
{ {
searchtag = id; searchtag = id;
start = tagManager.IDHashFirst[((unsigned int)id) % FTagManager::TAG_HASH_SIZE]; start = tagManager.IDHashFirst[((unsigned int)id) % FTagManager::TAG_HASH_SIZE];
@ -136,15 +140,15 @@ public:
}; };
inline int P_FindFirstSectorFromTag(int tag) inline int FTagManager::FindFirstSectorFromTag(int tag)
{ {
FSectorTagIterator it(tag); FSectorTagIterator it(*this, tag);
return it.Next(); return it.Next();
} }
inline int P_FindFirstLineFromID(int tag) inline int FTagManager::FindFirstLineFromID(int tag)
{ {
FLineIdIterator it(tag); FLineIdIterator it(*this, tag);
return it.Next(); return it.Next();
} }

View file

@ -255,7 +255,7 @@ static AActor *SelectTeleDest (FLevelLocals *Level, int tid, int tag, bool noran
int count = 0; int count = 0;
while ( (searcher = iterator.Next ()) ) while ( (searcher = iterator.Next ()) )
{ {
if (tag == 0 || tagManager.SectorHasTag(searcher->Sector, tag)) if (tag == 0 || Level->tagManager.SectorHasTag(searcher->Sector, tag))
{ {
count++; count++;
} }
@ -294,7 +294,7 @@ static AActor *SelectTeleDest (FLevelLocals *Level, int tid, int tag, bool noran
while (count > 0) while (count > 0)
{ {
searcher = iterator.Next (); searcher = iterator.Next ();
if (tag == 0 || tagManager.SectorHasTag(searcher->Sector, tag)) if (tag == 0 || Level->tagManager.SectorHasTag(searcher->Sector, tag))
{ {
count--; count--;
} }
@ -307,7 +307,7 @@ static AActor *SelectTeleDest (FLevelLocals *Level, int tid, int tag, bool noran
{ {
int secnum; int secnum;
FSectorTagIterator itr(tag); FSectorTagIterator itr(Level->tagManager, tag);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
// Scanning the snext links of things in the sector will not work, because // Scanning the snext links of things in the sector will not work, because
@ -432,7 +432,7 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO
if (side || thing->flags2 & MF2_NOTELEPORT || !line || line->sidedef[1] == NULL) if (side || thing->flags2 & MF2_NOTELEPORT || !line || line->sidedef[1] == NULL)
return false; return false;
FLineIdIterator itr(id); FLineIdIterator itr(Level->tagManager, id);
while ((i = itr.Next()) >= 0) while ((i = itr.Next()) >= 0)
{ {
if (line->Index() == i) if (line->Index() == i)
@ -720,7 +720,7 @@ bool EV_TeleportSector (FLevelLocals *Level, int tag, int source_tid, int dest_t
int secnum; int secnum;
secnum = -1; secnum = -1;
FSectorTagIterator itr(tag); FSectorTagIterator itr(Level->tagManager, tag);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
msecnode_t *node; msecnode_t *node;

View file

@ -62,6 +62,7 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid)
short tag = mld->tag; short tag = mld->tag;
uint32_t flags =mld->flags; uint32_t flags =mld->flags;
INTBOOL passthrough = 0; INTBOOL passthrough = 0;
auto Level = ld->GetLevel();
uint32_t flags1 = flags; uint32_t flags1 = flags;
uint32_t newflags = 0; uint32_t newflags = 0;
@ -102,7 +103,7 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid)
// line also needs to have its ID set to the same as its tag. // line also needs to have its ID set to the same as its tag.
// An external conversion program would need to do this more // An external conversion program would need to do this more
// intelligently. // intelligently.
tagManager.AddLineID(lineindexforid, tag); Level->tagManager.AddLineID(lineindexforid, tag);
} }
// 0 specials are never translated. // 0 specials are never translated.

View file

@ -211,7 +211,7 @@ static line_t *FindDestination(line_t *src, int tag)
{ {
int lineno = -1; int lineno = -1;
auto Level = src->GetLevel(); auto Level = src->GetLevel();
FLineIdIterator it(tag); FLineIdIterator it(Level->tagManager, tag);
while ((lineno = it.Next()) >= 0) while ((lineno = it.Next()) >= 0)
{ {
@ -310,11 +310,11 @@ void P_SpawnLinePortal(line_t* line)
{ {
// EE-style portals require that the first line ID is identical and the first arg of the two linked linedefs are 0 and 1 respectively. // EE-style portals require that the first line ID is identical and the first arg of the two linked linedefs are 0 and 1 respectively.
int mytag = tagManager.GetFirstLineID(line); int mytag = Level->tagManager.GetFirstLineID(line);
for (auto &ln : Level->lines) for (auto &ln : Level->lines)
{ {
if (tagManager.GetFirstLineID(&ln) == mytag && ln.args[0] == 1 && ln.special == Line_SetPortal) if (Level->tagManager.GetFirstLineID(&ln) == mytag && ln.args[0] == 1 && ln.special == Line_SetPortal)
{ {
line->portalindex = Level->linePortals.Reserve(1); line->portalindex = Level->linePortals.Reserve(1);
FLinePortal *port = &Level->linePortals.Last(); FLinePortal *port = &Level->linePortals.Last();
@ -491,7 +491,7 @@ bool P_ChangePortal(line_t *ln, int thisid, int destid)
auto Level = ln->GetLevel(); auto Level = ln->GetLevel();
if (thisid == 0) return ChangePortalLine(ln, destid); if (thisid == 0) return ChangePortalLine(ln, destid);
FLineIdIterator it(thisid); FLineIdIterator it(Level->tagManager, thisid);
bool res = false; bool res = false;
while ((lineno = it.Next()) >= 0) while ((lineno = it.Next()) >= 0)
{ {

View file

@ -245,7 +245,7 @@ class DSectorTagIterator : public DObject, public FSectorTagIterator
{ {
DECLARE_ABSTRACT_CLASS(DSectorTagIterator, DObject); DECLARE_ABSTRACT_CLASS(DSectorTagIterator, DObject);
public: public:
DSectorTagIterator(int tag, line_t *line) DSectorTagIterator(FTagManager &tagManager, int tag, line_t *line) : FSectorTagIterator(tagManager)
{ {
if (line == nullptr) Init(tag); if (line == nullptr) Init(tag);
else Init(tag, line); else Init(tag, line);
@ -254,17 +254,17 @@ public:
IMPLEMENT_CLASS(DSectorTagIterator, true, false); IMPLEMENT_CLASS(DSectorTagIterator, true, false);
static DSectorTagIterator *CreateSTI(int tag, line_t *line) static DSectorTagIterator *CreateSTI(FLevelLocals *Level, int tag, line_t *line)
{ {
return Create<DSectorTagIterator>(tag, line); return Create<DSectorTagIterator>(Level->tagManager, tag, line);
} }
DEFINE_ACTION_FUNCTION_NATIVE(DSectorTagIterator, Create, CreateSTI) DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, CreateSectorTagIterator, CreateSTI)
{ {
PARAM_PROLOGUE; PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
PARAM_INT(tag); PARAM_INT(tag);
PARAM_POINTER(line, line_t); PARAM_POINTER(line, line_t);
ACTION_RETURN_POINTER(Create<DSectorTagIterator>(tag, line)); ACTION_RETURN_POINTER(Create<DSectorTagIterator>(self->tagManager, tag, line));
} }
int NextSTI(DSectorTagIterator *self) int NextSTI(DSectorTagIterator *self)
@ -301,8 +301,8 @@ class DLineIdIterator : public DObject, public FLineIdIterator
{ {
DECLARE_ABSTRACT_CLASS(DLineIdIterator, DObject); DECLARE_ABSTRACT_CLASS(DLineIdIterator, DObject);
public: public:
DLineIdIterator(int tag) DLineIdIterator(FTagManager &tagManager, int tag)
: FLineIdIterator(tag) : FLineIdIterator(tagManager, tag)
{ {
} }
}; };
@ -310,16 +310,16 @@ public:
IMPLEMENT_CLASS(DLineIdIterator, true, false); IMPLEMENT_CLASS(DLineIdIterator, true, false);
static DLineIdIterator *CreateLTI(int tag) static DLineIdIterator *CreateLTI(FLevelLocals *Level, int tag)
{ {
return Create<DLineIdIterator>(tag); return Create<DLineIdIterator>(Level->tagManager, tag);
} }
DEFINE_ACTION_FUNCTION_NATIVE(DLineIdIterator, Create, CreateLTI) DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, CreateLineIDIterator, CreateLTI)
{ {
PARAM_PROLOGUE; PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
PARAM_INT(tag); PARAM_INT(tag);
ACTION_RETURN_POINTER(Create<DLineIdIterator>(tag)); ACTION_RETURN_POINTER(Create<DLineIdIterator>(self->tagManager, tag));
} }
int NextLTI(DLineIdIterator *self) int NextLTI(DLineIdIterator *self)

View file

@ -723,6 +723,9 @@ struct LevelLocals native
native void ChangeSky( TextureID sky1, TextureID sky2 ); native void ChangeSky( TextureID sky1, TextureID sky2 );
native SectorTagIterator CreateSectorTagIterator(int tag, line defline = null);
native LineIdIterator CreateLineIdIterator(int tag);
String TimeFormatted(bool totals = false) String TimeFormatted(bool totals = false)
{ {
int sec = Thinker.Tics2Seconds(totals? totaltime : time); int sec = Thinker.Tics2Seconds(totals? totaltime : time);

View file

@ -531,13 +531,19 @@ struct Sector native play
class SectorTagIterator : Object native class SectorTagIterator : Object native
{ {
native static SectorTagIterator Create(int tag, line defline = null); deprecated("3.8") static SectorTagIterator Create(int tag, line defline = null)
{
return level.CreateSectorTagIterator(tag, defline);
}
native int Next(); native int Next();
native int NextCompat(bool compat, int secnum); native int NextCompat(bool compat, int secnum);
} }
class LineIdIterator : Object native class LineIdIterator : Object native
{ {
native static LineIdIterator Create(int tag); deprecated("3.8") static LineIdIterator Create(int tag)
{
return level.CreateLineIdIterator(tag);
}
native int Next(); native int Next();
} }