diff --git a/src/gamedata/r_defs.h b/src/gamedata/r_defs.h index 57e87e32e4..2aa79a1fd9 100644 --- a/src/gamedata/r_defs.h +++ b/src/gamedata/r_defs.h @@ -37,6 +37,7 @@ #include "r_data/r_translate.h" #include "texmanip.h" #include "fcolormap.h" +#include "p_terrain.h" #include "hwrenderer/data/buffers.h" @@ -1769,6 +1770,8 @@ void TransferSpecial(sector_t *self, sector_t *model); void GetSpecial(sector_t *self, secspecial_t *spec); void SetSpecial(sector_t *self, const secspecial_t *spec); int GetTerrain(const sector_t *, int pos); +FTerrainDef *GetFloorTerrain_S(const sector_t* sec, int pos); +FTerrainDef *GetTerrainDef(const unsigned int num); void CheckPortalPlane(sector_t *sector, int plane); void AdjustFloorClip(const sector_t *sector); void SetColor(sector_t *sector, int color, int desat); diff --git a/src/playsim/p_sectors.cpp b/src/playsim/p_sectors.cpp index 5459792ede..e3963272b9 100644 --- a/src/playsim/p_sectors.cpp +++ b/src/playsim/p_sectors.cpp @@ -938,6 +938,16 @@ int GetTerrain(const sector_t *sector, int pos) return sector->terrainnum[pos] >= 0 ? sector->terrainnum[pos] : TerrainTypes[sector->GetTexture(pos)]; } +FTerrainDef *GetFloorTerrain_S(const sector_t* sec, int pos) +{ + return &Terrains[GetTerrain(sec, pos)]; +} + +FTerrainDef *GetTerrainDef(const unsigned int num) +{ + return (num >= 0 && num < Terrains.Size()) ? &Terrains[num] : nullptr; +} + //===================================================================================== // // diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index b32be00a2e..e35dd43bf3 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -470,6 +470,19 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetTerrain, GetTerrain) ACTION_RETURN_INT(GetTerrain(self, pos)); } +DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetFloorTerrain, GetFloorTerrain_S) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_POINTER(GetFloorTerrain_S(self, pos)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetTerrainDef, GetTerrainDef) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_UINT(floorterrain); + ACTION_RETURN_POINTER(GetTerrainDef(floorterrain)); +} DEFINE_ACTION_FUNCTION_NATIVE(_Sector, CheckPortalPlane, CheckPortalPlane) { diff --git a/wadsrc/static/zscript/constants.zs b/wadsrc/static/zscript/constants.zs index de7eab3d97..458363fc47 100644 --- a/wadsrc/static/zscript/constants.zs +++ b/wadsrc/static/zscript/constants.zs @@ -1021,6 +1021,9 @@ enum EFindFloorCeiling FFCF_NOCEILING = 64, FFCF_RESTRICTEDPORTAL = 128, // current values in the iterator's return are through a restricted portal type (i.e. some features are blocked.) FFCF_NODROPOFF = 256, // Caller does not need a dropoff (saves some time when checking portals) + FFCF_NONSOLID = 512, // [MC] Include non-solids + FFCF_NOSOLIDS = 1024, // [MC] Ignore solid + FFCF_SWIMMABLE = 2048, // [MC] Search for swimmables }; enum ERaise diff --git a/wadsrc/static/zscript/mapdata.zs b/wadsrc/static/zscript/mapdata.zs index f0cfce1c0d..8b296d9947 100644 --- a/wadsrc/static/zscript/mapdata.zs +++ b/wadsrc/static/zscript/mapdata.zs @@ -452,6 +452,8 @@ struct Sector native play native void GetSpecial(out SecSpecial spec); native void SetSpecial( SecSpecial spec); native int GetTerrain(int pos); + native TerrainDef GetTerrainDef(uint floorterrain); // Gets the terraindef from the number (such as an actor's floorterrain). May return null! + native TerrainDef GetFloorTerrain(int pos); // Gets the terraindef from floor/ceiling (see EPlane const). native void CheckPortalPlane(int plane); native double, Sector HighestCeilingAt(Vector2 a); native double, Sector LowestFloorAt(Vector2 a);