diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 6b572eb3b..0bf6c5c5e 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -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. diff --git a/src/g_level.cpp b/src/g_level.cpp index 7274e18f0..e2dc034b2 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -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; diff --git a/src/textures/automaptexture.cpp b/src/textures/automaptexture.cpp index 8155b1643..9a2b29df1 100644 --- a/src/textures/automaptexture.cpp +++ b/src/textures/automaptexture.cpp @@ -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]; diff --git a/src/textures/ddstexture.cpp b/src/textures/ddstexture.cpp index ec268b9e9..35ad52f01 100644 --- a/src/textures/ddstexture.cpp +++ b/src/textures/ddstexture.cpp @@ -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; diff --git a/src/textures/flattexture.cpp b/src/textures/flattexture.cpp index 2d3327078..400d3a02f 100644 --- a/src/textures/flattexture.cpp +++ b/src/textures/flattexture.cpp @@ -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) diff --git a/src/textures/imgztexture.cpp b/src/textures/imgztexture.cpp index f3ba48810..1d79e2595 100644 --- a/src/textures/imgztexture.cpp +++ b/src/textures/imgztexture.cpp @@ -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; diff --git a/src/textures/jpegtexture.cpp b/src/textures/jpegtexture.cpp index 674723b2e..7a45e6001 100644 --- a/src/textures/jpegtexture.cpp +++ b/src/textures/jpegtexture.cpp @@ -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; diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index 7de634583..570a1ebbc 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -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= 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, "./")) { diff --git a/src/textures/patchtexture.cpp b/src/textures/patchtexture.cpp index 4a8c93b8a..abb1b9b8d 100644 --- a/src/textures/patchtexture.cpp +++ b/src/textures/patchtexture.cpp @@ -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; diff --git a/src/textures/pcxtexture.cpp b/src/textures/pcxtexture.cpp index 85b43bf50..1a68d8996 100644 --- a/src/textures/pcxtexture.cpp +++ b/src/textures/pcxtexture.cpp @@ -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; diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index b1168fe57..e15f84f7d 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -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; diff --git a/src/textures/rawpagetexture.cpp b/src/textures/rawpagetexture.cpp index c4d3bb646..47fcd70ff 100644 --- a/src/textures/rawpagetexture.cpp +++ b/src/textures/rawpagetexture.cpp @@ -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; diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index aeafa6581..4cf9cba00 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -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 () diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index 44ccbe67f..c29223385 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -211,6 +211,30 @@ int FTextureManager::ListTextures (const char *name, TArray &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 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); } diff --git a/src/textures/textures.h b/src/textures/textures.h index fc3a8e786..7081e347f 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -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 &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); diff --git a/src/textures/tgatexture.cpp b/src/textures/tgatexture.cpp index 608f64188..e14f7fb3d 100644 --- a/src/textures/tgatexture.cpp +++ b/src/textures/tgatexture.cpp @@ -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; diff --git a/src/v_font.cpp b/src/v_font.cpp index 0c049b882..157b7b1e8 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -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; diff --git a/wadsrc/static/mapinfo/hexen.txt b/wadsrc/static/mapinfo/hexen.txt index a8a6806b0..25c35e4af 100644 --- a/wadsrc/static/mapinfo/hexen.txt +++ b/wadsrc/static/mapinfo/hexen.txt @@ -81,7 +81,7 @@ exittextislump music hub pic interpic -defaultmap +gamedefaults activateowndeathspecials infiniteflightpowerup fallingdamage diff --git a/wadsrc/static/mapinfo/strife.txt b/wadsrc/static/mapinfo/strife.txt index 91dcccc74..397727198 100644 --- a/wadsrc/static/mapinfo/strife.txt +++ b/wadsrc/static/mapinfo/strife.txt @@ -32,7 +32,7 @@ skill nightmare PicName "M_NMARE" Key b -defaultmap +gamedefaults forcenoskystretch strifefallingdamage nointermission