From c5b5b2b873fc2fac50f1482bca935c57bb28c411 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 19 Aug 2023 20:54:51 +0200 Subject: [PATCH] - cleanup. --- src/common/filesystem/file_wad.cpp | 2 +- src/common/filesystem/filesystem.cpp | 17 ++++++++--------- src/common/filesystem/filesystem.h | 13 ------------- src/common/models/models_iqm.cpp | 6 ------ 4 files changed, 9 insertions(+), 29 deletions(-) diff --git a/src/common/filesystem/file_wad.cpp b/src/common/filesystem/file_wad.cpp index beab514764..fb77a87810 100644 --- a/src/common/filesystem/file_wad.cpp +++ b/src/common/filesystem/file_wad.cpp @@ -197,7 +197,7 @@ bool FWadFile::Open(LumpFilterInfo*, FileSystemMessageFunc Printf) for(uint32_t i = 0; i < NumLumps; i++) { char n[9]; - uppercopy(n, fileinfo[i].Name); + for(int j = 0; j < 8; j++) n[j] = toupper(fileinfo[i].Name[j]); n[8] = 0; // This needs to be done differently. We cannot simply assume that all lumps where the first character's high bit is set are compressed without verification. // This requires explicit toggling for precisely the files that need it. diff --git a/src/common/filesystem/filesystem.cpp b/src/common/filesystem/filesystem.cpp index 796c319c91..f58fb51acf 100644 --- a/src/common/filesystem/filesystem.cpp +++ b/src/common/filesystem/filesystem.cpp @@ -43,9 +43,12 @@ #include "m_argv.h" #include "cmdlib.h" #include "filesystem.h" + #include "m_crc32.h" -#include "printf.h" + +#if __has_include("md5.h") #include "md5.h" +#endif // MACROS ------------------------------------------------------------------ @@ -352,7 +355,7 @@ void FileSystem::AddFile (const char *filename, FileReader *filer, LumpFilterInf if (resfile != NULL) { - if (!batchrun && Printf) + if (Printf) Printf(FSMessageLevel::Message, "adding %s, %d lumps\n", filename, resfile->LumpCount()); uint32_t lumpstart = FileInfo.Size(); @@ -379,6 +382,7 @@ void FileSystem::AddFile (const char *filename, FileReader *filer, LumpFilterInf } } +#if __has_include("md5.h") if (hashfile) { uint8_t cksum[16]; @@ -423,6 +427,7 @@ void FileSystem::AddFile (const char *filename, FileReader *filer, LumpFilterInf } } } +#endif return; } } @@ -895,12 +900,6 @@ LumpShortName& FileSystem::GetShortName(int i) return FileInfo[i].shortName; } -FString& FileSystem::GetLongName(int i) -{ - if ((unsigned)i >= NumEntries) throw FileSystemException("GetLongName: Invalid index"); - return FileInfo[i].longName; -} - void FileSystem::RenameFile(int num, const char* newfn) { if ((unsigned)num >= NumEntries) throw FileSystemException("RenameFile: Invalid index"); @@ -1311,7 +1310,7 @@ void FileSystem::ReadFile (int lump, void *dest) if (numread != size) { throw FileSystemException("W_ReadFile: only read %ld of %ld on '%s'\n", - numread, size, GetLongName(lump).GetChars()); + numread, size, FileInfo[lump].longName.GetChars()); } } diff --git a/src/common/filesystem/filesystem.h b/src/common/filesystem/filesystem.h index febb769114..0eb06b2fb7 100644 --- a/src/common/filesystem/filesystem.h +++ b/src/common/filesystem/filesystem.h @@ -11,7 +11,6 @@ #include "files.h" #include "tarray.h" #include "cmdlib.h" -#include "zstring.h" #include "resourcefile.h" class FResourceFile; @@ -85,10 +84,8 @@ public: inline int CheckNumForName (const uint8_t *name) { return CheckNumForName ((const char *)name, ns_global); } inline int CheckNumForName (const char *name) { return CheckNumForName (name, ns_global); } - inline int CheckNumForName (const FString &name) { return CheckNumForName (name.GetChars()); } inline int CheckNumForName (const uint8_t *name, int ns) { return CheckNumForName ((const char *)name, ns); } inline int GetNumForName (const char *name) { return GetNumForName (name, ns_global); } - inline int GetNumForName (const FString &name) { return GetNumForName (name.GetChars(), ns_global); } inline int GetNumForName (const uint8_t *name) { return GetNumForName ((const char *)name); } inline int GetNumForName (const uint8_t *name, int ns) { return GetNumForName ((const char *)name, ns); } @@ -105,25 +102,15 @@ public: return FindFile(name) >= 0; } - bool FileExists(const FString& name) - { - return FindFile(name) >= 0; - } - bool FileExists(const std::string& name) { return FindFile(name.c_str()) >= 0; } LumpShortName& GetShortName(int i); // may only be called before the hash chains are set up. - FString& GetLongName(int i); // may only be called before the hash chains are set up. void RenameFile(int num, const char* fn); bool CreatePathlessCopy(const char* name, int id, int flags); - inline int CheckNumForFullName(const FString &name, bool trynormal = false, int namespc = ns_global) { return CheckNumForFullName(name.GetChars(), trynormal, namespc); } - inline int CheckNumForFullName (const FString &name, int wadfile) { return CheckNumForFullName(name.GetChars(), wadfile); } - inline int GetNumForFullName (const FString &name) { return GetNumForFullName(name.GetChars()); } - void ReadFile (int lump, void *dest); // These should only be used if the file data really needs padding. FileData ReadFile (int lump); diff --git a/src/common/models/models_iqm.cpp b/src/common/models/models_iqm.cpp index a2d72b11ab..143c4334ad 100644 --- a/src/common/models/models_iqm.cpp +++ b/src/common/models/models_iqm.cpp @@ -63,12 +63,6 @@ bool IQMModel::Load(const char* path, int lumpnum, const char* buffer, int lengt uint32_t num_extensions = reader.ReadUInt32(); uint32_t ofs_extensions = reader.ReadUInt32(); - /*if (num_joints <= 0) - { - Printf("Invalid model: \"%s%s\", no joint data is present\n", path, fileSystem.GetLongName(mLumpNum).GetChars()); - return false; - }*/ - if (num_text == 0) return false;