diff --git a/docs/rh-log.txt b/docs/rh-log.txt index ce238f6f86..287da55532 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,9 @@ +January 27, 2007 +- Fixed: Since FMemLump is now implemented on top of FString, it never + contains a NULL point, so the GetMem() method should fake it by + returning NULL when the string is empty. Reverted p_xlat.cpp to its + old revision. + January 26, 2007 (Changes by Graf Zahl) - Fixed: The rewrite of FMemLump broke the non-standard use of it in P_TranslateLinedefs. diff --git a/src/p_xlat.cpp b/src/p_xlat.cpp index 2cf2e1eb0f..f9d81d945e 100644 --- a/src/p_xlat.cpp +++ b/src/p_xlat.cpp @@ -48,7 +48,6 @@ #include "w_wad.h" #include "sc_man.h" #include "cmdlib.h" -#include "i_system.h" // define names for the TriggerType field of the general linedefs @@ -64,17 +63,10 @@ typedef enum PushMany, } triggertype_e; - -BYTE *tlatetab; - -static void Freetlate() -{ - if (tlatetab != NULL) delete [] tlatetab; - tlatetab = NULL; -} - void P_TranslateLineDef (line_t *ld, maplinedef_t *mld) { + static FMemLump tlatebase; + const BYTE *tlate; short special = LittleShort(mld->special); short tag = LittleShort(mld->tag); DWORD flags = LittleShort(mld->flags); @@ -129,31 +121,23 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld) return; } - if (tlatetab == NULL) + // The translation lump is cached across calls to P_TranslateLineDef. + if (tlatebase.GetMem() == NULL) { - const char *lumpname; - int lumpnum, lumplen; if (gameinfo.gametype == GAME_Doom) { - lumpname = "DOOMX"; + tlatebase = Wads.ReadLump ("DOOMX"); } else if (gameinfo.gametype == GAME_Strife) { - lumpname = "STRIFEX"; + tlatebase = Wads.ReadLump ("STRIFEX"); } else { - lumpname = "HERETICX"; + tlatebase = Wads.ReadLump ("HERETICX"); } - - lumpnum = Wads.GetNumForName (lumpname); - lumplen = Wads.LumpLength(lumpnum); - - tlatetab = new BYTE[lumplen]; - Wads.ReadLump(lumpnum, tlatetab); - atterm(Freetlate); } - BYTE *tlate = tlatetab; + tlate = (const BYTE *)tlatebase.GetMem(); // Check if this is a regular linetype if (tlate[0] == 'N' && tlate[1] == 'O' && tlate[2] == 'R' && tlate[3] == 'M') diff --git a/src/w_wad.h b/src/w_wad.h index f92ddba90e..29177e9fb8 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -132,7 +132,8 @@ public: FMemLump (const FMemLump ©); FMemLump &operator= (const FMemLump ©); ~FMemLump (); - void *GetMem () { return (void *)Block.GetChars(); } + void *GetMem () { return Block.Len() == 0 ? NULL : (void *)Block.GetChars(); } + unsigned int GetSize () { return Block.Len(); } private: FMemLump (const FString &source);