- fix lump name setup.

This commit is contained in:
Christoph Oelckers 2023-08-22 19:11:08 +02:00
parent 54dc687436
commit 8e250abe0a
2 changed files with 17 additions and 18 deletions

View file

@ -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 = '\\';
}
}
}

View file

@ -608,7 +608,7 @@ int FIWadManager::IdentifyVersion (std::vector<std::string>&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.