From 43f0bce0596ec60434e48d8037ffed373bc13852 Mon Sep 17 00:00:00 2001 From: cat_or_not <41955154+catornot@users.noreply.github.com> Date: Thu, 14 Dec 2023 07:07:02 -0500 Subject: Add plugin dependency constants (#458) Adds dependency constants for plugins so mods can rely on plugins without always producing script errors when the plugin is missing --- NorthstarDLL/squirrel/squirrel.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'NorthstarDLL/squirrel/squirrel.cpp') diff --git a/NorthstarDLL/squirrel/squirrel.cpp b/NorthstarDLL/squirrel/squirrel.cpp index 68fffb9b..d8eff0d6 100644 --- a/NorthstarDLL/squirrel/squirrel.cpp +++ b/NorthstarDLL/squirrel/squirrel.cpp @@ -264,6 +264,13 @@ template void SquirrelManager::VMCreated(CSquir defconst(m_pSQVM, pair.first.c_str(), bWasFound); } + auto loadedPlugins = &g_pPluginManager->m_vLoadedPlugins; + for (const auto& pluginName : g_pModManager->m_PluginDependencyConstants) + { + auto f = [&](Plugin plugin) -> bool { return plugin.dependencyName == pluginName; }; + defconst(m_pSQVM, pluginName.c_str(), std::find_if(loadedPlugins->begin(), loadedPlugins->end(), f) != loadedPlugins->end()); + } + defconst(m_pSQVM, "MAX_FOLDER_SIZE", GetMaxSaveFolderSize() / 1024); // define squirrel constants for northstar(.dll) version -- cgit v1.2.3