From 421c40e929e6fea65c8cdcf3c748070669243c1a Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Tue, 22 Feb 2022 09:32:08 -0600 Subject: [PATCH] Replaced GetTerrainDef with the global Terrains array. --- src/g_game.cpp | 1 + src/gamedata/r_defs.h | 1 - src/playsim/p_sectors.cpp | 7 +------ src/scripting/vmthunks.cpp | 7 ------- wadsrc/static/zscript/doombase.zs | 1 + wadsrc/static/zscript/mapdata.zs | 1 - 6 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 10b4ee4c05..da11adf1d2 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -3132,3 +3132,4 @@ DEFINE_GLOBAL(automapactive); DEFINE_GLOBAL(Net_Arbitrator); DEFINE_GLOBAL(netgame); DEFINE_GLOBAL(paused); +DEFINE_GLOBAL(Terrains); diff --git a/src/gamedata/r_defs.h b/src/gamedata/r_defs.h index 2aa79a1fd9..d233e09e0c 100644 --- a/src/gamedata/r_defs.h +++ b/src/gamedata/r_defs.h @@ -1771,7 +1771,6 @@ 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 e3963272b9..bc31156a6d 100644 --- a/src/playsim/p_sectors.cpp +++ b/src/playsim/p_sectors.cpp @@ -943,12 +943,7 @@ 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 e35dd43bf3..11bee9835d 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -477,13 +477,6 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetFloorTerrain, GetFloorTerrain_S) 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) { PARAM_SELF_STRUCT_PROLOGUE(sector_t); diff --git a/wadsrc/static/zscript/doombase.zs b/wadsrc/static/zscript/doombase.zs index 1670e3b95e..34a00cdd47 100644 --- a/wadsrc/static/zscript/doombase.zs +++ b/wadsrc/static/zscript/doombase.zs @@ -5,6 +5,7 @@ extend struct _ native readonly Array<@PlayerClass> PlayerClasses; native readonly Array<@PlayerSkin> PlayerSkins; native readonly Array<@Team> Teams; + native readonly Array<@TerrainDef> Terrains; native int validcount; native play @DehInfo deh; native readonly bool automapactive; diff --git a/wadsrc/static/zscript/mapdata.zs b/wadsrc/static/zscript/mapdata.zs index 8b296d9947..01bf62b050 100644 --- a/wadsrc/static/zscript/mapdata.zs +++ b/wadsrc/static/zscript/mapdata.zs @@ -452,7 +452,6 @@ 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);