Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions primedev/core/filesystem/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static void __fastcall h_AddSearchPath(IFileSystem* fileSystem, const char* pPat
}
}

void SetNewModSearchPaths(Mod* mod)
void SetNewModSearchPaths(Mod* mod, const char* pPathID)
{
// put our new path to the head if we need to read from a different mod path
// in the future we could also determine whether the file we're setting paths for needs a mod dir, or compiled assets
Expand All @@ -65,19 +65,21 @@ void SetNewModSearchPaths(Mod* mod)
if ((fs::absolute(mod->m_ModDirectory) / MOD_OVERRIDE_DIR).string().compare(sCurrentModPath))
{
o_pAddSearchPath(
g_pFilesystem, (fs::absolute(mod->m_ModDirectory) / MOD_OVERRIDE_DIR).string().c_str(), "GAME", PATH_ADD_TO_HEAD);
g_pFilesystem, (fs::absolute(mod->m_ModDirectory) / MOD_OVERRIDE_DIR).string().c_str(), pPathID, PATH_ADD_TO_HEAD);
sCurrentModPath = (fs::absolute(mod->m_ModDirectory) / MOD_OVERRIDE_DIR).string();
}
}
else // push compiled to head
o_pAddSearchPath(g_pFilesystem, fs::absolute(GetCompiledAssetsPath()).string().c_str(), "GAME", PATH_ADD_TO_HEAD);
o_pAddSearchPath(g_pFilesystem, fs::absolute(GetCompiledAssetsPath()).string().c_str(), pPathID, PATH_ADD_TO_HEAD);
}

bool TryReplaceFile(const char* pPath, bool shouldCompile)
bool TryReplaceFile(const char* pPath, bool shouldCompile, const char* pPathID = nullptr)
{
if (bReadingOriginalFile)
return false;

const char* pathID = pPathID ? pPathID : "GAME";

if (shouldCompile)
g_pModManager->CompileAssetsForFile(pPath);

Expand All @@ -86,7 +88,7 @@ bool TryReplaceFile(const char* pPath, bool shouldCompile)
auto file = g_pModManager->m_ModFiles.find(g_pModManager->NormaliseModFilePath(fs::path(pPath)));
if (file != g_pModManager->m_ModFiles.end())
{
SetNewModSearchPaths(file->second.m_pOwningMod);
SetNewModSearchPaths(file->second.m_pOwningMod, pathID);
return true;
}

Expand Down Expand Up @@ -122,7 +124,7 @@ static FileHandle_t(__fastcall* o_pCBaseFileSystem__OpenEx)(
static FileHandle_t __fastcall h_CBaseFileSystem__OpenEx(
IFileSystem* filesystem, const char* pPath, const char* pOptions, uint32_t flags, const char* pPathID, char** ppszResolvedFilename)
{
TryReplaceFile(pPath, true);
TryReplaceFile(pPath, true, pPathID);
return o_pCBaseFileSystem__OpenEx(filesystem, pPath, pOptions, flags, pPathID, ppszResolvedFilename);
}

Expand Down