aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/modmanager.cpp
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2022-10-22 01:55:52 +0100
committerGitHub <noreply@github.com>2022-10-22 01:55:52 +0100
commit5a0f03a299e87252e5b943f85f33a92e18984c65 (patch)
treec4cfc6babcec6c779b11302423eea50b6e908f07 /NorthstarDLL/modmanager.cpp
parentca6269431c5d1e4e91687b2ab7fd7ee2f311a2e0 (diff)
downloadNorthstarLauncher-5a0f03a299e87252e5b943f85f33a92e18984c65.tar.gz
NorthstarLauncher-5a0f03a299e87252e5b943f85f33a92e18984c65.zip
Allow rpaks to use starpaks that are in the mod's folder (#279)v1.10.0-rc4
* this works * read starpak entires from rpak headers * formatting * move logging to after function * Use str.empty instead of str != "" * change allocatedNewPath to std::string * merge conflict resolution part 2 * change to use int + add comment * better comments + init variable * path syntax + another comment * use goto to exit loop + improve commenting * implement requested changes * remove accidental diff * explanatory comment
Diffstat (limited to 'NorthstarDLL/modmanager.cpp')
-rw-r--r--NorthstarDLL/modmanager.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/NorthstarDLL/modmanager.cpp b/NorthstarDLL/modmanager.cpp
index 05060902..07a197dd 100644
--- a/NorthstarDLL/modmanager.cpp
+++ b/NorthstarDLL/modmanager.cpp
@@ -469,6 +469,46 @@ void ModManager::LoadMods()
modPak.m_sPakName = pakName;
+ // read header of file and get the starpak paths
+ // this is done here as opposed to on starpak load because multiple rpaks can load a starpak
+ // and there is seemingly no good way to tell which rpak is causing the load of a starpak :/
+
+ std::ifstream rpakStream(file.path(), std::ios::binary);
+
+ // seek to the point in the header where the starpak reference size is
+ rpakStream.seekg(0x38, std::ios::beg);
+ int starpaksSize = 0;
+ rpakStream.read((char*)&starpaksSize, 2);
+
+ // seek to just after the header
+ rpakStream.seekg(0x58, std::ios::beg);
+ // read the starpak reference(s)
+ std::vector<char> buf(starpaksSize);
+ rpakStream.read(buf.data(), starpaksSize);
+
+ rpakStream.close();
+
+ // split the starpak reference(s) into strings to hash
+ std::string str = "";
+ for (int i = 0; i < starpaksSize; i++)
+ {
+ // if the current char is null, that signals the end of the current starpak path
+ if (buf[i] != 0x00)
+ {
+ str += buf[i];
+ }
+ else
+ {
+ // only add the string we are making if it isnt empty
+ if (!str.empty())
+ {
+ mod.StarpakPaths.push_back(STR_HASH(str));
+ spdlog::info("Mod {} registered starpak '{}'", mod.Name, str);
+ str = "";
+ }
+ }
+ }
+
// not using atm because we need to resolve path to rpak
// if (m_hasLoadedMods && modPak.m_bAutoLoad)
// g_pPakLoadManager->LoadPakAsync(pakName.c_str());