From b7edc3bf4b68ed28fc739cf6361d9eff297e596c Mon Sep 17 00:00:00 2001 From: Kaelan Date: Wed, 16 Oct 2024 14:38:42 -0600 Subject: [PATCH] Moved bounds check out of core engine as per request --- src/gamedata/r_defs.h | 55 ++++++++++++++++++-------------------- src/scripting/vmthunks.cpp | 2 ++ 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/gamedata/r_defs.h b/src/gamedata/r_defs.h index e940d80abd3..67752fb0a62 100644 --- a/src/gamedata/r_defs.h +++ b/src/gamedata/r_defs.h @@ -40,7 +40,6 @@ #include "r_sky.h" #include "p_terrain.h" #include "p_effect.h" -#include "vm.h" #include "hwrenderer/data/buffers.h" @@ -678,16 +677,16 @@ struct sector_t splane planes[2]; - FLevelLocals *Level; - extsector_t * e; // This stores data that requires construction/destruction. Such data must not be copied by R_FakeFlat. + FLevelLocals* Level; + extsector_t* e; // This stores data that requires construction/destruction. Such data must not be copied by R_FakeFlat. secplane_t floorplane, ceilingplane; // [RH] store floor and ceiling planes instead of heights DVector2 centerspot; // origin for any sounds played by the sector - TStaticPointedArray Lines; - sector_t *heightsec; // killough 3/7/98: support flat heights drawn at another sector's heights other sector, or NULL if no other sector + TStaticPointedArray Lines; + sector_t* heightsec; // killough 3/7/98: support flat heights drawn at another sector's heights other sector, or NULL if no other sector - struct msecnode_t *sectorportal_thinglist; // for cross-portal rendering. - struct msecnode_t *touching_renderthings; // this is used to allow wide things to be rendered not only from their main sector. + struct msecnode_t* sectorportal_thinglist; // for cross-portal rendering. + struct msecnode_t* touching_renderthings; // this is used to allow wide things to be rendered not only from their main sector. PalEntry SpecialColors[5]; // Doom64 style colors PalEntry AdditiveColors[5]; @@ -700,8 +699,8 @@ struct sector_t int validcount; // if == validcount, already checked uint32_t selfmap, bottommap, midmap, topmap; // killough 4/4/98: dynamic colormaps - // [RH] these can also be blend values if - // the alpha mask is non-zero + // [RH] these can also be blend values if + // the alpha mask is non-zero bool transdoor; // For transparent door hacks short lightlevel; @@ -718,8 +717,8 @@ struct sector_t int subsectorcount; // list of subsectors float reflect[2]; double transdoorheight; // for transparent door hacks - subsector_t ** subsectors; - FSectorPortalGroup * portals[2]; // floor and ceiling portals + subsector_t** subsectors; + FSectorPortalGroup* portals[2]; // floor and ceiling portals int vboindex[4]; // VBO indices of the 4 planes this sector uses during rendering. This is only needed for updating plane heights. int iboindex[4]; // IBO indices of the 4 planes this sector uses during rendering @@ -732,7 +731,7 @@ struct sector_t // Below are all properties which are not used by the renderer. TObjPtr SoundTarget; - AActor* thinglist; // list of actors in sector + AActor* thinglist; // list of actors in sector double gravity; // [RH] Sector gravity (1.0 is normal) // thinker_t for reversable actions @@ -744,7 +743,7 @@ struct sector_t // list of mobjs that are at least partially in the sector // thinglist is a subset of touching_thinglist - struct msecnode_t *touching_thinglist; // phares 3/14/98 + struct msecnode_t* touching_thinglist; // phares 3/14/98 // [RH] Action specials for sectors. Like Skull Tag, but more // flexible in a Bloody way. SecActTarget forms a list of actors @@ -801,36 +800,36 @@ struct sector_t return MoveCeiling(speed, dest, -1, direction, false); } - bool IsLinked(sector_t *other, bool ceiling) const; + bool IsLinked(sector_t* other, bool ceiling) const; void RemoveForceField(); int Index() const { return sectornum; } - void AdjustFloorClip () const; + void AdjustFloorClip() const; void SetColor(PalEntry pe, int desat); void SetFade(PalEntry pe); void SetFogDensity(int dens); - void ClosestPoint(const DVector2 &pos, DVector2 &out) const; + void ClosestPoint(const DVector2& pos, DVector2& out) const; int GetFloorLight() const; int GetCeilingLight() const; int GetSpriteLight() const; - sector_t *GetHeightSec() const + sector_t* GetHeightSec() const { - return (MoreFlags & SECMF_IGNOREHEIGHTSEC)? nullptr : heightsec; + return (MoreFlags & SECMF_IGNOREHEIGHTSEC) ? nullptr : heightsec; } - double GetFriction(int plane = sector_t::floor, double *movefac = NULL) const; - bool TriggerSectorActions(AActor *thing, int activation); + double GetFriction(int plane = sector_t::floor, double* movefac = NULL) const; + bool TriggerSectorActions(AActor* thing, int activation); - DInterpolation *SetInterpolation(int position, bool attach); + DInterpolation* SetInterpolation(int position, bool attach); - FSectorPortal *ValidatePortal(int which); + FSectorPortal* ValidatePortal(int which); void CheckPortalPlane(int plane); - int CheckSpriteGlow(int lightlevel, const DVector3 &pos); - bool GetWallGlow(float *topglowcolor, float *bottomglowcolor); + int CheckSpriteGlow(int lightlevel, const DVector3& pos); + bool GetWallGlow(float* topglowcolor, float* bottomglowcolor); void SetXOffset(int pos, double o) { @@ -939,7 +938,7 @@ struct sector_t planes[pos].Flags |= Or; } - int GetPlaneLight(int pos) const + int GetPlaneLight(int pos) const { return planes[pos].Light; } @@ -1025,20 +1024,18 @@ struct sector_t return lightlevel; } - secplane_t &GetSecPlane(int pos) + secplane_t& GetSecPlane(int pos) { - return pos == floor? floorplane:ceilingplane; + return pos == floor ? floorplane : ceilingplane; } void SetPlaneReflectivity(int pos, double val) { - if (pos < 0 || pos > 1) ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "pos must be either 0 or 1"); reflect[pos] = val; } double GetPlaneReflectivity(int pos) { - if (pos < 0 || pos > 1) ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "pos must be either 0 or 1"); return reflect[pos]; } diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index d93a83fdcdd..384347da3c4 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -871,6 +871,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetXOffset, SetXOffset) static void SetPlaneReflectivity(sector_t* self, int pos, double val) { + if (pos < 0 || pos > 1) ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "pos must be either 0 or 1"); self->SetPlaneReflectivity(pos, val); } @@ -885,6 +886,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetXOffset, SetXOffset) static double GetPlaneReflectivity(sector_t* self, int pos) { + if (pos < 0 || pos > 1) ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "pos must be either 0 or 1"); return self->GetPlaneReflectivity(pos); }