- 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:
Christoph Oelckers 2008-11-30 12:49:27 +00:00
parent c35be830c3
commit 3f2d5db348
19 changed files with 215 additions and 148 deletions

View file

@ -1,3 +1,18 @@
November 30, 2008 (Changes by Graf Zahl)
- 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.
November 29, 2008 November 29, 2008
- Fixed alignment of "finished" line in WI_drawLF() when the level name is a - Fixed alignment of "finished" line in WI_drawLF() when the level name is a
graphic and scaled. graphic and scaled.

View file

@ -168,6 +168,7 @@ extern bool timingdemo;
// Start time for timing demos // Start time for timing demos
int starttime; int starttime;
static level_info_t gamedefaults;
// ACS variables with world scope // ACS variables with world scope
@ -233,6 +234,7 @@ static const char *MapInfoTopLevel[] =
"skill", "skill",
"clearskills", "clearskills",
"adddefaultmap", "adddefaultmap",
"gamedefaults",
NULL NULL
}; };
@ -246,6 +248,7 @@ enum
MITL_SKILL, MITL_SKILL,
MITL_CLEARSKILLS, MITL_CLEARSKILLS,
MITL_ADDDEFAULTMAP, MITL_ADDDEFAULTMAP,
MITL_GAMEDEFAULTS,
}; };
static const char *MapInfoMapLevel[] = static const char *MapInfoMapLevel[] =
@ -263,7 +266,7 @@ static const char *MapInfoMapLevel[] =
"sucktime", "sucktime",
"music", "music",
"nointermission", "nointermission",
"intermission", "intermission",
"doublesky", "doublesky",
"nosoundclipping", "nosoundclipping",
"allowmonstertelefrags", "allowmonstertelefrags",
@ -283,7 +286,9 @@ static const char *MapInfoMapLevel[] =
"evenlighting", "evenlighting",
"smoothlighting", "smoothlighting",
"noautosequences", "noautosequences",
"autosequences",
"forcenoskystretch", "forcenoskystretch",
"skystretch",
"allowfreelook", "allowfreelook",
"nofreelook", "nofreelook",
"allowjump", "allowjump",
@ -436,7 +441,9 @@ MapHandlers[] =
{ MITYPE_CLRBYTES, lioffset(WallVertLight), lioffset(WallHorizLight) }, { MITYPE_CLRBYTES, lioffset(WallVertLight), lioffset(WallHorizLight) },
{ MITYPE_SETFLAG, LEVEL_SMOOTHLIGHTING, 0 }, { MITYPE_SETFLAG, LEVEL_SMOOTHLIGHTING, 0 },
{ MITYPE_SETFLAG, LEVEL_SNDSEQTOTALCTRL, 0 }, { MITYPE_SETFLAG, LEVEL_SNDSEQTOTALCTRL, 0 },
{ MITYPE_CLRFLAG, LEVEL_SNDSEQTOTALCTRL, 0 },
{ MITYPE_SETFLAG, LEVEL_FORCENOSKYSTRETCH, 0 }, { MITYPE_SETFLAG, LEVEL_FORCENOSKYSTRETCH, 0 },
{ MITYPE_CLRFLAG, LEVEL_FORCENOSKYSTRETCH, 0 },
{ MITYPE_SCFLAGS, LEVEL_FREELOOK_YES, ~LEVEL_FREELOOK_NO }, { MITYPE_SCFLAGS, LEVEL_FREELOOK_YES, ~LEVEL_FREELOOK_NO },
{ MITYPE_SCFLAGS, LEVEL_FREELOOK_NO, ~LEVEL_FREELOOK_YES }, { MITYPE_SCFLAGS, LEVEL_FREELOOK_NO, ~LEVEL_FREELOOK_YES },
{ MITYPE_CLRFLAG, LEVEL_JUMP_NO, 0 }, { MITYPE_CLRFLAG, LEVEL_JUMP_NO, 0 },
@ -609,6 +616,8 @@ void G_ParseMapInfo ()
atterm (G_UnloadMapInfo); atterm (G_UnloadMapInfo);
SetLevelDefaults (&gamedefaults);
// Parse the default MAPINFO for the current game. // Parse the default MAPINFO for the current game.
for(int i=0; i<2; i++) for(int i=0; i<2; i++)
{ {
@ -633,6 +642,7 @@ void G_ParseMapInfo ()
{ {
I_FatalError ("You cannot use clearskills in a MAPINFO if you do not define any new skills after it."); I_FatalError ("You cannot use clearskills in a MAPINFO if you do not define any new skills after it.");
} }
ClearLevelInfoStrings (&gamedefaults);
} }
static FSpecialAction *CopySpecialActions(FSpecialAction *spec) static FSpecialAction *CopySpecialActions(FSpecialAction *spec)
@ -709,6 +719,20 @@ static void ClearClusterInfoStrings(cluster_info_t *cinfo)
SafeDelete(cinfo->clustername); SafeDelete(cinfo->clustername);
} }
static void CopyLevelInfo(level_info_t *levelinfo, level_info_t *from)
{
memcpy (levelinfo, from, sizeof(*levelinfo));
CopyString(levelinfo->music);
CopyString(levelinfo->intermusic);
CopyString(levelinfo->translator);
CopyString(levelinfo->enterpic);
CopyString(levelinfo->exitpic);
CopyString(levelinfo->soundinfo);
CopyString(levelinfo->sndseq);
levelinfo->specialactions = CopySpecialActions(levelinfo->specialactions);
levelinfo->opdata = CopyOptData(levelinfo->opdata);
}
static void G_DoParseMapInfo (int lump) static void G_DoParseMapInfo (int lump)
{ {
@ -721,13 +745,21 @@ static void G_DoParseMapInfo (int lump)
FScanner sc(lump); FScanner sc(lump);
SetLevelDefaults (&defaultinfo); CopyLevelInfo(&defaultinfo, &gamedefaults);
HexenHack = false; HexenHack = false;
while (sc.GetString ()) while (sc.GetString ())
{ {
switch (sc.MustMatchString (MapInfoTopLevel)) switch (sc.MustMatchString (MapInfoTopLevel))
{ {
case MITL_GAMEDEFAULTS:
ClearLevelInfoStrings(&gamedefaults);
SetLevelDefaults (&gamedefaults);
ParseMapInfoLower (sc, MapHandlers, MapInfoMapLevel, &gamedefaults, NULL, defaultinfo.flags);
ClearLevelInfoStrings(&defaultinfo);
CopyLevelInfo(&defaultinfo, &gamedefaults);
break;
case MITL_DEFAULTMAP: case MITL_DEFAULTMAP:
ClearLevelInfoStrings(&defaultinfo); ClearLevelInfoStrings(&defaultinfo);
SetLevelDefaults (&defaultinfo); SetLevelDefaults (&defaultinfo);
@ -776,16 +808,7 @@ static void G_DoParseMapInfo (int lump)
ClearLevelInfoStrings (&wadlevelinfos[levelindex]); ClearLevelInfoStrings (&wadlevelinfos[levelindex]);
} }
levelinfo = &wadlevelinfos[levelindex]; levelinfo = &wadlevelinfos[levelindex];
memcpy (levelinfo, &defaultinfo, sizeof(*levelinfo)); CopyLevelInfo(levelinfo, &defaultinfo);
CopyString(levelinfo->music);
CopyString(levelinfo->intermusic);
CopyString(levelinfo->translator);
CopyString(levelinfo->enterpic);
CopyString(levelinfo->exitpic);
CopyString(levelinfo->soundinfo);
CopyString(levelinfo->sndseq);
levelinfo->specialactions = CopySpecialActions(levelinfo->specialactions);
levelinfo->opdata = CopyOptData(levelinfo->opdata);
if (HexenHack) if (HexenHack)
{ {
levelinfo->WallHorizLight = levelinfo->WallVertLight = 0; levelinfo->WallHorizLight = levelinfo->WallVertLight = 0;

View file

@ -56,14 +56,11 @@ public:
void Unload (); void Unload ();
void MakeTexture (); void MakeTexture ();
int GetSourceLump() { return LumpNum; }
FAutomapTexture (int lumpnum); FAutomapTexture (int lumpnum);
private: private:
BYTE *Pixels; BYTE *Pixels;
Span DummySpan[2]; Span DummySpan[2];
int LumpNum;
}; };
@ -89,11 +86,8 @@ FTexture *AutomapTexture_TryCreate(FileReader &data, int lumpnum)
//========================================================================== //==========================================================================
FAutomapTexture::FAutomapTexture (int lumpnum) FAutomapTexture::FAutomapTexture (int lumpnum)
: Pixels(NULL), LumpNum(lumpnum) : FTexture(NULL, lumpnum), Pixels(NULL)
{ {
Wads.GetLumpName (Name, lumpnum);
Name[8] = 0;
Width = 320; Width = 320;
Height = WORD(Wads.LumpLength(lumpnum) / 320); Height = WORD(Wads.LumpLength(lumpnum) / 320);
CalcBitSize (); CalcBitSize ();
@ -139,7 +133,7 @@ void FAutomapTexture::Unload ()
void FAutomapTexture::MakeTexture () void FAutomapTexture::MakeTexture ()
{ {
int x, y; int x, y;
FMemLump data = Wads.ReadLump (LumpNum); FMemLump data = Wads.ReadLump (SourceLump);
const BYTE *indata = (const BYTE *)data.GetMem(); const BYTE *indata = (const BYTE *)data.GetMem();
Pixels = new BYTE[Width * Height]; Pixels = new BYTE[Width * Height];

View file

@ -159,11 +159,9 @@ public:
const BYTE *GetPixels (); const BYTE *GetPixels ();
void Unload (); void Unload ();
FTextureFormat GetFormat (); FTextureFormat GetFormat ();
int GetSourceLump() { return SourceLump; }
protected: protected:
int SourceLump;
BYTE *Pixels; BYTE *Pixels;
Span **Spans; Span **Spans;
@ -285,13 +283,10 @@ FTexture *DDSTexture_TryCreate (FileReader &data, int lumpnum)
//========================================================================== //==========================================================================
FDDSTexture::FDDSTexture (FileReader &lump, int lumpnum, void *vsurfdesc) 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; DDSURFACEDESC2 *surf = (DDSURFACEDESC2 *)vsurfdesc;
Wads.GetLumpName (Name, lumpnum);
Name[8] = 0;
UseType = TEX_MiscPatch; UseType = TEX_MiscPatch;
LeftOffset = 0; LeftOffset = 0;
TopOffset = 0; TopOffset = 0;

View file

@ -55,10 +55,7 @@ public:
const BYTE *GetPixels (); const BYTE *GetPixels ();
void Unload (); void Unload ();
int GetSourceLump() { return SourceLump; }
protected: protected:
int SourceLump;
BYTE *Pixels; BYTE *Pixels;
Span DummySpans[2]; Span DummySpans[2];
@ -89,13 +86,11 @@ FTexture *FlatTexture_TryCreate(FileReader & file, int lumpnum)
//========================================================================== //==========================================================================
FFlatTexture::FFlatTexture (int lumpnum) FFlatTexture::FFlatTexture (int lumpnum)
: SourceLump(lumpnum), Pixels(0) : FTexture(NULL, lumpnum), Pixels(0)
{ {
int area; int area;
int bits; int bits;
Wads.GetLumpName (Name, lumpnum);
Name[8] = 0;
area = Wads.LumpLength (lumpnum); area = Wads.LumpLength (lumpnum);
switch (area) switch (area)

View file

@ -68,12 +68,8 @@ public:
const BYTE *GetPixels (); const BYTE *GetPixels ();
void Unload (); void Unload ();
int GetSourceLump() { return SourceLump; }
protected: protected:
int SourceLump;
BYTE *Pixels; BYTE *Pixels;
Span **Spans; 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) 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); Wads.GetLumpName (Name, lumpnum);
Name[8] = 0; Name[8] = 0;

View file

@ -170,11 +170,9 @@ public:
FTextureFormat GetFormat (); FTextureFormat GetFormat ();
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
bool UseBasePalette(); bool UseBasePalette();
int GetSourceLump() { return SourceLump; }
protected: protected:
int SourceLump;
BYTE *Pixels; BYTE *Pixels;
Span DummySpans[2]; Span DummySpans[2];
@ -240,11 +238,8 @@ FTexture *JPEGTexture_TryCreate(FileReader & data, int lumpnum)
//========================================================================== //==========================================================================
FJPEGTexture::FJPEGTexture (int lumpnum, int width, int height) 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; UseType = TEX_MiscPatch;
LeftOffset = 0; LeftOffset = 0;
TopOffset = 0; TopOffset = 0;

View file

@ -170,7 +170,6 @@ protected:
{ {
SWORD OriginX, OriginY; SWORD OriginX, OriginY;
BYTE Rotate; BYTE Rotate;
bool textureOwned;
BYTE op; BYTE op;
FRemapTable *Translation; FRemapTable *Translation;
PalEntry Blend; PalEntry Blend;
@ -315,7 +314,6 @@ FMultiPatchTexture::~FMultiPatchTexture ()
{ {
for(int i=0; i<NumParts;i++) 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; if (Parts[i].Translation != NULL) delete Parts[i].Translation;
} }
delete[] Parts; delete[] Parts;
@ -774,7 +772,6 @@ FMultiPatchTexture::TexPart::TexPart()
{ {
OriginX = OriginY = 0; OriginX = OriginY = 0;
Rotate = 0; Rotate = 0;
textureOwned = false;
Texture = NULL; Texture = NULL;
Translation = NULL; Translation = NULL;
Blend = 0; Blend = 0;
@ -972,8 +969,16 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part)
int lumpnum = Wads.CheckNumForFullName(sc.String); int lumpnum = Wads.CheckNumForFullName(sc.String);
if (lumpnum >= 0) if (lumpnum >= 0)
{ {
part.Texture = FTexture::CreateTexture(lumpnum, TEX_WallPatch); texno = TexMan.FindTextureByLumpNum(lumpnum);
part.textureOwned = true; 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, "./")) else if (strlen(sc.String) <= 8 && !strpbrk(sc.String, "./"))
{ {

View file

@ -57,10 +57,7 @@ public:
const BYTE *GetPixels (); const BYTE *GetPixels ();
void Unload (); void Unload ();
int GetSourceLump() { return SourceLump; }
protected: protected:
int SourceLump;
BYTE *Pixels; BYTE *Pixels;
Span **Spans; Span **Spans;
bool hackflag; bool hackflag;
@ -141,10 +138,8 @@ FTexture *PatchTexture_TryCreate(FileReader & file, int lumpnum)
//========================================================================== //==========================================================================
FPatchTexture::FPatchTexture (int lumpnum, patch_t * header) 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; Width = header->width;
Height = header->height; Height = header->height;
LeftOffset = header->leftoffset; LeftOffset = header->leftoffset;

View file

@ -93,10 +93,8 @@ public:
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
bool UseBasePalette(); bool UseBasePalette();
int GetSourceLump() { return SourceLump; }
protected: protected:
int SourceLump;
BYTE *Pixels; BYTE *Pixels;
Span DummySpans[2]; Span DummySpans[2];
@ -157,10 +155,8 @@ FTexture * PCXTexture_TryCreate(FileReader & file, int lumpnum)
//========================================================================== //==========================================================================
FPCXTexture::FPCXTexture(int lumpnum, PCXHeader & hdr) FPCXTexture::FPCXTexture(int lumpnum, PCXHeader & hdr)
: SourceLump(lumpnum), Pixels(0) : FTexture(NULL, lumpnum), Pixels(0)
{ {
Wads.GetLumpName (Name, lumpnum);
Name[8] = 0;
bMasked = false; bMasked = false;
Width = LittleShort(hdr.xmax) - LittleShort(hdr.xmin) + 1; Width = LittleShort(hdr.xmax) - LittleShort(hdr.xmin) + 1;
Height = LittleShort(hdr.ymax) - LittleShort(hdr.ymin) + 1; Height = LittleShort(hdr.ymax) - LittleShort(hdr.ymin) + 1;

View file

@ -60,11 +60,9 @@ public:
FTextureFormat GetFormat (); FTextureFormat GetFormat ();
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
bool UseBasePalette(); bool UseBasePalette();
int GetSourceLump() { return SourceLump; }
protected: protected:
int SourceLump;
FString SourceFile; FString SourceFile;
BYTE *Pixels; BYTE *Pixels;
Span **Spans; 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, FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height,
BYTE depth, BYTE colortype, BYTE interlace) 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), BitDepth(depth), ColorType(colortype), Interlace(interlace),
PaletteMap(0), PaletteSize(0), StartOfIDAT(0) PaletteMap(0), PaletteSize(0), StartOfIDAT(0)
{ {
@ -208,9 +206,6 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename
DWORD len, id; DWORD len, id;
int i; int i;
Wads.GetLumpName (Name, lumpnum);
Name[8] = 0;
UseType = TEX_MiscPatch; UseType = TEX_MiscPatch;
LeftOffset = 0; LeftOffset = 0;
TopOffset = 0; TopOffset = 0;

View file

@ -56,10 +56,7 @@ public:
const BYTE *GetPixels (); const BYTE *GetPixels ();
void Unload (); void Unload ();
int GetSourceLump() { return SourceLump; }
protected: protected:
int SourceLump;
BYTE *Pixels; BYTE *Pixels;
static const Span DummySpans[2]; static const Span DummySpans[2];
@ -176,11 +173,8 @@ const FTexture::Span FRawPageTexture::DummySpans[2] =
//========================================================================== //==========================================================================
FRawPageTexture::FRawPageTexture (int lumpnum) FRawPageTexture::FRawPageTexture (int lumpnum)
: SourceLump(lumpnum), Pixels(0) : FTexture(NULL, lumpnum), Pixels(0)
{ {
Wads.GetLumpName (Name, lumpnum);
Name[8] = 0;
Width = 320; Width = 320;
Height = 200; Height = 200;
WidthBits = 8; WidthBits = 8;

View file

@ -127,14 +127,34 @@ FTexture * FTexture::CreateTexture (int lumpnum, int usetype)
return NULL; 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), : 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), UseType(TEX_Any), bNoDecals(false), bNoRemap0(false), bWorldPanning(false),
bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false), bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false),
Rotations(0xFFFF), Width(0), Height(0), WidthMask(0), Native(NULL) 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 () FTexture::~FTexture ()

View file

@ -211,6 +211,30 @@ int FTextureManager::ListTextures (const char *name, TArray<FTextureID> &list)
return list.Size(); 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 // FTextureManager :: GetTextures
@ -273,12 +297,29 @@ void FTextureManager::UnloadAll ()
FTextureID FTextureManager::AddTexture (FTexture *texture) FTextureID FTextureManager::AddTexture (FTexture *texture)
{ {
size_t bucket;
int hash;
if (texture == NULL) return FTextureID(-1);
// Later textures take precedence over earlier ones // 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); int trans = Textures.Push (hasher);
Translation.Push (trans); Translation.Push (trans);
HashFirst[bucket] = trans; if (bucket >= 0) HashFirst[bucket] = trans;
return FTextureID(trans); return FTextureID(trans);
} }

View file

@ -87,6 +87,7 @@ class FNativeTexture;
class FTexture class FTexture
{ {
public: public:
static FTexture *CreateTexture(const char *name, int lumpnum, int usetype);
static FTexture *CreateTexture(int lumpnum, int usetype); static FTexture *CreateTexture(int lumpnum, int usetype);
virtual ~FTexture (); virtual ~FTexture ();
@ -97,6 +98,8 @@ public:
fixed_t xScale; fixed_t xScale;
fixed_t yScale; fixed_t yScale;
int SourceLump;
char Name[9]; char Name[9];
BYTE UseType; // This texture's primary purpose 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); 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); int CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, FRemapTable *remap, FCopyInfo *inf = NULL);
virtual bool UseBasePalette(); virtual bool UseBasePalette();
virtual int GetSourceLump() { return -1; } virtual int GetSourceLump() { return SourceLump; }
virtual FTexture *GetRedirect(bool wantwarped); virtual FTexture *GetRedirect(bool wantwarped);
virtual void Unload () = 0; virtual void Unload () = 0;
@ -210,7 +213,7 @@ protected:
static BYTE GrayMap[256]; static BYTE GrayMap[256];
FNativeTexture *Native; FNativeTexture *Native;
FTexture (); FTexture (const char *name = NULL, int lumpnum = -1);
Span **CreateSpans (const BYTE *pixels) const; Span **CreateSpans (const BYTE *pixels) const;
void FreeSpans (Span **spans) const; void FreeSpans (Span **spans) const;
@ -285,6 +288,7 @@ public:
FTextureID CheckForTexture (const char *name, int usetype, BITFIELD flags=TEXMAN_TryAny); FTextureID CheckForTexture (const char *name, int usetype, BITFIELD flags=TEXMAN_TryAny);
FTextureID GetTexture (const char *name, int usetype, BITFIELD flags=0); FTextureID GetTexture (const char *name, int usetype, BITFIELD flags=0);
FTextureID FindTextureByLumpNum (int lumpnum);
int ListTextures (const char *name, TArray<FTextureID> &list); 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); 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 LoadTextureDefs(int wadnum, const char *lumpname);
void ParseXTexture(FScanner &sc, int usetype); void ParseXTexture(FScanner &sc, int usetype);
void SortTexturesByType(int start, int end); void SortTexturesByType(int start, int end);
void RemoveTexture();
FTextureID CreateTexture (int lumpnum, int usetype=FTexture::TEX_Any); // Also calls AddTexture FTextureID CreateTexture (int lumpnum, int usetype=FTexture::TEX_Any); // Also calls AddTexture
FTextureID AddTexture (FTexture *texture); FTextureID AddTexture (FTexture *texture);

View file

@ -88,10 +88,8 @@ public:
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
bool UseBasePalette(); bool UseBasePalette();
int GetSourceLump() { return SourceLump; }
protected: protected:
int SourceLump;
BYTE *Pixels; BYTE *Pixels;
Span **Spans; Span **Spans;
@ -147,7 +145,7 @@ FTexture *TGATexture_TryCreate(FileReader & file, int lumpnum)
//========================================================================== //==========================================================================
FTGATexture::FTGATexture (int lumpnum, TGAHeader * hdr) FTGATexture::FTGATexture (int lumpnum, TGAHeader * hdr)
: SourceLump(lumpnum), Pixels(0), Spans(0) : FTexture(NULL, lumpnum), Pixels(0), Spans(0)
{ {
Wads.GetLumpName (Name, lumpnum); Wads.GetLumpName (Name, lumpnum);
Name[8] = 0; Name[8] = 0;

View file

@ -150,14 +150,14 @@ protected:
class FSpecialFont : public FFont class FSpecialFont : public FFont
{ {
public: public:
FSpecialFont (const char *name, int first, int count, int *lumplist, const bool *notranslate); FSpecialFont (const char *name, int first, int count, FTexture **lumplist, const bool *notranslate);
}; };
// This is a font character that loads a texture and recolors it. // This is a font character that loads a texture and recolors it.
class FFontChar1 : public FTexture class FFontChar1 : public FTexture
{ {
public: public:
FFontChar1 (int sourcelump, const BYTE *sourceremap); FFontChar1 (FTexture *sourcelump, const BYTE *sourceremap);
const BYTE *GetColumn (unsigned int column, const Span **spans_out); const BYTE *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels (); const BYTE *GetPixels ();
void Unload (); void Unload ();
@ -318,9 +318,10 @@ FArchive &SerializeFFontPtr (FArchive &arc, FFont* &font)
FFont::FFont (const char *name, const char *nametemplate, int first, int count, int start) FFont::FFont (const char *name, const char *nametemplate, int first, int count, int start)
{ {
int i, lump; int i;
FTextureID lump;
char buffer[12]; char buffer[12];
int *charlumps; FTexture **charlumps;
BYTE usedcolors[256], identity[256]; BYTE usedcolors[256], identity[256];
double *luminosity; double *luminosity;
int maxyoffs; int maxyoffs;
@ -328,7 +329,7 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count,
bool stcfn121 = false; bool stcfn121 = false;
Chars = new CharData[count]; Chars = new CharData[count];
charlumps = new int[count]; charlumps = new FTexture *[count];
PatchRemap = new BYTE[256]; PatchRemap = new BYTE[256];
FirstChar = first; FirstChar = first;
LastChar = first + count - 1; LastChar = first + count - 1;
@ -343,33 +344,34 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count,
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
charlumps[i] = -1; charlumps[i] = NULL;
mysnprintf (buffer, countof(buffer), nametemplate, i + start); mysnprintf (buffer, countof(buffer), nametemplate, i + start);
lump = Wads.CheckNumForName (buffer, ns_graphics);
if (doomtemplate && lump >= 0 && i + start == 121) lump = TexMan.CheckForTexture(buffer, FTexture::TEX_MiscPatch);
if (doomtemplate && lump.isValid() && i + start == 121)
{ // HACKHACK: Don't load STCFN121 in doom(2), because { // HACKHACK: Don't load STCFN121 in doom(2), because
// it's not really a lower-case 'y' but a '|'. // it's not really a lower-case 'y' but a '|'.
// Because a lot of wads with their own font seem to foolishly // Because a lot of wads with their own font seem to foolishly
// copy STCFN121 and make it a '|' themselves, wads must // copy STCFN121 and make it a '|' themselves, wads must
// provide STCFN120 (x) and STCFN122 (z) for STCFN121 to load. // provide STCFN120 (x) and STCFN122 (z) for STCFN121 to load as a 'y'.
if (Wads.CheckNumForName ("STCFN120", ns_graphics) == -1 || if (!TexMan.CheckForTexture("STCFN120", FTexture::TEX_MiscPatch).isValid() ||
Wads.CheckNumForName ("STCFN122", ns_graphics) == -1) !TexMan.CheckForTexture("STCFN122", FTexture::TEX_MiscPatch).isValid())
{ {
// insert the incorrectly named '|' graphic in its correct position. // insert the incorrectly named '|' graphic in its correct position.
if (count > 124-start) charlumps[124-start] = lump; if (count > 124-start) charlumps[124-start] = TexMan[lump];
lump = -1; lump.SetInvalid();
stcfn121 = true; stcfn121 = true;
} }
} }
if (lump >= 0) if (lump.isValid())
{ {
FTexture *pic = TexMan[buffer]; FTexture *pic = TexMan[lump];
if (pic != NULL) if (pic != NULL)
{ {
// set the lump here only if it represents a valid texture // set the lump here only if it represents a valid texture
if (i != 124-start || !stcfn121) if (i != 124-start || !stcfn121)
charlumps[i] = lump; charlumps[i] = pic;
int height = pic->GetScaledHeight(); int height = pic->GetScaledHeight();
int yoffs = pic->GetScaledTopOffset(); int yoffs = pic->GetScaledTopOffset();
@ -392,7 +394,7 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count,
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
if (charlumps[i] >= 0) if (charlumps[i] != NULL)
{ {
Chars[i].Pic = new FFontChar1 (charlumps[i], PatchRemap); Chars[i].Pic = new FFontChar1 (charlumps[i], PatchRemap);
} }
@ -1231,17 +1233,15 @@ int FSinglePicFont::GetCharWidth (int code) const
// //
//========================================================================== //==========================================================================
FFontChar1::FFontChar1 (int sourcelump, const BYTE *sourceremap) FFontChar1::FFontChar1 (FTexture *sourcelump, const BYTE *sourceremap)
: SourceRemap (sourceremap) : SourceRemap (sourceremap)
{ {
UseType = FTexture::TEX_FontChar; UseType = FTexture::TEX_FontChar;
Wads.GetLumpName(Name, sourcelump); BaseTexture = sourcelump;
Name[8] = 0;
BaseTexture = TexMan[Name]; // it has already been added!
Name[0] = 0; // Make this texture unnamed
// now copy all the properties from the base texture // now copy all the properties from the base texture
if (BaseTexture != NULL) CopySize(BaseTexture); assert(BaseTexture != NULL);
CopySize(BaseTexture);
Pixels = NULL; Pixels = NULL;
} }
@ -1516,11 +1516,10 @@ void FFontChar2::MakeTexture ()
// //
//========================================================================== //==========================================================================
FSpecialFont::FSpecialFont (const char *name, int first, int count, int *lumplist, const bool *notranslate) FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **lumplist, const bool *notranslate)
{ {
int i, j, lump; int i, j;
char buffer[12]; FTexture **charlumps;
int *charlumps;
BYTE usedcolors[256], identity[256]; BYTE usedcolors[256], identity[256];
double *luminosity; double *luminosity;
int maxyoffs; int maxyoffs;
@ -1529,7 +1528,7 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, int *lumplis
Name = copystring(name); Name = copystring(name);
Chars = new CharData[count]; Chars = new CharData[count];
charlumps = new int[count]; charlumps = new FTexture*[count];
PatchRemap = new BYTE[256]; PatchRemap = new BYTE[256];
FirstChar = first; FirstChar = first;
LastChar = first + count - 1; LastChar = first + count - 1;
@ -1543,36 +1542,23 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, int *lumplis
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
lump = charlumps[i] = lumplist[i]; pic = charlumps[i] = lumplist[i];
if (lump >= 0) if (pic != NULL)
{ {
Wads.GetLumpName(buffer, lump); int height = pic->GetScaledHeight();
if (buffer[0] != 0) int yoffs = pic->GetScaledTopOffset();
{
buffer[8] = 0;
pic = TexMan[buffer];
}
else
{
pic = NULL;
}
if (pic != NULL)
{
int height = pic->GetScaledHeight();
int yoffs = pic->GetScaledTopOffset();
if (yoffs > maxyoffs) if (yoffs > maxyoffs)
{ {
maxyoffs = yoffs; maxyoffs = yoffs;
}
height += abs (yoffs);
if (height > FontHeight)
{
FontHeight = height;
}
RecordTextureColors (pic, usedcolors);
} }
height += abs (yoffs);
if (height > FontHeight)
{
FontHeight = height;
}
RecordTextureColors (pic, usedcolors);
} }
} }
@ -1602,7 +1588,7 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, int *lumplis
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
if (charlumps[i] >= 0) if (charlumps[i] != NULL)
{ {
Chars[i].Pic = new FFontChar1 (charlumps[i], PatchRemap); Chars[i].Pic = new FFontChar1 (charlumps[i], PatchRemap);
} }
@ -1655,7 +1641,7 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, int *lumplis
void V_InitCustomFonts() void V_InitCustomFonts()
{ {
FScanner sc; FScanner sc;
int lumplist[256]; FTexture *lumplist[256];
bool notranslate[256]; bool notranslate[256];
FString namebuffer, templatebuf; FString namebuffer, templatebuf;
int i; int i;
@ -1670,7 +1656,7 @@ void V_InitCustomFonts()
sc.OpenLumpNum(llump); sc.OpenLumpNum(llump);
while (sc.GetString()) while (sc.GetString())
{ {
memset (lumplist, -1, sizeof(lumplist)); memset (lumplist, 0, sizeof(lumplist));
memset (notranslate, 0, sizeof(notranslate)); memset (notranslate, 0, sizeof(notranslate));
namebuffer = sc.String; namebuffer = sc.String;
format = 0; format = 0;
@ -1723,11 +1709,30 @@ void V_InitCustomFonts()
else else
{ {
if (format == 1) goto wrong; if (format == 1) goto wrong;
int *p = &lumplist[*(unsigned char*)sc.String]; FTexture **p = &lumplist[*(unsigned char*)sc.String];
sc.MustGetString(); sc.MustGetString();
if (-1 == (*p = Wads.CheckNumForFullName (sc.String, true))) FTextureID texid = TexMan.CheckForTexture(sc.String, FTexture::TEX_MiscPatch);
if (!texid.Exists())
{ {
*p = Wads.CheckNumForFullName (sc.String, true, ns_graphics); int lumpno = Wads.CheckNumForFullName (sc.String);
if (lumpno >= 0)
{
texid = TexMan.FindTextureByLumpNum(lumpno);
if (!texid.Exists())
{
FTexture *tex = FTexture::CreateTexture("", lumpno, FTexture::TEX_MiscPatch);
texid = TexMan.AddTexture(tex);
}
}
}
if (texid.Exists())
{
*p = TexMan[texid];
}
else if (Wads.GetLumpFile(sc.LumpNum) >= Wads.IWAD_FILENUM)
{
// Print a message only if this isn't in zdoom.pk3
sc.ScriptMessage("%s: Unable to find texture in font definition for %s", sc.String, namebuffer.GetChars());
} }
format = 2; format = 2;
} }
@ -1740,7 +1745,7 @@ void V_InitCustomFonts()
{ {
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
if (lumplist[i] != -1) if (lumplist[i] != NULL)
{ {
first = i; first = i;
break; break;
@ -1748,7 +1753,7 @@ void V_InitCustomFonts()
} }
for (i = 255; i >= 0; i--) for (i = 255; i >= 0; i--)
{ {
if (lumplist[i] != -1) if (lumplist[i] != NULL)
{ {
count = i - first + 1; count = i - first + 1;
break; break;

View file

@ -81,7 +81,7 @@ exittextislump
music hub music hub
pic interpic pic interpic
defaultmap gamedefaults
activateowndeathspecials activateowndeathspecials
infiniteflightpowerup infiniteflightpowerup
fallingdamage fallingdamage

View file

@ -32,7 +32,7 @@ skill nightmare
PicName "M_NMARE" PicName "M_NMARE"
Key b Key b
defaultmap gamedefaults
forcenoskystretch forcenoskystretch
strifefallingdamage strifefallingdamage
nointermission nointermission