From 8e250abe0adb0b04868633f9366b4e7811c8e090 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 22 Aug 2023 19:11:08 +0200 Subject: [PATCH] - fix lump name setup. --- src/common/filesystem/filesystem.cpp | 33 ++++++++++++++-------------- src/d_iwad.cpp | 2 +- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/common/filesystem/filesystem.cpp b/src/common/filesystem/filesystem.cpp index 39a730b7d2..f7150b28e4 100644 --- a/src/common/filesystem/filesystem.cpp +++ b/src/common/filesystem/filesystem.cpp @@ -148,7 +148,7 @@ struct FileSystem::LumpRecord { const char* p = LongName + encodedResID; char* q; - int id = (int)strtoull(p+2, &q, 10); // only decimal numbers allowed here. + int id = (int)strtoull(p + 2, &q, 10); // only decimal numbers allowed here. if (q[0] == '}' && (q[1] == '.' || q[1] == 0)) { longName.erase(longName.begin() + encodedResID, longName.begin() + (q - p) + 1); @@ -156,24 +156,23 @@ struct FileSystem::LumpRecord } LongName = sp->Strdup(longName.c_str()); } - ptrdiff_t slash = longName.find_last_of('/'); - std::string base = (slash != std::string::npos) ? LongName + (slash + 1) : LongName; - auto dot = base.find_last_of('.'); - if (dot != std::string::npos) base.resize(dot); - UpperCopy(shortName.String, base.c_str()); - shortName.String[8] = 0; + } + auto slash = strrchr(LongName, '/'); + std::string base = slash ? (slash + 1) : LongName; + auto dot = base.find_last_of('.'); + if (dot != std::string::npos) base.resize(dot); + UpperCopy(shortName.String, base.c_str()); - // Since '\' can't be used as a file name's part inside a ZIP - // we have to work around this for sprites because it is a valid - // frame character. - if (Namespace == ns_sprites || Namespace == ns_voxels || Namespace == ns_hires) + // Since '\' can't be used as a file name's part inside a ZIP + // we have to work around this for sprites because it is a valid + // frame character. + if (Namespace == ns_sprites || Namespace == ns_voxels || Namespace == ns_hires) + { + char* c; + + while ((c = (char*)memchr(shortName.String, '^', 8))) { - char* c; - - while ((c = (char*)memchr(shortName.String, '^', 8))) - { - *c = '\\'; - } + *c = '\\'; } } } diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index cf46eec13a..88cc0032e7 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -608,7 +608,7 @@ int FIWadManager::IdentifyVersion (std::vector&wadfiles, const char // Check for symbolic links leading to non-existent files and for files that are unreadable. for (unsigned int i = 0; i < mFoundWads.Size(); i++) { - if (!FileExists(mFoundWads[i].mFullPath) || !FileReadable(mFoundWads[i].mFullPath)) mFoundWads.Delete(i); + if (!FileExists(mFoundWads[i].mFullPath) || !FileReadable(mFoundWads[i].mFullPath)) mFoundWads.Delete(i--); } // Now check if what got collected actually is an IWAD.