- 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
- Fixed alignment of "finished" line in WI_drawLF() when the level name is a
graphic and scaled.

View file

@ -168,6 +168,7 @@ extern bool timingdemo;
// Start time for timing demos
int starttime;
static level_info_t gamedefaults;
// ACS variables with world scope
@ -233,6 +234,7 @@ static const char *MapInfoTopLevel[] =
"skill",
"clearskills",
"adddefaultmap",
"gamedefaults",
NULL
};
@ -246,6 +248,7 @@ enum
MITL_SKILL,
MITL_CLEARSKILLS,
MITL_ADDDEFAULTMAP,
MITL_GAMEDEFAULTS,
};
static const char *MapInfoMapLevel[] =
@ -263,7 +266,7 @@ static const char *MapInfoMapLevel[] =
"sucktime",
"music",
"nointermission",
"intermission",
"intermission",
"doublesky",
"nosoundclipping",
"allowmonstertelefrags",
@ -283,7 +286,9 @@ static const char *MapInfoMapLevel[] =
"evenlighting",
"smoothlighting",
"noautosequences",
"autosequences",
"forcenoskystretch",
"skystretch",
"allowfreelook",
"nofreelook",
"allowjump",
@ -436,7 +441,9 @@ MapHandlers[] =
{ MITYPE_CLRBYTES, lioffset(WallVertLight), lioffset(WallHorizLight) },
{ MITYPE_SETFLAG, LEVEL_SMOOTHLIGHTING, 0 },
{ MITYPE_SETFLAG, LEVEL_SNDSEQTOTALCTRL, 0 },
{ MITYPE_CLRFLAG, LEVEL_SNDSEQTOTALCTRL, 0 },
{ MITYPE_SETFLAG, LEVEL_FORCENOSKYSTRETCH, 0 },
{ MITYPE_CLRFLAG, LEVEL_FORCENOSKYSTRETCH, 0 },
{ MITYPE_SCFLAGS, LEVEL_FREELOOK_YES, ~LEVEL_FREELOOK_NO },
{ MITYPE_SCFLAGS, LEVEL_FREELOOK_NO, ~LEVEL_FREELOOK_YES },
{ MITYPE_CLRFLAG, LEVEL_JUMP_NO, 0 },
@ -609,6 +616,8 @@ void G_ParseMapInfo ()
atterm (G_UnloadMapInfo);
SetLevelDefaults (&gamedefaults);
// Parse the default MAPINFO for the current game.
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.");
}
ClearLevelInfoStrings (&gamedefaults);
}
static FSpecialAction *CopySpecialActions(FSpecialAction *spec)
@ -709,6 +719,20 @@ static void ClearClusterInfoStrings(cluster_info_t *cinfo)
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)
{
@ -721,13 +745,21 @@ static void G_DoParseMapInfo (int lump)
FScanner sc(lump);
SetLevelDefaults (&defaultinfo);
CopyLevelInfo(&defaultinfo, &gamedefaults);
HexenHack = false;
while (sc.GetString ())
{
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:
ClearLevelInfoStrings(&defaultinfo);
SetLevelDefaults (&defaultinfo);
@ -776,16 +808,7 @@ static void G_DoParseMapInfo (int lump)
ClearLevelInfoStrings (&wadlevelinfos[levelindex]);
}
levelinfo = &wadlevelinfos[levelindex];
memcpy (levelinfo, &defaultinfo, 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);
CopyLevelInfo(levelinfo, &defaultinfo);
if (HexenHack)
{
levelinfo->WallHorizLight = levelinfo->WallVertLight = 0;

View file

@ -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];

View file

@ -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;

View file

@ -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)

View file

@ -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;

View file

@ -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;

View file

@ -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, "./"))
{

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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 ()

View file

@ -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);
}

View file

@ -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);

View file

@ -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;

View file

@ -150,14 +150,14 @@ protected:
class FSpecialFont : public FFont
{
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.
class FFontChar1 : public FTexture
{
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 *GetPixels ();
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)
{
int i, lump;
int i;
FTextureID lump;
char buffer[12];
int *charlumps;
FTexture **charlumps;
BYTE usedcolors[256], identity[256];
double *luminosity;
int maxyoffs;
@ -328,7 +329,7 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count,
bool stcfn121 = false;
Chars = new CharData[count];
charlumps = new int[count];
charlumps = new FTexture *[count];
PatchRemap = new BYTE[256];
FirstChar = first;
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++)
{
charlumps[i] = -1;
charlumps[i] = NULL;
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
// it's not really a lower-case 'y' but a '|'.
// Because a lot of wads with their own font seem to foolishly
// copy STCFN121 and make it a '|' themselves, wads must
// provide STCFN120 (x) and STCFN122 (z) for STCFN121 to load.
if (Wads.CheckNumForName ("STCFN120", ns_graphics) == -1 ||
Wads.CheckNumForName ("STCFN122", ns_graphics) == -1)
// provide STCFN120 (x) and STCFN122 (z) for STCFN121 to load as a 'y'.
if (!TexMan.CheckForTexture("STCFN120", FTexture::TEX_MiscPatch).isValid() ||
!TexMan.CheckForTexture("STCFN122", FTexture::TEX_MiscPatch).isValid())
{
// insert the incorrectly named '|' graphic in its correct position.
if (count > 124-start) charlumps[124-start] = lump;
lump = -1;
if (count > 124-start) charlumps[124-start] = TexMan[lump];
lump.SetInvalid();
stcfn121 = true;
}
}
if (lump >= 0)
if (lump.isValid())
{
FTexture *pic = TexMan[buffer];
FTexture *pic = TexMan[lump];
if (pic != NULL)
{
// set the lump here only if it represents a valid texture
if (i != 124-start || !stcfn121)
charlumps[i] = lump;
charlumps[i] = pic;
int height = pic->GetScaledHeight();
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++)
{
if (charlumps[i] >= 0)
if (charlumps[i] != NULL)
{
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)
{
UseType = FTexture::TEX_FontChar;
Wads.GetLumpName(Name, sourcelump);
Name[8] = 0;
BaseTexture = TexMan[Name]; // it has already been added!
Name[0] = 0; // Make this texture unnamed
BaseTexture = sourcelump;
// now copy all the properties from the base texture
if (BaseTexture != NULL) CopySize(BaseTexture);
assert(BaseTexture != NULL);
CopySize(BaseTexture);
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;
char buffer[12];
int *charlumps;
int i, j;
FTexture **charlumps;
BYTE usedcolors[256], identity[256];
double *luminosity;
int maxyoffs;
@ -1529,7 +1528,7 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, int *lumplis
Name = copystring(name);
Chars = new CharData[count];
charlumps = new int[count];
charlumps = new FTexture*[count];
PatchRemap = new BYTE[256];
FirstChar = first;
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++)
{
lump = charlumps[i] = lumplist[i];
if (lump >= 0)
pic = charlumps[i] = lumplist[i];
if (pic != NULL)
{
Wads.GetLumpName(buffer, lump);
if (buffer[0] != 0)
{
buffer[8] = 0;
pic = TexMan[buffer];
}
else
{
pic = NULL;
}
if (pic != NULL)
{
int height = pic->GetScaledHeight();
int yoffs = pic->GetScaledTopOffset();
int height = pic->GetScaledHeight();
int yoffs = pic->GetScaledTopOffset();
if (yoffs > maxyoffs)
{
maxyoffs = yoffs;
}
height += abs (yoffs);
if (height > FontHeight)
{
FontHeight = height;
}
RecordTextureColors (pic, usedcolors);
if (yoffs > maxyoffs)
{
maxyoffs = yoffs;
}
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++)
{
if (charlumps[i] >= 0)
if (charlumps[i] != NULL)
{
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()
{
FScanner sc;
int lumplist[256];
FTexture *lumplist[256];
bool notranslate[256];
FString namebuffer, templatebuf;
int i;
@ -1670,7 +1656,7 @@ void V_InitCustomFonts()
sc.OpenLumpNum(llump);
while (sc.GetString())
{
memset (lumplist, -1, sizeof(lumplist));
memset (lumplist, 0, sizeof(lumplist));
memset (notranslate, 0, sizeof(notranslate));
namebuffer = sc.String;
format = 0;
@ -1723,11 +1709,30 @@ void V_InitCustomFonts()
else
{
if (format == 1) goto wrong;
int *p = &lumplist[*(unsigned char*)sc.String];
FTexture **p = &lumplist[*(unsigned char*)sc.String];
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;
}
@ -1740,7 +1745,7 @@ void V_InitCustomFonts()
{
for (i = 0; i < 256; i++)
{
if (lumplist[i] != -1)
if (lumplist[i] != NULL)
{
first = i;
break;
@ -1748,7 +1753,7 @@ void V_InitCustomFonts()
}
for (i = 255; i >= 0; i--)
{
if (lumplist[i] != -1)
if (lumplist[i] != NULL)
{
count = i - first + 1;
break;

View file

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

View file

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