- add #include support to TEXTURES lump

This commit is contained in:
Magnus Norddahl 2018-05-24 21:18:20 +02:00
parent cce6c9a085
commit cadc4f2a30
2 changed files with 151 additions and 132 deletions

View file

@ -607,12 +607,6 @@ void FTextureManager::AddHiresTextures (int wadnum)
void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname) void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname)
{ {
int remapLump, lastLump; int remapLump, lastLump;
FString src;
bool is32bit;
int width, height;
ETextureType type;
int mode;
TArray<FTextureID> tlist;
lastLump = 0; lastLump = 0;
@ -620,7 +614,16 @@ void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname)
{ {
if (Wads.GetLumpFile(remapLump) == wadnum) if (Wads.GetLumpFile(remapLump) == wadnum)
{ {
FScanner sc(remapLump); ParseTextureDef(remapLump);
}
}
}
void FTextureManager::ParseTextureDef(int lump)
{
TArray<FTextureID> tlist;
FScanner sc(lump);
while (sc.GetString()) while (sc.GetString())
{ {
if (sc.Compare("remap")) // remap an existing texture if (sc.Compare("remap")) // remap an existing texture
@ -628,6 +631,8 @@ void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname)
sc.MustGetString(); sc.MustGetString();
// allow selection by type // allow selection by type
int mode;
ETextureType type;
if (sc.Compare("wall")) type=ETextureType::Wall, mode=FTextureManager::TEXMAN_Overridable; if (sc.Compare("wall")) type=ETextureType::Wall, mode=FTextureManager::TEXMAN_Overridable;
else if (sc.Compare("flat")) type=ETextureType::Flat, mode=FTextureManager::TEXMAN_Overridable; else if (sc.Compare("flat")) type=ETextureType::Flat, mode=FTextureManager::TEXMAN_Overridable;
else if (sc.Compare("sprite")) type=ETextureType::Sprite, mode=0; else if (sc.Compare("sprite")) type=ETextureType::Sprite, mode=0;
@ -693,19 +698,19 @@ void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname)
FString base = ExtractFileBase(sc.String, false); FString base = ExtractFileBase(sc.String, false);
if (!base.IsEmpty()) if (!base.IsEmpty())
{ {
src = base.Left(8); FString src = base.Left(8);
int lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_patches); int lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_patches);
if (lumpnum == -1) lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_graphics); if (lumpnum == -1) lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_graphics);
sc.GetString(); sc.GetString();
is32bit = !!sc.Compare("force32bit"); bool is32bit = !!sc.Compare("force32bit");
if (!is32bit) sc.UnGet(); if (!is32bit) sc.UnGet();
sc.MustGetNumber(); sc.MustGetNumber();
width = sc.Number; int width = sc.Number;
sc.MustGetNumber(); sc.MustGetNumber();
height = sc.Number; int height = sc.Number;
if (lumpnum>=0) if (lumpnum>=0)
{ {
@ -750,13 +755,26 @@ void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname)
{ {
ParseXTexture(sc, ETextureType::MiscPatch); ParseXTexture(sc, ETextureType::MiscPatch);
} }
else if (sc.Compare("#include"))
{
sc.MustGetString();
// This is not using sc.Open because it can print a more useful error message when done here
int includelump = Wads.CheckNumForFullName(sc.String, true);
if (includelump == -1)
{
sc.ScriptError("Lump '%s' not found", sc.String);
}
else
{
ParseTextureDef(includelump);
}
}
else else
{ {
sc.ScriptError("Texture definition expected, found '%s'", sc.String); sc.ScriptError("Texture definition expected, found '%s'", sc.String);
} }
} }
}
}
} }
//========================================================================== //==========================================================================

View file

@ -584,6 +584,7 @@ public:
void AddPatches (int lumpnum); void AddPatches (int lumpnum);
void AddHiresTextures (int wadnum); void AddHiresTextures (int wadnum);
void LoadTextureDefs(int wadnum, const char *lumpname); void LoadTextureDefs(int wadnum, const char *lumpname);
void ParseTextureDef(int remapLump);
void ParseXTexture(FScanner &sc, ETextureType usetype); void ParseXTexture(FScanner &sc, ETextureType usetype);
void SortTexturesByType(int start, int end); void SortTexturesByType(int start, int end);
bool AreTexturesCompatible (FTextureID picnum1, FTextureID picnum2); bool AreTexturesCompatible (FTextureID picnum1, FTextureID picnum2);