mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 22:11:43 +00:00
- moved linked textures from file system to texture manager.
This commit is contained in:
parent
1dc47f91c2
commit
2524ea6b0e
7 changed files with 48 additions and 44 deletions
|
@ -1135,7 +1135,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FTextureID &value, FTe
|
||||||
const char *name;
|
const char *name;
|
||||||
auto lump = pic->GetSourceLump();
|
auto lump = pic->GetSourceLump();
|
||||||
|
|
||||||
if (fileSystem.GetLinkedTexture(lump) == pic)
|
if (TexMan.GetLinkedTexture(lump) == pic)
|
||||||
{
|
{
|
||||||
name = fileSystem.GetFileFullName(lump);
|
name = fileSystem.GetFileFullName(lump);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@
|
||||||
struct FileSystem::LumpRecord
|
struct FileSystem::LumpRecord
|
||||||
{
|
{
|
||||||
FResourceLump *lump;
|
FResourceLump *lump;
|
||||||
FGameTexture* linkedTexture;
|
|
||||||
LumpShortName shortName;
|
LumpShortName shortName;
|
||||||
FString longName;
|
FString longName;
|
||||||
int rfnum;
|
int rfnum;
|
||||||
|
@ -67,7 +66,6 @@ struct FileSystem::LumpRecord
|
||||||
{
|
{
|
||||||
lump = lmp;
|
lump = lmp;
|
||||||
rfnum = filenum;
|
rfnum = filenum;
|
||||||
linkedTexture = nullptr;
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
|
||||||
if (lump->Flags & LUMPF_SHORTNAME)
|
if (lump->Flags & LUMPF_SHORTNAME)
|
||||||
|
@ -748,35 +746,6 @@ int FileSystem::GetResource (int resid, const char *type, int filenum) const
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// link a texture with a given lump
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void FileSystem::SetLinkedTexture(int lump, FGameTexture *tex)
|
|
||||||
{
|
|
||||||
if ((size_t)lump < NumEntries)
|
|
||||||
{
|
|
||||||
FileInfo[lump].linkedTexture = tex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// retrieve linked texture
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
FGameTexture *FileSystem::GetLinkedTexture(int lump)
|
|
||||||
{
|
|
||||||
if ((size_t)lump < NumEntries)
|
|
||||||
{
|
|
||||||
return FileInfo[lump].linkedTexture;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// FileLength
|
// FileLength
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
class FResourceFile;
|
class FResourceFile;
|
||||||
struct FResourceLump;
|
struct FResourceLump;
|
||||||
class FGameTexture;
|
|
||||||
|
|
||||||
union LumpShortName
|
union LumpShortName
|
||||||
{
|
{
|
||||||
|
@ -125,10 +124,6 @@ public:
|
||||||
inline int CheckNumForFullName (const FString &name, int wadfile) { return CheckNumForFullName(name.GetChars(), wadfile); }
|
inline int CheckNumForFullName (const FString &name, int wadfile) { return CheckNumForFullName(name.GetChars(), wadfile); }
|
||||||
inline int GetNumForFullName (const FString &name) { return GetNumForFullName(name.GetChars()); }
|
inline int GetNumForFullName (const FString &name) { return GetNumForFullName(name.GetChars()); }
|
||||||
|
|
||||||
void SetLinkedTexture(int lump, FGameTexture *tex);
|
|
||||||
FGameTexture *GetLinkedTexture(int lump);
|
|
||||||
|
|
||||||
|
|
||||||
void ReadFile (int lump, void *dest);
|
void ReadFile (int lump, void *dest);
|
||||||
TArray<uint8_t> GetFileData(int lump, int pad = 0); // reads lump into a writable buffer and optionally adds some padding at the end. (FileData isn't writable!)
|
TArray<uint8_t> GetFileData(int lump, int pad = 0); // reads lump into a writable buffer and optionally adds some padding at the end. (FileData isn't writable!)
|
||||||
FileData ReadFile (int lump);
|
FileData ReadFile (int lump);
|
||||||
|
|
|
@ -424,7 +424,7 @@ DEFINE_ACTION_FUNCTION(_TexMan, GetName)
|
||||||
{
|
{
|
||||||
// Textures for full path names do not have their own name, they merely link to the source lump.
|
// Textures for full path names do not have their own name, they merely link to the source lump.
|
||||||
auto lump = tex->GetSourceLump();
|
auto lump = tex->GetSourceLump();
|
||||||
if (fileSystem.GetLinkedTexture(lump) == tex)
|
if (TexMan.GetLinkedTexture(lump) == tex)
|
||||||
retval = fileSystem.GetFileFullName(lump);
|
retval = fileSystem.GetFileFullName(lump);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,8 +98,8 @@ FGameTexture::~FGameTexture()
|
||||||
{
|
{
|
||||||
if (Base != nullptr)
|
if (Base != nullptr)
|
||||||
{
|
{
|
||||||
FGameTexture* link = fileSystem.GetLinkedTexture(GetSourceLump());
|
FGameTexture* link = TexMan.GetLinkedTexture(GetSourceLump());
|
||||||
if (link == this) fileSystem.SetLinkedTexture(GetSourceLump(), nullptr);
|
if (link == this) TexMan.SetLinkedTexture(GetSourceLump(), nullptr);
|
||||||
}
|
}
|
||||||
if (SoftwareTexture != nullptr)
|
if (SoftwareTexture != nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -244,11 +244,11 @@ FTextureID FTextureManager::CheckForTexture (const char *name, ETextureType uset
|
||||||
// Any graphic being placed in the zip's root directory can not be found by this.
|
// Any graphic being placed in the zip's root directory can not be found by this.
|
||||||
if (strchr(name, '/') || (flags & TEXMAN_ForceLookup))
|
if (strchr(name, '/') || (flags & TEXMAN_ForceLookup))
|
||||||
{
|
{
|
||||||
FGameTexture *const NO_TEXTURE = (FGameTexture*)-1;
|
FGameTexture *const NO_TEXTURE = (FGameTexture*)-1; // marker for lumps we already checked that do not map to a texture.
|
||||||
int lump = fileSystem.CheckNumForFullName(name);
|
int lump = fileSystem.CheckNumForFullName(name);
|
||||||
if (lump >= 0)
|
if (lump >= 0)
|
||||||
{
|
{
|
||||||
FGameTexture *tex = fileSystem.GetLinkedTexture(lump);
|
FGameTexture *tex = GetLinkedTexture(lump);
|
||||||
if (tex == NO_TEXTURE) return FTextureID(-1);
|
if (tex == NO_TEXTURE) return FTextureID(-1);
|
||||||
if (tex != NULL) return tex->GetID();
|
if (tex != NULL) return tex->GetID();
|
||||||
if (flags & TEXMAN_DontCreate) return FTextureID(-1); // we only want to check, there's no need to create a texture if we don't have one yet.
|
if (flags & TEXMAN_DontCreate) return FTextureID(-1); // we only want to check, there's no need to create a texture if we don't have one yet.
|
||||||
|
@ -256,13 +256,13 @@ FTextureID FTextureManager::CheckForTexture (const char *name, ETextureType uset
|
||||||
if (tex != NULL)
|
if (tex != NULL)
|
||||||
{
|
{
|
||||||
tex->AddAutoMaterials();
|
tex->AddAutoMaterials();
|
||||||
fileSystem.SetLinkedTexture(lump, tex);
|
SetLinkedTexture(lump, tex);
|
||||||
return AddGameTexture(tex);
|
return AddGameTexture(tex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// mark this lump as having no valid texture so that we don't have to retry creating one later.
|
// mark this lump as having no valid texture so that we don't have to retry creating one later.
|
||||||
fileSystem.SetLinkedTexture(lump, NO_TEXTURE);
|
SetLinkedTexture(lump, NO_TEXTURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1627,6 +1627,37 @@ void FTextureManager::Listaliases()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// link a texture with a given lump
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void FTextureManager::SetLinkedTexture(int lump, FGameTexture* tex)
|
||||||
|
{
|
||||||
|
if ((size_t)lump < fileSystem.GetNumEntries())
|
||||||
|
{
|
||||||
|
linkedMap.Insert(lump, tex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// retrieve linked texture
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
FGameTexture* FTextureManager::GetLinkedTexture(int lump)
|
||||||
|
{
|
||||||
|
if ((size_t)lump < fileSystem.GetNumEntries())
|
||||||
|
{
|
||||||
|
auto check = linkedMap.CheckKey(lump);
|
||||||
|
if (check) return *check;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// FTextureID::operator+
|
// FTextureID::operator+
|
||||||
|
|
|
@ -88,6 +88,15 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// link a texture with a given lump
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
TMap<int, FGameTexture*> linkedMap;
|
||||||
|
void SetLinkedTexture(int lump, FGameTexture* tex);
|
||||||
|
FGameTexture* GetLinkedTexture(int lump);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue