From 851bf89442d95ff6f7cc4f7f0590d761b1f9e0b5 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 29 Dec 2006 03:38:37 +0000 Subject: [PATCH] - Fixed all the warnings from GCC 4.2, including a handful that were present in older GCCs. SVN r430 (trunk) --- docs/rh-log.txt | 4 +++- src/am_map.cpp | 2 +- src/c_cmds.cpp | 2 +- src/c_console.cpp | 5 +++-- src/cmdlib.cpp | 2 +- src/cmdlib.h | 2 +- src/d_dehacked.cpp | 4 ++-- src/d_main.cpp | 9 +++++---- src/d_main.h | 2 +- src/f_finale.cpp | 2 +- src/g_game.cpp | 11 ++++++----- src/g_level.cpp | 26 ++++++++++++++++++++++---- src/g_level.h | 4 ++-- src/gi.cpp | 4 ++-- src/gi.h | 2 +- src/m_cheat.cpp | 2 +- src/m_cheat.h | 2 +- src/m_menu.cpp | 2 +- src/m_menu.h | 6 +++--- src/m_options.cpp | 36 ++++++++++-------------------------- src/nodebuild_extract.cpp | 6 ++++-- src/nodebuild_gl.cpp | 6 +++++- src/nodebuild_utility.cpp | 6 +++++- src/p_setup.cpp | 4 ++-- src/p_writemap.cpp | 2 +- src/r_main.cpp | 2 +- src/r_plane.cpp | 4 ++-- src/r_polymost.cpp | 6 +++--- src/sc_man.cpp | 1 - src/sc_man.h | 1 - src/tarray.h | 6 +++--- src/thingdef_codeptr.cpp | 2 +- src/w_wad.cpp | 18 +++++++++++------- 33 files changed, 106 insertions(+), 87 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 57914167c..a3aee8d12 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,6 @@ -December 28, 2006 +December 28, 2006 +- Fixed all the warnings from GCC 4.2, including a handful that were present in + older GCCs. - Fixed: The VC++ project was not set up to redefine RM using del in wadsrc/Makefile, nor did it use the makefile for cleaning. - Added ST_NetMessage() for mixing miscellaneous messages with the network diff --git a/src/am_map.cpp b/src/am_map.cpp index e0f9af5cc..852a3763d 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1135,7 +1135,7 @@ bool AM_clipMline (mline_t *ml, fline_t *fl) register int outcode2 = 0; register int outside; - fpoint_t tmp; + fpoint_t tmp = { 0, 0 }; int dx; int dy; diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index cd02d8b6a..460519dff 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -403,7 +403,7 @@ CCMD (exec) CCMD (logfile) { - char *timestr = myasctime (); + const char *timestr = myasctime (); if (Logfile) { diff --git a/src/c_console.cpp b/src/c_console.cpp index cecc0cc7d..e64c73bc8 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -698,8 +698,9 @@ void AddToConsole (int printlevel, const char *text) worklen = size; } if (work == NULL) - { - work = TEXTCOLOR_RED "*** OUT OF MEMORY ***"; + { + static char oom[] = TEXTCOLOR_RED "*** OUT OF MEMORY ***"; + work = oom; worklen = 0; } else diff --git a/src/cmdlib.cpp b/src/cmdlib.cpp index 9e64353b0..1b32884c3 100644 --- a/src/cmdlib.cpp +++ b/src/cmdlib.cpp @@ -326,7 +326,7 @@ void FormatGUID (char *text, const GUID &guid) } // [RH] Returns the current local time as ASCII, even if it's too early -char *myasctime () +const char *myasctime () { time_t clock; struct tm *lt; diff --git a/src/cmdlib.h b/src/cmdlib.h index 6c65b0610..c6222f92c 100644 --- a/src/cmdlib.h +++ b/src/cmdlib.h @@ -49,7 +49,7 @@ bool CheckWildcards (const char *pattern, const char *text); void FormatGUID (char *text, const GUID &guid); -char *myasctime (); +const char *myasctime (); void strbin (char *str); diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 07a5f5757..622c2253c 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -339,7 +339,7 @@ static BitName *BitNames; static int NumBitNames; struct Key { - char *name; + const char *name; ptrdiff_t offset; }; @@ -359,7 +359,7 @@ static int PatchCodePtrs (int); static int DoInclude (int); static const struct { - char *name; + const char *name; int (*func)(int); } Modes[] = { // These appear in .deh and .bex files diff --git a/src/d_main.cpp b/src/d_main.cpp index c0fe147e6..0ce931ffa 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -159,8 +159,8 @@ CVAR (Int, wipetype, 1, CVAR_ARCHIVE); bool DrawFSHUD; // [RH] Draw fullscreen HUD? wadlist_t *wadfiles; // [RH] remove limit on # of loaded wads bool devparm; // started game with -devparm -char *D_DrawIcon; // [RH] Patch name of icon to draw on next refresh -int NoWipe; // [RH] Allow wipe? (Needs to be set each time) +const char *D_DrawIcon; // [RH] Patch name of icon to draw on next refresh +int NoWipe; // [RH] Allow wipe? (Needs to be set each time) bool singletics = false; // debug flag to cancel adaptiveness char startmap[8]; bool autostart; @@ -2273,11 +2273,12 @@ void D_DoomMain (void) // turbo option // [RH] (now a cvar) { - UCVarValue value; + UCVarValue value; + static char one_hundred[] = "100"; value.String = Args.CheckValue ("-turbo"); if (value.String == NULL) - value.String = "100"; + value.String = one_hundred; else Printf ("turbo scale: %s%%\n", value.String); diff --git a/src/d_main.h b/src/d_main.h index 98b333571..398d0d733 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -52,7 +52,7 @@ void D_StartTitle (void); // [RH] Set this to something to draw an icon during the next screen refresh. -extern char *D_DrawIcon; +extern const char *D_DrawIcon; enum EIWADType diff --git a/src/f_finale.cpp b/src/f_finale.cpp index 60b128ad0..eefd7bcf9 100644 --- a/src/f_finale.cpp +++ b/src/f_finale.cpp @@ -69,7 +69,7 @@ static bool FinaleHasPic; static FString FinaleText; static size_t FinaleTextLen; -static char *FinaleFlat; +static const char *FinaleFlat; void F_StartCast (void); void F_CastTicker (void); diff --git a/src/g_game.cpp b/src/g_game.cpp index b9bf6d01b..7b094bc56 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -418,7 +418,7 @@ CCMD (useflechette) for (j = 0; j < 3; ++j) { AInventory *item; - if (item = who->FindInventory (bagnames[(i+j)%3])) + if ( (item = who->FindInventory (bagnames[(i+j)%3])) ) { SendItemUse = item; break; @@ -843,9 +843,10 @@ void G_Ticker () } if (ToggleFullscreen) - { + { + static char toggle_fullscreen[] = "toggle fullscreen"; ToggleFullscreen = false; - AddCommandString ("toggle fullscreen"); + AddCommandString (toggle_fullscreen); } // do things to change the game state @@ -1805,7 +1806,7 @@ void G_DoAutoSave () { // Keep up to four autosaves at a time UCVarValue num; - char *readableTime; + const char *readableTime; int count = autosavecount != 0 ? autosavecount : 1; num.Int = (autosavenum + 1) % count; @@ -1841,7 +1842,7 @@ static void PutSaveWads (FILE *file) static void PutSaveComment (FILE *file) { char comment[256]; - char *readableTime; + const char *readableTime; WORD len; int levelTime; diff --git a/src/g_level.cpp b/src/g_level.cpp index b4c3b6f3f..c7254c608 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -137,8 +137,26 @@ TArray wadlevelinfos; // MAPINFO is parsed slightly differently when the map name is just a number. static bool HexenHack; - -static level_info_t TheDefaultLevelInfo = { "", 0, "", "", "", "SKY1", 0, 0, 0, 0, NULL, "Unnamed", "COLORMAP", +8, -8 }; + +static char unnamed[] = "Unnamed"; +static level_info_t TheDefaultLevelInfo = +{ + "", // mapname + 0, // levelnum + "", // pname, + "", // nextmap + "", // secretmap + "SKY1", // skypic1 + 0, // cluster + 0, // partime + 0, // sucktime + 0, // flags + NULL, // music + unnamed, // level_name + "COLORMAP", // fadetable + +8, // WallVertLight + -8 // WallHorizLight +}; static cluster_info_t TheDefaultClusterInfo = { 0 }; @@ -1316,7 +1334,7 @@ bool CheckWarpTransMap (char mapname[9], bool substitute) // static char d_mapname[256]; -void G_DeferedInitNew (char *mapname) +void G_DeferedInitNew (const char *mapname) { strncpy (d_mapname, mapname, 8); CheckWarpTransMap (d_mapname, true); @@ -1414,7 +1432,7 @@ void G_DoNewGame (void) gameaction = ga_nothing; } -void G_InitNew (char *mapname, bool bTitleLevel) +void G_InitNew (const char *mapname, bool bTitleLevel) { EGameSpeed oldSpeed; bool wantFast; diff --git a/src/g_level.h b/src/g_level.h index 9c1281c86..18ee94254 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -291,12 +291,12 @@ extern bool savegamerestore; // mapname will be changed if it is a valid warptrans bool CheckWarpTransMap (char mapname[9], bool substitute); -void G_InitNew (char *mapname, bool bTitleLevel); +void G_InitNew (const char *mapname, bool bTitleLevel); // Can be called by the startup code or M_Responder. // A normal game starts at map 1, // but a warp test can start elsewhere -void G_DeferedInitNew (char *mapname); +void G_DeferedInitNew (const char *mapname); void G_ExitLevel (int position, bool keepFacing); void G_SecretExitLevel (int position); diff --git a/src/gi.cpp b/src/gi.cpp index 9962effda..b3e666c64 100644 --- a/src/gi.cpp +++ b/src/gi.cpp @@ -44,7 +44,7 @@ const char *GameNames[9] = NULL, "Doom", "Heretic", NULL, "Hexen", NULL, NULL, NULL, "Strife" }; -static char *quitsounds[8] = +static const char *quitsounds[8] = { "player/male/death1", "demon/pain", @@ -56,7 +56,7 @@ static char *quitsounds[8] = "demon/melee" }; -static char *quitsounds2[8] = +static const char *quitsounds2[8] = { "vile/active", "misc/p_pkup", diff --git a/src/gi.h b/src/gi.h index 084edfa6c..4120b45b8 100644 --- a/src/gi.h +++ b/src/gi.h @@ -104,7 +104,7 @@ typedef struct char numPages; } indexed; } info; - char **quitSounds; + const char **quitSounds; int maxSwitch; char borderFlat[9]; gameborder_t *border; diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index 92f04f62f..2c771414b 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -469,7 +469,7 @@ void GiveSpawner (player_t *player, const PClass *type, int amount) } } -void cht_Give (player_t *player, char *name, int amount) +void cht_Give (player_t *player, const char *name, int amount) { bool giveall; int i; diff --git a/src/m_cheat.h b/src/m_cheat.h index 86b9d5e70..0ca1f3e3e 100644 --- a/src/m_cheat.h +++ b/src/m_cheat.h @@ -31,7 +31,7 @@ class player_s; struct PClass; void cht_DoCheat (player_s *player, int cheat); -void cht_Give (player_s *player, char *item, int amount=1); +void cht_Give (player_s *player, const char *item, int amount=1); void cht_Suicide (player_s *player); const char *cht_Morph (player_s *player, const PClass *morphclass, bool quickundo); diff --git a/src/m_menu.cpp b/src/m_menu.cpp index 08b78474f..e56a20bd1 100644 --- a/src/m_menu.cpp +++ b/src/m_menu.cpp @@ -222,7 +222,7 @@ static oldmenu_t *TopLevelMenu; // The main menu everything hangs off of static DCanvas *FireScreen; static BYTE FireRemap[256]; -static char *genders[3] = { "male", "female", "other" }; +static const char *genders[3] = { "male", "female", "other" }; static FPlayerClass *PlayerClass; static int PlayerSkin; static FState *PlayerState; diff --git a/src/m_menu.h b/src/m_menu.h index ae7ef906b..a90a5b67f 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -116,7 +116,7 @@ struct GUIDName; typedef struct menuitem_s { itemtype type; - char *label; + const char *label; union { FBaseCVar *cvar; FIntCVar *intcvar; @@ -156,7 +156,7 @@ typedef struct menuitem_s { } menuitem_t; typedef struct menu_s { - char *texttitle; + const char *texttitle; int lastOn; int numitems; int indent; @@ -171,7 +171,7 @@ typedef struct menu_s { typedef struct value_s { float value; - char *name; + const char *name; } value_t; typedef struct diff --git a/src/m_options.cpp b/src/m_options.cpp index 13505d4f6..307b50fd6 100644 --- a/src/m_options.cpp +++ b/src/m_options.cpp @@ -133,7 +133,7 @@ value_t OnOff[2] = { menu_t *CurrentMenu; int CurrentItem; -static char *OldMessage; +static const char *OldMessage; static itemtype OldType; int flagsvar; @@ -149,7 +149,7 @@ enum * Confirm Menu - Used by safemore * *=======================================*/ -static void ActivateConfirm (char *text, void (*func)()); +static void ActivateConfirm (const char *text, void (*func)()); static void ConfirmIsAGo (); static menuitem_t ConfirmItems[] = { @@ -678,7 +678,7 @@ menu_t MapColorsMenu = * Color Picker Sub-menu * *=======================================*/ -static void StartColorPickerMenu (char *colorname, FColorCVar *cvar); +static void StartColorPickerMenu (const char *colorname, FColorCVar *cvar); static void ColorPickerReset (); static int CurrColorIndex; static int SelColorIndex; @@ -1173,24 +1173,7 @@ static menu_t AdvSoundMenu = AdvSoundItems, }; -void M_FreeValues (value_t **values, int num) -{ - int i; - - if (*values) - { - for (i = 0; i < num; i++) - { - if ((*values)[i].name) - free ((*values)[i].name); - } - - free (*values); - *values = NULL; - } -} - -static void ActivateConfirm (char *text, void (*func)()) +static void ActivateConfirm (const char *text, void (*func)()) { ConfirmItems[0].label = text; ConfirmItems[0].e.mfunc = func; @@ -1688,7 +1671,7 @@ void M_OptDrawer () case bitflag: { value_t *value; - char *str; + const char *str; if (item->b.min) value = NoYes; @@ -2551,7 +2534,7 @@ static void ActivateColorChoice () ColorPickerItems[0].a.colorcvar->SetGenericRep (val, CVAR_Int); } -static void StartColorPickerMenu (char *colorname, FColorCVar *cvar) +static void StartColorPickerMenu (const char *colorname, FColorCVar *cvar) { ColorPickerMenu.PreDraw = ColorPickerDrawer; ColorPickerMenu.EscapeHandler = ActivateColorChoice; @@ -2778,8 +2761,9 @@ CCMD (menu_mididevice) #endif static void MakeSoundChanges (void) -{ - AddCommandString ("snd_reset"); +{ + static char snd_reset[] = "snd_reset"; + AddCommandString (snd_reset); } static void VideoOptions (void) @@ -2932,7 +2916,7 @@ static void SetModesMenu (int w, int h, int bits) if (testingmode <= 1) { if (ModesItems[VM_ENTERLINE].label != VMEnterText) - free (ModesItems[VM_ENTERLINE].label); + free (const_cast(ModesItems[VM_ENTERLINE].label)); ModesItems[VM_ENTERLINE].label = VMEnterText; ModesItems[VM_TESTLINE].label = VMTestText; } diff --git a/src/nodebuild_extract.cpp b/src/nodebuild_extract.cpp index df15b6593..86d43a623 100644 --- a/src/nodebuild_extract.cpp +++ b/src/nodebuild_extract.cpp @@ -351,7 +351,8 @@ DWORD FNodeBuilder::PushGLSeg (TArray &segs, const FPrivSeg *seg, vertex_ newseg.sidedef = NULL; } newseg.PartnerSeg = (seg_t *)(seg->partner == DWORD_MAX ? 0 : (size_t)seg->partner + 1); - newseg.bPolySeg = false; + newseg.bPolySeg = false; + newseg.Subsector = NULL; return (DWORD)segs.Push (newseg); } @@ -366,6 +367,7 @@ void FNodeBuilder::PushConnectingGLSeg (int subsector, TArray &segs, vert newseg.linedef = NULL; newseg.sidedef = NULL; newseg.PartnerSeg = NULL; - newseg.bPolySeg = false; + newseg.bPolySeg = false; + newseg.Subsector = NULL; segs.Push (newseg); } diff --git a/src/nodebuild_gl.cpp b/src/nodebuild_gl.cpp index b40a05b70..501ecdf16 100644 --- a/src/nodebuild_gl.cpp +++ b/src/nodebuild_gl.cpp @@ -231,7 +231,11 @@ DWORD FNodeBuilder::AddMiniseg (int v1, int v2, DWORD partner, DWORD seg1, DWORD newseg.linedef = -1; newseg.loopnum = 0; newseg.next = DWORD_MAX; - newseg.planefront = true; + newseg.planefront = true; + newseg.hashnext = NULL; + newseg.storedseg = NULL; + newseg.frontsector = NULL; + newseg.backsector = NULL; if (splitseg != DWORD_MAX) { diff --git a/src/nodebuild_utility.cpp b/src/nodebuild_utility.cpp index 9dd8a1f73..297feb60a 100644 --- a/src/nodebuild_utility.cpp +++ b/src/nodebuild_utility.cpp @@ -148,7 +148,11 @@ int FNodeBuilder::CreateSeg (int linenum, int sidenum) seg.next = DWORD_MAX; seg.loopnum = 0; - seg.partner = DWORD_MAX; + seg.partner = DWORD_MAX; + seg.hashnext = NULL; + seg.planefront = DWORD_MAX; + seg.planenum = DWORD_MAX; + seg.storedseg = DWORD_MAX; if (sidenum == 0) { // front diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 540cd64c6..b6ec9c309 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -188,7 +188,7 @@ static void P_SetSideNum (DWORD *sidenum_p, WORD sidenum); struct checkstruct { - char *lumpname; + const char lumpname[9]; bool required; }; @@ -196,7 +196,7 @@ static int GetMapIndex(const char *mapname, int lastindex, const char *lumpname, { static const checkstruct check[] = { - {NULL, true}, + {"", true}, {"THINGS", true}, {"LINEDEFS", true}, {"SIDEDEFS", true}, diff --git a/src/p_writemap.cpp b/src/p_writemap.cpp index b05066cd2..78a4d230a 100644 --- a/src/p_writemap.cpp +++ b/src/p_writemap.cpp @@ -24,7 +24,7 @@ static int WriteBEHAVIOR (FILE *file); CCMD (dumpmap) { - char *mapname; + const char *mapname; FILE *file; if (argv.argc() < 2) diff --git a/src/r_main.cpp b/src/r_main.cpp index 770e3b729..94945e024 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -934,7 +934,7 @@ static InterpolationViewer *FindPastViewer (AActor *actor) } // Not found, so make a new one - InterpolationViewer iview; + InterpolationViewer iview = { 0 }; iview.ViewActor = actor; iview.otic = -1; return &PastViewers[PastViewers.Push (iview)]; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 844834d2d..8f850b365 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1045,7 +1045,7 @@ void R_DrawSkyBoxes () if (visplanes[MAXVISPLANES] == NULL) return; - VisplaneAndAlpha vaAdder; + VisplaneAndAlpha vaAdder = { 0 }; int savedextralight = extralight; fixed_t savedx = viewx; fixed_t savedy = viewy; @@ -1175,7 +1175,7 @@ void R_DrawSkyBoxes () // sake of nested skyboxes. while (interestingStack.Pop (FirstInterestingDrawseg)) { - ptrdiff_t pd; + ptrdiff_t pd = 0; drawsegStack.Pop (pd); firstdrawseg = drawsegs + pd; diff --git a/src/r_polymost.cpp b/src/r_polymost.cpp index e4954bc7f..082ea7661 100644 --- a/src/r_polymost.cpp +++ b/src/r_polymost.cpp @@ -327,7 +327,7 @@ int PolyClipper::DoMost (float x0, float y0, float x1, float y1, pmostcallbackty double dx, d, n, t; float spx[4], spy[4], cy[2], cv[2]; int j, k, z, scnt, dir, spt[4]; - vsptype *vsp, *nvsp, *vcnt, *ni; + vsptype *vsp, *nvsp, *vcnt = NULL, *ni; int did = 1; if (x0 < x1) @@ -670,7 +670,7 @@ void printnum(int x, int y, int num) void drawpolymosttest() { - float cx0, cy0, fx0, fy0; + float cx0 = 0, cy0 = 0, fx0 = 0, fy0 = 0; int ccol, fcol; PolyClipper::vsptype *vsp, *ovsp = &TestPoly.UsedList, *nvsp; @@ -1035,7 +1035,7 @@ void RP_AddLine (seg_t *line) fixed_t tx1, tx2, ty1, ty2; fixed_t fcz0, ffz0, fcz1, ffz1, bcz0, bfz0, bcz1, bfz1; double x0, x1, xp0, yp0, xp1, yp1, oxp0, oyp0, nx0, ny0, nx1, ny1, ryp0, ryp1; - double cy0, fy0, cy1, fy1, ocy0, ofy0, ocy1, ofy1; + double cy0, fy0, cy1, fy1, ocy0 = 0, ofy0 = 0, ocy1 = 0, ofy1 = 0; double t0, t1; double x, y; diff --git a/src/sc_man.cpp b/src/sc_man.cpp index 8e8bfa0a3..10f6852cf 100644 --- a/src/sc_man.cpp +++ b/src/sc_man.cpp @@ -62,7 +62,6 @@ int sc_Line; bool sc_End; bool sc_Crossed; bool sc_FileScripts = false; -char *sc_ScriptsDir = ""; // PRIVATE DATA DEFINITIONS ------------------------------------------------ diff --git a/src/sc_man.h b/src/sc_man.h index 4d8fc10b2..e1e293851 100644 --- a/src/sc_man.h +++ b/src/sc_man.h @@ -156,6 +156,5 @@ extern int sc_Line; extern bool sc_End; extern bool sc_Crossed; extern bool sc_FileScripts; -extern char *sc_ScriptsDir; #endif //__SC_MAN_H__ diff --git a/src/tarray.h b/src/tarray.h index 3037cf78d..45d96ca2b 100644 --- a/src/tarray.h +++ b/src/tarray.h @@ -122,9 +122,9 @@ public: item = Array[--Count]; Array[Count].~T(); return true; - } - return false; - } + } + return false; + } void Delete (unsigned int index) { if (index < Count) diff --git a/src/thingdef_codeptr.cpp b/src/thingdef_codeptr.cpp index 546f1d8ca..927d37ac7 100644 --- a/src/thingdef_codeptr.cpp +++ b/src/thingdef_codeptr.cpp @@ -400,7 +400,7 @@ static void DoJump(AActor * self, FState * CallingState, int offset) jumpto = cls->ActorInfo->FindState(numnames, &JumpParameters[offset+2]); if (jumpto == NULL) { - char * dot=""; + const char *dot=""; Printf("Jump target '"); if (classname != NAME_None) Printf("%s::", classname.GetChars()); for (int i=0;iflags & LUMPF_EXTERNAL) { - FILE * f; + static char zero = '\0'; + FILE *f; + if (wad != NULL) // The WadRecord in this case is just a means to store a path { FString name; @@ -1731,7 +1733,7 @@ FWadLump FWadCollection::OpenLumpNum (int lump) // the complete contents into a memory buffer first if (f != NULL) { - char * buffer = new char[l->size+1]; // the last byte is used as a reference counter + char *buffer = new char[l->size+1]; // the last byte is used as a reference counter buffer[l->size] = 0; fread(buffer, 1, l->size, f); fclose(f); @@ -1739,7 +1741,7 @@ FWadLump FWadCollection::OpenLumpNum (int lump) } // The file got deleted or worse. At least return something. Printf("%s: Unable to open file\n", l->fullname); - return FWadLump("", 1, false); + return FWadLump(&zero, 1, false); } else if (wad->MemoryData != NULL) { @@ -1796,8 +1798,10 @@ FWadLump *FWadCollection::ReopenLumpNum (int lump) return new FWadLump(buffer, l->size, true); //... but restore the file pointer afterward! } else if (l->flags & LUMPF_EXTERNAL) - { - FILE * f; + { + static char zero = '\0'; + FILE *f; + if (wad != NULL) // The WadRecord in this case is just a means to store a path { FString name; @@ -1813,7 +1817,7 @@ FWadLump *FWadCollection::ReopenLumpNum (int lump) // the complete contents into a memory buffer first if (f != NULL) { - char * buffer = new char[l->size+1]; // the last byte is used as a reference counter + char *buffer = new char[l->size+1]; // the last byte is used as a reference counter buffer[l->size] = 0; fread(buffer, 1, l->size, f); fclose(f); @@ -1821,7 +1825,7 @@ FWadLump *FWadCollection::ReopenLumpNum (int lump) } // The file got deleted or worse. At least return something. Printf("%s: Unable to open file\n", l->fullname); - return new FWadLump("", 1, false); + return new FWadLump(&zero, 1, false); } else if (wad->MemoryData!=NULL) {