From 6b9641d6736ce4ac84de9175d608d87c7e3e94d3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 8 Jan 2019 23:39:48 +0100 Subject: [PATCH] - moved the tag manager into FLevelLocals. This also involves deprecating the old creation functions because they do not have a proper level context. --- src/fragglescript/t_func.cpp | 18 ++++----- src/fragglescript/t_script.cpp | 2 +- src/g_levellocals.h | 2 + src/maploader/compatibility.cpp | 4 +- src/maploader/edata.cpp | 2 +- src/maploader/maploader.cpp | 16 ++++---- src/maploader/slopes.cpp | 4 +- src/maploader/udmf.cpp | 8 ++-- src/p_3dfloors.cpp | 4 +- src/p_3dmidtex.cpp | 6 +-- src/p_acs.cpp | 50 ++++++++++++------------- src/p_actionfunctions.cpp | 2 +- src/p_ceiling.cpp | 4 +- src/p_doors.cpp | 4 +- src/p_floor.cpp | 16 ++++---- src/p_lights.cpp | 20 +++++----- src/p_linkedsectors.cpp | 10 ++--- src/p_lnspec.cpp | 62 +++++++++++++++---------------- src/p_mobj.cpp | 2 +- src/p_pillar.cpp | 2 +- src/p_plats.cpp | 2 +- src/p_pusher.cpp | 10 ++--- src/p_scroll.cpp | 20 +++++----- src/p_setup.cpp | 7 ++-- src/p_spec.cpp | 35 ++++++++--------- src/p_tags.h | 24 +++++++----- src/p_teleport.cpp | 10 ++--- src/p_xlat.cpp | 3 +- src/portal.cpp | 8 ++-- src/scripting/vmiterators.cpp | 26 ++++++------- wadsrc/static/zscript/base.txt | 3 ++ wadsrc/static/zscript/mapdata.txt | 10 ++++- 32 files changed, 207 insertions(+), 189 deletions(-) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 52ca4e78e9..4ec2660a07 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -306,7 +306,7 @@ class FSSectorTagIterator : public FSectorTagIterator { public: FSSectorTagIterator(FLevelLocals *Level, int tag) - : FSectorTagIterator(tag) + : FSectorTagIterator(Level->tagManager, tag) { if (tag < 0) { @@ -1150,7 +1150,7 @@ void FParser::SF_ObjSector(void) } 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]); speed = t_argc>2 ? intvalue(t_argv[2]) : 1; - FSectorTagIterator it(sectag); + FSectorTagIterator it(Level->tagManager, sectag); while ((i = it.Next()) >= 0) { if (!Level->sectors[i].lightingdata) Create(&Level->sectors[i],destlevel,speed); @@ -2157,7 +2157,7 @@ void FParser::SF_SetLineBlocking(void) { blocking=blocks[blocking]; int tag=intvalue(t_argv[0]); - FLineIdIterator itr(tag); + FLineIdIterator itr(Level->tagManager, tag); int i; 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 tag=intvalue(t_argv[0]); - FLineIdIterator itr(tag); + FLineIdIterator itr(Level->tagManager, tag); int i; while ((i = itr.Next()) >= 0) { @@ -2237,7 +2237,7 @@ void FParser::SF_SetLineTexture(void) texture = stringvalue(t_argv[3]); texturenum = TexMan.GetTextureID(texture, ETextureType::Wall, FTextureManager::TEXMAN_Overridable); - FLineIdIterator itr(tag); + FLineIdIterator itr(Level->tagManager, tag); while ((i = itr.Next()) >= 0) { // bad sidedef, Hexen just SEGV'd here! @@ -2257,7 +2257,7 @@ void FParser::SF_SetLineTexture(void) int sections = intvalue(t_argv[3]); // set all sectors with tag - FLineIdIterator itr(tag); + FLineIdIterator itr(Level->tagManager, tag); while ((i = itr.Next()) >= 0) { side_t *sided = Level->lines[i].sidedef[side]; @@ -3792,7 +3792,7 @@ void FParser::SF_KillInSector() 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]); spec=intvalue(t_argv[1]); if (t_argc>2) tag=intvalue(t_argv[2]); - FLineIdIterator itr(id); + FLineIdIterator itr(Level->tagManager, id); while ((i = itr.Next()) >= 0) { maplinedef_t mld; diff --git a/src/fragglescript/t_script.cpp b/src/fragglescript/t_script.cpp index 0ca9713267..676325dea1 100644 --- a/src/fragglescript/t_script.cpp +++ b/src/fragglescript/t_script.cpp @@ -458,7 +458,7 @@ bool DFraggleThinker::wait_finished(DRunningScript *script) case wt_tagwait: { int secnum; - FSectorTagIterator itr(script->wait_data); + FSectorTagIterator itr(Level->tagManager, script->wait_data); while ((secnum = itr.Next()) >= 0) { sector_t *sec = &Level->sectors[secnum]; diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 368e5d5c08..7825f5f17f 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -44,6 +44,7 @@ #include "p_local.h" #include "po_man.h" #include "p_acs.h" +#include "p_tags.h" #include "p_destructible.h" #include "r_data/r_sections.h" #include "r_data/r_canvastexture.h" @@ -70,6 +71,7 @@ struct FLevelData TArray rejectmatrix; TArray Zones; TArray Polyobjects; + FTagManager tagManager; TArray sectorPortals; TArray linePortals; diff --git a/src/maploader/compatibility.cpp b/src/maploader/compatibility.cpp index 44dad087fc..cecbb0e1ed 100644 --- a/src/maploader/compatibility.cpp +++ b/src/maploader/compatibility.cpp @@ -394,7 +394,7 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, ClearSectorTags) { PARAM_SELF_PROLOGUE(DLevelCompatibility); PARAM_INT(sector); - tagManager.RemoveSectorTags(sector); + self->Level->tagManager.RemoveSectorTags(sector); return 0; } @@ -406,7 +406,7 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, AddSectorTag) if ((unsigned)sector < self->Level->sectors.Size()) { - tagManager.AddSectorTag(sector, tag); + self->Level->tagManager.AddSectorTag(sector, tag); } return 0; } diff --git a/src/maploader/edata.cpp b/src/maploader/edata.cpp index 1703acbe89..be2dd0de73 100644 --- a/src/maploader/edata.cpp +++ b/src/maploader/edata.cpp @@ -583,7 +583,7 @@ void MapLoader::ProcessEDLinedef(line_t *ld, int recordnum) ld->flags = (ld->flags&~fmask) | eld->flags; ld->setAlpha(eld->alpha); 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) diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index 28d7ebb0de..ed4c0f2ad0 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -1040,7 +1040,7 @@ void MapLoader::LoadSectors (MapData *map, FMissingTextureTracker &missingtex) ss->special = LittleShort(ms->special); else // [RH] Translate to new sector 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->touching_thinglist = nullptr; // phares 3/14/98 ss->sectorportal_thinglist = nullptr; @@ -1461,7 +1461,7 @@ void MapLoader::SetLineID (int i, line_t *ld) } 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++) { - if (tagManager.LineHasID(j, ld->args[0])) + if (Level->tagManager.LineHasID(j, ld->args[0])) { Level->lines[j].alpha = dalpha; if (additive) @@ -1685,7 +1685,7 @@ void MapLoader::LoadLineDefs (MapData * map) // do not assign the tag for Extradata lines. 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 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++) { - if (tagManager.SectorHasTag(s, tag)) + if (Level->tagManager.SectorHasTag(s, tag)) { if (colorgood) { @@ -2685,9 +2685,9 @@ void MapLoader::GroupLines (bool buildmap) { 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 - tagManager.RemoveSectorTags(i); + Level->tagManager.RemoveSectorTags(i); } else { @@ -2742,7 +2742,7 @@ void MapLoader::GroupLines (bool buildmap) } // killough 1/30/98: Create xref tables for tags - tagManager.HashTags(); + Level->tagManager.HashTags(); if (!buildmap) { diff --git a/src/maploader/slopes.cpp b/src/maploader/slopes.cpp index 86614cc359..b5d0450187 100644 --- a/src/maploader/slopes.cpp +++ b/src/maploader/slopes.cpp @@ -53,7 +53,7 @@ void MapLoader::SlopeLineToPoint (int lineid, const DVector3 &pos, bool slopeCei { int linenum; - FLineIdIterator itr(lineid); + FLineIdIterator itr(Level->tagManager, lineid); while ((linenum = itr.Next()) >= 0) { const line_t *line = &Level->lines[linenum]; @@ -123,7 +123,7 @@ void MapLoader::CopyPlane (int tag, sector_t *dest, bool copyCeil) sector_t *source; int secnum; - secnum = P_FindFirstSectorFromTag (tag); + secnum = Level->tagManager.FindFirstSectorFromTag (tag); if (secnum == -1) { return; diff --git a/src/maploader/udmf.cpp b/src/maploader/udmf.cpp index 4d1f4c4cf0..b1027c7997 100644 --- a/src/maploader/udmf.cpp +++ b/src/maploader/udmf.cpp @@ -856,7 +856,7 @@ public: case NAME_Id: lineid = CheckInt(key); - tagManager.AddLineID(index, lineid); + Level->tagManager.AddLineID(index, lineid); continue; case NAME_Sidefront: @@ -1127,7 +1127,7 @@ public: // scan the string as long as valid numbers can be found 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; case NAME_Id: - tagManager.AddSectorTag(index, CheckInt(key)); + Level->tagManager.AddSectorTag(index, CheckInt(key)); continue; default: @@ -1908,7 +1908,7 @@ public: // scan the string as long as valid numbers can be found while (sc.CheckNumber()) { - if (sc.Number != 0) tagManager.AddSectorTag(index, sc.Number); + if (sc.Number != 0) Level->tagManager.AddSectorTag(index, sc.Number); } } diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index a1f8e08af7..ace1356250 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -213,7 +213,7 @@ static int P_Set3DFloor(line_t * line, int param, int param2, int alpha) sector_t * sec = line->frontsector, *ss; auto Level = sec->Level; - FSectorTagIterator itr(tag); + FSectorTagIterator itr(Level->tagManager, tag); while ((s = itr.Next()) >= 0) { ss = &Level->sectors[s]; @@ -905,7 +905,7 @@ void P_Spawn3DFloors (FLevelLocals *Level) { if (line.args[1]&8) { - tagManager.AddLineID(line.Index(), line.args[4]); + Level->tagManager.AddLineID(line.Index(), line.args[4]); } else { diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index d76d458a2f..7af4f961f1 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -150,7 +150,7 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c if (tag == 0) { - FLineIdIterator itr(lineid); + FLineIdIterator itr(Level->tagManager, lineid); int line; while ((line = itr.Next()) >= 0) { @@ -166,13 +166,13 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c } else { - FSectorTagIterator it(tag); + FSectorTagIterator it(Level->tagManager, tag); int sec; while ((sec = it.Next()) >= 0) { 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)) { diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 7ddb7361b8..4c30a768a9 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -1853,7 +1853,7 @@ DPlaneWatcher::DPlaneWatcher (FLevelLocals *Level, AActor *it, line_t *line, int Args[2] = arg2; Args[3] = arg3; Args[4] = arg4; - secnum = P_FindFirstSectorFromTag (tag); + secnum = Level->tagManager.FindFirstSectorFromTag (tag); if (secnum >= 0) { secplane_t plane; @@ -3625,7 +3625,7 @@ do_count: if (actor->health > 0 && (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 if (actor->IsMapActor()) @@ -3644,7 +3644,7 @@ do_count: if (actor->health > 0 && (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 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); - FSectorTagIterator it(tag); + FSectorTagIterator it(Level->tagManager, tag); while ((secnum = it.Next()) >= 0) { 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); - FLineIdIterator itr(lineid); + FLineIdIterator itr(Level->tagManager, lineid); while ((linenum = itr.Next()) >= 0) { side_t *sidedef; @@ -4819,7 +4819,7 @@ int DLevelScript::SideFromID(int id, int side) } else { - int line = P_FindFirstLineFromID(id); + int line = Level->tagManager.FindFirstLineFromID(id); if (line == -1) return -1; if (Level->lines[line].sidedef[side] == NULL) return -1; return Level->lines[line].sidedef[side]->UDMFIndex; @@ -4835,7 +4835,7 @@ int DLevelScript::LineFromID(int id) } 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 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: - 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: 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]; if (seqname != NULL) { - FSectorTagIterator it(args[0]); + FSectorTagIterator it(Level->tagManager, args[0]); int s; while ((s = it.Next()) >= 0) { @@ -6205,7 +6205,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) if (argCount >= 2) { int line; - FLineIdIterator itr(args[0]); + FLineIdIterator itr(Level->tagManager, args[0]); while ((line = itr.Next()) >= 0) { Level->lines[line].activation = args[1]; @@ -6216,7 +6216,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_GetLineActivation: if (argCount > 0) { - int line = P_FindFirstLineFromID(args[0]); + int line = Level->tagManager.FindFirstLineFromID(args[0]); return line >= 0 ? Level->lines[line].activation : 0; } break; @@ -6429,7 +6429,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_SetSectorDamage: if (argCount >= 2) { - FSectorTagIterator it(args[0]); + FSectorTagIterator it(Level->tagManager, args[0]); int s; 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) { int terrain = P_FindTerrain(Level->Behaviors.LookupString(args[2])); - FSectorTagIterator it(args[0]); + FSectorTagIterator it(Level->tagManager, args[0]); int s; while ((s = it.Next()) >= 0) { @@ -6590,7 +6590,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) float height = float(args[5]); if (args[2] == -1) color = -1; - FSectorTagIterator it(args[0]); + FSectorTagIterator it(Level->tagManager, args[0]); int s; while ((s = it.Next()) >= 0) { @@ -6602,7 +6602,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_SetFogDensity: { - FSectorTagIterator it(args[0]); + FSectorTagIterator it(Level->tagManager, args[0]); int s; int d = clamp(args[1]/2, 0, 255); while ((s = it.Next()) >= 0) @@ -6662,7 +6662,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_GetSectorHealth: { int part = args[1]; - FSectorTagIterator it(args[0]); + FSectorTagIterator it(Level->tagManager, args[0]); int s = it.Next(); if (s < 0) return 0; @@ -6688,7 +6688,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_GetLineHealth: { - FLineIdIterator it(args[0]); + FLineIdIterator it(Level->tagManager, args[0]); int l = it.Next(); if (l < 0) return 0; @@ -6705,7 +6705,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_GetLineX: case ACSF_GetLineY: { - FLineIdIterator it(args[0]); + FLineIdIterator it(Level->tagManager, args[0]); int lineno = it.Next(); if (lineno < 0) return 0; DVector2 delta = Level->lines[lineno].Delta(); @@ -6821,7 +6821,7 @@ int DLevelScript::RunScript () // state running { int secnum; - FSectorTagIterator it(statedata); + FSectorTagIterator it(Level->tagManager, statedata); while ((secnum = it.Next()) >= 0) { if (Level->sectors[secnum].floordata || Level->sectors[secnum].ceilingdata) @@ -8930,7 +8930,7 @@ scriptwait: { int lineno; - FLineIdIterator itr(STACK(2)); + FLineIdIterator itr(Level->tagManager, STACK(2)); while ((lineno = itr.Next()) >= 0) { auto &line = Level->lines[lineno]; @@ -8967,7 +8967,7 @@ scriptwait: { int line; - FLineIdIterator itr(STACK(2)); + FLineIdIterator itr(Level->tagManager, STACK(2)); while ((line = itr.Next()) >= 0) { if (STACK(1)) @@ -8993,7 +8993,7 @@ scriptwait: arg0 = -FName(Level->Behaviors.LookupString(arg0)); } - FLineIdIterator itr(STACK(7)); + FLineIdIterator itr(Level->tagManager, STACK(7)); while ((linenum = itr.Next()) >= 0) { line_t *line = &Level->lines[linenum]; @@ -9467,7 +9467,7 @@ scriptwait: double z = 0; if (tag != 0) - secnum = P_FindFirstSectorFromTag (tag); + secnum = Level->tagManager.FindFirstSectorFromTag (tag); else secnum = P_PointInSector (x, y)->sectornum; @@ -9489,7 +9489,7 @@ scriptwait: case PCD_GETSECTORLIGHTLEVEL: { - int secnum = P_FindFirstSectorFromTag (STACK(1)); + int secnum = Level->tagManager.FindFirstSectorFromTag (STACK(1)); int z = -1; if (secnum >= 0) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index eda7f4bdf1..9cbdb1daa5 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -4832,7 +4832,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain) } 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.; DAngle an = (anglespeed / 10) * (360 / 8.); self->Thrust(an, speed); diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp index a1f2ac09ea..a1b112e08e 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -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 - FSectorTagIterator it(tag); + FSectorTagIterator it(Level->tagManager, tag); while ((secnum = it.Next()) >= 0) { 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) { int sec; - FSectorTagIterator it(tag, line); + FSectorTagIterator it(Level->tagManager, tag, line); while ((sec = it.Next()) >= 0) { if (Level->sectors[sec].ceilingdata) diff --git a/src/p_doors.cpp b/src/p_doors.cpp index f374543f08..0b9dc38e3d 100644 --- a/src/p_doors.cpp +++ b/src/p_doors.cpp @@ -490,7 +490,7 @@ bool EV_DoDoor (FLevelLocals *Level, DDoor::EVlDoor type, line_t *line, AActor * else { // [RH] Remote door - FSectorTagIterator it(tag); + FSectorTagIterator it(Level->tagManager, tag); while ((secnum = it.Next()) >= 0) { sec = &Level->sectors[secnum]; @@ -787,7 +787,7 @@ bool EV_SlidingDoor (FLevelLocals *Level, line_t *line, AActor *actor, int tag, return false; } - FSectorTagIterator it(tag); + FSectorTagIterator it(Level->tagManager, tag); while ((secnum = it.Next()) >= 0) { sec = &Level->sectors[secnum]; diff --git a/src/p_floor.cpp b/src/p_floor.cpp index e633fa19c6..8bab22dc84 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -532,7 +532,7 @@ bool EV_DoFloor (FLevelLocals *Level, DFloor::EFloor floortype, line_t *line, in bool rtn = false; // 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) { 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) { int secnum; - FSectorTagIterator it(tag, line); + FSectorTagIterator it(Level->tagManager, tag, line); while ((secnum = it.Next()) >= 0) { 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) { int sec; - FSectorTagIterator it(tag, line); + FSectorTagIterator it(Level->tagManager, tag, line); while ((sec = it.Next()) >= 0) { 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); // 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. // It needs the original linear search method. This was broken in Boom. 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; - FSectorTagIterator itr(tag, line); + FSectorTagIterator itr(Level->tagManager, tag, line); while ((secnum = itr.Next()) >= 0) { 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; rtn = false; - FSectorTagIterator itr(tag, line); + FSectorTagIterator itr(Level->tagManager, tag, line); // act on all sectors with the same tag as the triggering linedef while ((secnum = itr.Next()) >= 0) @@ -1106,7 +1106,7 @@ bool EV_DoChange (FLevelLocals *Level, line_t *line, EChange changetype, int tag rtn = false; // change all sectors with the same tag as the linedef - FSectorTagIterator it(tag); + FSectorTagIterator it(Level->tagManager, tag); while ((secnum = it.Next()) >= 0) { sec = &Level->sectors[secnum]; @@ -1320,7 +1320,7 @@ bool EV_StartWaggle (FLevelLocals *Level, int tag, line_t *line, int height, int retCode = false; - FSectorTagIterator itr(tag, line); + FSectorTagIterator itr(Level->tagManager, tag, line); while ((sectorIndex = itr.Next()) >= 0) { diff --git a/src/p_lights.cpp b/src/p_lights.cpp index 9ef124b736..7cb90de95a 100644 --- a/src/p_lights.cpp +++ b/src/p_lights.cpp @@ -326,7 +326,7 @@ DFlicker::DFlicker (sector_t *sector, int upper, int lower) void EV_StartLightFlickering (FLevelLocals *Level, int tag, int upper, int lower) { int secnum; - FSectorTagIterator it(tag); + FSectorTagIterator it(Level->tagManager, tag); while ((secnum = it.Next()) >= 0) { Create (&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) { int secnum; - FSectorTagIterator it(tag); + FSectorTagIterator it(Level->tagManager, tag); while ((secnum = it.Next()) >= 0) { 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) { int secnum; - FSectorTagIterator it(tag); + FSectorTagIterator it(Level->tagManager, tag); while ((secnum = it.Next()) >= 0) { 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) { int secnum; - FSectorTagIterator it(tag); + FSectorTagIterator it(Level->tagManager, tag); while ((secnum = it.Next()) >= 0) { 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) { int secnum; - FSectorTagIterator it(tag); + FSectorTagIterator it(Level->tagManager, tag); while ((secnum = it.Next()) >= 0) { 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 int secnum; - FSectorTagIterator it(tag); + FSectorTagIterator it(Level->tagManager, tag); while ((secnum = it.Next()) >= 0) { 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) { int secnum; - FSectorTagIterator it(tag); + FSectorTagIterator it(Level->tagManager, tag); while ((secnum = it.Next()) >= 0) { 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; } - FSectorTagIterator it(tag); + FSectorTagIterator it(Level->tagManager, tag); while ((secnum = it.Next()) >= 0) { 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) { int secnum; - FSectorTagIterator it(tag); + FSectorTagIterator it(Level->tagManager, tag); while ((secnum = it.Next()) >= 0) { sector_t *sec = &Level->sectors[secnum]; @@ -989,7 +989,7 @@ void EV_StopLightEffect (FLevelLocals *Level, int tag) while ((effect = iterator.Next()) != NULL) { - if (tagManager.SectorHasTag(effect->GetSector(), tag)) + if (Level->tagManager.SectorHasTag(effect->GetSector(), tag)) { effect->Destroy(); } diff --git a/src/p_linkedsectors.cpp b/src/p_linkedsectors.cpp index 27a7ee52e7..0a7fecf8fb 100644 --- a/src/p_linkedsectors.cpp +++ b/src/p_linkedsectors.cpp @@ -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--) { - if (tagManager.SectorHasTag(scrollplane.Sectors[i].Sector, tag)) + if (Level->tagManager.SectorHasTag(scrollplane.Sectors[i].Sector, tag)) { scrollplane.Sectors.Delete(i); } @@ -328,7 +328,7 @@ bool P_AddSectorLinks(sector_t *control, int tag, INTBOOL ceiling, int movetype) if (movetype > 0) { int sec; - FSectorTagIterator itr(tag); + FSectorTagIterator itr(Level->tagManager, tag); while ((sec = itr.Next()) >= 0) { // 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 { - RemoveTaggedSectors(scrollplane, tag); + RemoveTaggedSectors(Level, scrollplane, tag); } 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; auto Level = control->Level; - FLineIdIterator itr(id); + FLineIdIterator itr(Level->tagManager, id); int line; while ((line = itr.Next()) >= 0) { diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 28afd36e66..b854c77404 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -1520,7 +1520,7 @@ FUNC(LS_Thing_Destroy) while (actor) { 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); actor = temp; } @@ -1533,7 +1533,7 @@ FUNC(LS_Thing_Destroy) while (actor) { 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); actor = temp; } @@ -2194,7 +2194,7 @@ FUNC(LS_Sector_ChangeSound) return false; rtn = false; - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); while ((secNum = itr.Next()) >= 0) { Level->sectors[secNum].seqType = arg1; @@ -2213,7 +2213,7 @@ FUNC(LS_Sector_ChangeFlags) return false; rtn = false; - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); // exclude protected flags arg1 &= ~SECF_NOMODIFY; arg2 &= ~SECF_NOMODIFY; @@ -2262,7 +2262,7 @@ FUNC(LS_Sector_SetTranslucent) if (arg0 != 0) { int secnum; - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); while ((secnum = itr.Next()) >= 0) { 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 { - int control = P_FindFirstSectorFromTag(arg0); + int control = Level->tagManager.FindFirstSectorFromTag(arg0); if (control >= 0) { return P_AddSectorLinks(&Level->sectors[control], arg1, arg2, arg3); @@ -2379,7 +2379,7 @@ FUNC(LS_Sector_SetDamage) // problems by adding an unwanted constructor. // Since it doesn't really matter whether the type is translated // here or in P_PlayerInSpecialSector I think it's the best solution. - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -2418,7 +2418,7 @@ FUNC(LS_Sector_SetGravity) arg2 = 99; gravity = (double)arg1 + (double)arg2 * 0.01; - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); int secnum; while ((secnum = itr.Next()) >= 0) Level->sectors[secnum].gravity = gravity; @@ -2429,7 +2429,7 @@ FUNC(LS_Sector_SetGravity) FUNC(LS_Sector_SetColor) // Sector_SetColor (tag, r, g, b, desaturate) { - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -2442,7 +2442,7 @@ FUNC(LS_Sector_SetColor) FUNC(LS_Sector_SetFade) // Sector_SetFade (tag, r, g, b) { - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -2457,7 +2457,7 @@ FUNC(LS_Sector_SetCeilingPanning) double xofs = arg1 + arg2 / 100.; double yofs = arg3 + arg4 / 100.; - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -2473,7 +2473,7 @@ FUNC(LS_Sector_SetFloorPanning) double xofs = arg1 + arg2 / 100.; double yofs = arg3 + arg4 / 100.; - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -2494,7 +2494,7 @@ FUNC(LS_Sector_SetFloorScale) if (yscale) yscale = 1. / yscale; - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -2517,7 +2517,7 @@ FUNC(LS_Sector_SetCeilingScale) if (yscale) yscale = 1. / yscale; - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -2539,7 +2539,7 @@ FUNC(LS_Sector_SetFloorScale2) if (yscale) yscale = 1. / yscale; - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -2561,7 +2561,7 @@ FUNC(LS_Sector_SetCeilingScale2) if (yscale) yscale = 1. / yscale; - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -2579,7 +2579,7 @@ FUNC(LS_Sector_SetRotation) DAngle ceiling = (double)arg2; DAngle floor = (double)arg1; - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -2594,7 +2594,7 @@ FUNC(LS_Line_AlignCeiling) { bool ret = 0; - FLineIdIterator itr(arg0); + FLineIdIterator itr(Level->tagManager, arg0); int line; while ((line = itr.Next()) >= 0) { @@ -2608,7 +2608,7 @@ FUNC(LS_Line_AlignFloor) { bool ret = 0; - FLineIdIterator itr(arg0); + FLineIdIterator itr(Level->tagManager, arg0); int line; while ((line = itr.Next()) >= 0) { @@ -2627,7 +2627,7 @@ FUNC(LS_Line_SetTextureOffset) if (arg0 == 0 || arg3 < 0 || arg3 > 1) return false; - FLineIdIterator itr(arg0); + FLineIdIterator itr(Level->tagManager, arg0); int line; while ((line = itr.Next()) >= 0) { @@ -2682,7 +2682,7 @@ FUNC(LS_Line_SetTextureScale) if (arg0 == 0 || arg3 < 0 || arg3 > 1) return false; - FLineIdIterator itr(arg0); + FLineIdIterator itr(Level->tagManager, arg0); int line; while ((line = itr.Next()) >= 0) { @@ -2756,7 +2756,7 @@ FUNC(LS_Line_SetBlocking) if (arg2 & 1) clearflags |= flagtrans[i]; } - FLineIdIterator itr(arg0); + FLineIdIterator itr(Level->tagManager, arg0); int line; while ((line = itr.Next()) >= 0) { @@ -2788,7 +2788,7 @@ FUNC(LS_Line_SetAutomapFlags) if (arg2 & 1) clearflags |= flagtrans[i]; } - FLineIdIterator itr(arg0); + FLineIdIterator itr(Level->tagManager, arg0); int line; while ((line = itr.Next()) >= 0) { @@ -2803,7 +2803,7 @@ FUNC(LS_Line_SetAutomapStyle) { if (arg1 < AMLS_COUNT && arg1 >= 0) { - FLineIdIterator itr(arg0); + FLineIdIterator itr(Level->tagManager, arg0); int line; while ((line = itr.Next()) >= 0) { @@ -3103,7 +3103,7 @@ FUNC(LS_SetPlayerProperty) FUNC(LS_TranslucentLine) // TranslucentLine (id, amount, type) { - FLineIdIterator itr(arg0); + FLineIdIterator itr(Level->tagManager, arg0); int linenum; while ((linenum = itr.Next()) >= 0) { @@ -3233,7 +3233,7 @@ FUNC(LS_ClearForceField) { bool rtn = false; - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -3409,7 +3409,7 @@ FUNC(LS_Sector_SetPlaneReflection) // Sector_SetPlaneReflection (tag, floor, ceiling) { int secnum; - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); while ((secnum = itr.Next()) >= 0) { @@ -3450,7 +3450,7 @@ FUNC(LS_Sector_SetFloorGlow) int secnum; PalEntry color(arg2, arg3, arg4); if (arg1 < 0) color = -1; // negative height invalidates the glow. - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); while ((secnum = itr.Next()) >= 0) { @@ -3467,7 +3467,7 @@ FUNC(LS_Sector_SetCeilingGlow) int secnum; PalEntry color(arg2, arg3, arg4); if (arg1 < 0) color = -1; // negative height invalidates the glow. - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); while ((secnum = itr.Next()) >= 0) { @@ -3481,7 +3481,7 @@ FUNC(LS_Sector_SetCeilingGlow) FUNC(LS_Line_SetHealth) // Line_SetHealth(id, health) { - FLineIdIterator itr(arg0); + FLineIdIterator itr(Level->tagManager, arg0); int l; if (arg1 < 0) @@ -3500,7 +3500,7 @@ FUNC(LS_Line_SetHealth) FUNC(LS_Sector_SetHealth) // Sector_SetHealth(id, part, health) { - FSectorTagIterator itr(arg0); + FSectorTagIterator itr(Level->tagManager, arg0); int s; if (arg2 < 0) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 7a57c9fc15..7f5aab8124 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3792,7 +3792,7 @@ void AActor::Tick () } else if (scrolltype == Scroll_StrifeCurrent) { // Strife scroll special - int anglespeed = tagManager.GetFirstSectorTag(sec) - 100; + int anglespeed = Level->tagManager.GetFirstSectorTag(sec) - 100; double carryspeed = (anglespeed % 10) / (16 * CARRYFACTOR); DAngle angle = ((anglespeed / 10) * 45.); scrollv += angle.ToVector(carryspeed); diff --git a/src/p_pillar.cpp b/src/p_pillar.cpp index faa7f13dd2..8ec93096ee 100644 --- a/src/p_pillar.cpp +++ b/src/p_pillar.cpp @@ -218,7 +218,7 @@ bool EV_DoPillar (FLevelLocals *Level, DPillar::EPillar type, line_t *line, int bool rtn = false; // 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) { sec = &Level->sectors[secnum]; diff --git a/src/p_plats.cpp b/src/p_plats.cpp index 679bc5ec88..5afd0853b4 100644 --- a/src/p_plats.cpp +++ b/src/p_plats.cpp @@ -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 // of the activating line (if any). - FSectorTagIterator itr(tag, line); + FSectorTagIterator itr(Level->tagManager, tag, line); while ((secnum = itr.Next()) >= 0) { sec = &Level->sectors[secnum]; diff --git a/src/p_pusher.cpp b/src/p_pusher.cpp index ab66114695..f90c0d02e4 100644 --- a/src/p_pusher.cpp +++ b/src/p_pusher.cpp @@ -173,7 +173,7 @@ DPusher::DPusher (DPusher::EPusher type, line_t *l, int magnitude, int angle, AA 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(); else return -1; @@ -368,7 +368,7 @@ void P_SpawnPushers (FLevelLocals *Level) { case Sector_SetWind: // wind { - FSectorTagIterator itr(l->args[0]); + FSectorTagIterator itr(Level->tagManager, l->args[0]); while ((s = itr.Next()) >= 0) Create(DPusher::p_wind, l->args[3] ? l : nullptr, l->args[1], l->args[2], nullptr, &Level->sectors[s]); l->special = 0; @@ -377,7 +377,7 @@ void P_SpawnPushers (FLevelLocals *Level) case Sector_SetCurrent: // current { - FSectorTagIterator itr(l->args[0]); + FSectorTagIterator itr(Level->tagManager, l->args[0]); while ((s = itr.Next()) >= 0) Create(DPusher::p_current, l->args[3] ? l : nullptr, l->args[1], l->args[2], nullptr, &Level->sectors[s]); l->special = 0; @@ -386,7 +386,7 @@ void P_SpawnPushers (FLevelLocals *Level) case PointPush_SetForce: // push/pull 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) { AActor *thing = P_GetPushThing (&Level->sectors[s]); @@ -439,7 +439,7 @@ void AdjustPusher (FLevelLocals *Level, int tag, int magnitude, int angle, bool int secnum; // 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) { unsigned int i; diff --git a/src/p_scroll.cpp b/src/p_scroll.cpp index 45a54f8d3f..fb93ce573e 100644 --- a/src/p_scroll.cpp +++ b/src/p_scroll.cpp @@ -432,7 +432,7 @@ void P_SpawnScrollers(FLevelLocals *Level) if (line.special == Sector_CopyScroller) { // 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()); } @@ -510,7 +510,7 @@ void P_SpawnScrollers(FLevelLocals *Level) case Scroll_Ceiling: { - FSectorTagIterator itr(l->args[0]); + FSectorTagIterator itr(Level->tagManager, l->args[0]); while ((s = itr.Next()) >= 0) { Create(EScroll::sc_ceiling, -dx, dy, control, &Level->sectors[s], nullptr, accel); @@ -530,7 +530,7 @@ void P_SpawnScrollers(FLevelLocals *Level) case Scroll_Floor: if (l->args[2] != 1) { // scroll the floor texture - FSectorTagIterator itr(l->args[0]); + FSectorTagIterator itr(Level->tagManager, l->args[0]); while ((s = itr.Next()) >= 0) { Create (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) { // carry objects on the floor - FSectorTagIterator itr(l->args[0]); + FSectorTagIterator itr(Level->tagManager, l->args[0]); while ((s = itr.Next()) >= 0) { Create (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) case Scroll_Texture_Model: { - FLineIdIterator itr(l->args[0]); + FLineIdIterator itr(Level->tagManager, l->args[0]); while ((s = itr.Next()) >= 0) { if (s != (int)i) @@ -647,7 +647,7 @@ void SetWallScroller (FLevelLocals *Level, int id, int sidechoice, double dx, do { 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 (); } @@ -668,7 +668,7 @@ void SetWallScroller (FLevelLocals *Level, int id, int sidechoice, double dx, do if (wall != nullptr) { 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); Collection.Push(scroll); @@ -681,7 +681,7 @@ void SetWallScroller (FLevelLocals *Level, int id, int sidechoice, double dx, do int linenum; // 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) { 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 (tagManager.SectorHasTag(scroller->GetSector(), tag)) + if (Level->tagManager.SectorHasTag(scroller->GetSector(), tag)) { i++; 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) - FSectorTagIterator itr(tag); + FSectorTagIterator itr(Level->tagManager, tag); while ((i = itr.Next()) >= 0) { Create (type, dx, dy, nullptr, &Level->sectors[i], nullptr, 0); diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 561e902b39..9f3d452239 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -273,6 +273,10 @@ void FLevelLocals::ClearLevelData() } ClearPortals(); + tagManager.Clear(); + + Behaviors.UnloadModules(); + SpotState = nullptr; ACSThinker = nullptr; FraggleScriptThinker = nullptr; @@ -339,9 +343,6 @@ void P_FreeLevelData () level.ClearAllSubsectorLinks(); // can't be done as part of the polyobj deletion process. SN_StopAllSequences (); DThinker::DestroyAllThinkers (); - tagManager.Clear(); - - level.Behaviors.UnloadModules (); P_FreeStrifeConversations (); level.ClearLevelData(); diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 98d6b18fc7..07346bc2fb 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -165,6 +165,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe INTBOOL repeat; INTBOOL buttonSuccess; uint8_t special; + auto Level = line->GetLevel(); 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 (specialGeneric_Crusher) && // not for Boom's generalized linedefs 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) - 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); 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) { - FSectorTagIterator itr(tag); + FSectorTagIterator itr(Level->tagManager, tag); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -733,13 +734,13 @@ DLightTransfer::DLightTransfer (sector_t *srcSec, int target, bool copyFloor) auto Level = Source->Level; if (copyFloor) { - FSectorTagIterator itr(target); + FSectorTagIterator itr(Level->tagManager, target); while ((secnum = itr.Next()) >= 0) Level->sectors[secnum].ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING); } else { - FSectorTagIterator itr(target); + FSectorTagIterator itr(Level->tagManager, target); while ((secnum = itr.Next()) >= 0) 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; if (floor) { - FSectorTagIterator itr(target); + FSectorTagIterator itr(Level->tagManager, target); while ((secnum = itr.Next()) >= 0) Level->sectors[secnum].SetPlaneLight(sector_t::floor, llevel); } else { - FSectorTagIterator itr(target); + FSectorTagIterator itr(Level->tagManager, target); while ((secnum = itr.Next()) >= 0) 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; } - FLineIdIterator itr(target); + FLineIdIterator itr(Level->tagManager, target); auto Level = Source->Level; while ((linenum = itr.Next()) >= 0) { @@ -865,7 +866,7 @@ void DWallLightTransfer::DoTransfer (short lightlevel, int target, uint8_t flags int linenum; auto Level = Source->Level; - FLineIdIterator itr(target); + FLineIdIterator itr(Level->tagManager, target); while ((linenum = itr.Next()) >= 0) { 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) { int s; - FSectorTagIterator itr(sectortag); + FSectorTagIterator itr(Level->tagManager, sectortag); while ((s = itr.Next()) >= 0) { SetPortal(&Level->sectors[s], plane, pnum, alpha); @@ -1020,7 +1021,7 @@ static void CopyPortal(FLevelLocals *Level, int sectortag, int plane, unsigned p } else { - FSectorTagIterator itr(line.args[0]); + FSectorTagIterator itr(Level->tagManager, line.args[0]); while ((s = itr.Next()) >= 0) { SetPortal(&Level->sectors[s], plane, pnum, alpha); @@ -1037,7 +1038,7 @@ static void CopyPortal(FLevelLocals *Level, int sectortag, int plane, unsigned p } else { - FLineIdIterator itr(line.args[0]); + FLineIdIterator itr(Level->tagManager, line.args[0]); while ((s = itr.Next()) >= 0) { Level->lines[s].portaltransferred = pnum; @@ -1350,7 +1351,7 @@ void P_SpawnSpecials (MapLoader *ml) { sec->MoreFlags |= SECMF_NOFAKELIGHT; } - FSectorTagIterator itr(line.args[0]); + FSectorTagIterator itr(Level->tagManager, line.args[0]); while ((s = itr.Next()) >= 0) { Level->sectors[s].heightsec = sec; @@ -1426,7 +1427,7 @@ void P_SpawnSpecials (MapLoader *ml) case Init_Gravity: { double grav = line.Delta().Length() / 100.; - FSectorTagIterator itr(line.args[0]); + FSectorTagIterator itr(Level->tagManager, line.args[0]); while ((s = itr.Next()) >= 0) Level->sectors[s].gravity = grav; } @@ -1438,7 +1439,7 @@ void P_SpawnSpecials (MapLoader *ml) case Init_Damage: { int damage = int(line.Delta().Length()); - FSectorTagIterator itr(line.args[0]); + FSectorTagIterator itr(Level->tagManager, line.args[0]); while ((s = itr.Next()) >= 0) { sector_t *sec = &Level->sectors[s]; @@ -1479,7 +1480,7 @@ void P_SpawnSpecials (MapLoader *ml) case Init_TransferSky: { - FSectorTagIterator itr(line.args[0]); + FSectorTagIterator itr(Level->tagManager, line.args[0]); while ((s = itr.Next()) >= 0) Level->sectors[s].sky = (line.Index() + 1) | PL_SKYFLAT; break; @@ -1587,7 +1588,7 @@ void P_SetSectorFriction (FLevelLocals *Level, int tag, int amount, bool alterFl // higher friction value actually means 'less friction'. movefactor = FrictionToMoveFactor(friction); - FSectorTagIterator itr(tag); + FSectorTagIterator itr(Level->tagManager, tag); while ((s = itr.Next()) >= 0) { // killough 8/28/98: diff --git a/src/p_tags.h b/src/p_tags.h index 23b77ee8d4..cdadfeb5ea 100644 --- a/src/p_tags.h +++ b/src/p_tags.h @@ -68,17 +68,20 @@ public: void RemoveSectorTags(int sect); void DumpTags(); -}; -extern FTagManager tagManager; + int FindFirstSectorFromTag(int tag); + int FindFirstLineFromID(int tag); + +}; class FSectorTagIterator { protected: int searchtag; int start; + FTagManager &tagManager; - FSectorTagIterator() + FSectorTagIterator(FTagManager &manager) : tagManager(manager) { // For DSectorTagIterator } @@ -104,13 +107,13 @@ protected: } public: - FSectorTagIterator(int tag) + FSectorTagIterator(FTagManager &manager, int tag) : tagManager(manager) { Init(tag); } // 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); } @@ -124,9 +127,10 @@ class FLineIdIterator protected: int searchtag; int start; + FTagManager &tagManager; public: - FLineIdIterator(int id) + FLineIdIterator(FTagManager &manager, int id) : tagManager(manager) { searchtag = id; 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(); } -inline int P_FindFirstLineFromID(int tag) +inline int FTagManager::FindFirstLineFromID(int tag) { - FLineIdIterator it(tag); + FLineIdIterator it(*this, tag); return it.Next(); } diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 20b0bddb19..a2ca2790c6 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -255,7 +255,7 @@ static AActor *SelectTeleDest (FLevelLocals *Level, int tid, int tag, bool noran int count = 0; while ( (searcher = iterator.Next ()) ) { - if (tag == 0 || tagManager.SectorHasTag(searcher->Sector, tag)) + if (tag == 0 || Level->tagManager.SectorHasTag(searcher->Sector, tag)) { count++; } @@ -294,7 +294,7 @@ static AActor *SelectTeleDest (FLevelLocals *Level, int tid, int tag, bool noran while (count > 0) { searcher = iterator.Next (); - if (tag == 0 || tagManager.SectorHasTag(searcher->Sector, tag)) + if (tag == 0 || Level->tagManager.SectorHasTag(searcher->Sector, tag)) { count--; } @@ -307,7 +307,7 @@ static AActor *SelectTeleDest (FLevelLocals *Level, int tid, int tag, bool noran { int secnum; - FSectorTagIterator itr(tag); + FSectorTagIterator itr(Level->tagManager, tag); while ((secnum = itr.Next()) >= 0) { // 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) return false; - FLineIdIterator itr(id); + FLineIdIterator itr(Level->tagManager, id); while ((i = itr.Next()) >= 0) { if (line->Index() == i) @@ -720,7 +720,7 @@ bool EV_TeleportSector (FLevelLocals *Level, int tag, int source_tid, int dest_t int secnum; secnum = -1; - FSectorTagIterator itr(tag); + FSectorTagIterator itr(Level->tagManager, tag); while ((secnum = itr.Next()) >= 0) { msecnode_t *node; diff --git a/src/p_xlat.cpp b/src/p_xlat.cpp index 3fb541e3ec..4318015311 100644 --- a/src/p_xlat.cpp +++ b/src/p_xlat.cpp @@ -62,6 +62,7 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid) short tag = mld->tag; uint32_t flags =mld->flags; INTBOOL passthrough = 0; + auto Level = ld->GetLevel(); uint32_t flags1 = flags; 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. // An external conversion program would need to do this more // intelligently. - tagManager.AddLineID(lineindexforid, tag); + Level->tagManager.AddLineID(lineindexforid, tag); } // 0 specials are never translated. diff --git a/src/portal.cpp b/src/portal.cpp index ad0247efe1..eadcca7a7b 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -211,7 +211,7 @@ static line_t *FindDestination(line_t *src, int tag) { int lineno = -1; auto Level = src->GetLevel(); - FLineIdIterator it(tag); + FLineIdIterator it(Level->tagManager, tag); 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. - int mytag = tagManager.GetFirstLineID(line); + int mytag = Level->tagManager.GetFirstLineID(line); 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); FLinePortal *port = &Level->linePortals.Last(); @@ -491,7 +491,7 @@ bool P_ChangePortal(line_t *ln, int thisid, int destid) auto Level = ln->GetLevel(); if (thisid == 0) return ChangePortalLine(ln, destid); - FLineIdIterator it(thisid); + FLineIdIterator it(Level->tagManager, thisid); bool res = false; while ((lineno = it.Next()) >= 0) { diff --git a/src/scripting/vmiterators.cpp b/src/scripting/vmiterators.cpp index 90ac236734..9aea5fa908 100644 --- a/src/scripting/vmiterators.cpp +++ b/src/scripting/vmiterators.cpp @@ -245,7 +245,7 @@ class DSectorTagIterator : public DObject, public FSectorTagIterator { DECLARE_ABSTRACT_CLASS(DSectorTagIterator, DObject); public: - DSectorTagIterator(int tag, line_t *line) + DSectorTagIterator(FTagManager &tagManager, int tag, line_t *line) : FSectorTagIterator(tagManager) { if (line == nullptr) Init(tag); else Init(tag, line); @@ -254,17 +254,17 @@ public: 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(tag, line); + return Create(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_POINTER(line, line_t); - ACTION_RETURN_POINTER(Create(tag, line)); + ACTION_RETURN_POINTER(Create(self->tagManager, tag, line)); } int NextSTI(DSectorTagIterator *self) @@ -301,8 +301,8 @@ class DLineIdIterator : public DObject, public FLineIdIterator { DECLARE_ABSTRACT_CLASS(DLineIdIterator, DObject); public: - DLineIdIterator(int tag) - : FLineIdIterator(tag) + DLineIdIterator(FTagManager &tagManager, int tag) + : FLineIdIterator(tagManager, tag) { } }; @@ -310,16 +310,16 @@ public: IMPLEMENT_CLASS(DLineIdIterator, true, false); -static DLineIdIterator *CreateLTI(int tag) +static DLineIdIterator *CreateLTI(FLevelLocals *Level, int tag) { - return Create(tag); + return Create(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); - ACTION_RETURN_POINTER(Create(tag)); + ACTION_RETURN_POINTER(Create(self->tagManager, tag)); } int NextLTI(DLineIdIterator *self) diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 5c602b9fb6..dac8613cc0 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -723,6 +723,9 @@ struct LevelLocals native 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) { int sec = Thinker.Tics2Seconds(totals? totaltime : time); diff --git a/wadsrc/static/zscript/mapdata.txt b/wadsrc/static/zscript/mapdata.txt index 53a6b4bad7..c7a7a51fdc 100644 --- a/wadsrc/static/zscript/mapdata.txt +++ b/wadsrc/static/zscript/mapdata.txt @@ -531,13 +531,19 @@ struct Sector native play 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 NextCompat(bool compat, int secnum); } 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(); }