- removed use of copystring in Dehacked code and cleaned up the list of includes in cmdlib.cpp

This commit is contained in:
Christoph Oelckers 2020-04-11 12:10:09 +02:00
parent 30577e8a50
commit 6bfdf904b9
2 changed files with 13 additions and 23 deletions

View file

@ -277,7 +277,8 @@ DehSpriteMappings[] =
#define CHECKKEY(a,b) if (!stricmp (Line1, (a))) (b) = atoi(Line2); #define CHECKKEY(a,b) if (!stricmp (Line1, (a))) (b) = atoi(Line2);
static char *PatchFile, *PatchPt, *PatchName; static char* PatchFile, * PatchPt;
FString PatchName;
static int PatchSize; static int PatchSize;
static char *Line1, *Line2; static char *Line1, *Line2;
static int dversion, pversion; static int dversion, pversion;
@ -2341,7 +2342,8 @@ static int DoInclude (int dummy)
{ {
char *data; char *data;
int savedversion, savepversion, savepatchsize; int savedversion, savepversion, savepatchsize;
char *savepatchfile, *savepatchpt, *savepatchname; char* savepatchfile, * savepatchpt;
FString savepatchname;
if (including) if (including)
{ {
@ -2490,7 +2492,7 @@ bool D_LoadDehLump(int lumpnum)
PatchSize = Wads.LumpLength(lumpnum); PatchSize = Wads.LumpLength(lumpnum);
PatchName = copystring(Wads.GetLumpFullPath(lumpnum)); PatchName = Wads.GetLumpFullPath(lumpnum);
PatchFile = new char[PatchSize + 1]; PatchFile = new char[PatchSize + 1];
Wads.ReadLump(lumpnum, PatchFile); Wads.ReadLump(lumpnum, PatchFile);
PatchFile[PatchSize] = '\0'; // terminate with a '\0' character PatchFile[PatchSize] = '\0'; // terminate with a '\0' character
@ -2508,7 +2510,7 @@ bool D_LoadDehFile(const char *patchfile)
{ {
PatchSize = (int)fr.GetLength(); PatchSize = (int)fr.GetLength();
PatchName = copystring(patchfile); PatchName = patchfile;
PatchFile = new char[PatchSize + 1]; PatchFile = new char[PatchSize + 1];
fr.Read(PatchFile, PatchSize); fr.Read(PatchFile, PatchSize);
fr.Close(); fr.Close();
@ -2538,7 +2540,7 @@ bool D_LoadDehFile(const char *patchfile)
static bool DoDehPatch() static bool DoDehPatch()
{ {
if (!batchrun) Printf("Adding dehacked patch %s\n", PatchName); if (!batchrun) Printf("Adding dehacked patch %s\n", PatchName.GetChars());
int cont; int cont;
@ -2548,8 +2550,8 @@ static bool DoDehPatch()
{ {
if (PatchFile[25] < '3' && (PatchFile[25] < '2' || PatchFile[27] < '3')) if (PatchFile[25] < '3' && (PatchFile[25] < '2' || PatchFile[27] < '3'))
{ {
Printf (PRINT_BOLD, "\"%s\" is an old and unsupported DeHackEd patch\n", PatchName); Printf (PRINT_BOLD, "\"%s\" is an old and unsupported DeHackEd patch\n", PatchName.GetChars());
delete[] PatchName; PatchName = "";
delete[] PatchFile; delete[] PatchFile;
return false; return false;
} }
@ -2567,8 +2569,8 @@ static bool DoDehPatch()
} }
if (!cont || dversion == -1 || pversion == -1) if (!cont || dversion == -1 || pversion == -1)
{ {
Printf (PRINT_BOLD, "\"%s\" is not a DeHackEd patch file\n", PatchName); Printf (PRINT_BOLD, "\"%s\" is not a DeHackEd patch file\n", PatchName.GetChars());
delete[] PatchName; PatchName = "";
delete[] PatchFile; delete[] PatchFile;
return false; return false;
} }
@ -2608,7 +2610,7 @@ static bool DoDehPatch()
{ {
Printf ("Could not load DEH support data\n"); Printf ("Could not load DEH support data\n");
UnloadDehSupp (); UnloadDehSupp ();
delete[] PatchName; PatchName = "";
delete[] PatchFile; delete[] PatchFile;
return false; return false;
} }
@ -2627,7 +2629,7 @@ static bool DoDehPatch()
} while (cont); } while (cont);
UnloadDehSupp (); UnloadDehSupp ();
delete[] PatchName; PatchName = "";
delete[] PatchFile; delete[] PatchFile;
if (!batchrun) Printf ("Patch installed\n"); if (!batchrun) Printf ("Patch installed\n");
return true; return true;

View file

@ -22,18 +22,6 @@
// cmdlib.c (mostly borrowed from the Q2 source) // cmdlib.c (mostly borrowed from the Q2 source)
#ifdef _WIN32
#include <direct.h>
#include <io.h>
#else
#include <dirent.h>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#if !defined(__sun)
#include <fts.h>
#endif
#endif
#include "cmdlib.h" #include "cmdlib.h"
#include "i_system.h" #include "i_system.h"