Added GetTerrainDef and Sector variant of GetFloorTerrain.

- GetTerrainDef takes the raw number of the Terrains[] index. Can return null.
- GetFloorTerrain (Sector) gets the defs from the position given (either Sector.Floor or Sector.Ceiling).
This commit is contained in:
Major Cooke 2022-02-21 18:27:03 -06:00 committed by Christoph Oelckers
parent 85d68b30bb
commit 579c4152d2
5 changed files with 31 additions and 0 deletions

View file

@ -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);

View file

@ -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;
}
//=====================================================================================
//
//

View file

@ -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)
{

View file

@ -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

View file

@ -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);