- converted a few more in various files.

This commit is contained in:
Christoph Oelckers 2019-01-06 22:10:19 +01:00
parent 6e1b46cda5
commit 7d060dc696
17 changed files with 117 additions and 88 deletions

View file

@ -643,7 +643,7 @@ public:
AActor &operator= (const AActor &other);
~AActor ();
FLevelLocals *__GetLevel(); // With double underscore so that it can be replaced later, once a permanent solution has been implemented.
FLevelLocals *__GetLevel() const; // With double underscore so that it can be replaced later, once a permanent solution has been implemented.
virtual void OnDestroy() override;
virtual void Serialize(FSerializer &arc) override;

View file

@ -6,30 +6,38 @@
#include "d_player.h"
// These depend on both actor.h and r_defs.h so they cannot be in either file without creating a circular dependency.
// Needs something more permanent.
inline FLevelLocals *AActor::__GetLevel() const
{
return &level;
}
inline DVector3 AActor::PosRelative(int portalgroup) const
{
return Pos() + level.Displacements.getOffset(Sector->PortalGroup, portalgroup);
return Pos() + __GetLevel()->Displacements.getOffset(Sector->PortalGroup, portalgroup);
}
inline DVector3 AActor::PosRelative(const AActor *other) const
{
return Pos() + level.Displacements.getOffset(Sector->PortalGroup, other->Sector->PortalGroup);
return Pos() + __GetLevel()->Displacements.getOffset(Sector->PortalGroup, other->Sector->PortalGroup);
}
inline DVector3 AActor::PosRelative(sector_t *sec) const
{
return Pos() + level.Displacements.getOffset(Sector->PortalGroup, sec->PortalGroup);
return Pos() + __GetLevel()->Displacements.getOffset(Sector->PortalGroup, sec->PortalGroup);
}
inline DVector3 AActor::PosRelative(const line_t *line) const
{
return Pos() + level.Displacements.getOffset(Sector->PortalGroup, line->frontsector->PortalGroup);
return Pos() + __GetLevel()->Displacements.getOffset(Sector->PortalGroup, line->frontsector->PortalGroup);
}
/*
inline DVector3 PosRelative(const DVector3 &pos, line_t *line, sector_t *refsec = NULL)
{
return pos + level.Displacements.getOffset(refsec->PortalGroup, line->frontsector->PortalGroup);
return pos + __GetLevel()->Displacements.getOffset(refsec->PortalGroup, line->frontsector->PortalGroup);
}
*/
inline void AActor::ClearInterpolation()
@ -61,7 +69,7 @@ inline double AActor::GetBobOffset(double ticfrac) const
{
return 0;
}
return BobSin(FloatBobPhase + level.maptime + ticfrac) * FloatBobStrength;
return BobSin(FloatBobPhase + __GetLevel()->maptime + ticfrac) * FloatBobStrength;
}
inline double AActor::GetCameraHeight() const
@ -78,7 +86,7 @@ inline FDropItem *AActor::GetDropItems() const
inline double AActor::GetGravity() const
{
if (flags & MF_NOGRAVITY) return 0;
return level.gravity * Sector->gravity * Gravity * 0.00125;
return __GetLevel()->gravity * Sector->gravity * Gravity * 0.00125;
}
inline double AActor::AttackOffset(double offset)
@ -94,8 +102,3 @@ inline double AActor::AttackOffset(double offset)
}
// Needs something more permanent.
inline FLevelLocals *AActor::__GetLevel()
{
return &level;
}

View file

@ -243,32 +243,33 @@ extern FLevelLocals level;
inline FSectorPortal *line_t::GetTransferredPortal()
{
return portaltransferred >= level.sectorPortals.Size() ? (FSectorPortal*)nullptr : &level.sectorPortals[portaltransferred];
auto Level = GetLevel();
return portaltransferred >= Level->sectorPortals.Size() ? (FSectorPortal*)nullptr : &Level->sectorPortals[portaltransferred];
}
inline FSectorPortal *sector_t::GetPortal(int plane)
{
return &level.sectorPortals[Portals[plane]];
return &Level->sectorPortals[Portals[plane]];
}
inline double sector_t::GetPortalPlaneZ(int plane)
{
return level.sectorPortals[Portals[plane]].mPlaneZ;
return Level->sectorPortals[Portals[plane]].mPlaneZ;
}
inline DVector2 sector_t::GetPortalDisplacement(int plane)
{
return level.sectorPortals[Portals[plane]].mDisplacement;
return Level->sectorPortals[Portals[plane]].mDisplacement;
}
inline int sector_t::GetPortalType(int plane)
{
return level.sectorPortals[Portals[plane]].mType;
return Level->sectorPortals[Portals[plane]].mType;
}
inline int sector_t::GetOppositePortalGroup(int plane)
{
return level.sectorPortals[Portals[plane]].mDestination->PortalGroup;
return Level->sectorPortals[Portals[plane]].mDestination->PortalGroup;
}
inline bool sector_t::PortalBlocksView(int plane)
@ -299,29 +300,34 @@ inline bool sector_t::PortalIsLinked(int plane)
inline FLinePortal *line_t::getPortal() const
{
return portalindex >= level.linePortals.Size() ? (FLinePortal*)NULL : &level.linePortals[portalindex];
auto Level = GetLevel();
return portalindex >= Level->linePortals.Size() ? (FLinePortal*)NULL : &Level->linePortals[portalindex];
}
// returns true if the portal is crossable by actors
inline bool line_t::isLinePortal() const
{
return portalindex >= level.linePortals.Size() ? false : !!(level.linePortals[portalindex].mFlags & PORTF_PASSABLE);
auto Level = GetLevel();
return portalindex >= Level->linePortals.Size() ? false : !!(Level->linePortals[portalindex].mFlags & PORTF_PASSABLE);
}
// returns true if the portal needs to be handled by the renderer
inline bool line_t::isVisualPortal() const
{
return portalindex >= level.linePortals.Size() ? false : !!(level.linePortals[portalindex].mFlags & PORTF_VISIBLE);
auto Level = GetLevel();
return portalindex >= Level->linePortals.Size() ? false : !!(Level->linePortals[portalindex].mFlags & PORTF_VISIBLE);
}
inline line_t *line_t::getPortalDestination() const
{
return portalindex >= level.linePortals.Size() ? (line_t*)NULL : level.linePortals[portalindex].mDestination;
auto Level = GetLevel();
return portalindex >= Level->linePortals.Size() ? (line_t*)NULL : Level->linePortals[portalindex].mDestination;
}
inline int line_t::getPortalAlignment() const
{
return portalindex >= level.linePortals.Size() ? 0 : level.linePortals[portalindex].mAlign;
auto Level = GetLevel();
return portalindex >= Level->linePortals.Size() ? 0 : Level->linePortals[portalindex].mAlign;
}
inline bool line_t::hitSkyWall(AActor* mo) const

View file

@ -8895,7 +8895,7 @@ scriptwait:
const char *fromname = level.Behaviors.LookupString(STACK(3));
const char *toname = level.Behaviors.LookupString(STACK(2));
P_ReplaceTextures(fromname, toname, STACK(1));
P_ReplaceTextures(&level, fromname, toname, STACK(1));
sp -= 3;
break;
}

View file

@ -2598,7 +2598,7 @@ FUNC(LS_Line_AlignCeiling)
int line;
while ((line = itr.Next()) >= 0)
{
ret |= P_AlignFlat (line, !!arg1, 1);
ret |= P_AlignFlat (Level, line, !!arg1, 1);
}
return ret;
}
@ -2612,7 +2612,7 @@ FUNC(LS_Line_AlignFloor)
int line;
while ((line = itr.Next()) >= 0)
{
ret |= P_AlignFlat (line, !!arg1, 0);
ret |= P_AlignFlat (Level, line, !!arg1, 0);
}
return ret;
}

View file

@ -457,11 +457,11 @@ enum EDmgFlags
DMG_NO_ENHANCE = 4096,
};
struct FLevelLocals;
//
// P_SPEC
//
bool P_AlignFlat (int linenum, int side, int fc);
bool P_AlignFlat (FLevelLocals *l, int linenum, int side, int fc);
enum ETexReplaceFlags
{
@ -472,7 +472,7 @@ enum ETexReplaceFlags
NOT_CEILING = 16
};
void P_ReplaceTextures(const char *fromname, const char *toname, int flags);
void P_ReplaceTextures(FLevelLocals *l, const char *fromname, const char *toname, int flags);
enum ERaise
{

View file

@ -382,20 +382,21 @@ portnode_t *P_AddPortalnode(FLinePortal *s, AActor *thing, portnode_t *nextnode)
void AActor::UpdateRenderSectorList()
{
static const double SPRITE_SPACE = 64.;
auto Level = __GetLevel();
if (Pos() != OldRenderPos && !(flags & MF_NOSECTOR))
{
// Only check if the map contains line portals
ClearRenderLineList();
if (level.PortalBlockmap.containsLines && Pos().XY() != OldRenderPos.XY())
if (Level->PortalBlockmap.containsLines && Pos().XY() != OldRenderPos.XY())
{
int bx = level.blockmap.GetBlockX(X());
int by = level.blockmap.GetBlockY(Y());
int bx = Level->blockmap.GetBlockX(X());
int by = Level->blockmap.GetBlockY(Y());
FBoundingBox bb(X(), Y(), MIN(radius*1.5, 128.)); // Don't go further than 128 map units, even for large actors
// Are there any portals near the actor's position?
if (level.blockmap.isValidBlock(bx, by) && level.PortalBlockmap(bx, by).neighborContainsLines)
if (Level->blockmap.isValidBlock(bx, by) && Level->PortalBlockmap(bx, by).neighborContainsLines)
{
// Go through the entire list. In most cases this is faster than setting up a blockmap iterator
for (auto &p : level.linePortals)
for (auto &p : Level->linePortals)
{
if (p.mType == PORTT_VISUAL) continue;
if (bb.inRange(p.mOrigin) && bb.BoxOnLineSide(p.mOrigin))

View file

@ -623,7 +623,7 @@ double FindHighestFloorPoint (const sector_t *sector, vertex_t **v)
{
if (v != NULL)
{
if (sector->Lines.Size() == 0) *v = &level.vertexes[0];
if (sector->Lines.Size() == 0) *v = &sector->Level->vertexes[0];
else *v = sector->Lines[0]->v1;
}
return -sector->floorplane.fD();
@ -663,7 +663,7 @@ double FindLowestCeilingPoint (const sector_t *sector, vertex_t **v)
{
if (v != nullptr)
{
if (sector->Lines.Size() == 0) *v = &level.vertexes[0];
if (sector->Lines.Size() == 0) *v = &sector->Level->vertexes[0];
else *v = sector->Lines[0]->v1;
}
return sector->ceilingplane.fD();
@ -1358,9 +1358,9 @@ bool secplane_t::CopyPlaneIfValid (secplane_t *dest, const secplane_t *opp) cons
//
//==========================================================================
bool P_AlignFlat (int linenum, int side, int fc)
bool P_AlignFlat (FLevelLocals *Level, int linenum, int side, int fc)
{
line_t *line = &level.lines[linenum];
line_t *line = &Level->lines[linenum];
sector_t *sec = side ? line->backsector : line->frontsector;
if (!sec)
@ -1388,7 +1388,7 @@ bool P_AlignFlat (int linenum, int side, int fc)
//
//==========================================================================
void P_ReplaceTextures(const char *fromname, const char *toname, int flags)
void P_ReplaceTextures(FLevelLocals *Level, const char *fromname, const char *toname, int flags)
{
FTextureID picnum1, picnum2;
@ -1400,7 +1400,7 @@ void P_ReplaceTextures(const char *fromname, const char *toname, int flags)
picnum1 = TexMan.GetTextureID(fromname, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
picnum2 = TexMan.GetTextureID(toname, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
for (auto &side : level.sides)
for (auto &side : Level->sides)
{
for (int j = 0; j<3; j++)
{
@ -1417,7 +1417,7 @@ void P_ReplaceTextures(const char *fromname, const char *toname, int flags)
picnum1 = TexMan.GetTextureID(fromname, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
picnum2 = TexMan.GetTextureID(toname, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
for (auto &sec : level.sectors)
for (auto &sec : Level->sectors)
{
if (!(flags & NOT_FLOOR) && sec.GetTexture(sector_t::floor) == picnum1)
sec.SetTexture(sector_t::floor, picnum2);
@ -1438,11 +1438,12 @@ static FNodeBuilder PolyNodeBuilder(PolyNodeLevel);
void subsector_t::BuildPolyBSP()
{
assert((BSP == NULL || BSP->bDirty) && "BSP computed more than once");
auto Level = sector->Level;
// Set up level information for the node builder.
PolyNodeLevel.Sides = &level.sides[0];
PolyNodeLevel.NumSides = level.sides.Size();
PolyNodeLevel.Lines = &level.lines[0];
PolyNodeLevel.Sides = &Level->sides[0];
PolyNodeLevel.NumSides = Level->sides.Size();
PolyNodeLevel.Lines = &Level->lines[0];
PolyNodeLevel.NumLines = numlines; // is this correct???
// Feed segs to the nodebuilder and build the nodes.
@ -1528,26 +1529,27 @@ int side_t::GetLightLevel (bool foggy, int baselight, bool is3dlight, int *pfake
*pfakecontrast = 0;
}
auto Level = sector->Level;
if (!foggy || level.flags3 & LEVEL3_FORCEFAKECONTRAST) // Don't do relative lighting in foggy sectors
{
if (!(Flags & WALLF_NOFAKECONTRAST) && r_fakecontrast != 0)
{
DVector2 delta = linedef->Delta();
int rel;
if (((level.flags2 & LEVEL2_SMOOTHLIGHTING) || (Flags & WALLF_SMOOTHLIGHTING) || r_fakecontrast == 2) &&
if (((Level->flags2 & LEVEL2_SMOOTHLIGHTING) || (Flags & WALLF_SMOOTHLIGHTING) || r_fakecontrast == 2) &&
delta.X != 0)
{
rel = xs_RoundToInt // OMG LEE KILLOUGH LIVES! :/
(
level.WallHorizLight
Level->WallHorizLight
+ fabs(atan(delta.Y / delta.X) / 1.57079)
* (level.WallVertLight - level.WallHorizLight)
* (Level->WallVertLight - Level->WallHorizLight)
);
}
else
{
rel = delta.X == 0 ? level.WallVertLight :
delta.Y == 0 ? level.WallHorizLight : 0;
rel = delta.X == 0 ? Level->WallVertLight :
delta.Y == 0 ? Level->WallHorizLight : 0;
}
if (pfakecontrast != NULL)
{

View file

@ -92,6 +92,7 @@ static TArray<SightTask> portals(32);
class SightCheck
{
FLevelLocals *Level;
DVector3 sightstart;
DVector2 sightend;
double Startfrac;
@ -120,6 +121,7 @@ public:
void init(AActor * t1, AActor * t2, sector_t *startsector, SightTask *task, int flags)
{
Level = t1->__GetLevel();
sightstart = t1->PosRelative(task->portalgroup);
sightend = t2->PosRelative(task->portalgroup);
sightstart.Z += t1->Height * 0.75;
@ -407,7 +409,7 @@ bool SightCheck::LineBlocksSight(line_t *ld)
{
return true;
}
if (ld->args[1] != 0 && ld->args[1] != level.levelnum)
if (ld->args[1] != 0 && ld->args[1] != Level->levelnum)
{
return true;
}
@ -477,14 +479,14 @@ int SightCheck::P_SightBlockLinesIterator (int x, int y)
polyblock_t *polyLink;
unsigned int i;
offset = y*level.blockmap.bmapwidth+x;
offset = y*Level->blockmap.bmapwidth+x;
// if any of the previous blocks may contain a portal we may abort the collection of lines here, but we may not abort the sight check.
// (We still try to delay activating this for as long as possible.)
portalfound = portalfound || level.PortalBlockmap(x, y).containsLinkedPortals;
portalfound = portalfound || Level->PortalBlockmap(x, y).containsLinkedPortals;
polyLink = level.PolyBlockMap[offset];
portalfound |= (polyLink && level.PortalBlockmap.hasLinkedPolyPortals);
polyLink = Level->PolyBlockMap[offset];
portalfound |= (polyLink && Level->PortalBlockmap.hasLinkedPolyPortals);
while (polyLink)
{
if (polyLink->polyobj)
@ -505,9 +507,9 @@ int SightCheck::P_SightBlockLinesIterator (int x, int y)
polyLink = polyLink->next;
}
for (list = level.blockmap.GetLines(x, y); *list != -1; list++)
for (list = Level->blockmap.GetLines(x, y); *list != -1; list++)
{
if (!P_SightCheckLine (&level.lines[*list]))
if (!P_SightCheckLine (&Level->lines[*list]))
{
if (!portalfound) return 0;
else res = -1;
@ -661,13 +663,13 @@ bool SightCheck::P_SightPathTraverse ()
portals.Push({ 0, topslope, bottomslope, sector_t::floor, lastsector->GetOppositePortalGroup(sector_t::floor) });
}
x1 -= level.blockmap.bmaporgx;
y1 -= level.blockmap.bmaporgy;
x1 -= Level->blockmap.bmaporgx;
y1 -= Level->blockmap.bmaporgy;
xt1 = x1 / FBlockmap::MAPBLOCKUNITS;
yt1 = y1 / FBlockmap::MAPBLOCKUNITS;
x2 -= level.blockmap.bmaporgx;
y2 -= level.blockmap.bmaporgy;
x2 -= Level->blockmap.bmaporgx;
y2 -= Level->blockmap.bmaporgy;
xt2 = x2 / FBlockmap::MAPBLOCKUNITS;
yt2 = y2 / FBlockmap::MAPBLOCKUNITS;
@ -747,7 +749,7 @@ bool SightCheck::P_SightPathTraverse ()
{
// end traversing when reaching the end of the blockmap
// an early out is not possible because with portals a trace can easily land outside the map's bounds.
if (!level.blockmap.isValidBlock(mapx, mapy))
if (!Level->blockmap.isValidBlock(mapx, mapy))
{
break;
}
@ -846,15 +848,16 @@ int P_CheckSight (AActor *t1, AActor *t2, int flags)
return false;
}
auto Level = t1->__GetLevel();
const sector_t *s1 = t1->Sector;
const sector_t *s2 = t2->Sector;
int pnum = int(s1->Index()) * level.sectors.Size() + int(s2->Index());
int pnum = int(s1->Index()) * Level->sectors.Size() + int(s2->Index());
//
// check for trivial rejection
//
if (level.rejectmatrix.Size() > 0 &&
(level.rejectmatrix[pnum>>3] & (1 << (pnum & 7))))
if (Level->rejectmatrix.Size() > 0 &&
(Level->rejectmatrix[pnum>>3] & (1 << (pnum & 7))))
{
sightcounts[0]++;
res = false; // can't possibly be connected

View file

@ -205,7 +205,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVe
}
// some old WADs use this method to create walls that change the texture when shot.
else if (activationType == SPAC_Impact && // only for shootable triggers
(line->frontsector->Level->flags2 & LEVEL2_DUMMYSWITCHES) && // this is only a compatibility setting for an old hack!
(line->GetLevel()->flags2 & LEVEL2_DUMMYSWITCHES) && // this is only a compatibility setting for an old hack!
!repeat && // only non-repeatable triggers
(special<Generic_Floor || special>Generic_Crusher) && // not for Boom's generalized linedefs
special && // not for lines without a special
@ -316,7 +316,7 @@ bool P_TestActivateLine (line_t *line, AActor *mo, int side, int activationType,
// lax activation checks, monsters can also activate certain lines
// even without them being marked as monster activate-able. This is
// the default for non-Hexen maps in Hexen format.
if (!(line->frontsector->Level->flags2 & LEVEL2_LAXMONSTERACTIVATION))
if (!(line->GetLevel()->flags2 & LEVEL2_LAXMONSTERACTIVATION))
{
return false;
}

View file

@ -385,6 +385,7 @@ bool FTraceInfo::LineCheck(intercept_t *in, double dist, DVector3 hit, bool spec
int lineside;
sector_t *entersector;
auto Level = CurSector->Level;
double ff, fc, bf = 0, bc = 0;
if (in->d.line->frontsector->sectornum == CurSector->sectornum)
@ -452,7 +453,7 @@ bool FTraceInfo::LineCheck(intercept_t *in, double dist, DVector3 hit, bool spec
// hit crossed a water plane
if (CheckSectorPlane(hsec, true))
{
Results->CrossedWater = &level.sectors[CurSector->sectornum];
Results->CrossedWater = &Level->sectors[CurSector->sectornum];
Results->CrossedWaterPos = Results->HitPos;
Results->Distance = 0;
}
@ -583,7 +584,7 @@ cont:
if (Results->HitType != TRACE_HitNone)
{
// We hit something, so figure out where exactly
Results->Sector = &level.sectors[CurSector->sectornum];
Results->Sector = &Level->sectors[CurSector->sectornum];
if (Results->HitType != TRACE_HitWall &&
!CheckSectorPlane(CurSector, Results->HitType == TRACE_HitFloor))
@ -667,6 +668,7 @@ cont:
bool FTraceInfo::ThingCheck(intercept_t *in, double dist, DVector3 hit)
{
auto Level = CurSector->Level;
if (hit.Z > in->d.thing->Top())
{
// trace enters above actor
@ -720,7 +722,7 @@ bool FTraceInfo::ThingCheck(intercept_t *in, double dist, DVector3 hit)
// the trace hit a 3D floor before the thing.
// Calculate an intersection and abort.
Results->Sector = &level.sectors[CurSector->sectornum];
Results->Sector = &Level->sectors[CurSector->sectornum];
if (!CheckSectorPlane(CurSector, Results->HitType == TRACE_HitFloor))
{
Results->HitType = TRACE_HitNone;
@ -872,7 +874,7 @@ bool FTraceInfo::TraceTraverse (int ptflags)
}
// check for intersection with floor/ceiling
Results->Sector = &level.sectors[CurSector->sectornum];
Results->Sector = &CurSector->Level->sectors[CurSector->sectornum];
if (Results->CrossedWater == NULL &&
CurSector->heightsec != NULL &&
@ -886,7 +888,7 @@ bool FTraceInfo::TraceTraverse (int ptflags)
if (CheckSectorPlane(CurSector->heightsec, true))
{
Results->CrossedWater = &level.sectors[CurSector->sectornum];
Results->CrossedWater = &CurSector->Level->sectors[CurSector->sectornum];
Results->CrossedWaterPos = Results->HitPos;
Results->Distance = 0;
}

View file

@ -889,8 +889,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream)
return 0;
}
auto Level = self->__GetLevel();
// Handle the different player death screams
if ((((level.flags >> 15) | (dmflags)) &
if ((((Level->flags >> 15) | (dmflags)) &
(DF_FORCE_FALLINGZD | DF_FORCE_FALLINGHX)) &&
self->Vel.Z <= -39)
{
@ -1009,7 +1010,8 @@ void P_FallingDamage (AActor *actor)
int damage;
double vel;
damagestyle = ((level.flags >> 15) | (dmflags)) &
auto Level = actor->__GetLevel();
damagestyle = ((Level->flags >> 15) | (dmflags)) &
(DF_FORCE_FALLINGZD | DF_FORCE_FALLINGHX);
if (damagestyle == 0)
@ -1110,6 +1112,7 @@ void P_CheckMusicChange(player_t *player)
{
if (player->MUSINFOactor->args[0] != 0)
{
auto Level = player->mo->__GetLevel();
FName *music = level.info->MusicMap.CheckKey(player->MUSINFOactor->args[0]);
if (music != NULL)
@ -1248,7 +1251,7 @@ void P_PredictionLerpReset()
bool P_LerpCalculate(AActor *pmo, PredictPos from, PredictPos to, PredictPos &result, float scale)
{
//DVector2 pfrom = level.Displacements.getOffset(from.portalgroup, to.portalgroup);
//DVector2 pfrom = Level->Displacements.getOffset(from.portalgroup, to.portalgroup);
DVector3 vecFrom = from.pos;
DVector3 vecTo = to.pos;
DVector3 vecResult;
@ -1683,7 +1686,7 @@ bool P_IsPlayerTotallyFrozen(const player_t *player)
return
gamestate == GS_TITLELEVEL ||
player->cheats & CF_TOTALLYFROZEN ||
((level.flags2 & LEVEL2_FROZEN) && player->timefreezer == 0);
((player->mo->__GetLevel()->flags2 & LEVEL2_FROZEN) && player->timefreezer == 0);
}

View file

@ -210,7 +210,7 @@ static line_t *FindDestination(line_t *src, int tag)
if (tag)
{
int lineno = -1;
auto Level = src->frontsector->Level;
auto Level = src->GetLevel();
FLineIdIterator it(tag);
while ((lineno = it.Next()) >= 0)
@ -270,7 +270,7 @@ static void SetRotation(FLinePortal *port)
void P_SpawnLinePortal(line_t* line)
{
auto Level = line->frontsector->Level;
auto Level = line->GetLevel();
// portal destination is special argument #0
line_t* dst = nullptr;
@ -354,7 +354,7 @@ void P_SpawnLinePortal(line_t* line)
void P_UpdatePortal(FLinePortal *port)
{
auto Level = port->mOrigin->frontsector->Level;
auto Level = port->mOrigin->GetLevel();
if (port->mType != PORTT_VISUAL && port->mOrigin->backsector == nullptr && !(port->mOrigin->sidedef[0]->Flags & WALLF_POLYOBJ))
{
Printf(TEXTCOLOR_RED "Warning: Traversable portals must have a back-sector and empty space behind them (or be on a polyobject)! Changing line %d to visual-portal!\n", port->mOrigin->Index());
@ -445,7 +445,7 @@ void P_FinalizePortals(FLevelLocals *Level)
static bool ChangePortalLine(line_t *line, int destid)
{
auto Level = line->frontsector->Level;
auto Level = line->GetLevel();
if (line->portalindex >= Level->linePortals.Size()) return false;
FLinePortal *port = &Level->linePortals[line->portalindex];
if (port->mType == PORTT_LINKED) return false; // linked portals cannot be changed.
@ -489,7 +489,7 @@ bool P_ChangePortal(line_t *ln, int thisid, int destid)
{
int lineno;
auto Level = ln->frontsector->Level;
auto Level = ln->GetLevel();
if (thisid == 0) return ChangePortalLine(ln, destid);
FLineIdIterator it(thisid);
bool res = false;

View file

@ -1406,6 +1406,11 @@ struct line_t
alpha = a;
}
FLevelLocals *GetLevel() const
{
return frontsector->Level;
}
FSectorPortal *GetTransferredPortal();
void AdjustLine();

View file

@ -1620,18 +1620,18 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
//=====================================================================================
// This is needed to convert the strings to char pointers.
static void ReplaceTextures(const FString &from, const FString &to, int flags)
static void ReplaceTextures(FLevelLocals *l, const FString &from, const FString &to, int flags)
{
P_ReplaceTextures(from, to, flags);
P_ReplaceTextures(l, from, to, flags);
}
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, ReplaceTextures, ReplaceTextures)
DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, ReplaceTextures, ReplaceTextures)
{
PARAM_PROLOGUE;
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
PARAM_STRING(from);
PARAM_STRING(to);
PARAM_INT(flags);
P_ReplaceTextures(from, to, flags);
P_ReplaceTextures(self, from, to, flags);
return 0;
}

View file

@ -91,7 +91,10 @@ struct TexMan
};
native static TextureID CheckForTexture(String name, int usetype, int flags = TryAny);
native static void ReplaceTextures(String from, String to, int flags);
deprecated("3.8") static void ReplaceTextures(String from, String to, int flags)
{
level.ReplaceTextures(from, to, flags);
}
native static String GetName(TextureID tex);
native static int, int GetSize(TextureID tex);
native static Vector2 GetScaledSize(TextureID tex);
@ -702,6 +705,7 @@ struct LevelLocals native
native bool IsFreelookAllowed() const;
native void StartIntermission(Name type, int state) const;
native SpotState GetSpotState(bool create = true);
native void ReplaceTextures(String from, String to, int flags);
native clearscope bool IsPointInMap(vector3 p);

View file

@ -631,7 +631,7 @@ class Weapon : StateProvider
override Inventory CreateTossable (int amt)
{
// Only drop the weapon that is meant to be placed in a level. That is,
// Only drop the weapon that is meant to be placed in a Level. That is,
// only drop the weapon that normally gives you ammo.
if (SisterWeapon != NULL &&
Default.AmmoGive1 == 0 && Default.AmmoGive2 == 0 &&