2008-01-26 23:20:34 +00:00
|
|
|
/*
|
|
|
|
** texturemanager.cpp
|
|
|
|
** The texture manager class
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 2004-2008 Randy Heit
|
|
|
|
** Copyright 2006-2008 Christoph Oelckers
|
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "doomtype.h"
|
|
|
|
#include "w_wad.h"
|
|
|
|
#include "r_data.h"
|
|
|
|
#include "templates.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "r_translate.h"
|
|
|
|
#include "c_dispatch.h"
|
|
|
|
#include "v_text.h"
|
|
|
|
#include "sc_man.h"
|
|
|
|
#include "gi.h"
|
|
|
|
#include "st_start.h"
|
2008-04-08 17:25:19 +00:00
|
|
|
#include "cmdlib.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "g_level.h"
|
2008-01-26 23:20:34 +00:00
|
|
|
|
|
|
|
extern void R_InitBuildTiles();
|
|
|
|
|
|
|
|
|
|
|
|
FTextureManager TexMan;
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: FTextureManager
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
FTextureManager::FTextureManager ()
|
|
|
|
{
|
|
|
|
memset (HashFirst, -1, sizeof(HashFirst));
|
|
|
|
// Texture 0 is a dummy texture used to indicate "no texture"
|
|
|
|
AddTexture (new FDummyTexture);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: ~FTextureManager
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
FTextureManager::~FTextureManager ()
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < Textures.Size(); ++i)
|
|
|
|
{
|
|
|
|
delete Textures[i].Texture;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: CheckForTexture
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID FTextureManager::CheckForTexture (const char *name, int usetype, BITFIELD flags)
|
2008-01-26 23:20:34 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int firstfound = -1;
|
|
|
|
int firsttype = FTexture::TEX_Null;
|
|
|
|
|
|
|
|
if (name == NULL || name[0] == '\0')
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
return FTextureID(-1);
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
// [RH] Doom counted anything beginning with '-' as "no texture".
|
|
|
|
// Hopefully nobody made use of that and had textures like "-EMPTY",
|
|
|
|
// because -NOFLAT- is a valid graphic for ZDoom.
|
|
|
|
if (name[0] == '-' && name[1] == '\0')
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
return FTextureID(0);
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
i = HashFirst[MakeKey (name) % HASH_SIZE];
|
|
|
|
|
|
|
|
while (i != HASH_END)
|
|
|
|
{
|
|
|
|
const FTexture *tex = Textures[i].Texture;
|
|
|
|
|
|
|
|
if (stricmp (tex->Name, name) == 0)
|
|
|
|
{
|
|
|
|
// The name matches, so check the texture type
|
|
|
|
if (usetype == FTexture::TEX_Any)
|
|
|
|
{
|
|
|
|
// All NULL textures should actually return 0
|
2008-05-30 06:56:50 +00:00
|
|
|
if (tex->UseType == FTexture::TEX_FirstDefined && !(flags & TEXMAN_ReturnFirst)) return 0;
|
2008-06-15 18:36:26 +00:00
|
|
|
return FTextureID(tex->UseType==FTexture::TEX_Null? 0 : i);
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
else if ((flags & TEXMAN_Overridable) && tex->UseType == FTexture::TEX_Override)
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
return FTextureID(i);
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
else if (tex->UseType == usetype)
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
return FTextureID(i);
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
2008-05-23 14:04:16 +00:00
|
|
|
else if (tex->UseType == FTexture::TEX_FirstDefined && usetype == FTexture::TEX_Wall)
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
if (!(flags & TEXMAN_ReturnFirst)) return FTextureID(0);
|
|
|
|
else return FTextureID(i);
|
2008-05-23 14:04:16 +00:00
|
|
|
}
|
2008-05-17 23:41:51 +00:00
|
|
|
else if (tex->UseType == FTexture::TEX_Null && usetype == FTexture::TEX_Wall)
|
|
|
|
{
|
|
|
|
// We found a NULL texture on a wall -> return 0
|
2008-06-15 18:36:26 +00:00
|
|
|
return FTextureID(0);
|
2008-05-17 23:41:51 +00:00
|
|
|
}
|
2008-01-26 23:20:34 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (firsttype == FTexture::TEX_Null ||
|
|
|
|
(firsttype == FTexture::TEX_MiscPatch && tex->UseType != FTexture::TEX_Null)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
firstfound = i;
|
|
|
|
firsttype = tex->UseType;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i = Textures[i].HashNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((flags & TEXMAN_TryAny) && usetype != FTexture::TEX_Any)
|
|
|
|
{
|
2008-05-17 23:41:51 +00:00
|
|
|
// Never return the index of NULL textures.
|
2008-05-23 14:04:16 +00:00
|
|
|
if (firstfound != -1)
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
if (firsttype == FTexture::TEX_Null) return FTextureID(0);
|
|
|
|
if (firsttype == FTexture::TEX_FirstDefined && !(flags & TEXMAN_ReturnFirst)) return FTextureID(0);
|
2008-05-23 14:04:16 +00:00
|
|
|
}
|
2008-06-15 18:36:26 +00:00
|
|
|
return FTextureID(firstfound);
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
return FTextureID(-1);
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: ListTextures
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
int FTextureManager::ListTextures (const char *name, TArray<FTextureID> &list)
|
2008-01-26 23:20:34 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (name == NULL || name[0] == '\0')
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
// [RH] Doom counted anything beginning with '-' as "no texture".
|
|
|
|
// Hopefully nobody made use of that and had textures like "-EMPTY",
|
|
|
|
// because -NOFLAT- is a valid graphic for ZDoom.
|
|
|
|
if (name[0] == '-' && name[1] == '\0')
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
i = HashFirst[MakeKey (name) % HASH_SIZE];
|
|
|
|
|
|
|
|
while (i != HASH_END)
|
|
|
|
{
|
|
|
|
const FTexture *tex = Textures[i].Texture;
|
|
|
|
|
|
|
|
if (stricmp (tex->Name, name) == 0)
|
|
|
|
{
|
|
|
|
// NULL textures must be ignored.
|
|
|
|
if (tex->UseType!=FTexture::TEX_Null)
|
|
|
|
{
|
|
|
|
unsigned int j;
|
|
|
|
for(j = 0; j < list.Size(); j++)
|
|
|
|
{
|
|
|
|
// Check for overriding definitions from newer WADs
|
2008-06-15 18:36:26 +00:00
|
|
|
if (Textures[list[j].GetIndex()].Texture->UseType == tex->UseType) break;
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
2008-06-15 18:36:26 +00:00
|
|
|
if (j==list.Size()) list.Push(FTextureID(i));
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
i = Textures[i].HashNext;
|
|
|
|
}
|
|
|
|
return list.Size();
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: GetTextures
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID FTextureManager::GetTexture (const char *name, int usetype, BITFIELD flags)
|
2008-01-26 23:20:34 +00:00
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID i;
|
2008-01-26 23:20:34 +00:00
|
|
|
|
|
|
|
if (name == NULL || name[0] == 0)
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
return FTextureID(0);
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i = CheckForTexture (name, usetype, flags | TEXMAN_TryAny);
|
|
|
|
}
|
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
if (!i.Exists())
|
2008-01-26 23:20:34 +00:00
|
|
|
{
|
|
|
|
// Use a default texture instead of aborting like Doom did
|
|
|
|
Printf ("Unknown texture: \"%s\"\n", name);
|
|
|
|
i = DefaultTexture;
|
|
|
|
}
|
2008-06-15 18:36:26 +00:00
|
|
|
return FTextureID(i);
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
|
2008-01-27 09:38:37 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: FindTexture
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
FTexture *FTextureManager::FindTexture(const char *texname, int usetype, BITFIELD flags)
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID texnum = CheckForTexture (texname, usetype, flags);
|
|
|
|
return !texnum.isValid()? NULL : Textures[texnum.GetIndex()].Texture;
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: UnloadAll
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FTextureManager::UnloadAll ()
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < Textures.Size(); ++i)
|
|
|
|
{
|
|
|
|
Textures[i].Texture->Unload ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: AddTexture
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID FTextureManager::AddTexture (FTexture *texture)
|
2008-01-26 23:20:34 +00:00
|
|
|
{
|
|
|
|
// Later textures take precedence over earlier ones
|
|
|
|
size_t bucket = MakeKey (texture->Name) % HASH_SIZE;
|
|
|
|
TextureHash hasher = { texture, HashFirst[bucket] };
|
2008-05-30 06:56:50 +00:00
|
|
|
int trans = Textures.Push (hasher);
|
2008-01-26 23:20:34 +00:00
|
|
|
Translation.Push (trans);
|
|
|
|
HashFirst[bucket] = trans;
|
2008-06-15 18:36:26 +00:00
|
|
|
return FTextureID(trans);
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: CreateTexture
|
|
|
|
//
|
|
|
|
// Calls FTexture::CreateTexture and adds the texture to the manager.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID FTextureManager::CreateTexture (int lumpnum, int usetype)
|
2008-01-26 23:20:34 +00:00
|
|
|
{
|
|
|
|
if (lumpnum != -1)
|
|
|
|
{
|
|
|
|
FTexture *out = FTexture::CreateTexture(lumpnum, usetype);
|
|
|
|
|
|
|
|
if (out != NULL) return AddTexture (out);
|
|
|
|
else
|
|
|
|
{
|
2008-06-01 20:43:02 +00:00
|
|
|
Printf (TEXTCOLOR_ORANGE "Invalid data encountered for texture %s\n", Wads.GetLumpFullPath(lumpnum).GetChars());
|
2008-06-15 18:36:26 +00:00
|
|
|
return FTextureID(-1);
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
}
|
2008-06-15 18:36:26 +00:00
|
|
|
return FTextureID(-1);
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: ReplaceTexture
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
void FTextureManager::ReplaceTexture (FTextureID picnum, FTexture *newtexture, bool free)
|
2008-01-26 23:20:34 +00:00
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
int index = picnum.GetIndex();
|
|
|
|
if (unsigned(index) >= Textures.Size())
|
2008-01-26 23:20:34 +00:00
|
|
|
return;
|
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
FTexture *oldtexture = Textures[index].Texture;
|
2008-01-26 23:20:34 +00:00
|
|
|
|
|
|
|
strcpy (newtexture->Name, oldtexture->Name);
|
|
|
|
newtexture->UseType = oldtexture->UseType;
|
2008-06-15 18:36:26 +00:00
|
|
|
Textures[index].Texture = newtexture;
|
2008-01-26 23:20:34 +00:00
|
|
|
|
|
|
|
if (free)
|
|
|
|
{
|
|
|
|
delete oldtexture;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: AddGroup
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FTextureManager::AddGroup(int wadnum, const char * startlump, const char * endlump, int ns, int usetype)
|
|
|
|
{
|
2008-04-13 11:40:53 +00:00
|
|
|
int firsttx;
|
|
|
|
int lasttx;
|
|
|
|
|
|
|
|
if (startlump && endlump)
|
|
|
|
{
|
|
|
|
firsttx = Wads.CheckNumForName (startlump);
|
|
|
|
lasttx = Wads.CheckNumForName (endlump);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If there are no markers we have to search the entire lump directory... :(
|
|
|
|
firsttx = 0;
|
|
|
|
lasttx = Wads.GetNumLumps() - 1;
|
|
|
|
}
|
|
|
|
|
2008-01-26 23:20:34 +00:00
|
|
|
char name[9];
|
|
|
|
|
|
|
|
if (firsttx == -1 || lasttx == -1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
name[8] = 0;
|
|
|
|
|
|
|
|
// Go from first to last so that ANIMDEFS work as expected. However,
|
|
|
|
// to avoid duplicates (and to keep earlier entries from overriding
|
|
|
|
// later ones), the texture is only inserted if it is the one returned
|
|
|
|
// by doing a check by name in the list of wads.
|
|
|
|
|
|
|
|
for (firsttx += 1; firsttx < lasttx; ++firsttx)
|
|
|
|
{
|
2008-04-13 11:40:53 +00:00
|
|
|
if (Wads.GetLumpFile(firsttx) == wadnum && Wads.GetLumpNamespace(firsttx) == ns)
|
2008-01-26 23:20:34 +00:00
|
|
|
{
|
|
|
|
Wads.GetLumpName (name, firsttx);
|
|
|
|
|
|
|
|
if (Wads.CheckNumForName (name, ns) == firsttx)
|
|
|
|
{
|
|
|
|
CreateTexture (firsttx, usetype);
|
|
|
|
}
|
|
|
|
StartScreen->Progress();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Adds all hires texture definitions.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FTextureManager::AddHiresTextures (int wadnum)
|
|
|
|
{
|
|
|
|
int firsttx = Wads.CheckNumForName ("HI_START");
|
|
|
|
int lasttx = Wads.CheckNumForName ("HI_END");
|
|
|
|
char name[9];
|
2008-06-15 18:36:26 +00:00
|
|
|
TArray<FTextureID> tlist;
|
2008-01-26 23:20:34 +00:00
|
|
|
|
|
|
|
if (firsttx == -1 || lasttx == -1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
name[8] = 0;
|
|
|
|
|
|
|
|
for (firsttx += 1; firsttx < lasttx; ++firsttx)
|
|
|
|
{
|
|
|
|
if (Wads.GetLumpFile(firsttx) == wadnum)
|
|
|
|
{
|
|
|
|
tlist.Clear();
|
|
|
|
Wads.GetLumpName (name, firsttx);
|
|
|
|
|
|
|
|
if (Wads.CheckNumForName (name, ns_hires) == firsttx)
|
|
|
|
{
|
|
|
|
int amount = ListTextures(name, tlist);
|
|
|
|
if (amount == 0)
|
|
|
|
{
|
|
|
|
// A texture with this name does not yet exist
|
|
|
|
FTexture * newtex = FTexture::CreateTexture (firsttx, FTexture::TEX_Any);
|
2008-03-30 08:32:44 +00:00
|
|
|
if (newtex != NULL)
|
|
|
|
{
|
|
|
|
newtex->UseType=FTexture::TEX_Override;
|
|
|
|
AddTexture(newtex);
|
|
|
|
}
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < tlist.Size(); i++)
|
|
|
|
{
|
|
|
|
FTexture * newtex = FTexture::CreateTexture (firsttx, FTexture::TEX_Any);
|
|
|
|
if (newtex != NULL)
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
FTexture * oldtex = Textures[tlist[i].GetIndex()].Texture;
|
2008-01-26 23:20:34 +00:00
|
|
|
|
|
|
|
// Replace the entire texture and adjust the scaling and offset factors.
|
|
|
|
newtex->bWorldPanning = true;
|
|
|
|
newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight());
|
|
|
|
newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale);
|
|
|
|
newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale);
|
2008-06-15 18:36:26 +00:00
|
|
|
ReplaceTexture(tlist[i], newtex, true);
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StartScreen->Progress();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Loads the HIRESTEX lumps
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname)
|
2008-01-26 23:20:34 +00:00
|
|
|
{
|
|
|
|
int remapLump, lastLump;
|
|
|
|
char src[9];
|
|
|
|
bool is32bit;
|
|
|
|
int width, height;
|
|
|
|
int type, mode;
|
2008-06-15 18:36:26 +00:00
|
|
|
TArray<FTextureID> tlist;
|
2008-01-26 23:20:34 +00:00
|
|
|
|
|
|
|
lastLump = 0;
|
|
|
|
src[8] = '\0';
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
while ((remapLump = Wads.FindLump(lumpname, &lastLump)) != -1)
|
2008-01-26 23:20:34 +00:00
|
|
|
{
|
|
|
|
if (Wads.GetLumpFile(remapLump) == wadnum)
|
|
|
|
{
|
2008-04-03 03:19:21 +00:00
|
|
|
FScanner sc(remapLump);
|
2008-01-26 23:20:34 +00:00
|
|
|
while (sc.GetString())
|
|
|
|
{
|
|
|
|
if (sc.Compare("remap")) // remap an existing texture
|
|
|
|
{
|
|
|
|
sc.MustGetString();
|
|
|
|
|
|
|
|
// allow selection by type
|
|
|
|
if (sc.Compare("wall")) type=FTexture::TEX_Wall, mode=FTextureManager::TEXMAN_Overridable;
|
|
|
|
else if (sc.Compare("flat")) type=FTexture::TEX_Flat, mode=FTextureManager::TEXMAN_Overridable;
|
|
|
|
else if (sc.Compare("sprite")) type=FTexture::TEX_Sprite, mode=0;
|
|
|
|
else type = FTexture::TEX_Any, mode = 0;
|
|
|
|
|
2008-04-08 17:25:19 +00:00
|
|
|
if (type != FTexture::TEX_Any) sc.MustGetString();
|
|
|
|
|
2008-01-26 23:20:34 +00:00
|
|
|
sc.String[8]=0;
|
|
|
|
|
|
|
|
tlist.Clear();
|
|
|
|
int amount = ListTextures(sc.String, tlist);
|
|
|
|
FName texname = sc.String;
|
|
|
|
|
|
|
|
sc.MustGetString();
|
2008-05-30 06:56:50 +00:00
|
|
|
int lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_patches);
|
|
|
|
if (lumpnum == -1) lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_graphics);
|
2008-01-26 23:20:34 +00:00
|
|
|
|
|
|
|
if (tlist.Size() == 0)
|
|
|
|
{
|
|
|
|
Printf("Attempting to remap non-existent texture %s to %s\n",
|
|
|
|
texname.GetChars(), sc.String);
|
|
|
|
}
|
2008-03-30 08:32:44 +00:00
|
|
|
else if (lumpnum == -1)
|
|
|
|
{
|
|
|
|
Printf("Attempting to remap texture %s to non-existent lump %s\n",
|
|
|
|
texname.GetChars(), sc.String);
|
|
|
|
}
|
2008-01-26 23:20:34 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < tlist.Size(); i++)
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
FTexture * oldtex = Textures[tlist[i].GetIndex()].Texture;
|
2008-01-26 23:20:34 +00:00
|
|
|
int sl;
|
|
|
|
|
|
|
|
// only replace matching types. For sprites also replace any MiscPatches
|
|
|
|
// based on the same lump. These can be created for icons.
|
|
|
|
if (oldtex->UseType == type || type == FTexture::TEX_Any ||
|
|
|
|
(mode == TEXMAN_Overridable && oldtex->UseType == FTexture::TEX_Override) ||
|
|
|
|
(type == FTexture::TEX_Sprite && oldtex->UseType == FTexture::TEX_MiscPatch &&
|
|
|
|
(sl=oldtex->GetSourceLump()) >= 0 && Wads.GetLumpNamespace(sl) == ns_sprites)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
FTexture * newtex = FTexture::CreateTexture (lumpnum, FTexture::TEX_Any);
|
|
|
|
if (newtex != NULL)
|
|
|
|
{
|
|
|
|
// Replace the entire texture and adjust the scaling and offset factors.
|
|
|
|
newtex->bWorldPanning = true;
|
|
|
|
newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight());
|
|
|
|
newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale);
|
|
|
|
newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale);
|
|
|
|
ReplaceTexture(tlist[i], newtex, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sc.Compare("define")) // define a new "fake" texture
|
|
|
|
{
|
|
|
|
sc.GetString();
|
2008-04-08 17:25:19 +00:00
|
|
|
memcpy(src, ExtractFileBase(sc.String, false), 8);
|
2008-01-26 23:20:34 +00:00
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
int lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_patches);
|
|
|
|
if (lumpnum == -1) lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_graphics);
|
2008-01-26 23:20:34 +00:00
|
|
|
|
|
|
|
sc.GetString();
|
|
|
|
is32bit = !!sc.Compare("force32bit");
|
|
|
|
if (!is32bit) sc.UnGet();
|
|
|
|
|
|
|
|
sc.GetNumber();
|
|
|
|
width = sc.Number;
|
|
|
|
sc.GetNumber();
|
|
|
|
height = sc.Number;
|
|
|
|
|
|
|
|
if (lumpnum>=0)
|
|
|
|
{
|
|
|
|
FTexture *newtex = FTexture::CreateTexture(lumpnum, FTexture::TEX_Override);
|
|
|
|
|
|
|
|
if (newtex != NULL)
|
|
|
|
{
|
|
|
|
// Replace the entire texture and adjust the scaling and offset factors.
|
|
|
|
newtex->bWorldPanning = true;
|
|
|
|
newtex->SetScaledSize(width, height);
|
|
|
|
memcpy(newtex->Name, src, sizeof(newtex->Name));
|
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID oldtex = TexMan.CheckForTexture(src, FTexture::TEX_MiscPatch);
|
|
|
|
if (oldtex.isValid())
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
|
|
|
ReplaceTexture(oldtex, newtex, true);
|
|
|
|
newtex->UseType = FTexture::TEX_Override;
|
|
|
|
}
|
|
|
|
else AddTexture(newtex);
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//else Printf("Unable to define hires texture '%s'\n", tex->Name);
|
|
|
|
}
|
2008-04-12 15:31:18 +00:00
|
|
|
else if (sc.Compare("texture"))
|
|
|
|
{
|
|
|
|
ParseXTexture(sc, FTexture::TEX_Override);
|
|
|
|
}
|
|
|
|
else if (sc.Compare("sprite"))
|
|
|
|
{
|
|
|
|
ParseXTexture(sc, FTexture::TEX_Sprite);
|
|
|
|
}
|
2008-05-30 06:56:50 +00:00
|
|
|
else if (sc.Compare("walltexture"))
|
|
|
|
{
|
|
|
|
ParseXTexture(sc, FTexture::TEX_Wall);
|
|
|
|
}
|
|
|
|
else if (sc.Compare("flat"))
|
|
|
|
{
|
|
|
|
ParseXTexture(sc, FTexture::TEX_Flat);
|
|
|
|
}
|
2008-09-17 00:14:33 +00:00
|
|
|
else if (sc.Compare("graphic"))
|
|
|
|
{
|
|
|
|
ParseXTexture(sc, FTexture::TEX_MiscPatch);
|
|
|
|
}
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: AddPatches
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FTextureManager::AddPatches (int lumpnum)
|
|
|
|
{
|
|
|
|
FWadLump *file = Wads.ReopenLumpNum (lumpnum);
|
|
|
|
DWORD numpatches, i;
|
|
|
|
char name[9];
|
|
|
|
|
|
|
|
*file >> numpatches;
|
|
|
|
name[8] = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < numpatches; ++i)
|
|
|
|
{
|
|
|
|
file->Read (name, 8);
|
|
|
|
|
|
|
|
if (CheckForTexture (name, FTexture::TEX_WallPatch, false) == -1)
|
|
|
|
{
|
|
|
|
CreateTexture (Wads.CheckNumForName (name, ns_patches), FTexture::TEX_WallPatch);
|
|
|
|
}
|
|
|
|
StartScreen->Progress();
|
|
|
|
}
|
|
|
|
|
|
|
|
delete file;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
2008-01-27 09:38:37 +00:00
|
|
|
// FTextureManager :: LoadTexturesX
|
|
|
|
//
|
2008-01-26 23:20:34 +00:00
|
|
|
// Initializes the texture list with the textures from the world map.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FTextureManager::LoadTextureX(int wadnum)
|
|
|
|
{
|
|
|
|
// Use the most recent PNAMES for this WAD.
|
|
|
|
// Multiple PNAMES in a WAD will be ignored.
|
|
|
|
int pnames = Wads.CheckNumForName("PNAMES", ns_global, wadnum, false);
|
|
|
|
|
|
|
|
if (pnames < 0)
|
|
|
|
{
|
|
|
|
// should never happen except for zdoom.pk3
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only add the patches if the PNAMES come from the current file
|
|
|
|
// Otherwise they have already been processed.
|
|
|
|
if (Wads.GetLumpFile(pnames) == wadnum) TexMan.AddPatches (pnames);
|
|
|
|
|
|
|
|
int texlump1 = Wads.CheckNumForName ("TEXTURE1", ns_global, wadnum);
|
|
|
|
int texlump2 = Wads.CheckNumForName ("TEXTURE2", ns_global, wadnum);
|
2008-01-27 09:38:37 +00:00
|
|
|
AddTexturesLumps (texlump1, texlump2, pnames);
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: AddTexturesForWad
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FTextureManager::AddTexturesForWad(int wadnum)
|
|
|
|
{
|
2008-05-30 06:56:50 +00:00
|
|
|
int firsttexture = Textures.Size();
|
2008-01-26 23:20:34 +00:00
|
|
|
int lumpcount = Wads.GetNumLumps();
|
|
|
|
|
|
|
|
// First step: Load sprites
|
|
|
|
AddGroup(wadnum, "S_START", "S_END", ns_sprites, FTexture::TEX_Sprite);
|
|
|
|
|
2008-04-13 11:40:53 +00:00
|
|
|
// When loading a Zip, all graphics in the patches/ directory should be
|
|
|
|
// added as well.
|
|
|
|
AddGroup(wadnum, NULL, NULL, ns_patches, FTexture::TEX_WallPatch);
|
|
|
|
|
2008-01-26 23:20:34 +00:00
|
|
|
// Second step: TEXTUREx lumps
|
|
|
|
LoadTextureX(wadnum);
|
|
|
|
|
|
|
|
// Third step: Flats
|
|
|
|
AddGroup(wadnum, "F_START", "F_END", ns_flats, FTexture::TEX_Flat);
|
|
|
|
|
|
|
|
// Fourth step: Textures (TX_)
|
|
|
|
AddGroup(wadnum, "TX_START", "TX_END", ns_newtextures, FTexture::TEX_Override);
|
|
|
|
|
|
|
|
// Sixth step: Try to find any lump in the WAD that may be a texture and load as a TEX_MiscPatch
|
|
|
|
for (int i = 0; i < lumpcount; i++)
|
|
|
|
{
|
|
|
|
int file = Wads.GetLumpFile(i);
|
|
|
|
if (file > wadnum) break; // lumps in the global namespace are ordered by WAD
|
|
|
|
if (file < wadnum) continue;
|
|
|
|
|
|
|
|
char name[9];
|
|
|
|
Wads.GetLumpName(name, i);
|
|
|
|
name[8]=0;
|
|
|
|
|
|
|
|
// Ignore anything not in the global namespace
|
|
|
|
int ns = Wads.GetLumpNamespace(i);
|
|
|
|
if (ns == ns_global)
|
|
|
|
{
|
|
|
|
// In Zips all graphics must be in a separate namespace.
|
2008-04-13 14:27:58 +00:00
|
|
|
if (Wads.GetLumpFlags(i) & LUMPF_ZIPFILE) continue;
|
2008-01-26 23:20:34 +00:00
|
|
|
|
|
|
|
// Ignore lumps with empty names.
|
|
|
|
if (Wads.CheckLumpName(i, "")) continue;
|
|
|
|
|
|
|
|
// Ignore anything belonging to a map
|
|
|
|
if (Wads.CheckLumpName(i, "THINGS")) continue;
|
|
|
|
if (Wads.CheckLumpName(i, "LINEDEFS")) continue;
|
|
|
|
if (Wads.CheckLumpName(i, "SIDEDEFS")) continue;
|
|
|
|
if (Wads.CheckLumpName(i, "VERTEXES")) continue;
|
|
|
|
if (Wads.CheckLumpName(i, "SEGS")) continue;
|
|
|
|
if (Wads.CheckLumpName(i, "SSECTORS")) continue;
|
|
|
|
if (Wads.CheckLumpName(i, "NODES")) continue;
|
|
|
|
if (Wads.CheckLumpName(i, "SECTORS")) continue;
|
|
|
|
if (Wads.CheckLumpName(i, "REJECT")) continue;
|
|
|
|
if (Wads.CheckLumpName(i, "BLOCKMAP")) continue;
|
|
|
|
if (Wads.CheckLumpName(i, "BEHAVIOR")) continue;
|
|
|
|
|
|
|
|
// Don't bother looking this lump if something later overrides it.
|
|
|
|
if (Wads.CheckNumForName(name, ns_graphics) != i) continue;
|
|
|
|
|
|
|
|
// skip this if it has already been added as a wall patch.
|
2008-06-15 18:36:26 +00:00
|
|
|
if (CheckForTexture(name, FTexture::TEX_WallPatch, 0).Exists()) continue;
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
else if (ns == ns_graphics)
|
|
|
|
{
|
|
|
|
// Don't bother looking this lump if something later overrides it.
|
|
|
|
if (Wads.CheckNumForName(name, ns_graphics) != i) continue;
|
|
|
|
}
|
|
|
|
else continue;
|
|
|
|
|
|
|
|
// Try to create a texture from this lump and add it.
|
|
|
|
// Unfortunately we have to look at everything that comes through here...
|
|
|
|
FTexture *out = FTexture::CreateTexture(i, FTexture::TEX_MiscPatch);
|
|
|
|
|
|
|
|
if (out != NULL)
|
|
|
|
{
|
|
|
|
AddTexture (out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Seventh step: Check for hires replacements.
|
|
|
|
AddHiresTextures(wadnum);
|
2008-05-30 06:56:50 +00:00
|
|
|
LoadTextureDefs(wadnum, "TEXTURES");
|
|
|
|
LoadTextureDefs(wadnum, "HIRESTEX");
|
|
|
|
SortTexturesByType(firsttexture, Textures.Size());
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: SortTexturesByType
|
|
|
|
// sorts newly added textures by UseType so that anything defined
|
2008-06-15 18:36:26 +00:00
|
|
|
// in TEXTURES and HIRESTEX gets in its proper place.
|
2008-05-30 06:56:50 +00:00
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FTextureManager::SortTexturesByType(int start, int end)
|
|
|
|
{
|
|
|
|
TArray<FTexture *> newtextures;
|
|
|
|
|
|
|
|
// First unlink all newly added textures from the hash chain
|
|
|
|
for (int i = 0; i < HASH_SIZE; i++)
|
|
|
|
{
|
|
|
|
while (HashFirst[i] >= start && HashFirst[i] != HASH_END)
|
|
|
|
{
|
|
|
|
HashFirst[i] = Textures[HashFirst[i]].HashNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
newtextures.Resize(end-start);
|
|
|
|
for(int i=start; i<end; i++)
|
|
|
|
{
|
|
|
|
newtextures[i-start] = Textures[i].Texture;
|
|
|
|
}
|
|
|
|
Textures.Resize(start);
|
|
|
|
Translation.Resize(start);
|
2008-01-26 23:20:34 +00:00
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
static int texturetypes[] = {
|
|
|
|
FTexture::TEX_Sprite, FTexture::TEX_Null, FTexture::TEX_FirstDefined,
|
|
|
|
FTexture::TEX_WallPatch, FTexture::TEX_Wall, FTexture::TEX_Flat,
|
|
|
|
FTexture::TEX_Override, FTexture::TEX_MiscPatch
|
|
|
|
};
|
|
|
|
|
2008-06-05 04:30:18 +00:00
|
|
|
for(unsigned int i=0;i<countof(texturetypes);i++)
|
2008-05-30 06:56:50 +00:00
|
|
|
{
|
|
|
|
for(unsigned j = 0; j<newtextures.Size(); j++)
|
|
|
|
{
|
|
|
|
if (newtextures[j] != NULL && newtextures[j]->UseType == texturetypes[i])
|
|
|
|
{
|
|
|
|
AddTexture(newtextures[j]);
|
|
|
|
newtextures[j] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// This should never happen. All other UseTypes are only used outside
|
|
|
|
for(unsigned j = 0; j<newtextures.Size(); j++)
|
|
|
|
{
|
|
|
|
if (newtextures[j] != NULL)
|
|
|
|
{
|
|
|
|
Printf("Texture %s has unknown type!\n", newtextures[j]->Name);
|
|
|
|
AddTexture(newtextures[j]);
|
|
|
|
}
|
|
|
|
}
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: Init
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FTextureManager::Init()
|
|
|
|
{
|
2008-09-17 00:14:33 +00:00
|
|
|
FTexture::InitGrayMap();
|
|
|
|
|
2008-01-26 23:20:34 +00:00
|
|
|
int wadcnt = Wads.GetNumWads();
|
|
|
|
for(int i = 0; i< wadcnt; i++)
|
|
|
|
{
|
|
|
|
AddTexturesForWad(i);
|
|
|
|
}
|
|
|
|
R_InitBuildTiles ();
|
|
|
|
|
|
|
|
DefaultTexture = CheckForTexture ("-NOFLAT-", FTexture::TEX_Override, 0);
|
|
|
|
|
|
|
|
// The Hexen scripts use BLANK as a blank texture, even though it's really not.
|
|
|
|
// I guess the Doom renderer must have clipped away the line at the bottom of
|
|
|
|
// the texture so it wasn't visible. I'll just map it to 0, so it really is blank.
|
2008-06-15 18:36:26 +00:00
|
|
|
if (gameinfo.gametype == GAME_Hexen)
|
2008-01-26 23:20:34 +00:00
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID tex = CheckForTexture ("BLANK", FTexture::TEX_Wall, false);
|
|
|
|
if (tex.Exists())
|
|
|
|
{
|
|
|
|
SetTranslation (tex, 0);
|
|
|
|
}
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Hexen parallax skies use color 0 to indicate transparency on the front
|
|
|
|
// layer, so we must not remap color 0 on these textures. Unfortunately,
|
|
|
|
// the only way to identify these textures is to check the MAPINFO.
|
|
|
|
for (unsigned int i = 0; i < wadlevelinfos.Size(); ++i)
|
|
|
|
{
|
|
|
|
if (wadlevelinfos[i].flags & LEVEL_DOUBLESKY)
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID picnum = CheckForTexture (wadlevelinfos[i].skypic1, FTexture::TEX_Wall, false);
|
|
|
|
if (picnum.isValid())
|
2008-01-26 23:20:34 +00:00
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
Textures[picnum.GetIndex()].Texture->SetFrontSkyLayer ();
|
2008-01-26 23:20:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-01-27 09:38:37 +00:00
|
|
|
}
|
2008-06-15 18:36:26 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: WriteTexture
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FTextureManager::WriteTexture (FArchive &arc, int picnum)
|
|
|
|
{
|
|
|
|
FTexture *pic;
|
|
|
|
|
|
|
|
if (picnum < 0)
|
|
|
|
{
|
|
|
|
arc.WriteName(NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if ((size_t)picnum >= Textures.Size())
|
|
|
|
{
|
|
|
|
pic = Textures[0].Texture;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pic = Textures[picnum].Texture;
|
|
|
|
}
|
|
|
|
|
|
|
|
arc.WriteName (pic->Name);
|
|
|
|
arc.WriteCount (pic->UseType);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureManager :: ReadTexture
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
int FTextureManager::ReadTexture (FArchive &arc)
|
|
|
|
{
|
|
|
|
int usetype;
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
name = arc.ReadName ();
|
|
|
|
if (name != NULL)
|
|
|
|
{
|
|
|
|
usetype = arc.ReadCount ();
|
|
|
|
return GetTexture (name, usetype).GetIndex();
|
|
|
|
}
|
|
|
|
else return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// operator<<
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
FArchive &operator<< (FArchive &arc, FTextureID &tex)
|
|
|
|
{
|
|
|
|
if (arc.IsStoring())
|
|
|
|
{
|
|
|
|
TexMan.WriteTexture(arc, tex.texnum);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tex.texnum = TexMan.ReadTexture(arc);
|
|
|
|
}
|
|
|
|
return arc;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FTextureID::operator+
|
|
|
|
// Does not return incvalid texture IDs
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-06-24 02:56:27 +00:00
|
|
|
FTextureID FTextureID::operator +(int offset) throw()
|
2008-06-15 18:36:26 +00:00
|
|
|
{
|
|
|
|
if (!isValid()) return *this;
|
|
|
|
if (texnum + offset >= TexMan.NumTextures()) return FTextureID(-1);
|
|
|
|
return FTextureID(texnum + offset);
|
|
|
|
}
|