- 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) if (line.sidedef[0]->Flags & WALLF_POLYOBJ)
{ {
// For polyobjects we must test the surrounding sector to get the proper group. // 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 else
{ {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -219,7 +219,7 @@ void HWDrawInfo::ClearBuffers()
void HWDrawInfo::UpdateCurrentMapSection() void HWDrawInfo::UpdateCurrentMapSection()
{ {
const int mapsection = R_PointInSubsector(Viewpoint.Pos)->mapsection; const int mapsection = R_PointInSubsector(Level, Viewpoint.Pos)->mapsection;
CurrentMapSections.Set(mapsection); CurrentMapSections.Set(mapsection);
} }
@ -234,7 +234,7 @@ void HWDrawInfo::SetViewArea()
{ {
auto &vp = Viewpoint; auto &vp = Viewpoint;
// The render_sector is better suited to represent the current position in GL // 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! // Get the heightsec state from the render sector, not the current one!
if (vp.sector->GetHeightSec()) if (vp.sector->GetHeightSec())
@ -648,7 +648,7 @@ void HWDrawInfo::ProcessScene(bool toscreen, const std::function<void(HWDrawInfo
{ {
screen->mPortalState->BeginScene(); screen->mPortalState->BeginScene();
int mapsection = R_PointInSubsector(Viewpoint.Pos)->mapsection; int mapsection = R_PointInSubsector(Level, Viewpoint.Pos)->mapsection;
CurrentMapSections.Set(mapsection); CurrentMapSections.Set(mapsection);
DrawScene = drawScene; DrawScene = drawScene;
DrawScene(this, toscreen ? DM_MAINVIEW : DM_OFFSCREEN); 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(); line_t *line = lines[i].seg->linedef->getPortalDestination();
subsector_t *sub; subsector_t *sub;
if (line->sidedef[0]->Flags & WALLF_POLYOBJ) 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]; else sub = line->frontsector->subsectors[0];
di->CurrentMapSections.Set(sub->mapsection); 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. // 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. // 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)) if (!(di->ss_renderflags[sub->Index()] & SSRF_SEEN))
{ {
clipper->SafeAddClipRange(0, ANGLE_MAX); clipper->SafeAddClipRange(0, ANGLE_MAX);

View file

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

View file

@ -315,7 +315,7 @@ void MapLoader::TranslateToStartSpot (int tag, const DVector2 &origin)
} }
po->CalcCenter(); po->CalcCenter();
// For compatibility purposes // 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) 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); CopyPlane(tag, dest, copyCeil);
} }
@ -389,7 +389,7 @@ void MapLoader::SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt, const i
sector_t *sec; sector_t *sec;
bool ceiling; 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) if (mt->info->Special == SMT_SlopeCeilingPointLine || mt->info->Special == SMT_VavoomCeiling || mt->info->Special == SMT_SetCeilingSlope)
{ {
refplane = &sec->ceilingplane; 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) 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 // Above normal ceiling
cmpz = sec->ceilingplane.ZatPoint(pos); cmpz = sec->ceilingplane.ZatPoint(pos);
if (pos.Z >= cmpz) if (pos.Z >= cmpz)

View file

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

View file

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

View file

@ -187,7 +187,7 @@ void P_FindParticleSubsectors ()
for (uint16_t i = ActiveParticles; i != NO_PARTICLE; i = Particles[i].tnext) 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. // 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(); int ssnum = Particles[i].subsector->Index();
Particles[i].snext = ParticlesInSubsec[ssnum]; Particles[i].snext = ParticlesInSubsec[ssnum];
ParticlesInSubsec[ssnum] = i; ParticlesInSubsec[ssnum] = i;
@ -270,8 +270,8 @@ void P_ThinkParticles ()
particle->Pos.Y = newxy.Y; particle->Pos.Y = newxy.Y;
particle->Pos.Z += particle->Vel.Z; particle->Pos.Z += particle->Vel.Z;
particle->Vel += particle->Acc; particle->Vel += particle->Acc;
particle->subsector = R_PointInSubsector(particle->Pos);
sector_t *s = particle->subsector->sector; sector_t *s = particle->subsector->sector;
particle->subsector = R_PointInSubsector(s->Level, particle->Pos);
// Handle crossing a sector portal. // Handle crossing a sector portal.
if (!s->PortalBlocksMovement(sector_t::ceiling)) 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... // I wish there was a better method to do this than randomly looking through the portal at a few places...
if (checkabove) 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); NoiseMarkSector(upper, soundtarget, splash, emitter, soundblocks, maxdist);
} }
if (checkbelow) 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); 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) 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; 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); 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. // P_LineOpening requires the thing's z to be the destination z in order to work.
double savedz = thing->Z(); double savedz = thing->Z();
thing->SetZ(pos.Z); thing->SetZ(pos.Z);
sector_t *sector = P_PointInSector(pos); sector_t *sector = P_PointInSector(thing->Level, pos);
FPortalGroupArray grouplist; FPortalGroupArray grouplist;
FMultiBlockLinesIterator mit(grouplist, thing->Level, 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);
@ -1669,7 +1669,7 @@ bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, boo
tm.pos.Y = pos.Y; tm.pos.Y = pos.Y;
tm.pos.Z = thing->Z(); tm.pos.Z = thing->Z();
newsec = tm.sector = P_PointInSector(pos); newsec = tm.sector = P_PointInSector(thing->Level, pos);
tm.ceilingline = thing->BlockingLine = NULL; tm.ceilingline = thing->BlockingLine = NULL;
// Retrieve the base floor / ceiling from the target location. // 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->UnlinkFromWorld(&ctx);
thing->SetXYZ(thing->PosRelative(tm.portalgroup)); thing->SetXYZ(thing->PosRelative(tm.portalgroup));
thing->Prev += thing->Pos() - oldpos; 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->PrevPortalGroup = thing->Sector->PortalGroup;
thing->LinkToWorld(&ctx); 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.aimdir = position == sector_t::ceiling? aim_t::aim_up : aim_t::aim_down;
newtrace.startpos = startpos + entersec->GetPortalDisplacement(position); 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.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; newtrace.limitz = portalz;
if (aimdebug) if (aimdebug)
Printf("-----Entering %s portal from sector %d to sector %d\n", position ? "ceiling" : "floor", lastsector->sectornum, newtrace.lastsector->sectornum); 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; DVector2 pos = newtrace.startpos + newtrace.aimtrace * newtrace.startfrac;
newtrace.lastsector = P_PointInSector(pos); newtrace.lastsector = P_PointInSector(li->GetLevel(), pos);
P_TranslatePortalZ(li, limitz); P_TranslatePortalZ(li, limitz);
if (aimdebug) if (aimdebug)
Printf("-----Entering line portal from sector %d to sector %d\n", lastsector->sectornum, newtrace.lastsector->sectornum); 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) static void SpawnDeepSplash(AActor *t1, const FTraceResults &trace, AActor *puff)
{ {
const DVector3 *hitpos; const DVector3 *hitpos;
FLevelLocals *Level;
if (trace.Crossed3DWater) if (trace.Crossed3DWater)
{ {
hitpos = &trace.Crossed3DWaterPos; hitpos = &trace.Crossed3DWaterPos;
Level = trace.Crossed3DWater->model->Level;
} }
else if (trace.CrossedWater && trace.CrossedWater->heightsec) else if (trace.CrossedWater && trace.CrossedWater->heightsec)
{ {
hitpos = &trace.CrossedWaterPos; hitpos = &trace.CrossedWaterPos;
Level = trace.CrossedWater->Level;
} }
else return; 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 "po_man.h"
#include "vm.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); int P_VanillaPointOnDivlineSide(double x, double y, const divline_t* line);
@ -354,7 +354,7 @@ void AActor::UnlinkFromWorld (FLinkContext *ctx)
bool AActor::FixMapthingPos() 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 blockx = Level->blockmap.GetBlockX(X());
int blocky = Level->blockmap.GetBlockY(Y()); int blocky = Level->blockmap.GetBlockY(Y());
@ -452,16 +452,16 @@ void AActor::LinkToWorld(FLinkContext *ctx, bool spawningmapthing, sector_t *sec
{ {
if (!spawning) if (!spawning)
{ {
sector = P_PointInSector(Pos()); sector = P_PointInSector(Level, Pos());
} }
else else
{ {
sector = P_PointInSectorBuggy(X(), Y()); sector = P_PointInSectorBuggy(Level, X(), Y());
} }
} }
Sector = sector; 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; section = subsector->section;
if (!(flags & MF_NOSECTOR)) if (!(flags & MF_NOSECTOR))
@ -725,7 +725,7 @@ FMultiBlockLinesIterator::FMultiBlockLinesIterator(FPortalGroupArray &check, FLe
: checklist(check), blockIterator(Level) : checklist(check), blockIterator(Level)
{ {
checkpoint = { checkx, checky, checkz }; checkpoint = { checkx, checky, checkz };
if (newsec == NULL) newsec = P_PointInSector(checkx, checky); if (newsec == NULL) newsec = P_PointInSector(Level, checkx, checky);
startsector = newsec; startsector = newsec;
basegroup = newsec->PortalGroup; basegroup = newsec->PortalGroup;
if (!check.inited) P_CollectConnectedGroups(Level, basegroup, checkpoint, checkz + checkh, checkradius, checklist); 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 = 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 : P_PointInSector(offset); cursector = group == startsector->PortalGroup ? startsector : P_PointInSector(blockIterator.Level, 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.
@ -1068,7 +1068,7 @@ FMultiBlockThingsIterator::FMultiBlockThingsIterator(FPortalGroupArray &check, F
checkpoint.X = checkx; checkpoint.X = checkx;
checkpoint.Y = checky; checkpoint.Y = checky;
checkpoint.Z = checkz; checkpoint.Z = checkz;
if (newsec == NULL) newsec = P_PointInSector(checkx, checky); if (newsec == NULL) newsec = P_PointInSector(Level, checkx, checky);
basegroup = newsec->PortalGroup; basegroup = newsec->PortalGroup;
if (!check.inited) P_CollectConnectedGroups(Level, basegroup, checkpoint, checkz + checkh, checkradius, checklist); if (!check.inited) P_CollectConnectedGroups(Level, basegroup, checkpoint, checkz + checkh, checkradius, checklist);
checkpoint.Z = checkradius; 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; int side;
auto node = level.HeadGamenode(); auto node = Level->HeadGamenode();
if (node == nullptr) return &level.subsectors[0]; if (node == nullptr) return &Level->subsectors[0];
fixed_t xx = FLOAT2FIXED(x); fixed_t xx = FLOAT2FIXED(x);
fixed_t yy = FLOAT2FIXED(y); 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 // single subsector is a special case
auto node = level.HeadGamenode(); 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)) if (testz >= sec->GetPortalPlaneZ(sector_t::ceiling))
{ {
pos = PosRelative(sec->GetOppositePortalGroup(sector_t::ceiling)); pos = PosRelative(sec->GetOppositePortalGroup(sector_t::ceiling));
sec = P_PointInSector(pos); sec = P_PointInSector(Level, pos);
moved = true; moved = true;
} }
else break; else break;
@ -3421,7 +3421,7 @@ DVector3 AActor::GetPortalTransition(double byoffset, sector_t **pSec)
if (testz < sec->GetPortalPlaneZ(sector_t::floor)) if (testz < sec->GetPortalPlaneZ(sector_t::floor))
{ {
pos = PosRelative(sec->GetOppositePortalGroup(sector_t::floor)); pos = PosRelative(sec->GetOppositePortalGroup(sector_t::floor));
sec = P_PointInSector(pos); sec = P_PointInSector(Level, pos);
} }
else break; else break;
} }
@ -3444,7 +3444,7 @@ void AActor::CheckPortalTransition(bool islinked)
if (islinked && !moved) UnlinkFromWorld(&ctx); if (islinked && !moved) UnlinkFromWorld(&ctx);
SetXYZ(PosRelative(Sector->GetOppositePortalGroup(sector_t::ceiling))); SetXYZ(PosRelative(Sector->GetOppositePortalGroup(sector_t::ceiling)));
Prev += Pos() - oldpos; Prev += Pos() - oldpos;
Sector = P_PointInSector(Pos()); Sector = P_PointInSector(Level, Pos());
PrevPortalGroup = Sector->PortalGroup; PrevPortalGroup = Sector->PortalGroup;
moved = true; moved = true;
} }
@ -3461,7 +3461,7 @@ void AActor::CheckPortalTransition(bool islinked)
if (islinked && !moved) UnlinkFromWorld(&ctx); if (islinked && !moved) UnlinkFromWorld(&ctx);
SetXYZ(PosRelative(Sector->GetOppositePortalGroup(sector_t::floor))); SetXYZ(PosRelative(Sector->GetOppositePortalGroup(sector_t::floor)));
Prev += Pos() - oldpos; Prev += Pos() - oldpos;
Sector = P_PointInSector(Pos()); Sector = P_PointInSector(Level, Pos());
PrevPortalGroup = Sector->PortalGroup; PrevPortalGroup = Sector->PortalGroup;
moved = true; moved = true;
} }
@ -5360,7 +5360,7 @@ AActor *P_SpawnMapThing (FLevelLocals *Level, FMapThing *mthing, int position)
} }
else else
{ {
P_PointInSector (mthing->pos)->seqType = type; P_PointInSector (Level, mthing->pos)->seqType = type;
} }
return NULL; return NULL;
} }
@ -6197,7 +6197,7 @@ bool P_CheckMissileSpawn (AActor* th, double maxdist)
newpos = th->Vec3Offset(newpos); newpos = th->Vec3Offset(newpos);
th->SetXYZ(newpos); th->SetXYZ(newpos);
th->Sector = P_PointInSector(th->Pos()); th->Sector = P_PointInSector(th->Level, th->Pos());
FCheckPosition tm(!!(th->flags2 & MF2_RIP)); FCheckPosition tm(!!(th->flags2 & MF2_RIP));

View file

@ -416,7 +416,7 @@ void AActor::UpdateRenderSectorList()
if (Top() + SPRITE_SPACE < planeh) break; if (Top() + SPRITE_SPACE < planeh) break;
lasth = planeh; lasth = planeh;
DVector2 newpos = Pos() + sec->GetPortalDisplacement(sector_t::ceiling); 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); touching_sectorportallist = P_AddSecnode(sec, this, touching_sectorportallist, sec->sectorportal_thinglist);
} }
sec = Sector; sec = Sector;
@ -428,7 +428,7 @@ void AActor::UpdateRenderSectorList()
if (Z() - SPRITE_SPACE > planeh) break; if (Z() - SPRITE_SPACE > planeh) break;
lasth = planeh; lasth = planeh;
DVector2 newpos = Pos() + sec->GetPortalDisplacement(sector_t::floor); 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); 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); pos += check->GetPortalDisplacement(sector_t::ceiling);
planeheight = check->GetPortalPlaneZ(sector_t::ceiling); planeheight = check->GetPortalPlaneZ(sector_t::ceiling);
check = P_PointInSector(pos); check = P_PointInSector(check->Level, pos);
} }
if (resultsec) *resultsec = check; if (resultsec) *resultsec = check;
return check->ceilingplane.ZatPoint(pos); 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); pos += check->GetPortalDisplacement(sector_t::floor);
planeheight = check->GetPortalPlaneZ(sector_t::ceiling); planeheight = check->GetPortalPlaneZ(sector_t::ceiling);
check = P_PointInSector(pos); check = P_PointInSector(check->Level, pos);
} }
if (resultsec) *resultsec = check; if (resultsec) *resultsec = check;
return check->floorplane.ZatPoint(pos); return check->floorplane.ZatPoint(pos);
@ -1012,7 +1012,7 @@ double NextHighestCeilingAt(sector_t *sec, double x, double y, double bottomz, d
x += pos.X; x += pos.X;
y += pos.Y; y += pos.Y;
planeheight = sec->GetPortalPlaneZ(sector_t::ceiling); 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; x += pos.X;
y += pos.Y; y += pos.Y;
planeheight = sec->GetPortalPlaneZ(sector_t::floor); 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]) if (playeringame[i])
{ {
players[i].mo = nullptr; 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)) if (!(players[i].mo->flags & MF_FRIENDLY))
{ {
AActor * oldSpawn = players[i].mo; AActor * oldSpawn = players[i].mo;
G_DeathMatchSpawnPlayer(i); G_DeathMatchSpawnPlayer(Level, i);
oldSpawn->Destroy(); oldSpawn->Destroy();
} }
} }

View file

@ -629,7 +629,7 @@ bool SightCheck::P_SightPathTraverse ()
y1 = sightstart.Y + Startfrac * Trace.dy; y1 = sightstart.Y + Startfrac * Trace.dy;
x2 = sightend.X; x2 = sightend.X;
y2 = sightend.Y; 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: // 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 // 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) if (Sector == NULL)
{ {
Printf("Sector not initialized for SkyCamCompat\n"); 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) 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 // if the polyobject lies directly on a sector boundary
check.X = dll.x + dll.dx * (inter + 0.01); check.X = dll.x + dll.dx * (inter + 0.01);
check.Y = dll.y + dll.dy * (inter + 0.01); check.Y = dll.y + dll.dy * (inter + 0.01);
front = P_PointInSector(check); front = P_PointInSector(front->Level, check);
} }
else else
{ {

View file

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

View file

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

View file

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

View file

@ -1228,7 +1228,7 @@ bool P_CollectConnectedGroups(FLevelLocals *Level, int startgroup, const DVector
} }
if (out.method != FPortalGroupArray::PGA_NoSectorPortals) if (out.method != FPortalGroupArray::PGA_NoSectorPortals)
{ {
sector_t *sec = P_PointInSector(position); sector_t *sec = P_PointInSector(Level, position);
sector_t *wsec = sec; sector_t *wsec = sec;
while (!wsec->PortalBlocksMovement(sector_t::ceiling) && upperz > wsec->GetPortalPlaneZ(sector_t::ceiling)) 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; if (processMask.getBit(othergroup)) break;
processMask.setBit(othergroup); processMask.setBit(othergroup);
out.Add(othergroup | FPortalGroupArray::UPPER); 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; retval = true;
} }
wsec = sec; wsec = sec;
@ -1248,7 +1248,7 @@ bool P_CollectConnectedGroups(FLevelLocals *Level, int startgroup, const DVector
if (processMask.getBit(othergroup)) break; if (processMask.getBit(othergroup)) break;
processMask.setBit(othergroup); processMask.setBit(othergroup);
out.Add(othergroup | FPortalGroupArray::LOWER); 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; retval = true;
} }
if (out.method == FPortalGroupArray::PGA_Full3d && Level->PortalBlockmap.hasLinkedSectorPortals) 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 // 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 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; node_t *node;
int side; int side;
// single subsector is a special case // single subsector is a special case
if (level.nodes.Size() == 0) if (Level->nodes.Size() == 0)
return &level.subsectors[0]; return &Level->subsectors[0];
node = level.HeadNode(); node = Level->HeadNode();
do do
{ {
@ -450,8 +450,9 @@ void R_InterpolateView (FRenderViewpoint &viewpoint, player_t *player, double Fr
NoInterpolateView = false; NoInterpolateView = false;
iview->Old = iview->New; iview->Old = iview->New;
} }
int oldgroup = R_PointInSubsector(iview->Old.Pos)->sector->PortalGroup; auto Level = viewpoint.camera->Level;
int newgroup = R_PointInSubsector(iview->New.Pos)->sector->PortalGroup; 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 oviewangle = iview->Old.Angles.Yaw;
DAngle nviewangle = iview->New.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. // 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; bool moved = false;
while (!viewpoint.sector->PortalBlocksMovement(sector_t::ceiling)) 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.Pos += viewpoint.sector->GetPortalDisplacement(sector_t::ceiling);
viewpoint.ActorPos += 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; moved = true;
} }
else break; 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.Pos += viewpoint.sector->GetPortalDisplacement(sector_t::floor);
viewpoint.ActorPos += 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; moved = true;
} }
else break; else break;
@ -807,7 +808,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
if (player != NULL && gamestate != GS_TITLELEVEL && if (player != NULL && gamestate != GS_TITLELEVEL &&
((player->cheats & CF_CHASECAM) || (r_deathcamera && viewpoint.camera->health <= 0))) ((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 // [RH] Use chasecam view
DVector3 campos; DVector3 campos;
DAngle camangle; DAngle camangle;

View file

@ -109,10 +109,10 @@ struct DVector3a
}; };
subsector_t *R_PointInSubsector (fixed_t x, fixed_t y); subsector_t *R_PointInSubsector (FLevelLocals *Level, fixed_t x, fixed_t y);
inline subsector_t *R_PointInSubsector(const DVector2 &pos) 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_ResetViewInterpolation ();
void R_RebuildViewInterpolation(player_t *player); 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) if(type == SOURCE_Unattached)
{ {
assert(Level != NULL); 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); DVector2 disp = Level->Displacements.getOffset(pgroup, sec->PortalGroup);
pos->X = pt[0] - (float)disp.X; pos->X = pt[0] - (float)disp.X;
pos->Y = !(chanflags & CHAN_LISTENERZ) ? pt[1] : (float)listenpos.Z; 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)) if (!(i_compatflags & COMPATF_SECTORSOUNDS))
{ {
// Are we inside the sector? If yes, the closest point is the one we're on. // 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.X = (float)listenpos.X;
pos.Z = (float)listenpos.Y; pos.Z = (float)listenpos.Y;

View file

@ -656,12 +656,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
return 0; 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(x);
PARAM_FLOAT(y); 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) 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); native Actor Spawn(class<Actor> type, vector3 pos = (0,0,0), int replace = NO_REPLACE);
clearscope native HealthGroup FindHealthGroup(int id); clearscope native HealthGroup FindHealthGroup(int id);
native int FindUniqueTid(int start = 0, int limit = 0); native int FindUniqueTid(int start = 0, int limit = 0);
native Sector PointInSector(Vector2 v);
native clearscope bool IsPointInMap(vector3 p); 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 double, Sector, F3DFloor NextLowestFloorAt(double x, double y, double z, int flags = 0, double steph = 0);
native void RemoveForceField(); 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 bool PlaneMoving(int pos);
native int GetFloorLight(); native int GetFloorLight();

View file

@ -742,7 +742,7 @@ class AltHud ui
else else
{ {
pos.xy = Level.GetAutomapPosition(); 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; int xpos = hudwidth - SmallFont.StringWidth("X: -00000")-6;

View file

@ -296,7 +296,7 @@ class PhosphorousFire : Actor
Vector2 newpos = Vec2Offset(xofs, yofs); 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. // 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); double floorh = sec.NextLowestFloorAt(newpos.x, newpos.y, pos.z+4, 0, MaxStepHeight);