aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/modmanager.h
diff options
context:
space:
mode:
authorBobTheBob9 <for.oliver.kirkham@gmail.com>2022-07-07 21:31:41 +0100
committerBobTheBob9 <for.oliver.kirkham@gmail.com>2022-07-07 21:31:41 +0100
commit2ae34b67e36b8ba05132d481876eb4ed7a826283 (patch)
tree63f44c8e2dcdc959d7a5317a3a7b36efedbd7d38 /NorthstarDLL/modmanager.h
parent3406de7aaaf52cbef20b1549f2d7da0255d30f51 (diff)
downloadNorthstarLauncher-2ae34b67e36b8ba05132d481876eb4ed7a826283.tar.gz
NorthstarLauncher-2ae34b67e36b8ba05132d481876eb4ed7a826283.zip
almost fully replaced hooking lib
Diffstat (limited to 'NorthstarDLL/modmanager.h')
-rw-r--r--NorthstarDLL/modmanager.h294
1 files changed, 147 insertions, 147 deletions
diff --git a/NorthstarDLL/modmanager.h b/NorthstarDLL/modmanager.h
index ceddb402..ba47ce1e 100644
--- a/NorthstarDLL/modmanager.h
+++ b/NorthstarDLL/modmanager.h
@@ -1,147 +1,147 @@
-#pragma once
-#include "convar.h"
-#include <string>
-#include <vector>
-#include <filesystem>
-#include "rapidjson/document.h"
-#include "memalloc.h"
-#include "squirrel.h"
-
-namespace fs = std::filesystem;
-
-const std::string MOD_FOLDER_SUFFIX = "/mods";
-const fs::path MOD_OVERRIDE_DIR = "mod";
-const std::string COMPILED_ASSETS_SUFFIX = "/runtime/compiled";
-
-struct ModConVar
-{
- public:
- std::string Name;
- std::string DefaultValue;
- std::string HelpString;
- int Flags;
-};
-
-struct ModScriptCallback
-{
- public:
- ScriptContext Context;
-
- // called before the codecallback is executed
- std::string BeforeCallback;
- // called after the codecallback has finished executing
- std::string AfterCallback;
-};
-
-struct ModScript
-{
- public:
- std::string Path;
- std::string RsonRunOn;
-
- std::vector<ModScriptCallback> Callbacks;
-};
-
-// these are pretty much identical, could refactor to use the same stuff?
-struct ModVPKEntry
-{
- public:
- bool m_bAutoLoad;
- std::string m_sVpkPath;
-};
-
-struct ModRpakEntry
-{
- public:
- bool m_bAutoLoad;
- std::string m_sPakName;
-};
-
-class Mod
-{
- public:
- // runtime stuff
- fs::path ModDirectory;
- bool Enabled = true;
-
- // mod.json stuff:
-
- // the mod's name
- std::string Name;
- // the mod's description
- std::string Description;
- // the mod's version, should be in semver
- std::string Version;
- // a download link to the mod, for clients that try to join without the mod
- std::string DownloadLink;
-
- // whether clients need the mod to join servers running this mod
- bool RequiredOnClient;
- // the priority for this mod's files, mods with prio 0 are loaded first, then 1, then 2, etc
- int LoadPriority;
-
- // custom scripts used by the mod
- std::vector<ModScript> Scripts;
- // convars created by the mod
- std::vector<ModConVar*> ConVars;
- // custom localisation files created by the mod
- std::vector<std::string> LocalisationFiles;
-
- // other files:
-
- std::vector<ModVPKEntry> Vpks;
- std::unordered_map<size_t, std::string> KeyValues;
- std::vector<std::string> BinkVideos;
- std::string Pdiff; // only need one per mod
-
- std::vector<ModRpakEntry> Rpaks;
- std::unordered_map<std::string, std::string>
- RpakAliases; // paks we alias to other rpaks, e.g. to load sp_crashsite paks on the map mp_crashsite
-
- // other stuff
-
- bool wasReadSuccessfully = false;
-
- public:
- Mod(fs::path modPath, char* jsonBuf);
-};
-
-struct ModOverrideFile
-{
- public:
- Mod* owningMod;
- fs::path path;
-};
-
-class ModManager
-{
- private:
- bool m_hasLoadedMods = false;
- bool m_hasEnabledModsCfg;
- rapidjson_document m_enabledModsCfg;
-
- // precalculated hashes
- size_t m_hScriptsRsonHash;
- size_t m_hPdefHash;
-
- public:
- std::vector<Mod> m_loadedMods;
- std::unordered_map<std::string, ModOverrideFile> m_modFiles;
-
- public:
- ModManager();
- void LoadMods();
- void UnloadMods();
- std::string NormaliseModFilePath(const fs::path path);
- void CompileAssetsForFile(const char* filename);
-
- // compile asset type stuff, these are done in files under Mods/Compiled/
- void BuildScriptsRson();
- void TryBuildKeyValues(const char* filename);
- void BuildPdef();
-};
-
-fs::path GetModFolderPath();
-fs::path GetCompiledAssetsPath();
-
-extern ModManager* g_pModManager;
+#pragma once
+#include "convar.h"
+#include "memalloc.h"
+#include "squirrel.h"
+
+#include "rapidjson/document.h"
+#include <string>
+#include <vector>
+#include <filesystem>
+
+namespace fs = std::filesystem;
+
+const std::string MOD_FOLDER_SUFFIX = "/mods";
+const std::string REMOTE_MOD_FOLDER_SUFFIX = "/runtime/remote/mods";
+const fs::path MOD_OVERRIDE_DIR = "mod";
+const std::string COMPILED_ASSETS_SUFFIX = "/runtime/compiled";
+
+struct ModConVar
+{
+ public:
+ std::string Name;
+ std::string DefaultValue;
+ std::string HelpString;
+ int Flags;
+};
+
+struct ModScriptCallback
+{
+ public:
+ ScriptContext Context;
+
+ // called before the codecallback is executed
+ std::string BeforeCallback;
+ // called after the codecallback has finished executing
+ std::string AfterCallback;
+};
+
+struct ModScript
+{
+ public:
+ std::string Path;
+ std::string RunOn;
+
+ std::vector<ModScriptCallback> Callbacks;
+};
+
+// these are pretty much identical, could refactor to use the same stuff?
+struct ModVPKEntry
+{
+ public:
+ bool m_bAutoLoad;
+ std::string m_sVpkPath;
+};
+
+struct ModRpakEntry
+{
+ public:
+ bool m_bAutoLoad;
+ std::string m_sPakName;
+};
+
+class Mod
+{
+ public:
+ // runtime stuff
+ bool m_bEnabled = true;
+ bool m_bWasReadSuccessfully = false;
+ fs::path m_ModDirectory;
+ // bool m_bIsRemote;
+
+ // mod.json stuff:
+
+ // the mod's name
+ std::string Name;
+ // the mod's description
+ std::string Description;
+ // the mod's version, should be in semver
+ std::string Version;
+ // a download link to the mod, for clients that try to join without the mod
+ std::string DownloadLink;
+
+ // whether clients need the mod to join servers running this mod
+ bool RequiredOnClient;
+ // the priority for this mod's files, mods with prio 0 are loaded first, then 1, then 2, etc
+ int LoadPriority;
+
+ // custom scripts used by the mod
+ std::vector<ModScript> Scripts;
+ // convars created by the mod
+ std::vector<ModConVar*> ConVars;
+ // custom localisation files created by the mod
+ std::vector<std::string> LocalisationFiles;
+
+ // other files:
+
+ std::vector<ModVPKEntry> Vpks;
+ std::unordered_map<size_t, std::string> KeyValues;
+ std::vector<std::string> BinkVideos;
+ std::string Pdiff; // only need one per mod
+
+ std::vector<ModRpakEntry> Rpaks;
+ std::unordered_map<std::string, std::string>
+ RpakAliases; // paks we alias to other rpaks, e.g. to load sp_crashsite paks on the map mp_crashsite
+
+ public:
+ Mod(fs::path modPath, char* jsonBuf);
+};
+
+struct ModOverrideFile
+{
+ public:
+ Mod* m_pOwningMod;
+ fs::path m_Path;
+};
+
+class ModManager
+{
+ private:
+ bool m_bHasLoadedMods = false;
+ bool m_bHasEnabledModsCfg;
+ rapidjson_document m_EnabledModsCfg;
+
+ // precalculated hashes
+ size_t m_hScriptsRsonHash;
+ size_t m_hPdefHash;
+
+ public:
+ std::vector<Mod> m_LoadedMods;
+ std::unordered_map<std::string, ModOverrideFile> m_ModFiles;
+
+ public:
+ ModManager();
+ void LoadMods();
+ void UnloadMods();
+ std::string NormaliseModFilePath(const fs::path path);
+ void CompileAssetsForFile(const char* filename);
+
+ // compile asset type stuff, these are done in files under runtime/compiled/
+ void BuildScriptsRson();
+ void TryBuildKeyValues(const char* filename);
+ void BuildPdef();
+};
+
+fs::path GetModFolderPath();
+fs::path GetCompiledAssetsPath();
+
+extern ModManager* g_pModManager;