- Changed: Textures without a name no longer get added to the texture manager's
hash chains. - Fixed: specifying texture patches or font characters by full lump name instead of texture name didn't work. To do this properly the texture manager needs an option to look for a texture by lump number so that such textures can be maintained without interfering with regular operation. - added 'skystretch' and 'autosequences' keywords for MAPINFO so that the effects of 'noautosequences' and 'forcenoskystretch' can be cancelled. - Added a 'gamedefaults' section to MAPINFO after discovering that 'defaultmap' gets reset for each MAPINFO. A global section is needed to define a game's default setting in zdoom.pk3. The gamedefaults should normally not be changed by PWADs but it can be done if some mod intends to change gameplay settings but wants to allow custom add-ons on its own. SVN r1300 (trunk)
This commit is contained in:
parent
c35be830c3
commit
3f2d5db348
19 changed files with 212 additions and 145 deletions
|
|
@ -56,14 +56,11 @@ public:
|
|||
void Unload ();
|
||||
void MakeTexture ();
|
||||
|
||||
int GetSourceLump() { return LumpNum; }
|
||||
|
||||
FAutomapTexture (int lumpnum);
|
||||
|
||||
private:
|
||||
BYTE *Pixels;
|
||||
Span DummySpan[2];
|
||||
int LumpNum;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -89,11 +86,8 @@ FTexture *AutomapTexture_TryCreate(FileReader &data, int lumpnum)
|
|||
//==========================================================================
|
||||
|
||||
FAutomapTexture::FAutomapTexture (int lumpnum)
|
||||
: Pixels(NULL), LumpNum(lumpnum)
|
||||
: FTexture(NULL, lumpnum), Pixels(NULL)
|
||||
{
|
||||
Wads.GetLumpName (Name, lumpnum);
|
||||
Name[8] = 0;
|
||||
|
||||
Width = 320;
|
||||
Height = WORD(Wads.LumpLength(lumpnum) / 320);
|
||||
CalcBitSize ();
|
||||
|
|
@ -139,7 +133,7 @@ void FAutomapTexture::Unload ()
|
|||
void FAutomapTexture::MakeTexture ()
|
||||
{
|
||||
int x, y;
|
||||
FMemLump data = Wads.ReadLump (LumpNum);
|
||||
FMemLump data = Wads.ReadLump (SourceLump);
|
||||
const BYTE *indata = (const BYTE *)data.GetMem();
|
||||
|
||||
Pixels = new BYTE[Width * Height];
|
||||
|
|
|
|||
|
|
@ -159,11 +159,9 @@ public:
|
|||
const BYTE *GetPixels ();
|
||||
void Unload ();
|
||||
FTextureFormat GetFormat ();
|
||||
int GetSourceLump() { return SourceLump; }
|
||||
|
||||
protected:
|
||||
|
||||
int SourceLump;
|
||||
BYTE *Pixels;
|
||||
Span **Spans;
|
||||
|
||||
|
|
@ -285,13 +283,10 @@ FTexture *DDSTexture_TryCreate (FileReader &data, int lumpnum)
|
|||
//==========================================================================
|
||||
|
||||
FDDSTexture::FDDSTexture (FileReader &lump, int lumpnum, void *vsurfdesc)
|
||||
: SourceLump(lumpnum), Pixels(0), Spans(0)
|
||||
: FTexture(NULL, lumpnum), Pixels(0), Spans(0)
|
||||
{
|
||||
DDSURFACEDESC2 *surf = (DDSURFACEDESC2 *)vsurfdesc;
|
||||
|
||||
Wads.GetLumpName (Name, lumpnum);
|
||||
Name[8] = 0;
|
||||
|
||||
UseType = TEX_MiscPatch;
|
||||
LeftOffset = 0;
|
||||
TopOffset = 0;
|
||||
|
|
|
|||
|
|
@ -55,10 +55,7 @@ public:
|
|||
const BYTE *GetPixels ();
|
||||
void Unload ();
|
||||
|
||||
int GetSourceLump() { return SourceLump; }
|
||||
|
||||
protected:
|
||||
int SourceLump;
|
||||
BYTE *Pixels;
|
||||
Span DummySpans[2];
|
||||
|
||||
|
|
@ -89,13 +86,11 @@ FTexture *FlatTexture_TryCreate(FileReader & file, int lumpnum)
|
|||
//==========================================================================
|
||||
|
||||
FFlatTexture::FFlatTexture (int lumpnum)
|
||||
: SourceLump(lumpnum), Pixels(0)
|
||||
: FTexture(NULL, lumpnum), Pixels(0)
|
||||
{
|
||||
int area;
|
||||
int bits;
|
||||
|
||||
Wads.GetLumpName (Name, lumpnum);
|
||||
Name[8] = 0;
|
||||
area = Wads.LumpLength (lumpnum);
|
||||
|
||||
switch (area)
|
||||
|
|
|
|||
|
|
@ -68,12 +68,8 @@ public:
|
|||
const BYTE *GetPixels ();
|
||||
void Unload ();
|
||||
|
||||
int GetSourceLump() { return SourceLump; }
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
int SourceLump;
|
||||
BYTE *Pixels;
|
||||
Span **Spans;
|
||||
|
||||
|
|
@ -107,7 +103,7 @@ FTexture *IMGZTexture_TryCreate(FileReader & file, int lumpnum)
|
|||
//==========================================================================
|
||||
|
||||
FIMGZTexture::FIMGZTexture (int lumpnum, WORD w, WORD h, SWORD l, SWORD t)
|
||||
: SourceLump(lumpnum), Pixels(0), Spans(0)
|
||||
: FTexture(NULL, lumpnum), Pixels(0), Spans(0)
|
||||
{
|
||||
Wads.GetLumpName (Name, lumpnum);
|
||||
Name[8] = 0;
|
||||
|
|
|
|||
|
|
@ -170,11 +170,9 @@ public:
|
|||
FTextureFormat GetFormat ();
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
|
||||
bool UseBasePalette();
|
||||
int GetSourceLump() { return SourceLump; }
|
||||
|
||||
protected:
|
||||
|
||||
int SourceLump;
|
||||
BYTE *Pixels;
|
||||
Span DummySpans[2];
|
||||
|
||||
|
|
@ -240,11 +238,8 @@ FTexture *JPEGTexture_TryCreate(FileReader & data, int lumpnum)
|
|||
//==========================================================================
|
||||
|
||||
FJPEGTexture::FJPEGTexture (int lumpnum, int width, int height)
|
||||
: SourceLump(lumpnum), Pixels(0)
|
||||
: FTexture(NULL, lumpnum), Pixels(0)
|
||||
{
|
||||
Wads.GetLumpName (Name, lumpnum);
|
||||
Name[8] = 0;
|
||||
|
||||
UseType = TEX_MiscPatch;
|
||||
LeftOffset = 0;
|
||||
TopOffset = 0;
|
||||
|
|
|
|||
|
|
@ -170,7 +170,6 @@ protected:
|
|||
{
|
||||
SWORD OriginX, OriginY;
|
||||
BYTE Rotate;
|
||||
bool textureOwned;
|
||||
BYTE op;
|
||||
FRemapTable *Translation;
|
||||
PalEntry Blend;
|
||||
|
|
@ -315,7 +314,6 @@ FMultiPatchTexture::~FMultiPatchTexture ()
|
|||
{
|
||||
for(int i=0; i<NumParts;i++)
|
||||
{
|
||||
if (Parts[i].textureOwned && Parts[i].Texture != NULL) delete Parts[i].Texture;
|
||||
if (Parts[i].Translation != NULL) delete Parts[i].Translation;
|
||||
}
|
||||
delete[] Parts;
|
||||
|
|
@ -774,7 +772,6 @@ FMultiPatchTexture::TexPart::TexPart()
|
|||
{
|
||||
OriginX = OriginY = 0;
|
||||
Rotate = 0;
|
||||
textureOwned = false;
|
||||
Texture = NULL;
|
||||
Translation = NULL;
|
||||
Blend = 0;
|
||||
|
|
@ -972,8 +969,16 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part)
|
|||
int lumpnum = Wads.CheckNumForFullName(sc.String);
|
||||
if (lumpnum >= 0)
|
||||
{
|
||||
part.Texture = FTexture::CreateTexture(lumpnum, TEX_WallPatch);
|
||||
part.textureOwned = true;
|
||||
texno = TexMan.FindTextureByLumpNum(lumpnum);
|
||||
if (texno.isValid ())
|
||||
{
|
||||
part.Texture = TexMan[texno];
|
||||
}
|
||||
else
|
||||
{
|
||||
part.Texture = FTexture::CreateTexture("", lumpnum, TEX_WallPatch);
|
||||
TexMan.AddTexture(part.Texture);
|
||||
}
|
||||
}
|
||||
else if (strlen(sc.String) <= 8 && !strpbrk(sc.String, "./"))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,10 +57,7 @@ public:
|
|||
const BYTE *GetPixels ();
|
||||
void Unload ();
|
||||
|
||||
int GetSourceLump() { return SourceLump; }
|
||||
|
||||
protected:
|
||||
int SourceLump;
|
||||
BYTE *Pixels;
|
||||
Span **Spans;
|
||||
bool hackflag;
|
||||
|
|
@ -141,10 +138,8 @@ FTexture *PatchTexture_TryCreate(FileReader & file, int lumpnum)
|
|||
//==========================================================================
|
||||
|
||||
FPatchTexture::FPatchTexture (int lumpnum, patch_t * header)
|
||||
: SourceLump(lumpnum), Pixels(0), Spans(0), hackflag(false)
|
||||
: FTexture(NULL, lumpnum), Pixels(0), Spans(0), hackflag(false)
|
||||
{
|
||||
Wads.GetLumpName (Name, lumpnum);
|
||||
Name[8] = 0;
|
||||
Width = header->width;
|
||||
Height = header->height;
|
||||
LeftOffset = header->leftoffset;
|
||||
|
|
|
|||
|
|
@ -93,10 +93,8 @@ public:
|
|||
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
|
||||
bool UseBasePalette();
|
||||
int GetSourceLump() { return SourceLump; }
|
||||
|
||||
protected:
|
||||
int SourceLump;
|
||||
BYTE *Pixels;
|
||||
Span DummySpans[2];
|
||||
|
||||
|
|
@ -157,10 +155,8 @@ FTexture * PCXTexture_TryCreate(FileReader & file, int lumpnum)
|
|||
//==========================================================================
|
||||
|
||||
FPCXTexture::FPCXTexture(int lumpnum, PCXHeader & hdr)
|
||||
: SourceLump(lumpnum), Pixels(0)
|
||||
: FTexture(NULL, lumpnum), Pixels(0)
|
||||
{
|
||||
Wads.GetLumpName (Name, lumpnum);
|
||||
Name[8] = 0;
|
||||
bMasked = false;
|
||||
Width = LittleShort(hdr.xmax) - LittleShort(hdr.xmin) + 1;
|
||||
Height = LittleShort(hdr.ymax) - LittleShort(hdr.ymin) + 1;
|
||||
|
|
|
|||
|
|
@ -60,11 +60,9 @@ public:
|
|||
FTextureFormat GetFormat ();
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
|
||||
bool UseBasePalette();
|
||||
int GetSourceLump() { return SourceLump; }
|
||||
|
||||
protected:
|
||||
|
||||
int SourceLump;
|
||||
FString SourceFile;
|
||||
BYTE *Pixels;
|
||||
Span **Spans;
|
||||
|
|
@ -194,7 +192,7 @@ FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
|
|||
|
||||
FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height,
|
||||
BYTE depth, BYTE colortype, BYTE interlace)
|
||||
: SourceLump(lumpnum), SourceFile(filename), Pixels(0), Spans(0),
|
||||
: FTexture(NULL, lumpnum), SourceFile(filename), Pixels(0), Spans(0),
|
||||
BitDepth(depth), ColorType(colortype), Interlace(interlace),
|
||||
PaletteMap(0), PaletteSize(0), StartOfIDAT(0)
|
||||
{
|
||||
|
|
@ -208,9 +206,6 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename
|
|||
DWORD len, id;
|
||||
int i;
|
||||
|
||||
Wads.GetLumpName (Name, lumpnum);
|
||||
Name[8] = 0;
|
||||
|
||||
UseType = TEX_MiscPatch;
|
||||
LeftOffset = 0;
|
||||
TopOffset = 0;
|
||||
|
|
|
|||
|
|
@ -56,10 +56,7 @@ public:
|
|||
const BYTE *GetPixels ();
|
||||
void Unload ();
|
||||
|
||||
int GetSourceLump() { return SourceLump; }
|
||||
|
||||
protected:
|
||||
int SourceLump;
|
||||
BYTE *Pixels;
|
||||
static const Span DummySpans[2];
|
||||
|
||||
|
|
@ -176,11 +173,8 @@ const FTexture::Span FRawPageTexture::DummySpans[2] =
|
|||
//==========================================================================
|
||||
|
||||
FRawPageTexture::FRawPageTexture (int lumpnum)
|
||||
: SourceLump(lumpnum), Pixels(0)
|
||||
: FTexture(NULL, lumpnum), Pixels(0)
|
||||
{
|
||||
Wads.GetLumpName (Name, lumpnum);
|
||||
Name[8] = 0;
|
||||
|
||||
Width = 320;
|
||||
Height = 200;
|
||||
WidthBits = 8;
|
||||
|
|
|
|||
|
|
@ -127,14 +127,34 @@ FTexture * FTexture::CreateTexture (int lumpnum, int usetype)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
FTexture::FTexture ()
|
||||
FTexture * FTexture::CreateTexture (const char *name, int lumpnum, int usetype)
|
||||
{
|
||||
FTexture *tex = CreateTexture(lumpnum, usetype);
|
||||
if (tex != NULL && name != NULL) uppercopy(tex->Name, name);
|
||||
return tex;
|
||||
}
|
||||
|
||||
|
||||
FTexture::FTexture (const char *name, int lumpnum)
|
||||
: LeftOffset(0), TopOffset(0),
|
||||
WidthBits(0), HeightBits(0), xScale(FRACUNIT), yScale(FRACUNIT),
|
||||
WidthBits(0), HeightBits(0), xScale(FRACUNIT), yScale(FRACUNIT), SourceLump(lumpnum),
|
||||
UseType(TEX_Any), bNoDecals(false), bNoRemap0(false), bWorldPanning(false),
|
||||
bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false),
|
||||
Rotations(0xFFFF), Width(0), Height(0), WidthMask(0), Native(NULL)
|
||||
{
|
||||
*Name = 0;
|
||||
if (name != NULL)
|
||||
{
|
||||
uppercopy(Name, name);
|
||||
}
|
||||
else if (lumpnum < 0)
|
||||
{
|
||||
*Name = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Wads.GetLumpName (Name, lumpnum);
|
||||
Name[8] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
FTexture::~FTexture ()
|
||||
|
|
|
|||
|
|
@ -211,6 +211,30 @@ 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
|
||||
|
|
@ -273,12 +297,29 @@ void FTextureManager::UnloadAll ()
|
|||
|
||||
FTextureID FTextureManager::AddTexture (FTexture *texture)
|
||||
{
|
||||
size_t bucket;
|
||||
int hash;
|
||||
|
||||
if (texture == NULL) return FTextureID(-1);
|
||||
|
||||
// Later textures take precedence over earlier ones
|
||||
size_t bucket = MakeKey (texture->Name) % HASH_SIZE;
|
||||
TextureHash hasher = { texture, HashFirst[bucket] };
|
||||
|
||||
// Textures without name can't be looked for
|
||||
if (texture->Name[0] != 0)
|
||||
{
|
||||
bucket = MakeKey (texture->Name) % HASH_SIZE;
|
||||
hash = HashFirst[bucket];
|
||||
}
|
||||
else
|
||||
{
|
||||
bucket = -1;
|
||||
hash = -1;
|
||||
}
|
||||
|
||||
TextureHash hasher = { texture, hash };
|
||||
int trans = Textures.Push (hasher);
|
||||
Translation.Push (trans);
|
||||
HashFirst[bucket] = trans;
|
||||
if (bucket >= 0) HashFirst[bucket] = trans;
|
||||
return FTextureID(trans);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ class FNativeTexture;
|
|||
class FTexture
|
||||
{
|
||||
public:
|
||||
static FTexture *CreateTexture(const char *name, int lumpnum, int usetype);
|
||||
static FTexture *CreateTexture(int lumpnum, int usetype);
|
||||
virtual ~FTexture ();
|
||||
|
||||
|
|
@ -97,6 +98,8 @@ public:
|
|||
fixed_t xScale;
|
||||
fixed_t yScale;
|
||||
|
||||
int SourceLump;
|
||||
|
||||
char Name[9];
|
||||
BYTE UseType; // This texture's primary purpose
|
||||
|
||||
|
|
@ -146,7 +149,7 @@ public:
|
|||
virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL);
|
||||
int CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, FRemapTable *remap, FCopyInfo *inf = NULL);
|
||||
virtual bool UseBasePalette();
|
||||
virtual int GetSourceLump() { return -1; }
|
||||
virtual int GetSourceLump() { return SourceLump; }
|
||||
virtual FTexture *GetRedirect(bool wantwarped);
|
||||
|
||||
virtual void Unload () = 0;
|
||||
|
|
@ -210,7 +213,7 @@ protected:
|
|||
static BYTE GrayMap[256];
|
||||
FNativeTexture *Native;
|
||||
|
||||
FTexture ();
|
||||
FTexture (const char *name = NULL, int lumpnum = -1);
|
||||
|
||||
Span **CreateSpans (const BYTE *pixels) const;
|
||||
void FreeSpans (Span **spans) const;
|
||||
|
|
@ -285,6 +288,7 @@ public:
|
|||
|
||||
FTextureID CheckForTexture (const char *name, int usetype, BITFIELD flags=TEXMAN_TryAny);
|
||||
FTextureID GetTexture (const char *name, int usetype, BITFIELD flags=0);
|
||||
FTextureID FindTextureByLumpNum (int lumpnum);
|
||||
int ListTextures (const char *name, TArray<FTextureID> &list);
|
||||
|
||||
void AddTexturesLump (const void *lumpdata, int lumpsize, int deflumpnum, int patcheslump, int firstdup=0, bool texture1=false);
|
||||
|
|
@ -296,6 +300,7 @@ public:
|
|||
void LoadTextureDefs(int wadnum, const char *lumpname);
|
||||
void ParseXTexture(FScanner &sc, int usetype);
|
||||
void SortTexturesByType(int start, int end);
|
||||
void RemoveTexture();
|
||||
|
||||
FTextureID CreateTexture (int lumpnum, int usetype=FTexture::TEX_Any); // Also calls AddTexture
|
||||
FTextureID AddTexture (FTexture *texture);
|
||||
|
|
|
|||
|
|
@ -88,10 +88,8 @@ public:
|
|||
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
|
||||
bool UseBasePalette();
|
||||
int GetSourceLump() { return SourceLump; }
|
||||
|
||||
protected:
|
||||
int SourceLump;
|
||||
BYTE *Pixels;
|
||||
Span **Spans;
|
||||
|
||||
|
|
@ -147,7 +145,7 @@ FTexture *TGATexture_TryCreate(FileReader & file, int lumpnum)
|
|||
//==========================================================================
|
||||
|
||||
FTGATexture::FTGATexture (int lumpnum, TGAHeader * hdr)
|
||||
: SourceLump(lumpnum), Pixels(0), Spans(0)
|
||||
: FTexture(NULL, lumpnum), Pixels(0), Spans(0)
|
||||
{
|
||||
Wads.GetLumpName (Name, lumpnum);
|
||||
Name[8] = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue