Handle level in block iterators.

The scripted interface isn't done yet.
This commit is contained in:
Christoph Oelckers 2019-01-29 03:26:22 +01:00
parent 7d3cd53c7e
commit de1b89707d
13 changed files with 88 additions and 81 deletions

View file

@ -3712,7 +3712,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RadiusGive)
{ {
FPortalGroupArray check(FPortalGroupArray::PGA_Full3d); FPortalGroupArray check(FPortalGroupArray::PGA_Full3d);
double mid = self->Center(); double mid = self->Center();
FMultiBlockThingsIterator it(check, self->X(), self->Y(), mid-distance, mid+distance, distance, false, self->Sector); FMultiBlockThingsIterator it(check, self->Level, self->X(), self->Y(), mid-distance, mid+distance, distance, false, self->Sector);
FMultiBlockThingsIterator::CheckResult cres; FMultiBlockThingsIterator::CheckResult cres;
while ((it.Next(&cres)) && ((unlimited) || (given < limit))) while ((it.Next(&cres)) && ((unlimited) || (given < limit)))

View file

@ -520,7 +520,7 @@ void P_GeometryRadiusAttack(AActor* bombspot, AActor* bombsource, int bombdamage
// enumerate all lines around // enumerate all lines around
FBoundingBox bombbox(bombspot->X(), bombspot->Y(), bombdistance); FBoundingBox bombbox(bombspot->X(), bombspot->Y(), bombdistance);
FBlockLinesIterator it(bombbox); FBlockLinesIterator it(bombspot->Level, bombbox);
line_t* ln; line_t* ln;
int vc = validcount; int vc = validcount;
TArray<line_t*> lines; TArray<line_t*> lines;

View file

@ -867,7 +867,7 @@ void P_NewChaseDir(AActor * actor)
!(actor->flags & MF_FLOAT) && !(i_compatflags & COMPATF_DROPOFF)) !(actor->flags & MF_FLOAT) && !(i_compatflags & COMPATF_DROPOFF))
{ {
FBoundingBox box(actor->X(), actor->Y(), actor->radius); FBoundingBox box(actor->X(), actor->Y(), actor->radius);
FBlockLinesIterator it(box); FBlockLinesIterator it(actor->Level, box);
line_t *line; line_t *line;
double deltax = 0; double deltax = 0;
@ -2627,7 +2627,7 @@ bool P_CheckForResurrection(AActor *self, bool usevilestates)
FPortalGroupArray check(FPortalGroupArray::PGA_Full3d); FPortalGroupArray check(FPortalGroupArray::PGA_Full3d);
FMultiBlockThingsIterator it(check, viletry.X, viletry.Y, self->Z() - 64, self->Top() + 64, 32., false, NULL); FMultiBlockThingsIterator it(check, self->Level, viletry.X, viletry.Y, self->Z() - 64, self->Top() + 64, 32., false, NULL);
FMultiBlockThingsIterator::CheckResult cres; FMultiBlockThingsIterator::CheckResult cres;
while (it.Next(&cres)) while (it.Next(&cres))
{ {

View file

@ -421,7 +421,7 @@ bool P_TeleportMove(AActor* thing, const DVector3 &pos, bool telefrag, bool modi
sector_t *sector = thing->Level->PointInSector(pos); sector_t *sector = thing->Level->PointInSector(pos);
FPortalGroupArray grouplist; FPortalGroupArray grouplist;
FMultiBlockLinesIterator mit(grouplist, pos.X, pos.Y, pos.Z, thing->Height, thing->radius, sector); FMultiBlockLinesIterator mit(grouplist, thing->Level, pos.X, pos.Y, pos.Z, thing->Height, thing->radius, sector);
FMultiBlockLinesIterator::CheckResult cres; FMultiBlockLinesIterator::CheckResult cres;
while (mit.Next(&cres)) while (mit.Next(&cres))
@ -432,7 +432,7 @@ bool P_TeleportMove(AActor* thing, const DVector3 &pos, bool telefrag, bool modi
if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz; if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz;
FMultiBlockThingsIterator mit2(grouplist, pos.X, pos.Y, pos.Z, thing->Height, thing->radius, false, sector); FMultiBlockThingsIterator mit2(grouplist, thing->Level, pos.X, pos.Y, pos.Z, thing->Height, thing->radius, false, sector);
FMultiBlockThingsIterator::CheckResult cres2; FMultiBlockThingsIterator::CheckResult cres2;
while (mit2.Next(&cres2)) while (mit2.Next(&cres2))
@ -1082,7 +1082,7 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera
tm.thing->AddZ(zofs); tm.thing->AddZ(zofs);
FBoundingBox pbox(cres.Position.X, cres.Position.Y, tm.thing->radius); FBoundingBox pbox(cres.Position.X, cres.Position.Y, tm.thing->radius);
FBlockLinesIterator it(pbox); FBlockLinesIterator it(tm.thing->Level, pbox);
bool ret = false; bool ret = false;
line_t *ld; line_t *ld;
@ -1750,7 +1750,7 @@ bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, boo
FBoundingBox box(pos.X, pos.Y, thing->radius); FBoundingBox box(pos.X, pos.Y, thing->radius);
FPortalGroupArray pcheck; FPortalGroupArray pcheck;
FMultiBlockThingsIterator it2(pcheck, pos.X, pos.Y, thing->Z(), thing->Height, thing->radius, false, newsec); FMultiBlockThingsIterator it2(pcheck, thing->Level, pos.X, pos.Y, thing->Z(), thing->Height, thing->radius, false, newsec);
FMultiBlockThingsIterator::CheckResult tcres; FMultiBlockThingsIterator::CheckResult tcres;
while ((it2.Next(&tcres))) while ((it2.Next(&tcres)))
@ -1822,7 +1822,7 @@ bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, boo
return (thing->BlockingMobj = thingblocker) == NULL; return (thing->BlockingMobj = thingblocker) == NULL;
FMultiBlockLinesIterator it(pcheck, pos.X, pos.Y, thing->Z(), thing->Height, thing->radius, newsec); FMultiBlockLinesIterator it(pcheck, thing->Level, pos.X, pos.Y, thing->Z(), thing->Height, thing->radius, newsec);
FMultiBlockLinesIterator::CheckResult lcres; FMultiBlockLinesIterator::CheckResult lcres;
double thingdropoffz = tm.floorz; double thingdropoffz = tm.floorz;
@ -5836,7 +5836,7 @@ int P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bom
fulldamagedistance = clamp<int>(fulldamagedistance, 0, bombdistance - 1); fulldamagedistance = clamp<int>(fulldamagedistance, 0, bombdistance - 1);
FPortalGroupArray grouplist(FPortalGroupArray::PGA_Full3d); FPortalGroupArray grouplist(FPortalGroupArray::PGA_Full3d);
FMultiBlockThingsIterator it(grouplist, bombspot->X(), bombspot->Y(), bombspot->Z() - bombdistance, bombspot->Height + bombdistance*2, bombdistance, false, bombspot->Sector); FMultiBlockThingsIterator it(grouplist, bombspot->Level, bombspot->X(), bombspot->Y(), bombspot->Z() - bombdistance, bombspot->Height + bombdistance*2, bombdistance, false, bombspot->Sector);
FMultiBlockThingsIterator::CheckResult cres; FMultiBlockThingsIterator::CheckResult cres;
if (flags & RADF_SOURCEISSPOT) if (flags & RADF_SOURCEISSPOT)

View file

@ -581,9 +581,10 @@ void AActor::SetOrigin(double x, double y, double z, bool moving)
// //
//=========================================================================== //===========================================================================
FBlockLinesIterator::FBlockLinesIterator(int _minx, int _miny, int _maxx, int _maxy, bool keepvalidcount) FBlockLinesIterator::FBlockLinesIterator(FLevelLocals *l, int _minx, int _miny, int _maxx, int _maxy, bool keepvalidcount)
{ {
if (!keepvalidcount) validcount++; if (!keepvalidcount) validcount++;
Level = l;
minx = _minx; minx = _minx;
maxx = _maxx; maxx = _maxx;
miny = _miny; miny = _miny;
@ -594,15 +595,16 @@ FBlockLinesIterator::FBlockLinesIterator(int _minx, int _miny, int _maxx, int _m
void FBlockLinesIterator::init(const FBoundingBox &box) void FBlockLinesIterator::init(const FBoundingBox &box)
{ {
validcount++; validcount++;
maxy = level.blockmap.GetBlockY(box.Top()); maxy = Level->blockmap.GetBlockY(box.Top());
miny = level.blockmap.GetBlockY(box.Bottom()); miny = Level->blockmap.GetBlockY(box.Bottom());
maxx = level.blockmap.GetBlockX(box.Right()); maxx = Level->blockmap.GetBlockX(box.Right());
minx = level.blockmap.GetBlockX(box.Left()); minx = Level->blockmap.GetBlockX(box.Left());
Reset(); Reset();
} }
FBlockLinesIterator::FBlockLinesIterator(const FBoundingBox &box) FBlockLinesIterator::FBlockLinesIterator(FLevelLocals *l, const FBoundingBox &box)
{ {
Level = l;
init(box); init(box);
} }
@ -616,13 +618,13 @@ void FBlockLinesIterator::StartBlock(int x, int y)
{ {
curx = x; curx = x;
cury = y; cury = y;
if (level.blockmap.isValidBlock(x, y)) if (Level->blockmap.isValidBlock(x, y))
{ {
unsigned offset = y*level.blockmap.bmapwidth + x; unsigned offset = y*Level->blockmap.bmapwidth + x;
polyLink = level.PolyBlockMap.Size() > offset? level.PolyBlockMap[offset] : nullptr; polyLink = Level->PolyBlockMap.Size() > offset? Level->PolyBlockMap[offset] : nullptr;
polyIndex = 0; polyIndex = 0;
list = level.blockmap.GetLines(x, y); list = Level->blockmap.GetLines(x, y);
} }
else else
{ {
@ -681,7 +683,7 @@ line_t *FBlockLinesIterator::Next()
{ {
while (*list != -1) while (*list != -1)
{ {
line_t *ld = &level.lines[*list]; line_t *ld = &Level->lines[*list];
list++; list++;
if (ld->validcount != validcount) if (ld->validcount != validcount)
@ -710,24 +712,24 @@ line_t *FBlockLinesIterator::Next()
//=========================================================================== //===========================================================================
FMultiBlockLinesIterator::FMultiBlockLinesIterator(FPortalGroupArray &check, AActor *origin, double checkradius) FMultiBlockLinesIterator::FMultiBlockLinesIterator(FPortalGroupArray &check, AActor *origin, double checkradius)
: checklist(check) : checklist(check), blockIterator(origin->Level)
{ {
checkpoint = origin->Pos(); checkpoint = origin->Pos();
if (!check.inited) level.CollectConnectedGroups(origin->Sector->PortalGroup, checkpoint, origin->Top(), checkradius, checklist); if (!check.inited) origin->Level->CollectConnectedGroups(origin->Sector->PortalGroup, checkpoint, origin->Top(), checkradius, checklist);
checkpoint.Z = checkradius == -1? origin->radius : checkradius; checkpoint.Z = checkradius == -1? origin->radius : checkradius;
basegroup = origin->Sector->PortalGroup; basegroup = origin->Sector->PortalGroup;
startsector = origin->Sector; startsector = origin->Sector;
Reset(); Reset();
} }
FMultiBlockLinesIterator::FMultiBlockLinesIterator(FPortalGroupArray &check, double checkx, double checky, double checkz, double checkh, double checkradius, sector_t *newsec) FMultiBlockLinesIterator::FMultiBlockLinesIterator(FPortalGroupArray &check, FLevelLocals *Level, double checkx, double checky, double checkz, double checkh, double checkradius, sector_t *newsec)
: checklist(check) : checklist(check), blockIterator(Level)
{ {
checkpoint = { checkx, checky, checkz }; checkpoint = { checkx, checky, checkz };
if (newsec == NULL) newsec = level.PointInSector(checkx, checky); if (newsec == NULL) newsec = Level->PointInSector(checkx, checky);
startsector = newsec; startsector = newsec;
basegroup = newsec->PortalGroup; basegroup = newsec->PortalGroup;
if (!check.inited) level.CollectConnectedGroups(basegroup, checkpoint, checkz + checkh, checkradius, checklist); if (!check.inited) Level->CollectConnectedGroups(basegroup, checkpoint, checkz + checkh, checkradius, checklist);
checkpoint.Z = checkradius; checkpoint.Z = checkradius;
Reset(); Reset();
} }
@ -847,10 +849,10 @@ bool FMultiBlockLinesIterator::Next(FMultiBlockLinesIterator::CheckResult *item)
bool FMultiBlockLinesIterator::startIteratorForGroup(int group) bool FMultiBlockLinesIterator::startIteratorForGroup(int group)
{ {
offset = level.Displacements.getOffset(basegroup, group); offset = blockIterator.Level->Displacements.getOffset(basegroup, group);
offset.X += checkpoint.X; offset.X += checkpoint.X;
offset.Y += checkpoint.Y; offset.Y += checkpoint.Y;
cursector = group == startsector->PortalGroup ? startsector : level.PointInSector(offset); cursector = group == startsector->PortalGroup ? startsector : blockIterator.Level->PointInSector(offset);
// If we ended up in a different group, // If we ended up in a different group,
// presumably because the spot to be checked is too far outside the actual portal group, // presumably because the spot to be checked is too far outside the actual portal group,
// the search needs to abort. // the search needs to abort.
@ -880,18 +882,20 @@ void FMultiBlockLinesIterator::Reset()
// //
//=========================================================================== //===========================================================================
FBlockThingsIterator::FBlockThingsIterator() FBlockThingsIterator::FBlockThingsIterator(FLevelLocals *l)
: DynHash(0) : DynHash(0)
{ {
Level = l;
minx = maxx = 0; minx = maxx = 0;
miny = maxy = 0; miny = maxy = 0;
ClearHash(); ClearHash();
block = NULL; block = NULL;
} }
FBlockThingsIterator::FBlockThingsIterator(int _minx, int _miny, int _maxx, int _maxy) FBlockThingsIterator::FBlockThingsIterator(FLevelLocals *l, int _minx, int _miny, int _maxx, int _maxy)
: DynHash(0) : DynHash(0)
{ {
Level = l;
minx = _minx; minx = _minx;
maxx = _maxx; maxx = _maxx;
miny = _miny; miny = _miny;
@ -902,10 +906,10 @@ FBlockThingsIterator::FBlockThingsIterator(int _minx, int _miny, int _maxx, int
void FBlockThingsIterator::init(const FBoundingBox &box) void FBlockThingsIterator::init(const FBoundingBox &box)
{ {
maxy = level.blockmap.GetBlockY(box.Top()); maxy = Level->blockmap.GetBlockY(box.Top());
miny = level.blockmap.GetBlockY(box.Bottom()); miny = Level->blockmap.GetBlockY(box.Bottom());
maxx = level.blockmap.GetBlockX(box.Right()); maxx = Level->blockmap.GetBlockX(box.Right());
minx = level.blockmap.GetBlockX(box.Left()); minx = Level->blockmap.GetBlockX(box.Left());
ClearHash(); ClearHash();
Reset(); Reset();
} }
@ -933,9 +937,9 @@ void FBlockThingsIterator::StartBlock(int x, int y)
{ {
curx = x; curx = x;
cury = y; cury = y;
if (level.blockmap.isValidBlock(x, y)) if (Level->blockmap.isValidBlock(x, y))
{ {
block = level.blockmap.blocklinks[y*level.blockmap.bmapwidth + x]; block = Level->blockmap.blocklinks[y*Level->blockmap.bmapwidth + x];
} }
else else
{ {
@ -983,9 +987,9 @@ AActor *FBlockThingsIterator::Next(bool centeronly)
if (centeronly) if (centeronly)
{ {
// Block boundaries for compatibility mode // Block boundaries for compatibility mode
double blockleft = (curx * FBlockmap::MAPBLOCKUNITS) + level.blockmap.bmaporgx; double blockleft = (curx * FBlockmap::MAPBLOCKUNITS) + Level->blockmap.bmaporgx;
double blockright = blockleft + FBlockmap::MAPBLOCKUNITS; double blockright = blockleft + FBlockmap::MAPBLOCKUNITS;
double blockbottom = (cury * FBlockmap::MAPBLOCKUNITS) + level.blockmap.bmaporgy; double blockbottom = (cury * FBlockmap::MAPBLOCKUNITS) + Level->blockmap.bmaporgy;
double blocktop = blockbottom + FBlockmap::MAPBLOCKUNITS; double blocktop = blockbottom + FBlockmap::MAPBLOCKUNITS;
// only return actors with the center in this block // only return actors with the center in this block
@ -1052,24 +1056,24 @@ AActor *FBlockThingsIterator::Next(bool centeronly)
//=========================================================================== //===========================================================================
FMultiBlockThingsIterator::FMultiBlockThingsIterator(FPortalGroupArray &check, AActor *origin, double checkradius, bool ignorerestricted) FMultiBlockThingsIterator::FMultiBlockThingsIterator(FPortalGroupArray &check, AActor *origin, double checkradius, bool ignorerestricted)
: checklist(check) : checklist(check), blockIterator(origin->Level)
{ {
checkpoint = origin->Pos(); checkpoint = origin->Pos();
if (!check.inited) level.CollectConnectedGroups(origin->Sector->PortalGroup, checkpoint, origin->Top(), checkradius, checklist); if (!check.inited) origin->Level->CollectConnectedGroups(origin->Sector->PortalGroup, checkpoint, origin->Top(), checkradius, checklist);
checkpoint.Z = checkradius == -1? origin->radius : checkradius; checkpoint.Z = checkradius == -1? origin->radius : checkradius;
basegroup = origin->Sector->PortalGroup; basegroup = origin->Sector->PortalGroup;
Reset(); Reset();
} }
FMultiBlockThingsIterator::FMultiBlockThingsIterator(FPortalGroupArray &check, double checkx, double checky, double checkz, double checkh, double checkradius, bool ignorerestricted, sector_t *newsec) FMultiBlockThingsIterator::FMultiBlockThingsIterator(FPortalGroupArray &check, FLevelLocals *Level, double checkx, double checky, double checkz, double checkh, double checkradius, bool ignorerestricted, sector_t *newsec)
: checklist(check) : checklist(check), blockIterator(Level)
{ {
checkpoint.X = checkx; checkpoint.X = checkx;
checkpoint.Y = checky; checkpoint.Y = checky;
checkpoint.Z = checkz; checkpoint.Z = checkz;
if (newsec == NULL) newsec = level.PointInSector(checkx, checky); if (newsec == NULL) newsec = Level->PointInSector(checkx, checky);
basegroup = newsec->PortalGroup; basegroup = newsec->PortalGroup;
if (!check.inited) level.CollectConnectedGroups(basegroup, checkpoint, checkz + checkh, checkradius, checklist); if (!check.inited) Level->CollectConnectedGroups(basegroup, checkpoint, checkz + checkh, checkradius, checklist);
checkpoint.Z = checkradius; checkpoint.Z = checkradius;
Reset(); Reset();
} }
@ -1086,7 +1090,7 @@ bool FMultiBlockThingsIterator::Next(FMultiBlockThingsIterator::CheckResult *ite
if (thing != NULL) if (thing != NULL)
{ {
item->thing = thing; item->thing = thing;
item->Position = checkpoint + level.Displacements.getOffset(basegroup, thing->Sector->PortalGroup); item->Position = checkpoint + blockIterator.Level->Displacements.getOffset(basegroup, thing->Sector->PortalGroup);
item->portalflags = portalflags; item->portalflags = portalflags;
return true; return true;
} }
@ -1125,7 +1129,7 @@ bool FMultiBlockThingsIterator::Next(FMultiBlockThingsIterator::CheckResult *ite
void FMultiBlockThingsIterator::startIteratorForGroup(int group) void FMultiBlockThingsIterator::startIteratorForGroup(int group)
{ {
DVector2 offset = level.Displacements.getOffset(basegroup, group); DVector2 offset = blockIterator.Level->Displacements.getOffset(basegroup, group);
offset.X += checkpoint.X; offset.X += checkpoint.X;
offset.Y += checkpoint.Y; offset.Y += checkpoint.Y;
bbox.setBox(offset.X, offset.Y, checkpoint.Z); bbox.setBox(offset.X, offset.Y, checkpoint.Z);
@ -1168,7 +1172,7 @@ TArray<intercept_t> FPathTraverse::intercepts(128);
void FPathTraverse::AddLineIntercepts(int bx, int by) void FPathTraverse::AddLineIntercepts(int bx, int by)
{ {
FBlockLinesIterator it(bx, by, bx, by, true); FBlockLinesIterator it(Level, bx, by, bx, by, true);
line_t *ld; line_t *ld;
while ((ld = it.Next())) while ((ld = it.Next()))
@ -1542,7 +1546,7 @@ void FPathTraverse::init(double x1, double y1, double x2, double y2, int flags,
bool compatible = (flags & PT_COMPATIBLE) && (i_compatflags & COMPATF_HITSCAN); bool compatible = (flags & PT_COMPATIBLE) && (i_compatflags & COMPATF_HITSCAN);
// we want to use one list of checked actors for the entire operation // we want to use one list of checked actors for the entire operation
FBlockThingsIterator btit; FBlockThingsIterator btit(Level);
for (count = 0 ; count < 1000 ; count++) for (count = 0 ; count < 1000 ; count++)
{ {
if (flags & PT_ADDLINES) if (flags & PT_ADDLINES)
@ -1689,14 +1693,15 @@ AActor *P_BlockmapSearch (AActor *mo, int distance, AActor *(*check)(AActor*, in
int finalStop; int finalStop;
int count; int count;
AActor *target; AActor *target;
int bmapwidth = level.blockmap.bmapwidth; auto Level = mo->Level;
int bmapheight = level.blockmap.bmapheight; int bmapwidth = Level->blockmap.bmapwidth;
int bmapheight = Level->blockmap.bmapheight;
startX = level.blockmap.GetBlockX(mo->X()); startX = Level->blockmap.GetBlockX(mo->X());
startY = level.blockmap.GetBlockY(mo->Y()); startY = Level->blockmap.GetBlockY(mo->Y());
validcount++; validcount++;
if (level.blockmap.isValidBlock(startX, startY)) if (Level->blockmap.isValidBlock(startX, startY))
{ {
if ( (target = check (mo, startY*bmapwidth+startX, params)) ) if ( (target = check (mo, startY*bmapwidth+startX, params)) )
{ // found a target right away { // found a target right away
@ -1787,7 +1792,7 @@ static AActor *RoughBlockCheck (AActor *mo, int index, void *param)
FBlockNode *link; FBlockNode *link;
for (link = level.blockmap.blocklinks[index]; link != NULL; link = link->NextActor) for (link = mo->Level->blockmap.blocklinks[index]; link != NULL; link = link->NextActor)
{ {
if (link->Me != mo) if (link->Me != mo)
{ {
@ -1936,8 +1941,8 @@ subsector_t *FLevelLocals::PointInSubsector(double x, double y)
{ {
int side; int side;
auto node = level.HeadGamenode(); auto node = HeadGamenode();
if (node == nullptr) return &level.subsectors[0]; if (node == nullptr) return &subsectors[0];
fixed_t xx = FloatToFixed(x); fixed_t xx = FloatToFixed(x);
fixed_t yy = FloatToFixed(y); fixed_t yy = FloatToFixed(y);
@ -1960,8 +1965,8 @@ subsector_t *FLevelLocals::PointInSubsector(double x, double y)
sector_t *FLevelLocals::PointInSectorBuggy(double x, double y) sector_t *FLevelLocals::PointInSectorBuggy(double x, double y)
{ {
// single subsector is a special case // single subsector is a special case
auto node = level.HeadGamenode(); auto node = HeadGamenode();
if (node == nullptr) return level.subsectors[0].sector; if (node == nullptr) return subsectors[0].sector;
do do
{ {
// Use original buggy point-on-side test when spawning // Use original buggy point-on-side test when spawning
@ -1991,10 +1996,10 @@ subsector_t *FLevelLocals::PointInRenderSubsector (fixed_t x, fixed_t y)
int side; int side;
// single subsector is a special case // single subsector is a special case
if (level.nodes.Size() == 0) if (nodes.Size() == 0)
return &level.subsectors[0]; return &subsectors[0];
node = level.HeadNode(); node = HeadNode();
do do
{ {

View file

@ -206,6 +206,7 @@ private:
class FBlockLinesIterator class FBlockLinesIterator
{ {
friend class FMultiBlockLinesIterator; friend class FMultiBlockLinesIterator;
FLevelLocals *Level;
int minx, maxx; int minx, maxx;
int miny, maxy; int miny, maxy;
@ -216,11 +217,11 @@ class FBlockLinesIterator
void StartBlock(int x, int y); void StartBlock(int x, int y);
FBlockLinesIterator() {} FBlockLinesIterator(FLevelLocals *l) { Level = l; }
void init(const FBoundingBox &box); void init(const FBoundingBox &box);
public: public:
FBlockLinesIterator(int minx, int miny, int maxx, int maxy, bool keepvalidcount = false); FBlockLinesIterator(FLevelLocals *Level, int minx, int miny, int maxx, int maxy, bool keepvalidcount = false);
FBlockLinesIterator(const FBoundingBox &box); FBlockLinesIterator(FLevelLocals *Level, const FBoundingBox &box);
line_t *Next(); line_t *Next();
void Reset() { StartBlock(minx, miny); } void Reset() { StartBlock(minx, miny); }
}; };
@ -254,7 +255,7 @@ public:
}; };
FMultiBlockLinesIterator(FPortalGroupArray &check, AActor *origin, double checkradius = -1); FMultiBlockLinesIterator(FPortalGroupArray &check, AActor *origin, double checkradius = -1);
FMultiBlockLinesIterator(FPortalGroupArray &check, double checkx, double checky, double checkz, double checkh, double checkradius, sector_t *newsec); FMultiBlockLinesIterator(FPortalGroupArray &check, FLevelLocals *Level, double checkx, double checky, double checkz, double checkh, double checkradius, sector_t *newsec);
bool Next(CheckResult *item); bool Next(CheckResult *item);
void Reset(); void Reset();
@ -276,6 +277,7 @@ public:
class FBlockThingsIterator class FBlockThingsIterator
{ {
FLevelLocals *Level;
int minx, maxx; int minx, maxx;
int miny, maxy; int miny, maxy;
@ -302,14 +304,14 @@ class FBlockThingsIterator
// The following is only for use in the path traverser // The following is only for use in the path traverser
// and therefore declared private. // and therefore declared private.
FBlockThingsIterator(); FBlockThingsIterator(FLevelLocals *);
friend class FPathTraverse; friend class FPathTraverse;
friend class FMultiBlockThingsIterator; friend class FMultiBlockThingsIterator;
public: public:
FBlockThingsIterator(int minx, int miny, int maxx, int maxy); FBlockThingsIterator(FLevelLocals *Level, int minx, int miny, int maxx, int maxy);
FBlockThingsIterator(const FBoundingBox &box) FBlockThingsIterator(FLevelLocals *Level, const FBoundingBox &box)
{ {
init(box); init(box);
} }
@ -331,7 +333,7 @@ class FMultiBlockThingsIterator
void startIteratorForGroup(int group); void startIteratorForGroup(int group);
protected: protected:
FMultiBlockThingsIterator(FPortalGroupArray &check) : checklist(check) {} FMultiBlockThingsIterator(FPortalGroupArray &check, FLevelLocals *Level) : checklist(check), blockIterator(Level) {}
public: public:
struct CheckResult struct CheckResult
@ -342,7 +344,7 @@ public:
}; };
FMultiBlockThingsIterator(FPortalGroupArray &check, AActor *origin, double checkradius = -1, bool ignorerestricted = false); FMultiBlockThingsIterator(FPortalGroupArray &check, AActor *origin, double checkradius = -1, bool ignorerestricted = false);
FMultiBlockThingsIterator(FPortalGroupArray &check, double checkx, double checky, double checkz, double checkh, double checkradius, bool ignorerestricted, sector_t *newsec); FMultiBlockThingsIterator(FPortalGroupArray &check, FLevelLocals *Level, double checkx, double checky, double checkz, double checkh, double checkradius, bool ignorerestricted, sector_t *newsec);
bool Next(CheckResult *item); bool Next(CheckResult *item);
void Reset(); void Reset();
const FBoundingBox &Box() const const FBoundingBox &Box() const

View file

@ -237,7 +237,7 @@ msecnode_t *P_CreateSecNodeList(AActor *thing, double radius, msecnode_t *sector
} }
FBoundingBox box(thing->X(), thing->Y(), radius); FBoundingBox box(thing->X(), thing->Y(), radius);
FBlockLinesIterator it(box); FBlockLinesIterator it(thing->Level, box);
line_t *ld; line_t *ld;
while ((ld = it.Next())) while ((ld = it.Next()))

View file

@ -914,7 +914,7 @@ sightcounts[0]++;
SightTask task = { 0, topslope, bottomslope, -1, sec->PortalGroup }; SightTask task = { 0, topslope, bottomslope, -1, sec->PortalGroup };
SightCheck s(&level); SightCheck s(t1->Level);
s.init(t1, t2, sec, &task, flags); s.init(t1, t2, sec, &task, flags);
res = s.P_SightPathTraverse (); res = s.P_SightPathTraverse ();
if (!res) if (!res)

View file

@ -249,7 +249,7 @@ DEFINE_ACTION_FUNCTION(_Line, RemoteActivate)
bool P_TestActivateLine (line_t *line, AActor *mo, int side, int activationType, DVector3 *optpos) bool P_TestActivateLine (line_t *line, AActor *mo, int side, int activationType, DVector3 *optpos)
{ {
auto Level = &level; auto Level = line->GetLevel();
int lineActivation = line->activation; int lineActivation = line->activation;
if (line->flags & ML_FIRSTSIDEONLY && side == 1) if (line->flags & ML_FIRSTSIDEONLY && side == 1)

View file

@ -779,7 +779,7 @@ bool FTraceInfo::TraceTraverse (int ptflags)
// Do a 3D floor check in the starting sector // Do a 3D floor check in the starting sector
Setup3DFloors(); Setup3DFloors();
FPathTraverse it(&level, Start.X, Start.Y, Vec.X * MaxDist, Vec.Y * MaxDist, ptflags | PT_DELTA, startfrac); FPathTraverse it(Level, Start.X, Start.Y, Vec.X * MaxDist, Vec.Y * MaxDist, ptflags | PT_DELTA, startfrac);
intercept_t *in; intercept_t *in;
int lastsplashsector = -1; int lastsplashsector = -1;

View file

@ -1232,7 +1232,7 @@ void FPolyObj::LinkPolyobj ()
void FPolyObj::RecalcActorFloorCeil(FBoundingBox bounds) const void FPolyObj::RecalcActorFloorCeil(FBoundingBox bounds) const
{ {
FBlockThingsIterator it(bounds); FBlockThingsIterator it(Level, bounds);
AActor *actor; AActor *actor;
while ((actor = it.Next()) != nullptr) while ((actor = it.Next()) != nullptr)

View file

@ -1147,7 +1147,7 @@ bool FLevelLocals::CollectConnectedGroups(int startgroup, const DVector3 &positi
{ {
DVector2 disp = Displacements.getOffset(startgroup, thisgroup & ~FPortalGroupArray::FLAT); DVector2 disp = Displacements.getOffset(startgroup, thisgroup & ~FPortalGroupArray::FLAT);
FBoundingBox box(position.X + disp.X, position.Y + disp.Y, checkradius); FBoundingBox box(position.X + disp.X, position.Y + disp.Y, checkradius);
FBlockLinesIterator it(box); FBlockLinesIterator it(this, box);
line_t *ld; line_t *ld;
while ((ld = it.Next())) while ((ld = it.Next()))
{ {

View file

@ -109,7 +109,7 @@ public:
} }
DBlockLinesIterator(double x, double y, double z, double height, double radius, sector_t *sec) DBlockLinesIterator(double x, double y, double z, double height, double radius, sector_t *sec)
:FMultiBlockLinesIterator(check, x, y, z, height, radius, sec) :FMultiBlockLinesIterator(check, &level, x, y, z, height, radius, sec)
{ {
cres.line = nullptr; cres.line = nullptr;
cres.Position.Zero(); cres.Position.Zero();
@ -183,7 +183,7 @@ public:
} }
DBlockThingsIterator(double checkx, double checky, double checkz, double checkh, double checkradius, bool ignorerestricted, sector_t *newsec) DBlockThingsIterator(double checkx, double checky, double checkz, double checkh, double checkradius, bool ignorerestricted, sector_t *newsec)
: iterator(check, checkx, checky, checkz, checkh, checkradius, ignorerestricted, newsec) : iterator(check, &level, checkx, checky, checkz, checkh, checkradius, ignorerestricted, newsec)
{ {
cres.thing = nullptr; cres.thing = nullptr;
cres.Position.Zero(); cres.Position.Zero();