- allow texture lookup by full path names. Due to technical limitations this may result in double textures if the same graphics lump is also referenced by its short texture name.

This commit is contained in:
Christoph Oelckers 2014-05-13 20:51:16 +02:00
commit ca4179caa3
10 changed files with 84 additions and 60 deletions

View file

@ -224,6 +224,35 @@ FTextureID FTextureManager::CheckForTexture (const char *name, int usetype, BITF
return FTextureID(firstfound);
}
if (!(flags & TEXMAN_ShortNameOnly))
{
// We intentionally only look for textures in subdirectories.
// Any graphic being placed in the zip's root directory can not be found by this.
if (strchr(name, '/'))
{
FTexture *const NO_TEXTURE = (FTexture*)-1;
int lump = Wads.CheckNumForFullName(name);
if (lump != NULL)
{
FTexture *tex = Wads.GetLinkedTexture(lump);
if (tex == NO_TEXTURE) return FTextureID(-1);
if (tex != NULL) return tex->id;
tex = FTexture::CreateTexture("", lump, FTexture::TEX_Override);
if (tex != NULL)
{
Wads.SetLinkedTexture(lump, tex);
return AddTexture(tex);
}
else
{
// mark this lump as having no valid texture so that we don't have to retry creating one later.
Wads.SetLinkedTexture(lump, NO_TEXTURE);
}
}
}
}
return FTextureID(-1);
}
@ -273,30 +302,6 @@ int FTextureManager::ListTextures (const char *name, TArray<FTextureID> &list)
return list.Size();
}
//==========================================================================
//
// FTextureManager :: FindTextureByLumpNum
//
//==========================================================================
FTextureID FTextureManager::FindTextureByLumpNum (int lumpnum)
{
if (lumpnum < 0)
{
return FTextureID(-1);
}
// This can't use hashing because using ReplaceTexture would break the hash chains. :(
for(unsigned i = 0; i <Textures.Size(); i++)
{
if (Textures[i].Texture->SourceLump == lumpnum)
{
return FTextureID(i);
}
}
return FTextureID(-1);
}
//==========================================================================
//
// FTextureManager :: GetTextures
@ -1093,8 +1098,15 @@ void FTextureManager::WriteTexture (FArchive &arc, int picnum)
pic = Textures[picnum].Texture;
}
arc.WriteName (pic->Name);
arc.WriteCount (pic->UseType);
if (Wads.GetLinkedTexture(pic->SourceLump) == pic)
{
arc.WriteName(Wads.GetLumpFullName(pic->SourceLump));
}
else
{
arc.WriteName(pic->Name);
}
arc.WriteCount(pic->UseType);
}
//==========================================================================