Skip to content

Commit 4956b04

Browse files
committed
add mount point to pak paths
1 parent 78a4c63 commit 4956b04

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

libsave/src/Pak/PakFile.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ SatisfactorySave::PakFile::PakFile(const std::filesystem::path& pakPath) : NumEn
7878
throw std::runtime_error("FullDirectoryIndex missing in pak file!");
7979
}
8080

81+
if (!MountPoint.starts_with("../../../")) {
82+
throw std::runtime_error("Invalid mount point");
83+
}
84+
const auto abs_mount_point = MountPoint.substr(9);
85+
8186
// Parse full directory index. Structure is TMap<FString, TMap<FString, int32>>.
8287
ar.seek(FullDirectoryIndexOffset);
8388
const int32_t FullDirectoryIndexNum = ar.read<int32_t>();
@@ -89,7 +94,7 @@ SatisfactorySave::PakFile::PakFile(const std::filesystem::path& pakPath) : NumEn
8994
std::string fileName;
9095
ar << fileName;
9196
const int32_t fileEntryIdx = ar.read<int32_t>();
92-
const std::string fullFileName = directoryName + fileName;
97+
const std::string fullFileName = abs_mount_point + directoryName + fileName;
9398
if (directoryEntries_.contains(fullFileName)) {
9499
throw std::runtime_error("Directory filename entry is not unique!");
95100
}

libsave/src/Pak/PakManager.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ void SatisfactorySave::PakManager::cacheLatestPakNames(const std::optional<std::
9696
path = "Game/" + filename.substr(20);
9797
}
9898
} else {
99-
if (filename.starts_with("Content/")) {
100-
path = filename.substr(8);
99+
if (!path.starts_with("FactoryGame/Mods/")) {
100+
throw std::runtime_error("Mod asset outside \"FactoryGame/Mods/\"!");
101101
}
102-
bool startsWithSlash = !path.empty() && path[0] == '/';
103-
if (startsWithSlash) {
104-
path = modPrefix.value() + path;
105-
} else {
106-
path = modPrefix.value() + "/" + path;
102+
path = path.substr(17);
103+
104+
const auto content_name = modPrefix.value() + "/Content/";
105+
if (path.starts_with(content_name)) {
106+
path = modPrefix.value() + "/" + path.substr(content_name.size());
107107
}
108108
}
109109

0 commit comments

Comments
 (0)