Skip to content

Commit

Permalink
- fixed: FileSystem.CreatePathlessCopy must set the copy to not have …
Browse files Browse the repository at this point in the history
…a full path.

Otherwise it may evade special lookup rules for music and not be found
  • Loading branch information
coelckers committed Apr 20, 2021
1 parent 9e40e49 commit 588fa5f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions source/common/filesystem/filesystem.cpp
Expand Up @@ -63,12 +63,14 @@ struct FileSystem::LumpRecord
int rfnum;
int Namespace;
int resourceId;
int flags;

void SetFromLump(int filenum, FResourceLump* lmp)
{
lump = lmp;
rfnum = filenum;
linkedTexture = nullptr;
flags = 0;

if (lump->Flags & LUMPF_SHORTNAME)
{
Expand Down Expand Up @@ -487,7 +489,7 @@ int FileSystem::CheckNumForName (const char *name, int space)
// from a Zip return that. WADs don't know these namespaces and single lumps must
// work as well.
if (space > ns_specialzipdirectory && lump.Namespace == ns_global &&
!(lump.lump->Flags & LUMPF_FULLPATH)) break;
!((lump.lump->Flags ^lump.flags) & LUMPF_FULLPATH)) break;
}
i = NextLumpIndex[i];
}
Expand Down Expand Up @@ -796,7 +798,7 @@ int FileSystem::GetFileFlags (int lump)
return 0;
}

return FileInfo[lump].lump->Flags;
return FileInfo[lump].lump->Flags ^ FileInfo[lump].flags;
}

//==========================================================================
Expand Down Expand Up @@ -1532,11 +1534,19 @@ bool FileSystem::CreatePathlessCopy(const char *name, int id, int /*flags*/)

auto oldlump = FileInfo[lump];
int slash = oldlump.longName.LastIndexOf('/');
if (slash == -1) return true; // already is pathless.
// Note: already pathless entries must be duplica

if (slash == -1)
{
FileInfo[lump].flags = LUMPF_FULLPATH;
return true; // already is pathless.
}


// just create a new reference to the original data with a different name.
oldlump.longName = oldlump.longName.Mid(slash + 1);
oldlump.resourceId = id;
oldlump.flags = LUMPF_FULLPATH;
FileInfo.Push(oldlump);
return true;
}
Expand Down

0 comments on commit 588fa5f

Please sign in to comment.