diff options
author | Rémy Raes <raes.remy@gmail.com> | 2024-09-08 00:27:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-08 00:27:44 +0200 |
commit | 8c546ed68c83b42cdff32d9b848b25ec2cba9c18 (patch) | |
tree | e1281836b33a2a1a4b0636fbb74c27ff31407cae /primedev/mods/autodownload/moddownloader.h | |
parent | 160f503bc81bffdef6dbaa16eec7c73fccef0eee (diff) | |
download | NorthstarLauncher-8c546ed68c83b42cdff32d9b848b25ec2cba9c18.tar.gz NorthstarLauncher-8c546ed68c83b42cdff32d9b848b25ec2cba9c18.zip |
Adjust for restructured `verified-mods.json` (#748)
Updates the launcher code to deal with adjusted verified mods JSON structure from the default manifest source
The idea here is to allow installing mods from other sources than Thunderstore.
Diffstat (limited to 'primedev/mods/autodownload/moddownloader.h')
-rw-r--r-- | primedev/mods/autodownload/moddownloader.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/primedev/mods/autodownload/moddownloader.h b/primedev/mods/autodownload/moddownloader.h index 98fc27ae..c7a88c19 100644 --- a/primedev/mods/autodownload/moddownloader.h +++ b/primedev/mods/autodownload/moddownloader.h @@ -5,17 +5,22 @@ class ModDownloader private: const char* VERIFICATION_FLAG = "-disablemodverification"; const char* CUSTOM_MODS_URL_FLAG = "-customverifiedurl="; - const char* STORE_URL = "https://gcdn.thunderstore.io/live/repository/packages/"; const char* DEFAULT_MODS_LIST_URL = "https://raw.githubusercontent.com/R2Northstar/VerifiedMods/main/verified-mods.json"; char* modsListUrl; + enum class VerifiedModPlatform + { + Unknown, + Thunderstore + }; struct VerifiedModVersion { std::string checksum; + std::string downloadLink; + VerifiedModPlatform platform; }; struct VerifiedModDetails { - std::string dependencyPrefix; std::unordered_map<std::string, VerifiedModVersion> versions = {}; }; std::unordered_map<std::string, VerifiedModDetails> verifiedMods = {}; @@ -45,7 +50,7 @@ private: * @param modVersion version of the mod to be downloaded * @returns location of the downloaded archive */ - std::optional<fs::path> FetchModFromDistantStore(std::string_view modName, std::string_view modVersion); + std::optional<fs::path> FetchModFromDistantStore(std::string_view modName, VerifiedModVersion modVersion); /** * Tells if a mod archive has not been corrupted. @@ -65,12 +70,13 @@ private: * Extracts a mod archive to the game folder. * * This extracts a downloaded mod archive from its original location to the - * current game profile, in the remote mods folder. + * current game profile; the install folder is defined by the platform parameter. * * @param modPath location of the downloaded archive + * @param platform origin of the downloaded archive * @returns nothing */ - void ExtractMod(fs::path modPath); + void ExtractMod(fs::path modPath, VerifiedModPlatform platform); public: ModDownloader(); @@ -131,7 +137,8 @@ public: MOD_FETCHING_FAILED, MOD_CORRUPTED, // Downloaded archive checksum does not match verified hash NO_DISK_SPACE_AVAILABLE, - NOT_FOUND // Mod is not currently being auto-downloaded + NOT_FOUND, // Mod is not currently being auto-downloaded + UNKNOWN_PLATFORM }; struct MOD_STATE |