diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 9afbbcb3b..008ad91af 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -62,6 +62,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "d_net.h" #include "v_video.h" #include "v_draw.h" +#include "texturemanager.h" #include "statusbar.h" BEGIN_BLD_NS @@ -395,6 +396,16 @@ void GameInterface::DrawBackground() DrawTexture(twod, tileGetTexture(2518, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE); } +#define x(a, b) registerName(#a, b); +static void SetTileNames() +{ + auto registerName = [](const char* name, int index) + { + TexMan.AddAlias(name, tileGetTexture(index)); + }; +#include "namelist.h" +} +#undef x void ReadAllRFS(); @@ -417,6 +428,7 @@ void GameInterface::app_init() levelLoadDefaults(); LoadDefinitions(); + SetTileNames(); TileFiles.SetBackup(); powerupInit(); diff --git a/source/blood/src/common_game.h b/source/blood/src/common_game.h index e3f697399..cebe888f3 100644 --- a/source/blood/src/common_game.h +++ b/source/blood/src/common_game.h @@ -55,46 +55,46 @@ void _consoleSysMsg(const char* pMessage, ...); #define dassert(x) assert(x) - -#define kMaxSectors MAXSECTORS -#define kMaxWalls MAXWALLS -#define kMaxSprites MAXSPRITES - -#define kMaxTiles MAXTILES -#define kMaxStatus MAXSTATUS -#define kMaxPlayers 8 #define kMaxViewSprites maxspritesonscreen -#define kMaxVoxels MAXVOXELS +enum +{ + kMaxSectors = MAXSECTORS, + kMaxWalls = MAXWALLS, + kMaxSprites = MAXSPRITES, -#define kTicRate 120 -#define kTicsPerFrame 4 -#define kTicsPerSec (kTicRate/kTicsPerFrame) + kMaxTiles = MAXTILES, + kMaxStatus = MAXSTATUS, + kMaxPlayers = 8, + kMaxVoxels = MAXVOXELS, -#define TILTBUFFER 4078 + kTicRate = 120, + kTicsPerFrame = 4, + kTicsPerSec = (kTicRate / kTicsPerFrame), -#define kExplodeMax 8 + kExplodeMax = 8, -#define kLensSize 80 -#define kViewEffectMax 19 + kLensSize = 80, + kViewEffectMax = 19, -#define kNoTile -1 + kNoTile = -1, -// defined by NoOne: -// ------------------------------- + //= = = = // = defined = by = NoOne: + //= = = = // = ------------------------------- -#define kMaxPAL 5 -#define kUserPLUStart 15 + kMaxPAL = 5, + kUserPLUStart = 15, -#define kDmgFall 0 -#define kDmgBurn 1 -#define kDmgBullet 2 -#define kDmgExplode 3 -#define kDmgChoke 4 -#define kDmgSpirit 5 -#define kDmgElectric 6 -#define kDmgMax 7 + kDmgFall = 0, + kDmgBurn = 1, + kDmgBullet = 2, + kDmgExplode = 3, + kDmgChoke = 4, + kDmgSpirit = 5, + kDmgElectric = 6, + kDmgMax = 7, +}; // MEDIUM ///////////////////////////////////////////////////// enum { diff --git a/source/common/textures/texturemanager.cpp b/source/common/textures/texturemanager.cpp index 4d3c94281..4a505600b 100644 --- a/source/common/textures/texturemanager.cpp +++ b/source/common/textures/texturemanager.cpp @@ -1554,7 +1554,7 @@ void FTextureManager::SetTranslation(FTextureID fromtexnum, FTextureID totexnum) void FTextureManager::AddAlias(const char* name, FGameTexture* tex) { FTextureID id = tex->GetID(); - if (tex != Textures[id.GetIndex()].Texture) return; // Whatever got passed in here was not valid, so ignore the alias. + if (tex != Textures[id.GetIndex()].Texture || !tex->isValid()) return; // Whatever got passed in here was not valid, so ignore the alias. aliases.Insert(name, id.GetIndex()); } diff --git a/source/core/textures/buildtiles.cpp b/source/core/textures/buildtiles.cpp index c1b20d1d6..2d15b8f9a 100644 --- a/source/core/textures/buildtiles.cpp +++ b/source/core/textures/buildtiles.cpp @@ -1195,6 +1195,7 @@ void processSetAnim(const char* cmd, FScriptPosition& pos, SetAnim& imp) TileSiz tilesiz; PicAnm picanm; +#if 0 // this only gets in if unavoidable. It'd be preferable if the script side can solely operate on texture names. #include "vm.h" static int GetTexture(int tile, int anim) @@ -1211,3 +1212,4 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TileFiles, GetTexture, GetTexture) PARAM_BOOL(animate); ACTION_RETURN_INT(GetTexture(tile, animate)); } +#endif diff --git a/wadsrc/static/zscript/base.zs b/wadsrc/static/zscript/base.zs index 19fb306fc..a2a49abe3 100644 --- a/wadsrc/static/zscript/base.zs +++ b/wadsrc/static/zscript/base.zs @@ -230,7 +230,7 @@ struct TexMan NOT_FLAT = 24 }; - native static TextureID CheckForTexture(String name, int usetype, int flags = TryAny); + native static TextureID CheckForTexture(String name, int usetype = Type_Any, int flags = TryAny); native static String GetName(TextureID tex); native static int, int GetSize(TextureID tex); native static Vector2 GetScaledSize(TextureID tex); diff --git a/wadsrc/static/zscript/games/blood/ui/menu.zs b/wadsrc/static/zscript/games/blood/ui/menu.zs index c1d8de23f..5c304c0b5 100644 --- a/wadsrc/static/zscript/games/blood/ui/menu.zs +++ b/wadsrc/static/zscript/games/blood/ui/menu.zs @@ -4,7 +4,7 @@ class MenuCustomizerBlood : MenuCustomize override int DrawCaption(String title, Font fnt, int y, bool drawit) { let font = generic_ui? NewConsoleFont : BigFont; // this ignores the passed font intentionally. - let texid = tileFiles.GetTexture(2038, true); + let texid = TexMan.CheckForTexture("MENUBAR"); let texsize = TexMan.GetScaledSize(texid); let fonth = font.GetGlyphHeight("A"); if (drawit) diff --git a/wadsrc/static/zscript/razebase.zs b/wadsrc/static/zscript/razebase.zs index 2292be072..f06008f19 100644 --- a/wadsrc/static/zscript/razebase.zs +++ b/wadsrc/static/zscript/razebase.zs @@ -1,5 +1,6 @@ - +/* struct TileFiles { native static TextureID GetTexture(int tile, bool animate = false); } +*/