Skip to content

Commit

Permalink
Moved bounds check out of core engine as per request
Browse files Browse the repository at this point in the history
  • Loading branch information
kevansevans committed Oct 16, 2024
1 parent 0dbff4a commit b7edc3b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 29 deletions.
55 changes: 26 additions & 29 deletions src/gamedata/r_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include "r_sky.h"
#include "p_terrain.h"
#include "p_effect.h"
#include "vm.h"

#include "hwrenderer/data/buffers.h"

Expand Down Expand Up @@ -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<line_t *> 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<line_t*> 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];
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -732,7 +731,7 @@ struct sector_t
// Below are all properties which are not used by the renderer.

TObjPtr<AActor*> 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
Expand All @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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];
}

Expand Down
2 changes: 2 additions & 0 deletions src/scripting/vmthunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down

0 comments on commit b7edc3b

Please sign in to comment.