- added Level parameter to R/P_PointInSector(Sub)Sector.

This commit is contained in:
Christoph Oelckers 2019-01-10 00:30:04 +01:00
parent a28d5dd973
commit 2aa9c065ac
39 changed files with 132 additions and 123 deletions

View file

@ -2591,7 +2591,7 @@ void AM_drawWalls (bool allmap)
if (line.sidedef[0]->Flags & WALLF_POLYOBJ)
{
// For polyobjects we must test the surrounding sector to get the proper group.
pg = P_PointInSector(line.v1->fX() + line.Delta().X / 2, line.v1->fY() + line.Delta().Y / 2)->PortalGroup;
pg = P_PointInSector(line.GetLevel(), line.v1->fX() + line.Delta().X / 2, line.v1->fY() + line.Delta().Y / 2)->PortalGroup;
}
else
{

View file

@ -866,7 +866,7 @@ void FParser::SF_Spawn(void)
// [Graf Zahl] added option of spawning with a relative z coordinate
if(t_argc > 5)
{
if (intvalue(t_argv[5])) pos.Z += P_PointInSector(pos)->floorplane.ZatPoint(pos);
if (intvalue(t_argv[5])) pos.Z += P_PointInSector(Level, pos)->floorplane.ZatPoint(pos);
}
}
else
@ -2928,7 +2928,7 @@ void FParser::SF_SpawnExplosion()
if(t_argc > 3)
pos.Z = floatvalue(t_argv[3]);
else
pos.Z = P_PointInSector(pos)->floorplane.ZatPoint(pos);
pos.Z = P_PointInSector(Level, pos)->floorplane.ZatPoint(pos);
spawn = Spawn (Level, pclass, pos, ALLOW_REPLACE);
t_return.type = svt_int;

View file

@ -1315,7 +1315,7 @@ void G_PlayerReborn (int player)
// because something is occupying it
//
bool G_CheckSpot (int playernum, FPlayerStart *mthing)
bool G_CheckSpot (FLevelLocals *Level, int playernum, FPlayerStart *mthing)
{
DVector3 spot;
double oldz;
@ -1329,7 +1329,7 @@ bool G_CheckSpot (int playernum, FPlayerStart *mthing)
{
spot.Z = 0;
}
spot.Z += P_PointInSector (spot)->floorplane.ZatPoint (spot);
spot.Z += P_PointInSector (Level, spot)->floorplane.ZatPoint (spot);
if (!players[playernum].mo)
{ // first spawn of level, before corpses
@ -1409,27 +1409,28 @@ static FPlayerStart *SelectFarthestDeathmatchSpot (size_t selections)
}
// [RH] Select a deathmatch spawn spot at random (original mechanism)
static FPlayerStart *SelectRandomDeathmatchSpot (int playernum, unsigned int selections)
static FPlayerStart *SelectRandomDeathmatchSpot (FLevelLocals *Level, int playernum, unsigned int selections)
{
unsigned int i, j;
for (j = 0; j < 20; j++)
{
i = pr_dmspawn() % selections;
if (G_CheckSpot (playernum, &level.deathmatchstarts[i]) )
if (G_CheckSpot (Level, playernum, &level.deathmatchstarts[i]) )
{
return &level.deathmatchstarts[i];
return &Level->deathmatchstarts[i];
}
}
// [RH] return a spot anyway, since we allow telefragging when a player spawns
return &level.deathmatchstarts[i];
return &Level->deathmatchstarts[i];
}
DEFINE_ACTION_FUNCTION(DObject, G_PickDeathmatchStart)
{
PARAM_PROLOGUE;
unsigned int selections = level.deathmatchstarts.Size();
auto Level = &level;
unsigned int selections = Level->deathmatchstarts.Size();
DVector3 pos;
int angle;
if (selections == 0)
@ -1440,8 +1441,8 @@ DEFINE_ACTION_FUNCTION(DObject, G_PickDeathmatchStart)
else
{
unsigned int i = pr_dmspawn() % selections;
angle = level.deathmatchstarts[i].angle;
pos = level.deathmatchstarts[i].pos;
angle = Level->deathmatchstarts[i].angle;
pos = Level->deathmatchstarts[i].pos;
}
if (numret > 1)
@ -1456,12 +1457,12 @@ DEFINE_ACTION_FUNCTION(DObject, G_PickDeathmatchStart)
return numret;
}
void G_DeathMatchSpawnPlayer (int playernum)
void G_DeathMatchSpawnPlayer (FLevelLocals *Level, int playernum)
{
unsigned int selections;
FPlayerStart *spot;
selections = level.deathmatchstarts.Size ();
selections = Level->deathmatchstarts.Size ();
// [RH] We can get by with just 1 deathmatch start
if (selections < 1)
I_Error ("No deathmatch starts");
@ -1472,28 +1473,28 @@ void G_DeathMatchSpawnPlayer (int playernum)
if ((dmflags & DF_SPAWN_FARTHEST) && players[playernum].mo)
spot = SelectFarthestDeathmatchSpot (selections);
else
spot = SelectRandomDeathmatchSpot (playernum, selections);
spot = SelectRandomDeathmatchSpot (Level, playernum, selections);
if (spot == NULL)
{ // No good spot, so the player will probably get stuck.
// We were probably using select farthest above, and all
// the spots were taken.
spot = G_PickPlayerStart(playernum, PPS_FORCERANDOM);
if (!G_CheckSpot(playernum, spot))
if (!G_CheckSpot(&level, playernum, spot))
{ // This map doesn't have enough coop spots for this player
// to use one.
spot = SelectRandomDeathmatchSpot(playernum, selections);
spot = SelectRandomDeathmatchSpot(Level, playernum, selections);
if (spot == NULL)
{ // We have a player 1 start, right?
spot = &level.playerstarts[0];
if (spot->type == 0)
{ // Fine, whatever.
spot = &level.deathmatchstarts[0];
spot = &Level->deathmatchstarts[0];
}
}
}
}
AActor *mo = P_SpawnPlayer(&level, spot, playernum);
AActor *mo = P_SpawnPlayer(Level, spot, playernum);
if (mo != NULL) P_PlayerStartStomp(mo);
}
@ -1519,7 +1520,7 @@ FPlayerStart *G_PickPlayerStart(int playernum, int flags)
// Find all unblocked player starts.
for (i = 0; i < level.AllPlayerStarts.Size(); ++i)
{
if (G_CheckSpot(playernum, &level.AllPlayerStarts[i]))
if (G_CheckSpot(&level, playernum, &level.AllPlayerStarts[i]))
{
good_starts.Push(&level.AllPlayerStarts[i]);
}
@ -1630,13 +1631,13 @@ void G_DoReborn (int playernum, bool freshbot)
// spawn at random spot if in deathmatch
if ((deathmatch || isUnfriendly) && (level.deathmatchstarts.Size () > 0))
{
G_DeathMatchSpawnPlayer (playernum);
G_DeathMatchSpawnPlayer (&level, playernum);
return;
}
if (!(level.flags2 & LEVEL2_RANDOMPLAYERSTARTS) &&
level.playerstarts[playernum].type != 0 &&
G_CheckSpot (playernum, &level.playerstarts[playernum]))
G_CheckSpot (&level, playernum, &level.playerstarts[playernum]))
{
AActor *mo = P_SpawnPlayer(&level, &level.playerstarts[playernum], playernum);
if (mo != NULL) P_PlayerStartStomp(mo, true);

View file

@ -34,11 +34,12 @@ struct event_t;
class AActor;
struct FLevelLocals;
//
// GAME
//
void G_DeathMatchSpawnPlayer (int playernum);
void G_DeathMatchSpawnPlayer (FLevelLocals *Level, int playernum);
struct FPlayerStart *G_PickPlayerStart (int playernum, int flags = 0);
enum

View file

@ -2062,7 +2062,7 @@ void FLevelLocals::SetMusicVolume(float f)
int IsPointInMap(FLevelLocals *Level, double x, double y, double z)
{
subsector_t *subsector = R_PointInSubsector(FLOAT2FIXED(x), FLOAT2FIXED(y));
subsector_t *subsector = R_PointInSubsector(Level, FLOAT2FIXED(x), FLOAT2FIXED(y));
if (!subsector) return false;
for (uint32_t i = 0; i < subsector->numlines; i++)
@ -2102,8 +2102,8 @@ inline T VecDiff(FLevelLocals *Level, const T& v1, const T& v2)
if (level.subsectors.Size() > 0)
{
const sector_t *const sec1 = P_PointInSector(v1);
const sector_t *const sec2 = P_PointInSector(v2);
const sector_t *const sec1 = P_PointInSector(Level, v1);
const sector_t *const sec2 = P_PointInSector(Level, v2);
if (nullptr != sec1 && nullptr != sec2)
{

View file

@ -591,7 +591,7 @@ void FDynamicLight::CollectWithinRadius(const DVector3 &opos, FSection *section,
line_t *other = port->mDestination;
if (other->validcount != ::validcount)
{
subsector_t *othersub = R_PointInSubsector(other->v1->fPos() + other->Delta() / 2);
subsector_t *othersub = R_PointInSubsector(Level, other->v1->fPos() + other->Delta() / 2);
FSection *othersect = othersub->section;
if (othersect->validcount != ::validcount)
{
@ -642,7 +642,7 @@ void FDynamicLight::CollectWithinRadius(const DVector3 &opos, FSection *section,
if (sec->GetPortalPlaneZ(sector_t::ceiling) < Z() + radius)
{
DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sec->GetPortalDisplacement(sector_t::ceiling);
subsector_t *othersub = R_PointInSubsector(refpos);
subsector_t *othersub = R_PointInSubsector(Level, refpos);
FSection *othersect = othersub->section;
if (othersect->validcount != dl_validcount)
{
@ -657,7 +657,7 @@ void FDynamicLight::CollectWithinRadius(const DVector3 &opos, FSection *section,
if (sec->GetPortalPlaneZ(sector_t::floor) > Z() - radius)
{
DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sec->GetPortalDisplacement(sector_t::floor);
subsector_t *othersub = R_PointInSubsector(refpos);
subsector_t *othersub = R_PointInSubsector(Level, refpos);
FSection *othersect = othersub->section;
if (othersect->validcount != dl_validcount)
{
@ -697,7 +697,7 @@ void FDynamicLight::LinkLight()
if (radius>0)
{
// passing in radius*radius allows us to do a distance check without any calls to sqrt
FSection *sect = R_PointInSubsector(Pos)->section;
FSection *sect = R_PointInSubsector(Level, Pos)->section;
dl_validcount++;
::validcount++;

View file

@ -219,7 +219,7 @@ void HWDrawInfo::ClearBuffers()
void HWDrawInfo::UpdateCurrentMapSection()
{
const int mapsection = R_PointInSubsector(Viewpoint.Pos)->mapsection;
const int mapsection = R_PointInSubsector(Level, Viewpoint.Pos)->mapsection;
CurrentMapSections.Set(mapsection);
}
@ -234,7 +234,7 @@ void HWDrawInfo::SetViewArea()
{
auto &vp = Viewpoint;
// The render_sector is better suited to represent the current position in GL
vp.sector = R_PointInSubsector(vp.Pos)->render_sector;
vp.sector = R_PointInSubsector(Level, vp.Pos)->render_sector;
// Get the heightsec state from the render sector, not the current one!
if (vp.sector->GetHeightSec())
@ -648,7 +648,7 @@ void HWDrawInfo::ProcessScene(bool toscreen, const std::function<void(HWDrawInfo
{
screen->mPortalState->BeginScene();
int mapsection = R_PointInSubsector(Viewpoint.Pos)->mapsection;
int mapsection = R_PointInSubsector(Level, Viewpoint.Pos)->mapsection;
CurrentMapSections.Set(mapsection);
DrawScene = drawScene;
DrawScene(this, toscreen ? DM_MAINVIEW : DM_OFFSCREEN);

View file

@ -625,7 +625,7 @@ bool HWLineToLinePortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *cl
line_t *line = lines[i].seg->linedef->getPortalDestination();
subsector_t *sub;
if (line->sidedef[0]->Flags & WALLF_POLYOBJ)
sub = R_PointInSubsector(line->v1->fixX(), line->v1->fixY());
sub = R_PointInSubsector(di->Level, line->v1->fixX(), line->v1->fixY());
else sub = line->frontsector->subsectors[0];
di->CurrentMapSections.Set(sub->mapsection);
}
@ -791,7 +791,7 @@ bool HWSectorStackPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *c
// If the viewpoint is not within the portal, we need to invalidate the entire clip area.
// The portal will re-validate the necessary parts when its subsectors get traversed.
subsector_t *sub = R_PointInSubsector(vp.Pos);
subsector_t *sub = R_PointInSubsector(di->Level, vp.Pos);
if (!(di->ss_renderflags[sub->Index()] & SSRF_SEEN))
{
clipper->SafeAddClipRange(0, ANGLE_MAX);

View file

@ -1123,7 +1123,7 @@ void HWDrawInfo::ProcessLowerMinisegs(TArray<seg_t *> &lowersegs)
void HWDrawInfo::HandleHackedSubsectors()
{
viewsubsector = R_PointInSubsector(Viewpoint.Pos);
viewsubsector = R_PointInSubsector(Level, Viewpoint.Pos);
// Each subsector may only be processed once in this loop!
validcount++;

View file

@ -315,7 +315,7 @@ void MapLoader::TranslateToStartSpot (int tag, const DVector2 &origin)
}
po->CalcCenter();
// For compatibility purposes
po->CenterSubsector = R_PointInSubsector(po->CenterSpot.pos);
po->CenterSubsector = R_PointInSubsector(po->GetLevel(), po->CenterSpot.pos);
}
//==========================================================================

View file

@ -143,7 +143,7 @@ void MapLoader::CopyPlane (int tag, sector_t *dest, bool copyCeil)
void MapLoader::CopyPlane (int tag, const DVector2 &pos, bool copyCeil)
{
sector_t *dest = P_PointInSector (pos);
sector_t *dest = P_PointInSector (Level, pos);
CopyPlane(tag, dest, copyCeil);
}
@ -389,7 +389,7 @@ void MapLoader::SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt, const i
sector_t *sec;
bool ceiling;
sec = P_PointInSector (mt->pos);
sec = P_PointInSector (Level, mt->pos);
if (mt->info->Special == SMT_SlopeCeilingPointLine || mt->info->Special == SMT_VavoomCeiling || mt->info->Special == SMT_SetCeilingSlope)
{
refplane = &sec->ceilingplane;

View file

@ -965,10 +965,6 @@ secplane_t P_FindFloorPlane(sector_t * sector, const DVector3 &pos)
int P_Find3DFloor(sector_t * sec, const DVector3 &pos, bool above, bool floor, double &cmpz)
{
// If no sector given, find the one appropriate
if (sec == NULL)
sec = P_PointInSector(pos);
// Above normal ceiling
cmpz = sec->ceilingplane.ZatPoint(pos);
if (pos.Z >= cmpz)

View file

@ -9470,7 +9470,7 @@ scriptwait:
if (tag != 0)
secnum = Level->tagManager.FindFirstSectorFromTag (tag);
else
secnum = P_PointInSector (x, y)->sectornum;
secnum = P_PointInSector (Level, x, y)->sectornum;
if (secnum >= 0)
{

View file

@ -295,7 +295,7 @@ DEFINE_ACTION_FUNCTION(AActor, GetZAt)
double c = angle.Cos();
pos = mobj->Vec2Offset(pos.X * c + pos.Y * s, pos.X * s - pos.Y * c);
}
sector_t *sec = P_PointInSector(pos);
sector_t *sec = P_PointInSector(mobj->Level, pos);
if (sec)
{
@ -2290,7 +2290,7 @@ DEFINE_ACTION_FUNCTION(AActor, CheckLOF)
range
*/
sector_t *sec = P_PointInSector(pos);
sector_t *sec = P_PointInSector(self->Level, pos);
if (range == 0)
{

View file

@ -187,7 +187,7 @@ void P_FindParticleSubsectors ()
for (uint16_t i = ActiveParticles; i != NO_PARTICLE; i = Particles[i].tnext)
{
// Try to reuse the subsector from the last portal check, if still valid.
if (Particles[i].subsector == NULL) Particles[i].subsector = R_PointInSubsector(Particles[i].Pos);
if (Particles[i].subsector == NULL) Particles[i].subsector = R_PointInSubsector(&level, Particles[i].Pos);
int ssnum = Particles[i].subsector->Index();
Particles[i].snext = ParticlesInSubsec[ssnum];
ParticlesInSubsec[ssnum] = i;
@ -270,8 +270,8 @@ void P_ThinkParticles ()
particle->Pos.Y = newxy.Y;
particle->Pos.Z += particle->Vel.Z;
particle->Vel += particle->Acc;
particle->subsector = R_PointInSubsector(particle->Pos);
sector_t *s = particle->subsector->sector;
particle->subsector = R_PointInSubsector(s->Level, particle->Pos);
// Handle crossing a sector portal.
if (!s->PortalBlocksMovement(sector_t::ceiling))
{

View file

@ -161,12 +161,12 @@ static void P_RecursiveSound(sector_t *sec, AActor *soundtarget, bool splash, AA
// I wish there was a better method to do this than randomly looking through the portal at a few places...
if (checkabove)
{
sector_t *upper = P_PointInSector(check->v1->fPos() + check->Delta() / 2 + sec->GetPortalDisplacement(sector_t::ceiling));
sector_t *upper = P_PointInSector(sec->Level, check->v1->fPos() + check->Delta() / 2 + sec->GetPortalDisplacement(sector_t::ceiling));
NoiseMarkSector(upper, soundtarget, splash, emitter, soundblocks, maxdist);
}
if (checkbelow)
{
sector_t *lower = P_PointInSector(check->v1->fPos() + check->Delta() / 2 + sec->GetPortalDisplacement(sector_t::floor));
sector_t *lower = P_PointInSector(sec->Level, check->v1->fPos() + check->Delta() / 2 + sec->GetPortalDisplacement(sector_t::floor));
NoiseMarkSector(lower, soundtarget, splash, emitter, soundblocks, maxdist);
}

View file

@ -275,7 +275,7 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator &mit, FMultiBlockLines
void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags)
{
sector_t *sec = (!(flags & FFCF_SAMESECTOR) || tmf.thing->Sector == NULL)? P_PointInSector(tmf.pos) : tmf.sector;
sector_t *sec = (!(flags & FFCF_SAMESECTOR) || tmf.thing->Sector == NULL)? P_PointInSector(tmf.thing->Level, tmf.pos) : tmf.sector;
F3DFloor *ffc, *fff;
tmf.ceilingz = NextHighestCeilingAt(sec, tmf.pos.X, tmf.pos.Y, tmf.pos.Z, tmf.pos.Z + tmf.thing->Height, flags, &tmf.ceilingsector, &ffc);
@ -418,7 +418,7 @@ bool P_TeleportMove(AActor* thing, const DVector3 &pos, bool telefrag, bool modi
// P_LineOpening requires the thing's z to be the destination z in order to work.
double savedz = thing->Z();
thing->SetZ(pos.Z);
sector_t *sector = P_PointInSector(pos);
sector_t *sector = P_PointInSector(thing->Level, pos);
FPortalGroupArray grouplist;
FMultiBlockLinesIterator mit(grouplist, thing->Level, pos.X, pos.Y, pos.Z, thing->Height, thing->radius, sector);
@ -1669,7 +1669,7 @@ bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, boo
tm.pos.Y = pos.Y;
tm.pos.Z = thing->Z();
newsec = tm.sector = P_PointInSector(pos);
newsec = tm.sector = P_PointInSector(thing->Level, pos);
tm.ceilingline = thing->BlockingLine = NULL;
// Retrieve the base floor / ceiling from the target location.
@ -2598,7 +2598,7 @@ bool P_TryMove(AActor *thing, const DVector2 &pos,
thing->UnlinkFromWorld(&ctx);
thing->SetXYZ(thing->PosRelative(tm.portalgroup));
thing->Prev += thing->Pos() - oldpos;
thing->Sector = P_PointInSector(thing->Pos());
thing->Sector = P_PointInSector(thing->Level, thing->Pos());
thing->PrevPortalGroup = thing->Sector->PortalGroup;
thing->LinkToWorld(&ctx);
@ -3821,7 +3821,7 @@ struct aim_t
newtrace.aimdir = position == sector_t::ceiling? aim_t::aim_up : aim_t::aim_down;
newtrace.startpos = startpos + entersec->GetPortalDisplacement(position);
newtrace.startfrac = frac + 1. / attackrange; // this is to skip the transition line to the portal which would produce a bogus opening
newtrace.lastsector = P_PointInSector(newtrace.startpos + aimtrace * newtrace.startfrac);
newtrace.lastsector = P_PointInSector(entersec->Level, newtrace.startpos + aimtrace * newtrace.startfrac);
newtrace.limitz = portalz;
if (aimdebug)
Printf("-----Entering %s portal from sector %d to sector %d\n", position ? "ceiling" : "floor", lastsector->sectornum, newtrace.lastsector->sectornum);
@ -3860,7 +3860,7 @@ struct aim_t
DVector2 pos = newtrace.startpos + newtrace.aimtrace * newtrace.startfrac;
newtrace.lastsector = P_PointInSector(pos);
newtrace.lastsector = P_PointInSector(li->GetLevel(), pos);
P_TranslatePortalZ(li, limitz);
if (aimdebug)
Printf("-----Entering line portal from sector %d to sector %d\n", lastsector->sectornum, newtrace.lastsector->sectornum);
@ -6770,17 +6770,20 @@ void SpawnShootDecal(AActor *t1, const FTraceResults &trace)
static void SpawnDeepSplash(AActor *t1, const FTraceResults &trace, AActor *puff)
{
const DVector3 *hitpos;
FLevelLocals *Level;
if (trace.Crossed3DWater)
{
hitpos = &trace.Crossed3DWaterPos;
Level = trace.Crossed3DWater->model->Level;
}
else if (trace.CrossedWater && trace.CrossedWater->heightsec)
{
hitpos = &trace.CrossedWaterPos;
Level = trace.CrossedWater->Level;
}
else return;
P_HitWater(puff != NULL ? puff : t1, P_PointInSector(*hitpos), *hitpos);
P_HitWater(puff != NULL ? puff : t1, P_PointInSector(Level, *hitpos), *hitpos);
}
//=============================================================================

View file

@ -80,7 +80,7 @@
#include "po_man.h"
#include "vm.h"
sector_t *P_PointInSectorBuggy(double x, double y);
sector_t *P_PointInSectorBuggy(FLevelLocals *Level, double x, double y);
int P_VanillaPointOnDivlineSide(double x, double y, const divline_t* line);
@ -354,7 +354,7 @@ void AActor::UnlinkFromWorld (FLinkContext *ctx)
bool AActor::FixMapthingPos()
{
sector_t *secstart = P_PointInSectorBuggy(X(), Y());
sector_t *secstart = P_PointInSectorBuggy(Level, X(), Y());
int blockx = Level->blockmap.GetBlockX(X());
int blocky = Level->blockmap.GetBlockY(Y());
@ -452,16 +452,16 @@ void AActor::LinkToWorld(FLinkContext *ctx, bool spawningmapthing, sector_t *sec
{
if (!spawning)
{
sector = P_PointInSector(Pos());
sector = P_PointInSector(Level, Pos());
}
else
{
sector = P_PointInSectorBuggy(X(), Y());
sector = P_PointInSectorBuggy(Level, X(), Y());
}
}
Sector = sector;
subsector = R_PointInSubsector(Pos()); // this is from the rendering nodes, not the gameplay nodes!
subsector = R_PointInSubsector(Level, Pos()); // this is from the rendering nodes, not the gameplay nodes!
section = subsector->section;
if (!(flags & MF_NOSECTOR))
@ -725,7 +725,7 @@ FMultiBlockLinesIterator::FMultiBlockLinesIterator(FPortalGroupArray &check, FLe
: checklist(check), blockIterator(Level)
{
checkpoint = { checkx, checky, checkz };
if (newsec == NULL) newsec = P_PointInSector(checkx, checky);
if (newsec == NULL) newsec = P_PointInSector(Level, checkx, checky);
startsector = newsec;
basegroup = newsec->PortalGroup;
if (!check.inited) P_CollectConnectedGroups(Level, basegroup, checkpoint, checkz + checkh, checkradius, checklist);
@ -851,7 +851,7 @@ bool FMultiBlockLinesIterator::startIteratorForGroup(int group)
offset = blockIterator.Level->Displacements.getOffset(basegroup, group);
offset.X += checkpoint.X;
offset.Y += checkpoint.Y;
cursector = group == startsector->PortalGroup ? startsector : P_PointInSector(offset);
cursector = group == startsector->PortalGroup ? startsector : P_PointInSector(blockIterator.Level, offset);
// If we ended up in a different group,
// presumably because the spot to be checked is too far outside the actual portal group,
// the search needs to abort.
@ -1068,7 +1068,7 @@ FMultiBlockThingsIterator::FMultiBlockThingsIterator(FPortalGroupArray &check, F
checkpoint.X = checkx;
checkpoint.Y = checky;
checkpoint.Z = checkz;
if (newsec == NULL) newsec = P_PointInSector(checkx, checky);
if (newsec == NULL) newsec = P_PointInSector(Level, checkx, checky);
basegroup = newsec->PortalGroup;
if (!check.inited) P_CollectConnectedGroups(Level, basegroup, checkpoint, checkz + checkh, checkradius, checklist);
checkpoint.Z = checkradius;
@ -1934,12 +1934,12 @@ int P_VanillaPointOnLineSide(double x, double y, const line_t* line)
//
//==========================================================================
subsector_t *P_PointInSubsector(double x, double y)
subsector_t *P_PointInSubsector(FLevelLocals *Level, double x, double y)
{
int side;
auto node = level.HeadGamenode();
if (node == nullptr) return &level.subsectors[0];
auto node = Level->HeadGamenode();
if (node == nullptr) return &Level->subsectors[0];
fixed_t xx = FLOAT2FIXED(x);
fixed_t yy = FLOAT2FIXED(y);
@ -1959,7 +1959,7 @@ subsector_t *P_PointInSubsector(double x, double y)
//
//==========================================================================
sector_t *P_PointInSectorBuggy(double x, double y)
sector_t *P_PointInSectorBuggy(FLevelLocals *Level, double x, double y)
{
// single subsector is a special case
auto node = level.HeadGamenode();

View file

@ -3409,7 +3409,7 @@ DVector3 AActor::GetPortalTransition(double byoffset, sector_t **pSec)
if (testz >= sec->GetPortalPlaneZ(sector_t::ceiling))
{
pos = PosRelative(sec->GetOppositePortalGroup(sector_t::ceiling));
sec = P_PointInSector(pos);
sec = P_PointInSector(Level, pos);
moved = true;
}
else break;
@ -3421,7 +3421,7 @@ DVector3 AActor::GetPortalTransition(double byoffset, sector_t **pSec)
if (testz < sec->GetPortalPlaneZ(sector_t::floor))
{
pos = PosRelative(sec->GetOppositePortalGroup(sector_t::floor));
sec = P_PointInSector(pos);
sec = P_PointInSector(Level, pos);
}
else break;
}
@ -3444,7 +3444,7 @@ void AActor::CheckPortalTransition(bool islinked)
if (islinked && !moved) UnlinkFromWorld(&ctx);
SetXYZ(PosRelative(Sector->GetOppositePortalGroup(sector_t::ceiling)));
Prev += Pos() - oldpos;
Sector = P_PointInSector(Pos());
Sector = P_PointInSector(Level, Pos());
PrevPortalGroup = Sector->PortalGroup;
moved = true;
}
@ -3461,7 +3461,7 @@ void AActor::CheckPortalTransition(bool islinked)
if (islinked && !moved) UnlinkFromWorld(&ctx);
SetXYZ(PosRelative(Sector->GetOppositePortalGroup(sector_t::floor)));
Prev += Pos() - oldpos;
Sector = P_PointInSector(Pos());
Sector = P_PointInSector(Level, Pos());
PrevPortalGroup = Sector->PortalGroup;
moved = true;
}
@ -5360,7 +5360,7 @@ AActor *P_SpawnMapThing (FLevelLocals *Level, FMapThing *mthing, int position)
}
else
{
P_PointInSector (mthing->pos)->seqType = type;
P_PointInSector (Level, mthing->pos)->seqType = type;
}
return NULL;
}
@ -6197,7 +6197,7 @@ bool P_CheckMissileSpawn (AActor* th, double maxdist)
newpos = th->Vec3Offset(newpos);
th->SetXYZ(newpos);
th->Sector = P_PointInSector(th->Pos());
th->Sector = P_PointInSector(th->Level, th->Pos());
FCheckPosition tm(!!(th->flags2 & MF2_RIP));

View file

@ -416,7 +416,7 @@ void AActor::UpdateRenderSectorList()
if (Top() + SPRITE_SPACE < planeh) break;
lasth = planeh;
DVector2 newpos = Pos() + sec->GetPortalDisplacement(sector_t::ceiling);
sec = P_PointInSector(newpos);
sec = P_PointInSector(sec->Level, newpos);
touching_sectorportallist = P_AddSecnode(sec, this, touching_sectorportallist, sec->sectorportal_thinglist);
}
sec = Sector;
@ -428,7 +428,7 @@ void AActor::UpdateRenderSectorList()
if (Z() - SPRITE_SPACE > planeh) break;
lasth = planeh;
DVector2 newpos = Pos() + sec->GetPortalDisplacement(sector_t::floor);
sec = P_PointInSector(newpos);
sec = P_PointInSector(sec->Level, newpos);
touching_sectorportallist = P_AddSecnode(sec, this, touching_sectorportallist, sec->sectorportal_thinglist);
}
}

View file

@ -941,7 +941,7 @@ double HighestCeilingAt(sector_t *check, double x, double y, sector_t **resultse
{
pos += check->GetPortalDisplacement(sector_t::ceiling);
planeheight = check->GetPortalPlaneZ(sector_t::ceiling);
check = P_PointInSector(pos);
check = P_PointInSector(check->Level, pos);
}
if (resultsec) *resultsec = check;
return check->ceilingplane.ZatPoint(pos);
@ -963,7 +963,7 @@ double LowestFloorAt(sector_t *check, double x, double y, sector_t **resultsec)
{
pos += check->GetPortalDisplacement(sector_t::floor);
planeheight = check->GetPortalPlaneZ(sector_t::ceiling);
check = P_PointInSector(pos);
check = P_PointInSector(check->Level, pos);
}
if (resultsec) *resultsec = check;
return check->floorplane.ZatPoint(pos);
@ -1012,7 +1012,7 @@ double NextHighestCeilingAt(sector_t *sec, double x, double y, double bottomz, d
x += pos.X;
y += pos.Y;
planeheight = sec->GetPortalPlaneZ(sector_t::ceiling);
sec = P_PointInSector(x, y);
sec = P_PointInSector(sec->Level, x, y);
}
}
}
@ -1061,7 +1061,7 @@ double NextLowestFloorAt(sector_t *sec, double x, double y, double z, int flags,
x += pos.X;
y += pos.Y;
planeheight = sec->GetPortalPlaneZ(sector_t::floor);
sec = P_PointInSector(x, y);
sec = P_PointInSector(sec->Level, x, y);
}
}
}

View file

@ -445,7 +445,7 @@ void P_SetupLevel(FLevelLocals *Level, const char *lumpname, int position, bool
if (playeringame[i])
{
players[i].mo = nullptr;
G_DeathMatchSpawnPlayer(i);
G_DeathMatchSpawnPlayer(Level, i);
}
}
}
@ -474,7 +474,7 @@ void P_SetupLevel(FLevelLocals *Level, const char *lumpname, int position, bool
if (!(players[i].mo->flags & MF_FRIENDLY))
{
AActor * oldSpawn = players[i].mo;
G_DeathMatchSpawnPlayer(i);
G_DeathMatchSpawnPlayer(Level, i);
oldSpawn->Destroy();
}
}

View file

@ -629,7 +629,7 @@ bool SightCheck::P_SightPathTraverse ()
y1 = sightstart.Y + Startfrac * Trace.dy;
x2 = sightend.X;
y2 = sightend.Y;
if (lastsector == NULL) lastsector = P_PointInSector(x1, y1);
if (lastsector == NULL) lastsector = P_PointInSector(seeingthing->Level, x1, y1);
// for FF_SEETHROUGH the following rule applies:
// If the viewer is in an area without FF_SEETHROUGH he can only see into areas without this flag

View file

@ -1080,7 +1080,7 @@ void P_SpawnSkybox(AActor *origin)
if (Sector == NULL)
{
Printf("Sector not initialized for SkyCamCompat\n");
origin->Sector = Sector = P_PointInSector(origin->Pos());
origin->Sector = Sector = P_PointInSector(origin->Level, origin->Pos());
}
if (Sector)
{

View file

@ -154,7 +154,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 *
// if the polyobject lies directly on a sector boundary
check.X = dll.x + dll.dx * (inter + 0.01);
check.Y = dll.y + dll.dy * (inter + 0.01);
front = P_PointInSector(check);
front = P_PointInSector(front->Level, check);
}
else
{

View file

@ -108,7 +108,7 @@ bool P_Teleport (AActor *thing, DVector3 pos, DAngle angle, int flags)
old = thing->Pos();
aboveFloor = thing->Z() - thing->floorz;
destsect = P_PointInSector (pos);
destsect = P_PointInSector (thing->Level, pos);
// killough 5/12/98: exclude voodoo dolls:
player = thing->player;
if (player && player->mo != thing)

View file

@ -125,6 +125,9 @@ void P_Ticker (void)
ac->ClearInterpolation();
}
// Since things will be moving, it's okay to interpolate them in the renderer.
r_NoInterpolate = false;
P_ThinkParticles(); // [RH] make the particles think
});

View file

@ -116,7 +116,7 @@ static void GetPortalTransition(DVector3 &pos, sector_t *&sec)
if (pos.Z > sec->GetPortalPlaneZ(sector_t::ceiling))
{
pos += sec->GetPortalDisplacement(sector_t::ceiling);
sec = P_PointInSector(pos);
sec = P_PointInSector(sec->Level, pos);
moved = true;
}
else break;
@ -128,7 +128,7 @@ static void GetPortalTransition(DVector3 &pos, sector_t *&sec)
if (pos.Z <= sec->GetPortalPlaneZ(sector_t::floor))
{
pos += sec->GetPortalDisplacement(sector_t::floor);
sec = P_PointInSector(pos);
sec = P_PointInSector(sec->Level, pos);
}
else break;
}
@ -220,7 +220,7 @@ void FTraceInfo::EnterSectorPortal(FPathTraverse &pt, int position, double frac,
DVector3 enter = exit + displacement;
Start += displacement;
CurSector = P_PointInSector(enter);
CurSector = P_PointInSector(entersec->Level, enter);
inshootthrough = true;
startfrac = frac;
EnterDist = enterdist;
@ -259,7 +259,7 @@ void FTraceInfo::EnterLinePortal(FPathTraverse &pt, intercept_t *in)
P_TranslatePortalVXVY(li, Vec.X, Vec.Y);
P_TranslatePortalZ(li, limitz);
CurSector = P_PointInSector(Start + enterdist * Vec);
CurSector = P_PointInSector(li->GetLevel(), Start + enterdist * Vec);
EnterDist = enterdist;
inshootthrough = true;
startfrac = frac;

View file

@ -234,7 +234,7 @@ void PolyDrawLinePortal::SaveGlobals()
}
viewpoint.camera = nullptr;
viewpoint.sector = R_PointInSubsector(viewpoint.Pos)->sector;
viewpoint.sector = R_PointInSubsector(viewpoint.camera->Level, viewpoint.Pos)->sector;
viewpoint.SetViewAngle(viewwindow);
}

View file

@ -1228,7 +1228,7 @@ bool P_CollectConnectedGroups(FLevelLocals *Level, int startgroup, const DVector
}
if (out.method != FPortalGroupArray::PGA_NoSectorPortals)
{
sector_t *sec = P_PointInSector(position);
sector_t *sec = P_PointInSector(Level, position);
sector_t *wsec = sec;
while (!wsec->PortalBlocksMovement(sector_t::ceiling) && upperz > wsec->GetPortalPlaneZ(sector_t::ceiling))
{
@ -1237,7 +1237,7 @@ bool P_CollectConnectedGroups(FLevelLocals *Level, int startgroup, const DVector
if (processMask.getBit(othergroup)) break;
processMask.setBit(othergroup);
out.Add(othergroup | FPortalGroupArray::UPPER);
wsec = P_PointInSector(pos); // get upper sector at the exact spot we want to check and repeat
wsec = P_PointInSector(Level, pos); // get upper sector at the exact spot we want to check and repeat
retval = true;
}
wsec = sec;
@ -1248,7 +1248,7 @@ bool P_CollectConnectedGroups(FLevelLocals *Level, int startgroup, const DVector
if (processMask.getBit(othergroup)) break;
processMask.setBit(othergroup);
out.Add(othergroup | FPortalGroupArray::LOWER);
wsec = P_PointInSector(pos); // get lower sector at the exact spot we want to check and repeat
wsec = P_PointInSector(Level, pos); // get lower sector at the exact spot we want to check and repeat
retval = true;
}
if (out.method == FPortalGroupArray::PGA_Full3d && Level->PortalBlockmap.hasLinkedSectorPortals)

View file

@ -1603,21 +1603,21 @@ typedef uint8_t lighttable_t; // This could be wider for >8 bit display.
// not the same as R_PointInSubsector
//
//----------------------------------------------------------------------------------
subsector_t *P_PointInSubsector(double x, double y);
subsector_t *P_PointInSubsector(FLevelLocals *Level, double x, double y);
inline sector_t *P_PointInSector(const DVector2 &pos)
inline sector_t *P_PointInSector(FLevelLocals *Level, const DVector2 &pos)
{
return P_PointInSubsector(pos.X, pos.Y)->sector;
return P_PointInSubsector(Level, pos.X, pos.Y)->sector;
}
inline sector_t *P_PointInSector(double X, double Y)
inline sector_t *P_PointInSector(FLevelLocals *Level, double X, double Y)
{
return P_PointInSubsector(X, Y)->sector;
return P_PointInSubsector(Level, X, Y)->sector;
}
inline sector_t *P_PointInSectorXY(double X, double Y) // This is for the benefit of unambiguously looking up this function's address
inline sector_t *P_PointInSectorXY(FLevelLocals *Level, double X, double Y) // This is for the benefit of unambiguously looking up this function's address
{
return P_PointInSubsector(X, Y)->sector;
return P_PointInSubsector(Level, X, Y)->sector;
}
inline bool FBoundingBox::inRange(const line_t *ld) const

View file

@ -367,16 +367,16 @@ CUSTOM_CVAR (Int, screenblocks, 10, CVAR_ARCHIVE)
//
//==========================================================================
subsector_t *R_PointInSubsector (fixed_t x, fixed_t y)
subsector_t *R_PointInSubsector (FLevelLocals *Level, fixed_t x, fixed_t y)
{
node_t *node;
int side;
// single subsector is a special case
if (level.nodes.Size() == 0)
return &level.subsectors[0];
if (Level->nodes.Size() == 0)
return &Level->subsectors[0];
node = level.HeadNode();
node = Level->HeadNode();
do
{
@ -450,8 +450,9 @@ void R_InterpolateView (FRenderViewpoint &viewpoint, player_t *player, double Fr
NoInterpolateView = false;
iview->Old = iview->New;
}
int oldgroup = R_PointInSubsector(iview->Old.Pos)->sector->PortalGroup;
int newgroup = R_PointInSubsector(iview->New.Pos)->sector->PortalGroup;
auto Level = viewpoint.camera->Level;
int oldgroup = R_PointInSubsector(Level, iview->Old.Pos)->sector->PortalGroup;
int newgroup = R_PointInSubsector(Level, iview->New.Pos)->sector->PortalGroup;
DAngle oviewangle = iview->Old.Angles.Yaw;
DAngle nviewangle = iview->New.Angles.Yaw;
@ -556,7 +557,7 @@ void R_InterpolateView (FRenderViewpoint &viewpoint, player_t *player, double Fr
}
// Due to interpolation this is not necessarily the same as the sector the camera is in.
viewpoint.sector = R_PointInSubsector(viewpoint.Pos)->sector;
viewpoint.sector = R_PointInSubsector(Level, viewpoint.Pos)->sector;
bool moved = false;
while (!viewpoint.sector->PortalBlocksMovement(sector_t::ceiling))
{
@ -564,7 +565,7 @@ void R_InterpolateView (FRenderViewpoint &viewpoint, player_t *player, double Fr
{
viewpoint.Pos += viewpoint.sector->GetPortalDisplacement(sector_t::ceiling);
viewpoint.ActorPos += viewpoint.sector->GetPortalDisplacement(sector_t::ceiling);
viewpoint.sector = R_PointInSubsector(viewpoint.Pos)->sector;
viewpoint.sector = R_PointInSubsector(Level, viewpoint.Pos)->sector;
moved = true;
}
else break;
@ -577,7 +578,7 @@ void R_InterpolateView (FRenderViewpoint &viewpoint, player_t *player, double Fr
{
viewpoint.Pos += viewpoint.sector->GetPortalDisplacement(sector_t::floor);
viewpoint.ActorPos += viewpoint.sector->GetPortalDisplacement(sector_t::floor);
viewpoint.sector = R_PointInSubsector(viewpoint.Pos)->sector;
viewpoint.sector = R_PointInSubsector(Level, viewpoint.Pos)->sector;
moved = true;
}
else break;
@ -807,7 +808,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
if (player != NULL && gamestate != GS_TITLELEVEL &&
((player->cheats & CF_CHASECAM) || (r_deathcamera && viewpoint.camera->health <= 0)))
{
sector_t *oldsector = R_PointInSubsector(iview->Old.Pos)->sector;
sector_t *oldsector = R_PointInSubsector(actor->Level, iview->Old.Pos)->sector;
// [RH] Use chasecam view
DVector3 campos;
DAngle camangle;

View file

@ -109,10 +109,10 @@ struct DVector3a
};
subsector_t *R_PointInSubsector (fixed_t x, fixed_t y);
inline subsector_t *R_PointInSubsector(const DVector2 &pos)
subsector_t *R_PointInSubsector (FLevelLocals *Level, fixed_t x, fixed_t y);
inline subsector_t *R_PointInSubsector(FLevelLocals *Level, const DVector2 &pos)
{
return R_PointInSubsector(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y));
return R_PointInSubsector(Level, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y));
}
void R_ResetViewInterpolation ();
void R_RebuildViewInterpolation(player_t *player);

View file

@ -714,7 +714,7 @@ static void CalcPosVel( int type, const AActor *actor, const sector_t *sector,
if(type == SOURCE_Unattached)
{
assert(Level != NULL);
sector_t *sec = P_PointInSector(pt[0], pt[2]);
sector_t *sec = P_PointInSector(SoundMainLevel, pt[0], pt[2]);
DVector2 disp = Level->Displacements.getOffset(pgroup, sec->PortalGroup);
pos->X = pt[0] - (float)disp.X;
pos->Y = !(chanflags & CHAN_LISTENERZ) ? pt[1] : (float)listenpos.Z;
@ -865,7 +865,7 @@ static void CalcSectorSoundOrg(const DVector3 &listenpos, const sector_t *sec, i
if (!(i_compatflags & COMPATF_SECTORSOUNDS))
{
// Are we inside the sector? If yes, the closest point is the one we're on.
if (P_PointInSector(listenpos.X, listenpos.Y) == sec)
if (P_PointInSector(sec->Level, listenpos.X, listenpos.Y) == sec)
{
pos.X = (float)listenpos.X;
pos.Z = (float)listenpos.Y;

View file

@ -656,12 +656,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
return 0;
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, PointInSector, P_PointInSectorXY)
DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, PointInSector, P_PointInSectorXY)
{
PARAM_PROLOGUE;
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
PARAM_FLOAT(x);
PARAM_FLOAT(y);
ACTION_RETURN_POINTER(P_PointInSector(x, y));
ACTION_RETURN_POINTER(P_PointInSector(self, x, y));
}
static void SetXOffset(sector_t *self, int pos, double o)

View file

@ -712,6 +712,7 @@ struct LevelLocals native
native Actor Spawn(class<Actor> type, vector3 pos = (0,0,0), int replace = NO_REPLACE);
clearscope native HealthGroup FindHealthGroup(int id);
native int FindUniqueTid(int start = 0, int limit = 0);
native Sector PointInSector(Vector2 v);
native clearscope bool IsPointInMap(vector3 p);

View file

@ -370,7 +370,10 @@ struct Sector native play
native double, Sector, F3DFloor NextLowestFloorAt(double x, double y, double z, int flags = 0, double steph = 0);
native void RemoveForceField();
native static clearscope Sector PointInSector(Vector2 pt);
deprecated("3.8") static clearscope Sector PointInSector(Vector2 pt)
{
return level.PointInSector(pt);
}
native bool PlaneMoving(int pos);
native int GetFloorLight();

View file

@ -742,7 +742,7 @@ class AltHud ui
else
{
pos.xy = Level.GetAutomapPosition();
pos.z = Sector.PointInSector(pos.xy).floorplane.ZatPoint(pos.xy);
pos.z = Level.PointInSector(pos.xy).floorplane.ZatPoint(pos.xy);
}
int xpos = hudwidth - SmallFont.StringWidth("X: -00000")-6;

View file

@ -296,7 +296,7 @@ class PhosphorousFire : Actor
Vector2 newpos = Vec2Offset(xofs, yofs);
Sector sec = Sector.PointInSector(newpos);
Sector sec = Level.PointInSector(newpos);
// Consider portals and 3D floors instead of just using the current sector's z.
double floorh = sec.NextLowestFloorAt(newpos.x, newpos.y, pos.z+4, 0, MaxStepHeight);