From 60873bc5d673a69d59fc0af7cf848df0c64b1ec9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 29 Jan 2019 01:30:41 +0100 Subject: [PATCH] Moved the PointInSector functions into FLevelLocals --- src/actor.h | 3 +- src/am_map.cpp | 2 +- src/fragglescript/t_func.cpp | 4 +- src/g_game.cpp | 2 +- src/g_level.cpp | 16 +++--- src/g_levellocals.h | 20 +++++++- src/g_shared/a_dynlight.cpp | 8 +-- src/hwrenderer/scene/hw_drawinfo.cpp | 6 +-- src/hwrenderer/scene/hw_portal.cpp | 4 +- src/hwrenderer/scene/hw_renderhacks.cpp | 2 +- src/maploader/polyobjects.cpp | 2 +- src/maploader/slopes.cpp | 4 +- src/maploader/specials.cpp | 2 +- src/p_3dfloors.cpp | 5 +- src/p_actionfunctions.cpp | 4 +- src/p_effect.cpp | 6 +-- src/p_enemy.cpp | 4 +- src/p_map.cpp | 14 ++--- src/p_maputl.cpp | 51 ++++++++++++++----- src/p_mobj.cpp | 12 ++--- src/p_secnodes.cpp | 4 +- src/p_sectors.cpp | 8 +-- src/p_sight.cpp | 2 +- src/p_switch.cpp | 2 +- src/p_teleport.cpp | 2 +- src/p_trace.cpp | 10 ++-- src/p_user.cpp | 1 - src/polyrenderer/scene/poly_portal.cpp | 2 +- src/portal.cpp | 6 +-- src/r_defs.h | 19 +------ src/r_utility.cpp | 42 +++------------ src/r_utility.h | 6 --- src/s_sound.cpp | 4 +- src/scripting/vmthunks.cpp | 33 +++++++----- wadsrc/static/zscript/base.txt | 8 ++- wadsrc/static/zscript/mapdata.txt | 5 +- wadsrc/static/zscript/statusbar/alt_hud.txt | 2 +- .../static/zscript/strife/weapongrenade.txt | 2 +- 38 files changed, 167 insertions(+), 162 deletions(-) diff --git a/src/actor.h b/src/actor.h index 9d7651d33..d6657a83e 100644 --- a/src/actor.h +++ b/src/actor.h @@ -90,8 +90,7 @@ struct FLevelLocals; // // Every actor is linked into a single sector // based on its origin coordinates. -// The subsector_t is found with R_PointInSubsector(x,y), -// and the sector_t can be found with subsector->sector. +// The subsector_t is found with PointInSector(x,y). // The sector links are only used by the rendering code, // the play simulation does not care about them at all. // diff --git a/src/am_map.cpp b/src/am_map.cpp index 93682dee1..54e769883 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -2480,7 +2480,7 @@ void DAutomap::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 = Level->PointInSector(line.v1->fX() + line.Delta().X / 2, line.v1->fY() + line.Delta().Y / 2)->PortalGroup; } else { diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 7d3fc89ae..e6f2a583e 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -839,7 +839,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 += Level->PointInSector(pos)->floorplane.ZatPoint(pos); } } else @@ -2900,7 +2900,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 = Level->PointInSector(pos)->floorplane.ZatPoint(pos); spawn = Spawn (pclass, pos, ALLOW_REPLACE); t_return.type = svt_int; diff --git a/src/g_game.cpp b/src/g_game.cpp index 5d8cdde6f..1926c9338 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1340,7 +1340,7 @@ bool FLevelLocals::CheckSpot (int playernum, FPlayerStart *mthing) { spot.Z = 0; } - spot.Z += P_PointInSector (spot)->floorplane.ZatPoint (spot); + spot.Z += PointInSector (spot)->floorplane.ZatPoint (spot); if (!players[playernum].mo) { // first spawn of level, before corpses diff --git a/src/g_level.cpp b/src/g_level.cpp index b820eb421..a6a6efa29 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -2078,10 +2078,10 @@ int FLevelLocals::GetInfighting() // Made by dpJudas, modified and implemented by Major Cooke //========================================================================== - -int IsPointInMap(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)); + // This uses the render nodes because those are guaranteed to be GL nodes, meaning all subsectors are closed. + subsector_t *subsector = Level->PointInRenderSubsector(FLOAT2FIXED(x), FLOAT2FIXED(y)); if (!subsector) return false; for (uint32_t i = 0; i < subsector->numlines; i++) @@ -2105,13 +2105,13 @@ int IsPointInMap(double x, double y, double z) return true; } -DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, IsPointInMap, IsPointInMap) +DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, IsPointInLevel, IsPointInMap) { - PARAM_PROLOGUE; + PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); PARAM_FLOAT(x); PARAM_FLOAT(y); PARAM_FLOAT(z); - ACTION_RETURN_BOOL(IsPointInMap(x, y, z)); + ACTION_RETURN_BOOL(IsPointInMap(self, x, y, z)); } template @@ -2121,8 +2121,8 @@ inline T VecDiff(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 = level.PointInSector(v1); + const sector_t *const sec2 = level.PointInSector(v2); if (nullptr != sec1 && nullptr != sec2) { diff --git a/src/g_levellocals.h b/src/g_levellocals.h index b2ade4bd6..5f7d202b0 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -317,11 +317,27 @@ public: return frozenstate; } +private: // The engine should never ever access subsectors of the game nodes. This is only needed for actually implementing PointInSector. + subsector_t *PointInSubsector(double x, double y); +public: + sector_t *PointInSectorBuggy(double x, double y); + subsector_t *PointInRenderSubsector (fixed_t x, fixed_t y); + sector_t *PointInSector(const DVector2 &pos) { - return P_PointInSector(pos); + return PointInSubsector(pos.X, pos.Y)->sector; } - + + sector_t *PointInSector(double x, double y) + { + return PointInSubsector(x, y)->sector; + } + + subsector_t *PointInRenderSubsector (const DVector2 &pos) + { + return PointInRenderSubsector(FloatToFixed(pos.X), FloatToFixed(pos.Y)); + } + FPolyObj *GetPolyobj (int polyNum) { auto index = Polyobjects.FindEx([=](const auto &poly) { return poly.tag == polyNum; }); diff --git a/src/g_shared/a_dynlight.cpp b/src/g_shared/a_dynlight.cpp index e333bffc5..a24a82bfe 100644 --- a/src/g_shared/a_dynlight.cpp +++ b/src/g_shared/a_dynlight.cpp @@ -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 = Level->PointInRenderSubsector(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 = Level->PointInRenderSubsector(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 = Level->PointInRenderSubsector(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 = Level->PointInRenderSubsector(Pos)->section; dl_validcount++; ::validcount++; diff --git a/src/hwrenderer/scene/hw_drawinfo.cpp b/src/hwrenderer/scene/hw_drawinfo.cpp index fc1f74f73..5d86051cc 100644 --- a/src/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/hwrenderer/scene/hw_drawinfo.cpp @@ -224,7 +224,7 @@ void HWDrawInfo::ClearBuffers() void HWDrawInfo::UpdateCurrentMapSection() { - const int mapsection = R_PointInSubsector(Viewpoint.Pos)->mapsection; + const int mapsection = Level->PointInRenderSubsector(Viewpoint.Pos)->mapsection; CurrentMapSections.Set(mapsection); } @@ -239,7 +239,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 = Level->PointInRenderSubsector(vp.Pos)->render_sector; // Get the heightsec state from the render sector, not the current one! if (vp.sector->GetHeightSec()) @@ -652,7 +652,7 @@ void HWDrawInfo::ProcessScene(bool toscreen, const std::functionmPortalState->BeginScene(); - int mapsection = R_PointInSubsector(Viewpoint.Pos)->mapsection; + int mapsection = Level->PointInRenderSubsector(Viewpoint.Pos)->mapsection; CurrentMapSections.Set(mapsection); DrawScene = drawScene; DrawScene(this, toscreen ? DM_MAINVIEW : DM_OFFSCREEN); diff --git a/src/hwrenderer/scene/hw_portal.cpp b/src/hwrenderer/scene/hw_portal.cpp index 457f0fb4d..b052c2676 100644 --- a/src/hwrenderer/scene/hw_portal.cpp +++ b/src/hwrenderer/scene/hw_portal.cpp @@ -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 = di->Level->PointInRenderSubsector(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 = di->Level->PointInRenderSubsector(vp.Pos); if (!(di->ss_renderflags[sub->Index()] & SSRF_SEEN)) { clipper->SafeAddClipRange(0, ANGLE_MAX); diff --git a/src/hwrenderer/scene/hw_renderhacks.cpp b/src/hwrenderer/scene/hw_renderhacks.cpp index 65a3da607..9ed505444 100644 --- a/src/hwrenderer/scene/hw_renderhacks.cpp +++ b/src/hwrenderer/scene/hw_renderhacks.cpp @@ -1123,7 +1123,7 @@ void HWDrawInfo::ProcessLowerMinisegs(TArray &lowersegs) void HWDrawInfo::HandleHackedSubsectors() { - viewsubsector = R_PointInSubsector(Viewpoint.Pos); + viewsubsector = Level->PointInRenderSubsector(Viewpoint.Pos); // Each subsector may only be processed once in this loop! validcount++; diff --git a/src/maploader/polyobjects.cpp b/src/maploader/polyobjects.cpp index e1b042743..1ff264712 100644 --- a/src/maploader/polyobjects.cpp +++ b/src/maploader/polyobjects.cpp @@ -316,7 +316,7 @@ void MapLoader::TranslateToStartSpot (int tag, const DVector2 &origin) } po->CalcCenter(); // For compatibility purposes - po->CenterSubsector = R_PointInSubsector(po->CenterSpot.pos); + po->CenterSubsector = Level->PointInRenderSubsector(po->CenterSpot.pos); } //========================================================================== diff --git a/src/maploader/slopes.cpp b/src/maploader/slopes.cpp index cd6100179..92c761103 100644 --- a/src/maploader/slopes.cpp +++ b/src/maploader/slopes.cpp @@ -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 = Level->PointInSector (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 = Level->PointInSector (mt->pos); if (mt->info->Special == SMT_SlopeCeilingPointLine || mt->info->Special == SMT_VavoomCeiling || mt->info->Special == SMT_SetCeilingSlope) { refplane = &sec->ceilingplane; diff --git a/src/maploader/specials.cpp b/src/maploader/specials.cpp index 7177de655..3eef88e48 100644 --- a/src/maploader/specials.cpp +++ b/src/maploader/specials.cpp @@ -419,7 +419,7 @@ void MapLoader::SpawnSkybox(AActor *origin) if (Sector == NULL) { Printf("Sector not initialized for SkyCamCompat\n"); - origin->Sector = Sector = P_PointInSector(origin->Pos()); + origin->Sector = Sector = Level->PointInSector(origin->Pos()); } if (Sector) { diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index 213987718..d132da69f 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -814,9 +814,8 @@ 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); + // sector must be given + if (sec == nullptr) return -1; // Above normal ceiling cmpz = sec->ceilingplane.ZatPoint(pos); diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 55bcb4a86..a6ccd9e4b 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -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 = self->Level->PointInSector(pos); if (sec) { @@ -2302,7 +2302,7 @@ DEFINE_ACTION_FUNCTION(AActor, CheckLOF) range */ - sector_t *sec = P_PointInSector(pos); + sector_t *sec = self->Level->PointInSector(pos); if (range == 0) { diff --git a/src/p_effect.cpp b/src/p_effect.cpp index 3f0bebb7e..fbfb0f322 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -184,7 +184,7 @@ void P_FindParticleSubsectors (FLevelLocals *Level) for (uint16_t i = Level->ActiveParticles; i != NO_PARTICLE; i = Level->Particles[i].tnext) { // Try to reuse the subsector from the last portal check, if still valid. - if (Level->Particles[i].subsector == nullptr) Level->Particles[i].subsector = R_PointInSubsector(Level->Particles[i].Pos); + if (Level->Particles[i].subsector == nullptr) Level->Particles[i].subsector = Level->PointInRenderSubsector(Level->Particles[i].Pos); int ssnum = Level->Particles[i].subsector->Index(); Level->Particles[i].snext = Level->ParticlesInSubsec[ssnum]; Level->ParticlesInSubsec[ssnum] = i; @@ -261,12 +261,12 @@ void P_ThinkParticles (FLevelLocals *Level) } // Handle crossing a line portal - DVector2 newxy = level.GetPortalOffsetPosition(particle->Pos.X, particle->Pos.Y, particle->Vel.X, particle->Vel.Y); + DVector2 newxy = Level->GetPortalOffsetPosition(particle->Pos.X, particle->Pos.Y, particle->Vel.X, particle->Vel.Y); particle->Pos.X = newxy.X; particle->Pos.Y = newxy.Y; particle->Pos.Z += particle->Vel.Z; particle->Vel += particle->Acc; - particle->subsector = R_PointInSubsector(particle->Pos); + particle->subsector = Level->PointInRenderSubsector(particle->Pos); sector_t *s = particle->subsector->sector; // Handle crossing a sector portal. if (!s->PortalBlocksMovement(sector_t::ceiling)) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index bc1341d1f..43a2b9ce2 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -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 = sec->Level->PointInSector(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 = sec->Level->PointInSector(check->v1->fPos() + check->Delta() / 2 + sec->GetPortalDisplacement(sector_t::floor)); NoiseMarkSector(lower, soundtarget, splash, emitter, soundblocks, maxdist); } diff --git a/src/p_map.cpp b/src/p_map.cpp index 164c94ade..cfd905f0c 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -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)? tmf.thing->Level->PointInSector(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 = thing->Level->PointInSector(pos); FPortalGroupArray grouplist; FMultiBlockLinesIterator mit(grouplist, pos.X, pos.Y, pos.Z, thing->Height, thing->radius, sector); @@ -1668,7 +1668,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 = thing->Level->PointInSector(pos); tm.ceilingline = thing->BlockingLine = NULL; // Retrieve the base floor / ceiling from the target location. @@ -2596,7 +2596,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 = thing->Level->PointInSector(thing->Pos()); thing->PrevPortalGroup = thing->Sector->PortalGroup; thing->LinkToWorld(&ctx); @@ -3819,7 +3819,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 = entersec->Level->PointInSector(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); @@ -3858,7 +3858,7 @@ struct aim_t DVector2 pos = newtrace.startpos + newtrace.aimtrace * newtrace.startfrac; - newtrace.lastsector = P_PointInSector(pos); + newtrace.lastsector = li->GetLevel()->PointInSector(pos); P_TranslatePortalZ(li, limitz); if (aimdebug) Printf("-----Entering line portal from sector %d to sector %d\n", lastsector->sectornum, newtrace.lastsector->sectornum); @@ -6775,7 +6775,7 @@ static void SpawnDeepSplash(AActor *t1, const FTraceResults &trace, AActor *puff } else return; - P_HitWater(puff != NULL ? puff : t1, P_PointInSector(*hitpos), *hitpos); + P_HitWater(puff != NULL ? puff : t1, t1->Level->PointInSector(*hitpos), *hitpos); } //============================================================================= diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 4d748aa72..32c5b4b4b 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -80,7 +80,6 @@ #include "po_man.h" #include "vm.h" -sector_t *P_PointInSectorBuggy(double x, double y); int P_VanillaPointOnDivlineSide(double x, double y, const divline_t* line); @@ -354,7 +353,7 @@ void AActor::UnlinkFromWorld (FLinkContext *ctx) bool AActor::FixMapthingPos() { - sector_t *secstart = P_PointInSectorBuggy(X(), Y()); + sector_t *secstart = Level->PointInSectorBuggy(X(), Y()); int blockx = Level->blockmap.GetBlockX(X()); int blocky = Level->blockmap.GetBlockY(Y()); @@ -452,16 +451,16 @@ void AActor::LinkToWorld(FLinkContext *ctx, bool spawningmapthing, sector_t *sec { if (!spawning) { - sector = P_PointInSector(Pos()); + sector = Level->PointInSector(Pos()); } else { - sector = P_PointInSectorBuggy(X(), Y()); + sector = Level->PointInSectorBuggy(X(), Y()); } } Sector = sector; - subsector = R_PointInSubsector(Pos()); // this is from the rendering nodes, not the gameplay nodes! + subsector = Level->PointInRenderSubsector(Pos()); // this is from the rendering nodes, not the gameplay nodes! section = subsector->section; if (!(flags & MF_NOSECTOR)) @@ -725,7 +724,7 @@ FMultiBlockLinesIterator::FMultiBlockLinesIterator(FPortalGroupArray &check, dou : checklist(check) { checkpoint = { checkx, checky, checkz }; - if (newsec == NULL) newsec = P_PointInSector(checkx, checky); + if (newsec == NULL) newsec = level.PointInSector(checkx, checky); startsector = newsec; basegroup = newsec->PortalGroup; if (!check.inited) level.CollectConnectedGroups(basegroup, checkpoint, checkz + checkh, checkradius, checklist); @@ -851,7 +850,7 @@ bool FMultiBlockLinesIterator::startIteratorForGroup(int group) offset = 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 : level.PointInSector(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 +1067,7 @@ FMultiBlockThingsIterator::FMultiBlockThingsIterator(FPortalGroupArray &check, d checkpoint.X = checkx; checkpoint.Y = checky; checkpoint.Z = checkz; - if (newsec == NULL) newsec = P_PointInSector(checkx, checky); + if (newsec == NULL) newsec = level.PointInSector(checkx, checky); basegroup = newsec->PortalGroup; if (!check.inited) level.CollectConnectedGroups(basegroup, checkpoint, checkz + checkh, checkradius, checklist); checkpoint.Z = checkradius; @@ -1933,15 +1932,15 @@ int P_VanillaPointOnLineSide(double x, double y, const line_t* line) // //========================================================================== -subsector_t *P_PointInSubsector(double x, double y) +subsector_t *FLevelLocals::PointInSubsector(double x, double y) { int side; auto node = level.HeadGamenode(); if (node == nullptr) return &level.subsectors[0]; - fixed_t xx = FLOAT2FIXED(x); - fixed_t yy = FLOAT2FIXED(y); + fixed_t xx = FloatToFixed(x); + fixed_t yy = FloatToFixed(y); do { side = R_PointOnSide(xx, yy, node); @@ -1958,7 +1957,7 @@ subsector_t *P_PointInSubsector(double x, double y) // //========================================================================== -sector_t *P_PointInSectorBuggy(double x, double y) +sector_t *FLevelLocals::PointInSectorBuggy(double x, double y) { // single subsector is a special case auto node = level.HeadGamenode(); @@ -1979,3 +1978,31 @@ sector_t *P_PointInSectorBuggy(double x, double y) subsector_t *ssec = (subsector_t *)((uint8_t *)node - 1); return ssec->sector; } + +//========================================================================== +// +// RPointInRenderSubsector +// +//========================================================================== + +subsector_t *FLevelLocals::PointInRenderSubsector (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]; + + node = level.HeadNode(); + + do + { + side = R_PointOnSide (x, y, node); + node = (node_t *)node->children[side]; + } + while (!((size_t)node & 1)); + + return (subsector_t *)((uint8_t *)node - 1); +} + diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 9b960d48f..52e413278 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3395,7 +3395,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 = Level->PointInSector(pos); moved = true; } else break; @@ -3407,7 +3407,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 = Level->PointInSector(pos); } else break; } @@ -3430,7 +3430,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 = Level->PointInSector(Pos()); PrevPortalGroup = Sector->PortalGroup; moved = true; } @@ -3447,7 +3447,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 = Level->PointInSector(Pos()); PrevPortalGroup = Sector->PortalGroup; moved = true; } @@ -5340,7 +5340,7 @@ AActor *FLevelLocals::SpawnMapThing (FMapThing *mthing, int position) } else { - P_PointInSector (mthing->pos)->seqType = type; + PointInSector (mthing->pos)->seqType = type; } return NULL; } @@ -6176,7 +6176,7 @@ bool P_CheckMissileSpawn (AActor* th, double maxdist) newpos = th->Vec3Offset(newpos); th->SetXYZ(newpos); - th->Sector = P_PointInSector(th->Pos()); + th->Sector = th->Level->PointInSector(th->Pos()); FCheckPosition tm(!!(th->flags2 & MF2_RIP)); diff --git a/src/p_secnodes.cpp b/src/p_secnodes.cpp index 9f5554b7c..d7b2c1a64 100644 --- a/src/p_secnodes.cpp +++ b/src/p_secnodes.cpp @@ -415,7 +415,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 = sec->Level->PointInSector(newpos); touching_sectorportallist = P_AddSecnode(sec, this, touching_sectorportallist, sec->sectorportal_thinglist); } sec = Sector; @@ -427,7 +427,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 = sec->Level->PointInSector(newpos); touching_sectorportallist = P_AddSecnode(sec, this, touching_sectorportallist, sec->sectorportal_thinglist); } } diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 6001a3fe3..1694652d5 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -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 = check->Level->PointInSector(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 = check->Level->PointInSector(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 = sec->Level->PointInSector(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 = sec->Level->PointInSector(x, y); } } } diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 41ecd23e8..0577f0d62 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -633,7 +633,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 = Level->PointInSector(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 diff --git a/src/p_switch.cpp b/src/p_switch.cpp index bfb8478a4..04bca2ca1 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -153,7 +153,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 = line->GetLevel()->PointInSector(check); } else { diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 63e5d3353..8bbdd7a61 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -107,7 +107,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 = thing->Level->PointInSector (pos); // killough 5/12/98: exclude voodoo dolls: player = thing->player; if (player && player->mo != thing) diff --git a/src/p_trace.cpp b/src/p_trace.cpp index cdeb967f8..9fcecede5 100644 --- a/src/p_trace.cpp +++ b/src/p_trace.cpp @@ -117,7 +117,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 = sec->Level->PointInSector(pos); moved = true; } else break; @@ -129,7 +129,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 = sec->Level->PointInSector(pos); } else break; } @@ -222,7 +222,7 @@ void FTraceInfo::EnterSectorPortal(FPathTraverse &pt, int position, double frac, DVector3 enter = exit + displacement; Start += displacement; - CurSector = P_PointInSector(enter); + CurSector = entersec->Level->PointInSector(enter); inshootthrough = true; startfrac = frac; EnterDist = enterdist; @@ -261,7 +261,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 = li->GetLevel()->PointInSector(Start + enterdist * Vec); EnterDist = enterdist; inshootthrough = true; startfrac = frac; @@ -1085,4 +1085,4 @@ ETraceStatus DLineTracer::CallZScriptCallback() } return TRACE_Stop; -} \ No newline at end of file +} diff --git a/src/p_user.cpp b/src/p_user.cpp index a5f129122..d4e20a79f 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -1263,7 +1263,6 @@ bool P_LerpCalculate(AActor *pmo, PredictPos from, PredictPos to, PredictPos &re DVector3 delta = vecResult - vecTo; result.pos = pmo->Vec3Offset(vecResult - to.pos); - //result.portalgroup = P_PointInSector(result.pos.x, result.pos.y)->PortalGroup; // As a fail safe, assume extrapolation is the threshold. return (delta.LengthSquared() > cl_predict_lerpthreshold && scale <= 1.00f); diff --git a/src/polyrenderer/scene/poly_portal.cpp b/src/polyrenderer/scene/poly_portal.cpp index ea9b2b949..c70d659ec 100644 --- a/src/polyrenderer/scene/poly_portal.cpp +++ b/src/polyrenderer/scene/poly_portal.cpp @@ -234,7 +234,7 @@ void PolyDrawLinePortal::SaveGlobals() } viewpoint.camera = nullptr; - viewpoint.sector = R_PointInSubsector(viewpoint.Pos)->sector; + viewpoint.sector = viewpoint.ViewLevel->PointInRenderSubsector(viewpoint.Pos)->sector; viewpoint.SetViewAngle(viewwindow); } diff --git a/src/portal.cpp b/src/portal.cpp index 128905bf7..ed321829c 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -1115,7 +1115,7 @@ bool FLevelLocals::CollectConnectedGroups(int startgroup, const DVector3 &positi } if (out.method != FPortalGroupArray::PGA_NoSectorPortals) { - sector_t *sec = P_PointInSector(position); + sector_t *sec = PointInSector(position); sector_t *wsec = sec; while (!wsec->PortalBlocksMovement(sector_t::ceiling) && upperz > wsec->GetPortalPlaneZ(sector_t::ceiling)) { @@ -1124,7 +1124,7 @@ bool FLevelLocals::CollectConnectedGroups(int startgroup, const DVector3 &positi 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 = PointInSector(pos); // get upper sector at the exact spot we want to check and repeat retval = true; } wsec = sec; @@ -1135,7 +1135,7 @@ bool FLevelLocals::CollectConnectedGroups(int startgroup, const DVector3 &positi 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 = PointInSector(pos); // get lower sector at the exact spot we want to check and repeat retval = true; } if (out.method == FPortalGroupArray::PGA_Full3d && PortalBlockmap.hasLinkedSectorPortals) diff --git a/src/r_defs.h b/src/r_defs.h index e22fd3f62..15d608c6c 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1598,26 +1598,9 @@ typedef uint8_t lighttable_t; // This could be wider for >8 bit display. //---------------------------------------------------------------------------------- // -// The playsim can use different nodes than the renderer so this is -// not the same as R_PointInSubsector +// // //---------------------------------------------------------------------------------- -subsector_t *P_PointInSubsector(double x, double y); - -inline sector_t *P_PointInSector(const DVector2 &pos) -{ - return P_PointInSubsector(pos.X, pos.Y)->sector; -} - -inline sector_t *P_PointInSector(double X, double Y) -{ - return P_PointInSubsector(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 -{ - return P_PointInSubsector(X, Y)->sector; -} inline bool FBoundingBox::inRange(const line_t *ld) const { diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 89a631712..f7064149f 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -361,33 +361,6 @@ CUSTOM_CVAR (Int, screenblocks, 10, CVAR_ARCHIVE) R_SetViewSize (self); } -//========================================================================== -// -// R_PointInSubsector -// -//========================================================================== - -subsector_t *R_PointInSubsector (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]; - - node = level.HeadNode(); - - do - { - side = R_PointOnSide (x, y, node); - node = (node_t *)node->children[side]; - } - while (!((size_t)node & 1)); - - return (subsector_t *)((uint8_t *)node - 1); -} - //========================================================================== // // @@ -450,8 +423,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.ViewLevel; + int oldgroup = Level->PointInRenderSubsector(iview->Old.Pos)->sector->PortalGroup; + int newgroup = Level->PointInRenderSubsector(iview->New.Pos)->sector->PortalGroup; DAngle oviewangle = iview->Old.Angles.Yaw; DAngle nviewangle = iview->New.Angles.Yaw; @@ -556,7 +530,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 = Level->PointInRenderSubsector(viewpoint.Pos)->sector; bool moved = false; while (!viewpoint.sector->PortalBlocksMovement(sector_t::ceiling)) { @@ -564,7 +538,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 = Level->PointInRenderSubsector(viewpoint.Pos)->sector; moved = true; } else break; @@ -577,7 +551,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 = Level->PointInRenderSubsector(viewpoint.Pos)->sector; moved = true; } else break; @@ -771,6 +745,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor { I_Error ("Tried to render from a NULL actor."); } + viewpoint.ViewLevel = actor->Level; player_t *player = actor->player; unsigned int newblend; @@ -807,7 +782,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 = viewpoint.ViewLevel->PointInRenderSubsector(iview->Old.Pos)->sector; // [RH] Use chasecam view DVector3 campos; DAngle camangle; @@ -1032,7 +1007,6 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor viewpoint.HWAngles.Pitch = RAD2DEG((float)asin(angy / alen)); viewpoint.HWAngles.Roll.Degrees = (float)viewpoint.Angles.Roll.Degrees; // copied for convenience. - viewpoint.ViewLevel = actor->Level; // ViewActor only gets set, if the camera actor should not be rendered if (actor->player && actor->player - players == consoleplayer && diff --git a/src/r_utility.h b/src/r_utility.h index 53218615f..bdc9aea17 100644 --- a/src/r_utility.h +++ b/src/r_utility.h @@ -111,12 +111,6 @@ struct DVector3a DAngle angle; }; - -subsector_t *R_PointInSubsector (fixed_t x, fixed_t y); -inline subsector_t *R_PointInSubsector(const DVector2 &pos) -{ - return R_PointInSubsector(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y)); -} void R_ResetViewInterpolation (); void R_RebuildViewInterpolation(player_t *player); bool R_GetViewInterpolationStatus(); diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 606fcd71e..7179b8bbe 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -704,7 +704,7 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, // on static analysis. if(type == SOURCE_Unattached) { - sector_t *sec = P_PointInSector(pt[0], pt[2]); + sector_t *sec = currentUILevel->PointInSector(pt[0], pt[2]); DVector2 disp = currentUILevel->Displacements.getOffset(pgroup, sec->PortalGroup); pos->X = pt[0] - (float)disp.X; pos->Y = !(chanflags & CHAN_LISTENERZ) ? pt[1] : (float)listenpos.Z; @@ -851,7 +851,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 (currentUILevel->PointInSector(listenpos.X, listenpos.Y) == sec) { pos.X = (float)listenpos.X; pos.Z = (float)listenpos.Y; diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index bb3a8918e..ee66b957f 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -657,22 +657,27 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField) return 0; } - DEFINE_ACTION_FUNCTION_NATIVE(_Sector, PointInSector, P_PointInSectorXY) - { - PARAM_PROLOGUE; - PARAM_FLOAT(x); - PARAM_FLOAT(y); - ACTION_RETURN_POINTER(P_PointInSector(x, y)); - } +static sector_t *PointInSectorXY(FLevelLocals *self, double x, double y) +{ + return self->PointInSector(x ,y); +} - static void SetXOffset(sector_t *self, int pos, double o) - { - self->SetXOffset(pos, o); - } +DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, PointInSector, PointInSectorXY) +{ + PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + ACTION_RETURN_POINTER(PointInSectorXY(self, x, y)); +} - DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetXOffset, SetXOffset) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); +static void SetXOffset(sector_t *self, int pos, double o) +{ + self->SetXOffset(pos, o); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetXOffset, SetXOffset) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); PARAM_INT(pos); PARAM_FLOAT(o); self->SetXOffset(pos, o); diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index f0f81d5b6..49e77fb0d 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -714,7 +714,13 @@ struct LevelLocals native native int isFrozen(); native void setFrozen(bool on); - native static clearscope bool IsPointInMap(vector3 p); + native clearscope Sector PointInSector(Vector2 pt); + + native clearscope bool IsPointInLevel(vector3 p); + deprecated("3.8") clearscope static bool IsPointInMap(vector3 p) + { + return level.IsPointInLevel(p); + } native static clearscope vector2 Vec2Diff(vector2 v1, vector2 v2); native static clearscope vector3 Vec3Diff(vector3 v1, vector3 v2); diff --git a/wadsrc/static/zscript/mapdata.txt b/wadsrc/static/zscript/mapdata.txt index 9d056ffed..4a1154feb 100644 --- a/wadsrc/static/zscript/mapdata.txt +++ b/wadsrc/static/zscript/mapdata.txt @@ -368,7 +368,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(); diff --git a/wadsrc/static/zscript/statusbar/alt_hud.txt b/wadsrc/static/zscript/statusbar/alt_hud.txt index 93b21cdda..7fd694c98 100644 --- a/wadsrc/static/zscript/statusbar/alt_hud.txt +++ b/wadsrc/static/zscript/statusbar/alt_hud.txt @@ -735,7 +735,7 @@ class AltHud ui else { pos.xy = currentUILevel.GetAutomapPosition(); - pos.z = Sector.PointInSector(pos.xy).floorplane.ZatPoint(pos.xy); + pos.z = currentUILevel.PointInSector(pos.xy).floorplane.ZatPoint(pos.xy); } int xpos = hudwidth - SmallFont.StringWidth("X: -00000")-6; diff --git a/wadsrc/static/zscript/strife/weapongrenade.txt b/wadsrc/static/zscript/strife/weapongrenade.txt index dc0958a64..9b0db47da 100644 --- a/wadsrc/static/zscript/strife/weapongrenade.txt +++ b/wadsrc/static/zscript/strife/weapongrenade.txt @@ -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);