diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index d5b6592c2..931f2bc3a 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -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->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); + auto it = Level->GetSectorTagIterator(sectag); while ((i = it.Next()) >= 0) { if (!Level->sectors[i].lightingdata) Create(&Level->sectors[i],destlevel,speed); @@ -2097,7 +2097,7 @@ void FParser::SF_LineTrigger() maplinedef_t mld; mld.special=intvalue(t_argv[0]); mld.tag=t_argc > 1 ? intvalue(t_argv[1]) : 0; - P_TranslateLineDef(&line, &mld); + Level->TranslateLineDef(&line, &mld); P_ExecuteSpecial(line.special, NULL, Script->trigger, false, line.args[0],line.args[1],line.args[2],line.args[3],line.args[4]); } @@ -2157,7 +2157,7 @@ void FParser::SF_SetLineBlocking(void) { blocking=blocks[blocking]; int tag=intvalue(t_argv[0]); - FLineIdIterator itr(tag); + auto itr = Level->GetLineIdIterator(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); + auto itr = Level->GetLineIdIterator(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); + auto itr = Level->GetLineIdIterator(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); + auto itr = Level->GetLineIdIterator(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->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); + auto itr = Level->GetLineIdIterator(id); while ((i = itr.Next()) >= 0) { maplinedef_t mld; @@ -3822,7 +3822,7 @@ void FParser::SF_SetLineTrigger() mld.tag = tag; mld.flags = 0; int f = Level->lines[i].flags; - P_TranslateLineDef(&Level->lines[i], &mld); + Level->TranslateLineDef(&Level->lines[i], &mld); Level->lines[i].flags = (Level->lines[i].flags & (ML_MONSTERSCANACTIVATE | ML_REPEAT_SPECIAL | ML_SPAC_MASK | ML_FIRSTSIDEONLY)) | (f & ~(ML_MONSTERSCANACTIVATE | ML_REPEAT_SPECIAL | ML_SPAC_MASK | ML_FIRSTSIDEONLY)); diff --git a/src/fragglescript/t_script.cpp b/src/fragglescript/t_script.cpp index 9fb156fee..3311184a7 100644 --- a/src/fragglescript/t_script.cpp +++ b/src/fragglescript/t_script.cpp @@ -456,7 +456,7 @@ bool DFraggleThinker::wait_finished(DRunningScript *script) case wt_tagwait: { int secnum; - FSectorTagIterator itr(script->wait_data); + auto itr = level.GetSectorTagIterator(script->wait_data); while ((secnum = itr.Next()) >= 0) { sector_t *sec = &level.sectors[secnum]; diff --git a/src/g_level.h b/src/g_level.h index 5f2275777..1cbd0f463 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -254,7 +254,7 @@ enum ELevelFlags : unsigned int struct FSpecialAction { FName Type; // this is initialized before the actors... - uint8_t Action; + int Action; int Args[5]; }; diff --git a/src/g_levellocals.h b/src/g_levellocals.h index d499c7b5a..c73bb0365 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -117,6 +117,8 @@ struct FLevelLocals : public FLevelData bool CheckIfExitIsGood(AActor *self, level_info_t *newmap); void FormatMapName(FString &mapname, const char *mapnamecolor); void ClearAllSubsectorLinks(); + void TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid = -1); + FSectorTagIterator GetSectorTagIterator(int tag) { return FSectorTagIterator(tag); @@ -154,10 +156,40 @@ struct FLevelLocals : public FLevelData { return tagManager.SectorHasTag(sector, tag); } + int GetFirstSectorTag(const sector_t *sect) const + { + return tagManager.GetFirstSectorTag(sect); + } + int GetFirstSectorTag(int i) const + { + return tagManager.GetFirstSectorTag(i); + } + int GetFirstLineId(const line_t *sect) const + { + return tagManager.GetFirstLineID(sect); + } + bool LineHasId(int line, int tag) { return tagManager.LineHasID(line, tag); } + bool LineHasId(line_t *line, int tag) + { + return tagManager.LineHasID(line, tag); + } + + int FindFirstSectorFromTag(int tag) + { + auto it = GetSectorTagIterator(tag); + return it.Next(); + } + + int FindFirstLineFromID(int tag) + { + auto it = GetLineIdIterator(tag); + return it.Next(); + } + sector_t *PointInSector(const DVector2 &pos) { return P_PointInSector(pos); diff --git a/src/maploader/edata.cpp b/src/maploader/edata.cpp index e35094639..5a6f8547c 100644 --- a/src/maploader/edata.cpp +++ b/src/maploader/edata.cpp @@ -50,7 +50,7 @@ #include "maploader.h" -static void parseLinedef(FScanner &sc, TMap &EDLines) +void MapLoader::parseEDLinedef(FScanner &sc, TMap &EDLines) { EDLinedef ld; bool argsset = false; @@ -159,7 +159,7 @@ static void parseLinedef(FScanner &sc, TMap &EDLines) maplinedef_t mld; mld.special = -ld.special; mld.tag = ld.tag; - P_TranslateLineDef(&line, &mld); + Level->TranslateLineDef(&line, &mld); ld.special = line.special; ld.activation = line.activation; ld.flags = (ld.flags & ~(ML_REPEAT_SPECIAL | ML_FIRSTSIDEONLY)) | (line.flags & (ML_REPEAT_SPECIAL | ML_FIRSTSIDEONLY)); @@ -529,7 +529,7 @@ void MapLoader::InitED() { if (sc.Compare("linedef")) { - parseLinedef(sc, EDLines); + parseEDLinedef(sc, EDLines); } else if (sc.Compare("mapthing")) { diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index 2d8542b4c..1724cdc12 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -1749,7 +1749,7 @@ void MapLoader::LoadLineDefs (MapData * map) mld->special = LittleShort(mld->special); mld->tag = LittleShort(mld->tag); mld->flags = LittleShort(mld->flags); - P_TranslateLineDef (ld, mld, -1); + Level->TranslateLineDef (ld, mld, -1); // do not assign the tag for Extradata lines. if (ld->special != Static_Init || (ld->args[1] != Init_EDLine && ld->args[1] != Init_EDSector)) { @@ -2753,7 +2753,7 @@ 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->GetFirstSectorTag(Index(sector))); // 0 the sector's tag so that no specials can use it tagManager.RemoveSectorTags(i); } @@ -3241,7 +3241,7 @@ void MapLoader::LoadLevel(MapData *map, const char *lumpname, int position) CopySlopes(); // Spawn 3d floors - must be done before spawning things so it can't be done in P_SpawnSpecials - P_Spawn3DFloors(); + Spawn3DFloors(); SpawnThings(position); diff --git a/src/maploader/maploader.h b/src/maploader/maploader.h index 22793a422..884a827a4 100644 --- a/src/maploader/maploader.h +++ b/src/maploader/maploader.h @@ -141,6 +141,7 @@ private: void ProcessEDMapthing(FMapThing *mt, int recordnum); void ProcessEDLinedef(line_t *line, int recordnum); void ProcessEDSector(sector_t *sec, int recordnum); + void parseEDLinedef(FScanner &sc, TMap &EDLines); // Polyobjects void InitSideLists(); @@ -189,6 +190,8 @@ private: void SetupFloorPortal (AActor *point); void SetupCeilingPortal (AActor *point); void TranslateTeleportThings(); + int Set3DFloor(line_t * line, int param, int param2, int alpha); + void Spawn3DFloors (); void SetTexture(side_t *side, int position, const char *name, FMissingTextureTracker &track); void SetTexture(sector_t *sector, int index, int position, const char *name, FMissingTextureTracker &track, bool truncate); diff --git a/src/maploader/slopes.cpp b/src/maploader/slopes.cpp index 86614cc35..cd6100179 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); + auto itr = Level->GetLineIdIterator(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->FindFirstSectorFromTag (tag); if (secnum == -1) { return; diff --git a/src/maploader/udmf.cpp b/src/maploader/udmf.cpp index c574f9ed7..46db16d33 100644 --- a/src/maploader/udmf.cpp +++ b/src/maploader/udmf.cpp @@ -792,7 +792,7 @@ public: mld.flags = 0; mld.special = th->special; mld.tag = th->args[0]; - P_TranslateLineDef(&ld, &mld); + Level->TranslateLineDef(&ld, &mld); th->special = ld.special; memcpy(th->args, ld.args, sizeof (ld.args)); } @@ -1139,7 +1139,7 @@ public: memset(&mld, 0, sizeof(mld)); mld.special = ld->special; mld.tag = ld->args[0]; - P_TranslateLineDef(ld, &mld); + Level->TranslateLineDef(ld, &mld); ld->flags = saved | (ld->flags&(ML_MONSTERSCANACTIVATE|ML_REPEAT_SPECIAL|ML_FIRSTSIDEONLY)); } if (passuse && (ld->activation & SPAC_Use)) diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index b962c612c..4167cce3c 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -46,6 +46,7 @@ #include "p_spec.h" #include "g_levellocals.h" #include "actorinlines.h" +#include "maploader/maploader.h" //========================================================================== // @@ -200,105 +201,6 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag } } -//========================================================================== -// -// Creates all 3D floors defined by one linedef -// -//========================================================================== -static int P_Set3DFloor(line_t * line, int param, int param2, int alpha) -{ - int s; - int flags; - int tag = line->args[0]; - sector_t * sec = line->frontsector, *ss; - - FSectorTagIterator itr(tag); - while ((s = itr.Next()) >= 0) - { - ss = &level.sectors[s]; - - if (param == 0) - { - flags = FF_EXISTS | FF_RENDERALL | FF_SOLID | FF_INVERTSECTOR; - alpha = 255; - for (auto l: sec->Lines) - { - if (l->special == Sector_SetContents && l->frontsector == sec) - { - alpha = clamp(l->args[1], 0, 100); - if (l->args[2] & 1) flags &= ~FF_SOLID; - if (l->args[2] & 2) flags |= FF_SEETHROUGH; - if (l->args[2] & 4) flags |= FF_SHOOTTHROUGH; - if (l->args[2] & 8) flags |= FF_ADDITIVETRANS; - if (alpha != 100) flags |= FF_TRANSLUCENT;//|FF_BOTHPLANES|FF_ALLSIDES; - if (l->args[0]) - { - // Yes, Vavoom's 3D-floor definitions suck! - // The content list changed in r1783 of Vavoom to be unified - // among all its supported games, so it has now ten different - // values instead of just five. - static uint32_t vavoomcolors[] = { VC_EMPTY, - VC_WATER, VC_LAVA, VC_NUKAGE, VC_SLIME, VC_HELLSLIME, - VC_BLOOD, VC_SLUDGE, VC_HAZARD, VC_BOOMWATER }; - flags |= FF_SWIMMABLE | FF_BOTHPLANES | FF_ALLSIDES | FF_FLOOD; - - l->frontsector->Colormap.FadeColor = vavoomcolors[l->args[0]] & VC_COLORMASK; - l->frontsector->Colormap.FogDensity = 0; - } - alpha = (alpha * 255) / 100; - break; - } - } - } - else if (param == 4) - { - flags = FF_EXISTS | FF_RENDERPLANES | FF_INVERTPLANES | FF_NOSHADE | FF_FIX; - if (param2 & 1) flags |= FF_SEETHROUGH; // marker for allowing missing texture checks - alpha = 255; - } - else - { - static const int defflags[] = { 0, - FF_SOLID, - FF_SWIMMABLE | FF_BOTHPLANES | FF_ALLSIDES | FF_SHOOTTHROUGH | FF_SEETHROUGH, - FF_SHOOTTHROUGH | FF_SEETHROUGH, - }; - - flags = defflags[param & 3] | FF_EXISTS | FF_RENDERALL; - - if (param & 4) flags |= FF_ALLSIDES | FF_BOTHPLANES; - if (param & 16) flags ^= FF_SEETHROUGH; - if (param & 32) flags ^= FF_SHOOTTHROUGH; - - if (param2 & 1) flags |= FF_NOSHADE; - if (param2 & 2) flags |= FF_DOUBLESHADOW; - if (param2 & 4) flags |= FF_FOG; - if (param2 & 8) flags |= FF_THINFLOOR; - if (param2 & 16) flags |= FF_UPPERTEXTURE; - if (param2 & 32) flags |= FF_LOWERTEXTURE; - if (param2 & 64) flags |= FF_ADDITIVETRANS | FF_TRANSLUCENT; - // if flooding is used the floor must be non-solid and is automatically made shootthrough and seethrough - if ((param2 & 128) && !(flags & FF_SOLID)) flags |= FF_FLOOD | FF_SEETHROUGH | FF_SHOOTTHROUGH; - if (param2 & 512) flags |= FF_FADEWALLS; - if (param2&1024) flags |= FF_RESET; - FTextureID tex = line->sidedef[0]->GetTexture(side_t::top); - if (!tex.Exists() && alpha < 255) - { - alpha = -tex.GetIndex(); - } - alpha = clamp(alpha, 0, 255); - if (alpha == 0) flags &= ~(FF_RENDERALL | FF_BOTHPLANES | FF_ALLSIDES); - else if (alpha != 255) flags |= FF_TRANSLUCENT; - - } - P_Add3DFloor(ss, sec, line, flags, alpha); - } - // To be 100% safe this should be done even if the alpha by texture value isn't used. - if (!line->sidedef[0]->GetTexture(side_t::top).isValid()) - line->sidedef[0]->SetTexture(side_t::top, FNullTextureID()); - return 1; -} - //========================================================================== // // P_PlayerOnSpecial3DFloor @@ -876,31 +778,129 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li } } +//========================================================================== +// +// Creates all 3D floors defined by one linedef +// +//========================================================================== +int MapLoader::Set3DFloor(line_t * line, int param, int param2, int alpha) +{ + int s; + int flags; + int tag = line->args[0]; + sector_t * sec = line->frontsector, *ss; + + auto itr = Level->GetSectorTagIterator(tag); + while ((s = itr.Next()) >= 0) + { + ss = &Level->sectors[s]; + + if (param == 0) + { + flags = FF_EXISTS | FF_RENDERALL | FF_SOLID | FF_INVERTSECTOR; + alpha = 255; + for (auto l: sec->Lines) + { + if (l->special == Sector_SetContents && l->frontsector == sec) + { + alpha = clamp(l->args[1], 0, 100); + if (l->args[2] & 1) flags &= ~FF_SOLID; + if (l->args[2] & 2) flags |= FF_SEETHROUGH; + if (l->args[2] & 4) flags |= FF_SHOOTTHROUGH; + if (l->args[2] & 8) flags |= FF_ADDITIVETRANS; + if (alpha != 100) flags |= FF_TRANSLUCENT;//|FF_BOTHPLANES|FF_ALLSIDES; + if (l->args[0]) + { + // Yes, Vavoom's 3D-floor definitions suck! + // The content list changed in r1783 of Vavoom to be unified + // among all its supported games, so it has now ten different + // values instead of just five. + static uint32_t vavoomcolors[] = { VC_EMPTY, + VC_WATER, VC_LAVA, VC_NUKAGE, VC_SLIME, VC_HELLSLIME, + VC_BLOOD, VC_SLUDGE, VC_HAZARD, VC_BOOMWATER }; + flags |= FF_SWIMMABLE | FF_BOTHPLANES | FF_ALLSIDES | FF_FLOOD; + + l->frontsector->Colormap.FadeColor = vavoomcolors[l->args[0]] & VC_COLORMASK; + l->frontsector->Colormap.FogDensity = 0; + } + alpha = (alpha * 255) / 100; + break; + } + } + } + else if (param == 4) + { + flags = FF_EXISTS | FF_RENDERPLANES | FF_INVERTPLANES | FF_NOSHADE | FF_FIX; + if (param2 & 1) flags |= FF_SEETHROUGH; // marker for allowing missing texture checks + alpha = 255; + } + else + { + static const int defflags[] = { 0, + FF_SOLID, + FF_SWIMMABLE | FF_BOTHPLANES | FF_ALLSIDES | FF_SHOOTTHROUGH | FF_SEETHROUGH, + FF_SHOOTTHROUGH | FF_SEETHROUGH, + }; + + flags = defflags[param & 3] | FF_EXISTS | FF_RENDERALL; + + if (param & 4) flags |= FF_ALLSIDES | FF_BOTHPLANES; + if (param & 16) flags ^= FF_SEETHROUGH; + if (param & 32) flags ^= FF_SHOOTTHROUGH; + + if (param2 & 1) flags |= FF_NOSHADE; + if (param2 & 2) flags |= FF_DOUBLESHADOW; + if (param2 & 4) flags |= FF_FOG; + if (param2 & 8) flags |= FF_THINFLOOR; + if (param2 & 16) flags |= FF_UPPERTEXTURE; + if (param2 & 32) flags |= FF_LOWERTEXTURE; + if (param2 & 64) flags |= FF_ADDITIVETRANS | FF_TRANSLUCENT; + // if flooding is used the floor must be non-solid and is automatically made shootthrough and seethrough + if ((param2 & 128) && !(flags & FF_SOLID)) flags |= FF_FLOOD | FF_SEETHROUGH | FF_SHOOTTHROUGH; + if (param2 & 512) flags |= FF_FADEWALLS; + if (param2&1024) flags |= FF_RESET; + FTextureID tex = line->sidedef[0]->GetTexture(side_t::top); + if (!tex.Exists() && alpha < 255) + { + alpha = -tex.GetIndex(); + } + alpha = clamp(alpha, 0, 255); + if (alpha == 0) flags &= ~(FF_RENDERALL | FF_BOTHPLANES | FF_ALLSIDES); + else if (alpha != 255) flags |= FF_TRANSLUCENT; + + } + P_Add3DFloor(ss, sec, line, flags, alpha); + } + // To be 100% safe this should be done even if the alpha by texture value isn't used. + if (!line->sidedef[0]->GetTexture(side_t::top).isValid()) + line->sidedef[0]->SetTexture(side_t::top, FNullTextureID()); + return 1; +} //========================================================================== // // Spawns 3D floors // //========================================================================== -void P_Spawn3DFloors (void) +void MapLoader::Spawn3DFloors () { static int flagvals[] = {512, 2+512, 512+1024}; - for (auto &line : level.lines) + for (auto &line : Level->lines) { switch(line.special) { case ExtraFloor_LightOnly: if (line.args[1] < 0 || line.args[1] > 2) line.args[1] = 0; if (line.args[0] != 0) - P_Set3DFloor(&line, 3, flagvals[line.args[1]], 0); + Set3DFloor(&line, 3, flagvals[line.args[1]], 0); break; case Sector_Set3DFloor: // The flag high-byte/line id is only needed in Hexen format. // UDMF can set both of these parameters without any restriction of the usable values. // In Doom format the translators can take full integers for the tag and the line ID always is the same as the tag. - if (level.maptype == MAPTYPE_HEXEN) + if (Level->maptype == MAPTYPE_HEXEN) { if (line.args[1]&8) { @@ -912,7 +912,7 @@ void P_Spawn3DFloors (void) line.args[4]=0; } } - P_Set3DFloor(&line, line.args[1]&~8, line.args[2], line.args[3]); + Set3DFloor(&line, line.args[1]&~8, line.args[2], line.args[3]); break; default: @@ -922,7 +922,7 @@ void P_Spawn3DFloors (void) line.args[0] = line.args[1] = line.args[2] = line.args[3] = line.args[4] = 0; } - for (auto &sec : level.sectors) + for (auto &sec : Level->sectors) { P_Recalculate3DFloors(&sec); } diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index 6b54d6558..81fb56c0e 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -149,7 +149,7 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c if (tag == 0) { - FLineIdIterator itr(lineid); + auto itr = level.GetLineIdIterator(lineid); int line; while ((line = itr.Next()) >= 0) { @@ -165,13 +165,13 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c } else { - FSectorTagIterator it(tag); + auto it = level.GetSectorTagIterator(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.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 ddf02616c..32e4b685d 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -1838,7 +1838,7 @@ DPlaneWatcher::DPlaneWatcher (AActor *it, line_t *line, int lineSide, bool ceili Args[2] = arg2; Args[3] = arg3; Args[4] = arg4; - secnum = P_FindFirstSectorFromTag (tag); + secnum = level.FindFirstSectorFromTag (tag); if (secnum >= 0) { secplane_t plane; @@ -3609,7 +3609,7 @@ do_count: if (actor->health > 0 && (kind == NULL || actor->IsA (kind))) { - if (tag == -1 || tagManager.SectorHasTag(actor->Sector, tag)) + if (tag == -1 || level.SectorHasTag(actor->Sector, tag)) { // Don't count items in somebody's inventory if (actor->IsMapActor()) @@ -3628,7 +3628,7 @@ do_count: if (actor->health > 0 && (kind == NULL || actor->IsA (kind))) { - if (tag == -1 || tagManager.SectorHasTag(actor->Sector, tag)) + if (tag == -1 || level.SectorHasTag(actor->Sector, tag)) { // Don't count items in somebody's inventory if (actor->IsMapActor()) @@ -3664,7 +3664,7 @@ void DLevelScript::ChangeFlat (int tag, int name, bool floorOrCeiling) flat = TexMan.GetTextureID(flatname, ETextureType::Flat, FTextureManager::TEXMAN_Overridable); - FSectorTagIterator it(tag); + auto it = level.GetSectorTagIterator(tag); while ((secnum = it.Next()) >= 0) { int pos = floorOrCeiling? sector_t::ceiling : sector_t::floor; @@ -3696,7 +3696,7 @@ void DLevelScript::SetLineTexture (int lineid, int side, int position, int name) texture = TexMan.GetTextureID(texname, ETextureType::Wall, FTextureManager::TEXMAN_Overridable); - FLineIdIterator itr(lineid); + auto itr = level.GetLineIdIterator(lineid); while ((linenum = itr.Next()) >= 0) { side_t *sidedef; @@ -4802,7 +4802,7 @@ int DLevelScript::SideFromID(int id, int side) } else { - int line = P_FindFirstLineFromID(id); + int line = level.FindFirstLineFromID(id); if (line == -1) return -1; if (level.lines[line].sidedef[side] == NULL) return -1; return level.lines[line].sidedef[side]->UDMFIndex; @@ -4818,7 +4818,7 @@ int DLevelScript::LineFromID(int id) } else { - return P_FindFirstLineFromID(id); + return level.FindFirstLineFromID(id); } } @@ -5304,10 +5304,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.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.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])); @@ -5639,7 +5639,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]); + auto it = level.GetSectorTagIterator(args[0]); int s; while ((s = it.Next()) >= 0) { @@ -6187,7 +6187,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) if (argCount >= 2) { int line; - FLineIdIterator itr(args[0]); + auto itr = level.GetLineIdIterator(args[0]); while ((line = itr.Next()) >= 0) { level.lines[line].activation = args[1]; @@ -6198,7 +6198,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_GetLineActivation: if (argCount > 0) { - int line = P_FindFirstLineFromID(args[0]); + int line = level.FindFirstLineFromID(args[0]); return line >= 0 ? level.lines[line].activation : 0; } break; @@ -6411,7 +6411,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_SetSectorDamage: if (argCount >= 2) { - FSectorTagIterator it(args[0]); + auto it = level.GetSectorTagIterator(args[0]); int s; while ((s = it.Next()) >= 0) { @@ -6431,7 +6431,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]); + auto it = level.GetSectorTagIterator(args[0]); int s; while ((s = it.Next()) >= 0) { @@ -6572,7 +6572,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) float height = float(args[5]); if (args[2] == -1) color = -1; - FSectorTagIterator it(args[0]); + auto it = level.GetSectorTagIterator(args[0]); int s; while ((s = it.Next()) >= 0) { @@ -6584,7 +6584,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_SetFogDensity: { - FSectorTagIterator it(args[0]); + auto it = level.GetSectorTagIterator(args[0]); int s; int d = clamp(args[1]/2, 0, 255); while ((s = it.Next()) >= 0) @@ -6644,7 +6644,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_GetSectorHealth: { int part = args[1]; - FSectorTagIterator it(args[0]); + auto it = level.GetSectorTagIterator(args[0]); int s = it.Next(); if (s < 0) return 0; @@ -6670,7 +6670,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_GetLineHealth: { - FLineIdIterator it(args[0]); + auto it = level.GetLineIdIterator(args[0]); int l = it.Next(); if (l < 0) return 0; @@ -6687,7 +6687,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_GetLineX: case ACSF_GetLineY: { - FLineIdIterator it(args[0]); + auto it = level.GetLineIdIterator(args[0]); int lineno = it.Next(); if (lineno < 0) return 0; DVector2 delta = level.lines[lineno].Delta(); @@ -6803,7 +6803,7 @@ int DLevelScript::RunScript () // state running { int secnum; - FSectorTagIterator it(statedata); + auto it = level.GetSectorTagIterator(statedata); while ((secnum = it.Next()) >= 0) { if (level.sectors[secnum].floordata || level.sectors[secnum].ceilingdata) @@ -8911,7 +8911,7 @@ scriptwait: { int lineno; - FLineIdIterator itr(STACK(2)); + auto itr = level.GetLineIdIterator(STACK(2)); while ((lineno = itr.Next()) >= 0) { auto &line = level.lines[lineno]; @@ -8948,7 +8948,7 @@ scriptwait: { int line; - FLineIdIterator itr(STACK(2)); + auto itr = level.GetLineIdIterator(STACK(2)); while ((line = itr.Next()) >= 0) { if (STACK(1)) @@ -8974,7 +8974,7 @@ scriptwait: arg0 = -FName(level.Behaviors.LookupString(arg0)); } - FLineIdIterator itr(STACK(7)); + auto itr = level.GetLineIdIterator(STACK(7)); while ((linenum = itr.Next()) >= 0) { line_t *line = &level.lines[linenum]; @@ -9450,9 +9450,9 @@ scriptwait: double z = 0; if (tag != 0) - secnum = P_FindFirstSectorFromTag (tag); + secnum = level.FindFirstSectorFromTag (tag); else - secnum = P_PointInSector (x, y)->sectornum; + secnum = level.PointInSector (DVector2(x, y))->sectornum; if (secnum >= 0) { @@ -9472,7 +9472,7 @@ scriptwait: case PCD_GETSECTORLIGHTLEVEL: { - int secnum = P_FindFirstSectorFromTag (STACK(1)); + int secnum = level.FindFirstSectorFromTag (STACK(1)); int z = -1; if (secnum >= 0) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 95e667fa2..546573446 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -3288,7 +3288,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LineEffect) if ((oldjunk.special = special)) // Linedef type { oldjunk.tag = tag; // Sector tag for linedef - P_TranslateLineDef(&junk, &oldjunk); // Turn into native type + level.TranslateLineDef(&junk, &oldjunk); // Turn into native type res = !!P_ExecuteSpecial(junk.special, NULL, self, false, junk.args[0], junk.args[1], junk.args[2], junk.args[3], junk.args[4]); if (res && !(junk.flags & ML_REPEAT_SPECIAL)) // If only once, @@ -4828,7 +4828,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain) } else if (sec->special == Scroll_StrifeCurrent) { - int anglespeed = tagManager.GetFirstSectorTag(sec) - 100; + int anglespeed = level.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 4199ccb64..976cc45b4 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -520,7 +520,7 @@ bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line, } // affects all sectors with the same tag as the linedef - FSectorTagIterator it(tag); + auto it = level.GetSectorTagIterator(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 (int tag, bool remove) bool EV_StopCeiling(int tag, line_t *line) { int sec; - FSectorTagIterator it(tag, line); + auto it = level.GetSectorTagIterator(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 ec38df326..a90b73b31 100644 --- a/src/p_doors.cpp +++ b/src/p_doors.cpp @@ -490,7 +490,7 @@ bool EV_DoDoor (DDoor::EVlDoor type, line_t *line, AActor *thing, else { // [RH] Remote door - FSectorTagIterator it(tag); + auto it = level.GetSectorTagIterator(tag); while ((secnum = it.Next()) >= 0) { sec = &level.sectors[secnum]; @@ -787,7 +787,7 @@ bool EV_SlidingDoor (line_t *line, AActor *actor, int tag, int speed, int delay, return false; } - FSectorTagIterator it(tag); + auto it = level.GetSectorTagIterator(tag); while ((secnum = it.Next()) >= 0) { sec = &level.sectors[secnum]; diff --git a/src/p_floor.cpp b/src/p_floor.cpp index e36a1aca2..cfcfbe4d5 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -532,7 +532,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, bool rtn = false; // check if a manual trigger; if so do just the sector on the backside - FSectorTagIterator it(tag, line); + auto it = level.GetSectorTagIterator(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 (DFloor::EFloor floortype, line_t *line, int tag, bool EV_FloorCrushStop (int tag, line_t *line) { int secnum; - FSectorTagIterator it(tag, line); + auto it = level.GetSectorTagIterator(tag, line); while ((secnum = it.Next()) >= 0) { sector_t *sec = &level.sectors[secnum]; @@ -571,7 +571,7 @@ bool EV_FloorCrushStop (int tag, line_t *line) bool EV_StopFloor(int tag, line_t *line) { int sec; - FSectorTagIterator it(tag, line); + auto it = level.GetSectorTagIterator(tag, line); while ((sec = it.Next()) >= 0) { if (level.sectors[sec].floordata) @@ -619,7 +619,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line, persteptime = int(stairsize / speed); // check if a manual trigger, if so do just the sector on the backside - FSectorTagIterator itr(tag, line); + auto itr = level.GetSectorTagIterator(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 (int tag, line_t *line, double pillarspeed, double slimespeed) rtn = false; - FSectorTagIterator itr(tag, line); + auto itr = level.GetSectorTagIterator(tag, line); while ((secnum = itr.Next()) >= 0) { s1 = &level.sectors[secnum]; // s1 is pillar's sector @@ -1011,7 +1011,7 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype, secnum = -1; rtn = false; - FSectorTagIterator itr(tag, line); + auto itr = level.GetSectorTagIterator(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 (line_t *line, EChange changetype, int tag) rtn = false; // change all sectors with the same tag as the linedef - FSectorTagIterator it(tag); + auto it = level.GetSectorTagIterator(tag); while ((secnum = it.Next()) >= 0) { sec = &level.sectors[secnum]; @@ -1320,7 +1320,7 @@ bool EV_StartWaggle (int tag, line_t *line, int height, int speed, int offset, retCode = false; - FSectorTagIterator itr(tag, line); + auto itr = level.GetSectorTagIterator(tag, line); while ((sectorIndex = itr.Next()) >= 0) { diff --git a/src/p_lights.cpp b/src/p_lights.cpp index 4db7e2ce4..f36fde90c 100644 --- a/src/p_lights.cpp +++ b/src/p_lights.cpp @@ -327,7 +327,7 @@ DFlicker::DFlicker (sector_t *sector, int upper, int lower) void EV_StartLightFlickering (int tag, int upper, int lower) { int secnum; - FSectorTagIterator it(tag); + auto it = level.GetSectorTagIterator(tag); while ((secnum = it.Next()) >= 0) { Create (&level.sectors[secnum], upper, lower); @@ -504,7 +504,7 @@ DStrobe::DStrobe (sector_t *sector, int utics, int ltics, bool inSync) void EV_StartLightStrobing (int tag, int upper, int lower, int utics, int ltics) { int secnum; - FSectorTagIterator it(tag); + auto it = level.GetSectorTagIterator(tag); while ((secnum = it.Next()) >= 0) { sector_t *sec = &level.sectors[secnum]; @@ -518,7 +518,7 @@ void EV_StartLightStrobing (int tag, int upper, int lower, int utics, int ltics) void EV_StartLightStrobing (int tag, int utics, int ltics) { int secnum; - FSectorTagIterator it(tag); + auto it = level.GetSectorTagIterator(tag); while ((secnum = it.Next()) >= 0) { sector_t *sec = &level.sectors[secnum]; @@ -540,7 +540,7 @@ void EV_StartLightStrobing (int tag, int utics, int ltics) void EV_TurnTagLightsOff (int tag) { int secnum; - FSectorTagIterator it(tag); + auto it = level.GetSectorTagIterator(tag); while ((secnum = it.Next()) >= 0) { sector_t *sector = &level.sectors[secnum]; @@ -569,7 +569,7 @@ void EV_TurnTagLightsOff (int tag) void EV_LightTurnOn (int tag, int bright) { int secnum; - FSectorTagIterator it(tag); + auto it = level.GetSectorTagIterator(tag); while ((secnum = it.Next()) >= 0) { sector_t *sector = &level.sectors[secnum]; @@ -622,7 +622,7 @@ void EV_LightTurnOnPartway (int tag, double frac) // Search all sectors for ones with same tag as activating line int secnum; - FSectorTagIterator it(tag); + auto it = level.GetSectorTagIterator(tag); while ((secnum = it.Next()) >= 0) { sector_t *temp, *sector = &level.sectors[secnum]; @@ -658,7 +658,7 @@ void EV_LightTurnOnPartway (int tag, double frac) void EV_LightChange (int tag, int value) { int secnum; - FSectorTagIterator it(tag); + auto it = level.GetSectorTagIterator(tag); while ((secnum = it.Next()) >= 0) { level.sectors[secnum].SetLightLevel(level.sectors[secnum].lightlevel + value); @@ -824,7 +824,7 @@ void EV_StartLightGlowing (int tag, int upper, int lower, int tics) lower = temp; } - FSectorTagIterator it(tag); + auto it = level.GetSectorTagIterator(tag); while ((secnum = it.Next()) >= 0) { sector_t *sec = &level.sectors[secnum]; @@ -844,7 +844,7 @@ void EV_StartLightGlowing (int tag, int upper, int lower, int tics) void EV_StartLightFading (int tag, int value, int tics) { int secnum; - FSectorTagIterator it(tag); + auto it = level.GetSectorTagIterator(tag); while ((secnum = it.Next()) >= 0) { sector_t *sec = &level.sectors[secnum]; @@ -990,7 +990,7 @@ void EV_StopLightEffect (int tag) while ((effect = iterator.Next()) != NULL) { - if (tagManager.SectorHasTag(effect->GetSector(), tag)) + if (level.SectorHasTag(effect->GetSector(), tag)) { effect->Destroy(); } diff --git a/src/p_linkedsectors.cpp b/src/p_linkedsectors.cpp index 11e520a0d..f50c68b60 100644 --- a/src/p_linkedsectors.cpp +++ b/src/p_linkedsectors.cpp @@ -288,7 +288,7 @@ static void RemoveTaggedSectors(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.SectorHasTag(scrollplane.Sectors[i].Sector, tag)) { scrollplane.Sectors.Delete(i); } @@ -327,7 +327,7 @@ bool P_AddSectorLinks(sector_t *control, int tag, INTBOOL ceiling, int movetype) if (movetype > 0) { int sec; - FSectorTagIterator itr(tag); + auto itr = level.GetSectorTagIterator(tag); while ((sec = itr.Next()) >= 0) { // Don't attach to self (but allow attaching to this sector's oposite plane. @@ -360,7 +360,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; - FLineIdIterator itr(id); + auto itr = level.GetLineIdIterator(id); int line; while ((line = itr.Next()) >= 0) { diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 395ea2c1f..cfdf283a9 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->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->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); + auto itr = Level->GetSectorTagIterator(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); + auto itr = Level->GetSectorTagIterator(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); + auto itr = Level->GetSectorTagIterator(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.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); + auto itr = Level->GetSectorTagIterator(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); + auto itr = Level->GetSectorTagIterator(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); + auto itr = Level->GetSectorTagIterator(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); + auto itr = Level->GetSectorTagIterator(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); + auto itr = Level->GetSectorTagIterator(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); + auto itr = Level->GetSectorTagIterator(arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -2494,7 +2494,7 @@ FUNC(LS_Sector_SetFloorScale) if (yscale) yscale = 1. / yscale; - FSectorTagIterator itr(arg0); + auto itr = Level->GetSectorTagIterator(arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -2517,7 +2517,7 @@ FUNC(LS_Sector_SetCeilingScale) if (yscale) yscale = 1. / yscale; - FSectorTagIterator itr(arg0); + auto itr = Level->GetSectorTagIterator(arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -2539,7 +2539,7 @@ FUNC(LS_Sector_SetFloorScale2) if (yscale) yscale = 1. / yscale; - FSectorTagIterator itr(arg0); + auto itr = Level->GetSectorTagIterator(arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -2561,7 +2561,7 @@ FUNC(LS_Sector_SetCeilingScale2) if (yscale) yscale = 1. / yscale; - FSectorTagIterator itr(arg0); + auto itr = Level->GetSectorTagIterator(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); + auto itr = Level->GetSectorTagIterator(arg0); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -2594,7 +2594,7 @@ FUNC(LS_Line_AlignCeiling) { bool ret = 0; - FLineIdIterator itr(arg0); + auto itr = Level->GetLineIdIterator(arg0); int line; while ((line = itr.Next()) >= 0) { @@ -2608,7 +2608,7 @@ FUNC(LS_Line_AlignFloor) { bool ret = 0; - FLineIdIterator itr(arg0); + auto itr = Level->GetLineIdIterator(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); + auto itr = Level->GetLineIdIterator(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); + auto itr = Level->GetLineIdIterator(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); + auto itr = Level->GetLineIdIterator(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); + auto itr = Level->GetLineIdIterator(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); + auto itr = Level->GetLineIdIterator(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); + auto itr = Level->GetLineIdIterator(arg0); int linenum; while ((linenum = itr.Next()) >= 0) { @@ -3233,7 +3233,7 @@ FUNC(LS_ClearForceField) { bool rtn = false; - FSectorTagIterator itr(arg0); + auto itr = Level->GetSectorTagIterator(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); + auto itr = Level->GetSectorTagIterator(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); + auto itr = Level->GetSectorTagIterator(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); + auto itr = Level->GetSectorTagIterator(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); + auto itr = Level->GetLineIdIterator(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); + auto itr = Level->GetSectorTagIterator(arg0); int s; if (arg2 < 0) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index feac7212c..cb8fc943d 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3776,7 +3776,7 @@ void AActor::Tick () } else if (scrolltype == Scroll_StrifeCurrent) { // Strife scroll special - int anglespeed = tagManager.GetFirstSectorTag(sec) - 100; + int anglespeed = level.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 8503c1d7e..5c3453b4f 100644 --- a/src/p_pillar.cpp +++ b/src/p_pillar.cpp @@ -218,7 +218,7 @@ bool EV_DoPillar (DPillar::EPillar type, line_t *line, int tag, bool rtn = false; // check if a manual trigger; if so do just the sector on the backside - FSectorTagIterator itr(tag, line); + auto itr = level.GetSectorTagIterator(tag, line); while ((secnum = itr.Next()) >= 0) { sec = &level.sectors[secnum]; diff --git a/src/p_plats.cpp b/src/p_plats.cpp index 183f759b8..e368fcaa5 100644 --- a/src/p_plats.cpp +++ b/src/p_plats.cpp @@ -244,7 +244,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height, // [RH] If tag is zero, use the sector on the back side // of the activating line (if any). - FSectorTagIterator itr(tag, line); + auto itr = level.GetSectorTagIterator(tag, line); while ((secnum = itr.Next()) >= 0) { sec = &level.sectors[secnum]; diff --git a/src/p_pusher.cpp b/src/p_pusher.cpp index b920cb99d..bbe135bd1 100644 --- a/src/p_pusher.cpp +++ b/src/p_pusher.cpp @@ -175,7 +175,7 @@ DPusher::DPusher (DPusher::EPusher type, line_t *l, int magnitude, int angle, int DPusher::CheckForSectorMatch (EPusher type, int tag) { - if (m_Type == type && tagManager.SectorHasTag(m_Affectee, tag)) + if (m_Type == type && level.SectorHasTag(m_Affectee, tag)) return m_Affectee; else return -1; @@ -444,7 +444,7 @@ void AdjustPusher (int tag, int magnitude, int angle, bool wind) int secnum; // Now create pushers for any sectors that don't already have them. - FSectorTagIterator itr(tag); + auto itr = level.GetSectorTagIterator(tag); while ((secnum = itr.Next()) >= 0) { unsigned int i; diff --git a/src/p_scroll.cpp b/src/p_scroll.cpp index edb97cec0..5e24b09d2 100644 --- a/src/p_scroll.cpp +++ b/src/p_scroll.cpp @@ -648,7 +648,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->LineHasId(wall->linedef, id) && wall->linedef->sidedef[sidechoice] == wall && Where == scroller->GetScrollParts()) { scroller->Destroy (); } @@ -669,7 +669,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->LineHasId(line, id) && line->sidedef[sidechoice] == wall && Where == scroll->GetScrollParts()) { scroll->SetRate(dx, dy); Collection.Push(scroll); @@ -682,7 +682,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); + auto itr = Level->GetLineIdIterator(id); while ((linenum = itr.Next()) >= 0) { side_t *side = Level->lines[linenum].sidedef[sidechoice]; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 1d181be2b..295cdcb63 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -275,6 +275,7 @@ void FLevelLocals::ClearLevelData() } ClearPortals(); + tagManager.Clear(); SpotState = nullptr; ACSThinker = nullptr; FraggleScriptThinker = nullptr; @@ -341,7 +342,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 (); diff --git a/src/p_setup.h b/src/p_setup.h index 1cd67c2ad..a85801a32 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -157,7 +157,6 @@ struct line_t; struct maplinedef_t; void P_LoadTranslator(const char *lumpname); -void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid = -1); int P_TranslateSectorSpecial (int); int GetUDMFInt(int type, int index, FName key); diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 80191b01d..0611627c8 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -201,9 +201,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.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.FindFirstSectorFromTag (line->args[0]) == -1) // only if no sector is tagged to this linedef { P_ChangeSwitchTexture (line->sidedef[0], repeat, special); line->special = 0; @@ -516,7 +516,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); + auto itr = Level->GetSectorTagIterator(tag); int secnum; while ((secnum = itr.Next()) >= 0) { @@ -751,13 +751,13 @@ DLightTransfer::DLightTransfer (sector_t *srcSec, int target, bool copyFloor) auto Level = &level; if (copyFloor) { - FSectorTagIterator itr(target); + auto itr = Level->GetSectorTagIterator(target); while ((secnum = itr.Next()) >= 0) Level->sectors[secnum].ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING); } else { - FSectorTagIterator itr(target); + auto itr = Level->GetSectorTagIterator(target); while ((secnum = itr.Next()) >= 0) Level->sectors[secnum].ChangeFlags(sector_t::ceiling, 0, PLANEF_ABSLIGHTING); } @@ -782,13 +782,13 @@ void DLightTransfer::DoTransfer (int llevel, int target, bool floor) auto Level = &level; if (floor) { - FSectorTagIterator itr(target); + auto itr = Level->GetSectorTagIterator(target); while ((secnum = itr.Next()) >= 0) Level->sectors[secnum].SetPlaneLight(sector_t::floor, llevel); } else { - FSectorTagIterator itr(target); + auto itr = Level->GetSectorTagIterator(target); while ((secnum = itr.Next()) >= 0) Level->sectors[secnum].SetPlaneLight(sector_t::ceiling, llevel); } @@ -850,8 +850,8 @@ DWallLightTransfer::DWallLightTransfer (sector_t *srcSec, int target, uint8_t fl wallflags = WALLF_ABSLIGHTING | WALLF_NOFAKECONTRAST; } - FLineIdIterator itr(target); auto Level = &level; + auto itr = Level->GetLineIdIterator(target); while ((linenum = itr.Next()) >= 0) { if (flags & WLF_SIDE1 && Level->lines[linenum].sidedef[0] != NULL) @@ -883,7 +883,7 @@ void DWallLightTransfer::DoTransfer (short lightlevel, int target, uint8_t flags int linenum; auto Level = &level; - FLineIdIterator itr(target); + auto itr = Level->GetLineIdIterator(target); while ((linenum = itr.Next()) >= 0) { line_t *line = &Level->lines[linenum]; diff --git a/src/p_tags.cpp b/src/p_tags.cpp index 654f0bb40..ab521520c 100644 --- a/src/p_tags.cpp +++ b/src/p_tags.cpp @@ -371,7 +371,7 @@ int FSectorTagIterator::NextCompat(bool compat, int start) for (unsigned i = start + 1; i < level.sectors.Size(); i++) { - if (tagManager.SectorHasTag(i, searchtag)) return i; + if (level.SectorHasTag(i, searchtag)) return i; } return -1; } diff --git a/src/p_tags.h b/src/p_tags.h index 8ce6b3568..f99353d8e 100644 --- a/src/p_tags.h +++ b/src/p_tags.h @@ -13,6 +13,7 @@ struct FTagItem class FSectorTagIterator; class FLineIdIterator; +struct FLevelLocals; class FTagManager { @@ -21,8 +22,12 @@ class FTagManager TAG_HASH_SIZE = 256 }; + // Only the iterators and the map loader, including its helpers may access this. Everything else should go through FLevelLocals's interface. friend class FSectorTagIterator; friend class FLineIdIterator; + friend class MapLoader; + friend struct FLevelLocals; + friend class UDMFParser; TArray allTags; TArray allIDs; @@ -41,7 +46,6 @@ class FTagManager return sect >= 0 && sect < (int)startForLine.Size() && startForLine[sect] >= 0; } -public: void Clear() { allTags.Clear(); @@ -63,6 +67,7 @@ public: bool LineHasID(const line_t *line, int id) const; void HashTags(); +public: // The ones below are called by functions that cannot be declared as friend. void AddSectorTag(int sector, int tag); void AddLineID(int line, int tag); void RemoveSectorTags(int sect); @@ -75,6 +80,7 @@ extern FTagManager tagManager; class FSectorTagIterator { + friend struct FLevelLocals; protected: int searchtag; int start; @@ -104,7 +110,6 @@ protected: } } -public: FSectorTagIterator(int tag) { Init(tag); @@ -115,38 +120,27 @@ public: { Init(tag, line); } - +public: int Next(); int NextCompat(bool compat, int secnum); }; class FLineIdIterator { + friend struct FLevelLocals; protected: int searchtag; int start; -public: FLineIdIterator(int id) { searchtag = id; start = tagManager.IDHashFirst[((unsigned int)id) % FTagManager::TAG_HASH_SIZE]; } +public: int Next(); }; -inline int P_FindFirstSectorFromTag(int tag) -{ - FSectorTagIterator it(tag); - return it.Next(); -} - -inline int P_FindFirstLineFromID(int tag) -{ - FLineIdIterator it(tag); - return it.Next(); -} - #endif diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 2dfc754ab..783834c25 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -254,7 +254,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom) int count = 0; while ( (searcher = iterator.Next ()) ) { - if (tag == 0 || tagManager.SectorHasTag(searcher->Sector, tag)) + if (tag == 0 || level.SectorHasTag(searcher->Sector, tag)) { count++; } @@ -293,7 +293,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom) while (count > 0) { searcher = iterator.Next (); - if (tag == 0 || tagManager.SectorHasTag(searcher->Sector, tag)) + if (tag == 0 || level.SectorHasTag(searcher->Sector, tag)) { count--; } @@ -306,7 +306,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom) { int secnum; - FSectorTagIterator itr(tag); + auto itr = level.GetSectorTagIterator(tag); while ((secnum = itr.Next()) >= 0) { // Scanning the snext links of things in the sector will not work, because @@ -430,7 +430,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); + auto itr = level.GetLineIdIterator(id); while ((i = itr.Next()) >= 0) { if (line->Index() == i) @@ -718,7 +718,7 @@ bool EV_TeleportSector (int tag, int source_tid, int dest_tid, bool fog, int gro int secnum; secnum = -1; - FSectorTagIterator itr(tag); + auto itr = level.GetSectorTagIterator(tag); while ((secnum = itr.Next()) >= 0) { msecnode_t *node; diff --git a/src/p_xlat.cpp b/src/p_xlat.cpp index b2e908f3c..963cff272 100644 --- a/src/p_xlat.cpp +++ b/src/p_xlat.cpp @@ -56,7 +56,7 @@ typedef enum PushMany, } triggertype_e; -void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid) +void FLevelLocals::TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid) { uint32_t special = mld->special; short tag = mld->tag; diff --git a/src/portal.cpp b/src/portal.cpp index b8cf9a0e5..434cc7320 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -208,7 +208,7 @@ static line_t *FindDestination(line_t *src, int tag) if (tag) { int lineno = -1; - FLineIdIterator it(tag); + auto it = level.GetLineIdIterator(tag); while ((lineno = it.Next()) >= 0) { @@ -305,11 +305,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.GetFirstLineId(line); for (auto &ln : level.lines) { - if (tagManager.GetFirstLineID(&ln) == mytag && ln.args[0] == 1 && ln.special == Line_SetPortal) + if (level.GetFirstLineId(&ln) == mytag && ln.args[0] == 1 && ln.special == Line_SetPortal) { line->portalindex = level.linePortals.Reserve(1); FLinePortal *port = &level.linePortals.Last(); @@ -483,7 +483,7 @@ bool P_ChangePortal(line_t *ln, int thisid, int destid) int lineno; if (thisid == 0) return ChangePortalLine(ln, destid); - FLineIdIterator it(thisid); + auto it = level.GetLineIdIterator(thisid); bool res = false; while ((lineno = it.Next()) >= 0) { diff --git a/src/umapinfo.cpp b/src/umapinfo.cpp index 3c1517632..eccace0d6 100644 --- a/src/umapinfo.cpp +++ b/src/umapinfo.cpp @@ -271,6 +271,7 @@ static int ParseStandardProperty(FScanner &scanner, UMapEntry *mape) scanner.MustGetValue(false); int tag = scanner.Number; // allow no 0-tag specials here, unless a level exit. +#pragma message("Fixme: This needs to be evaluated at run time") if (tag != 0 || special == 11 || special == 51 || special == 52 || special == 124) { FSpecialAction & bossact = mape->BossActions[mape->BossActions.Reserve(1)]; @@ -278,7 +279,7 @@ static int ParseStandardProperty(FScanner &scanner, UMapEntry *mape) maplinedef_t mld; mld.special = special; mld.tag = tag; - P_TranslateLineDef(&line, &mld); + //level.TranslateLineDef(&line, &mld); bossact = { type, (uint8_t)line.special, {line.args[0], line.args[1],line.args[2],line.args[3],line.args[4]} }; } } @@ -473,4 +474,4 @@ void CommitUMapinfo(level_info_t *defaultinfo) // All done. If we get here again, start fresh. Maps.Clear(); Maps.ShrinkToFit(); -} \ No newline at end of file +}