diff --git a/source/lib/sysdep/os/osx/osx_atlas.h b/source/lib/sysdep/os/osx/osx_atlas.h index 4cf5204109..34193f6bad 100644 --- a/source/lib/sysdep/os/osx/osx_atlas.h +++ b/source/lib/sysdep/os/osx/osx_atlas.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -23,11 +23,14 @@ #ifndef OSX_ATLAS_H #define OSX_ATLAS_H +#include + +class CStr8; /** * Runs a new pyrogenesis process with the -editor argument. * Necessary because SDL and WxWidgets conflict. */ -void startNewAtlasProcess(); +void startNewAtlasProcess(const std::vector& mods); #endif // OSX_ATLAS_H diff --git a/source/lib/sysdep/os/osx/osx_atlas.mm b/source/lib/sysdep/os/osx/osx_atlas.mm index 6254318724..79f85fa802 100644 --- a/source/lib/sysdep/os/osx/osx_atlas.mm +++ b/source/lib/sysdep/os/osx/osx_atlas.mm @@ -28,14 +28,7 @@ #include "lib/types.h" #include "ps/CStr.h" -#include - -namespace Mod -{ -extern std::vector g_ModsLoaded; -} - -void startNewAtlasProcess() +void startNewAtlasProcess(const std::vector& mods) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -43,7 +36,7 @@ void startNewAtlasProcess() [args addObject:@"--editor"]; // Pass mods on the command line. - for (const CStr& mod : Mod::g_ModsLoaded) + for (const CStr8& mod : mods) { std::string arg = std::string("-mod=") + mod; [args addObject:[[NSString alloc] initWithUTF8String:arg.c_str()]]; diff --git a/source/main.cpp b/source/main.cpp index eaa06f2cb4..f252a28cae 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -598,7 +598,7 @@ static void RunGameOrAtlas(int argc, const char* argv[]) g_VFS = CreateVfs(); // Mount with highest priority, we don't want mods overwriting this. g_VFS->Mount(L"cache/", paths.Cache(), VFS_MOUNT_ARCHIVABLE, VFS_MAX_PRIORITY); - MountMods(paths, Mod::GetModsFromArguments(args, INIT_MODS)); + MountMods(paths, g_Mods.GetModsFromArguments(args, INIT_MODS)); { CReplayPlayer replay; @@ -698,7 +698,7 @@ static void RunGameOrAtlas(int argc, const char* argv[]) // Do not install mods again in case of restart (typically from the mod selector) modsToInstall.clear(); - Mod::ClearIncompatibleMods(); + g_Mods.ClearIncompatibleMods(); Shutdown(0); MainControllerShutdown(); @@ -708,7 +708,7 @@ static void RunGameOrAtlas(int argc, const char* argv[]) #if OS_MACOSX if (g_Shutdown == ShutdownType::RestartAsAtlas) - startNewAtlasProcess(); + startNewAtlasProcess(g_Mods.GetEnabledMods()); #else if (g_Shutdown == ShutdownType::RestartAsAtlas) ATLAS_RunIfOnCmdLine(args, true); diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index c0d8b8a258..94ab83b255 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -441,7 +441,7 @@ static void InitVfs(const CmdLineArgs& args, int flags) // Engine localization files (regular priority, these can be overwritten). g_VFS->Mount(L"l10n/", paths.RData()/"l10n"/""); - MountMods(paths, Mod::GetModsFromArguments(args, flags)); + MountMods(paths, g_Mods.GetModsFromArguments(args, flags)); // note: don't bother with g_VFS->TextRepresentation - directories // haven't yet been populated and are empty. @@ -851,18 +851,18 @@ bool AutostartVisualReplay(const std::string& replayFile); bool EnableModsOrSetDefault(const CmdLineArgs& args, const std::vector& mods, bool fromConfig) { ScriptInterface scriptInterface("Engine", "CheckAndEnableMods", g_ScriptContext); - if (Mod::CheckAndEnableMods(scriptInterface, mods)) + if (g_Mods.CheckAndEnableMods(scriptInterface, mods)) return true; // Here we refuse to start as there is no gui anyway if (args.Has("autostart-nonvisual")) { if (fromConfig) - LOGERROR("Trying to start with incompatible mods from configuration file: %s.", boost::algorithm::join(Mod::GetIncompatibleMods(), ", ")); + LOGERROR("Trying to start with incompatible mods from configuration file: %s.", boost::algorithm::join(g_Mods.GetIncompatibleMods(), ", ")); else - LOGERROR("Trying to start with incompatible mods: %s.", boost::algorithm::join(Mod::GetIncompatibleMods(), ", ")); + LOGERROR("Trying to start with incompatible mods: %s.", boost::algorithm::join(g_Mods.GetIncompatibleMods(), ", ")); return false; } - Mod::SetDefaultMods(); + g_Mods.SetDefaultMods(); RestartEngine(); return false; } @@ -901,7 +901,7 @@ bool Init(const CmdLineArgs& args, int flags) const int heapGrowthBytesGCTrigger = 20 * 1024 * 1024; g_ScriptContext = ScriptContext::CreateContext(contextSize, heapGrowthBytesGCTrigger); - Mod::CacheEnabledModVersions(g_ScriptContext); + g_Mods.CacheEnabledModVersions(g_ScriptContext); // Special command-line mode to dump the entity schemas instead of running the game. // (This must be done after loading VFS etc, but should be done before wasting time @@ -945,7 +945,7 @@ bool Init(const CmdLineArgs& args, int flags) return false; } } - else if (!EnableModsOrSetDefault(args, Mod::g_ModsLoaded, false)) + else if (!EnableModsOrSetDefault(args, g_Mods.GetEnabledMods(), false)) return false; } diff --git a/source/ps/Mod.cpp b/source/ps/Mod.cpp index 9e4f3c1c26..1b7b76bf0b 100644 --- a/source/ps/Mod.cpp +++ b/source/ps/Mod.cpp @@ -24,6 +24,7 @@ #include "lib/file/vfs/vfs.h" #include "lib/utf8.h" #include "ps/Filesystem.h" +#include "ps/GameSetup/CmdLineArgs.h" #include "ps/GameSetup/GameSetup.h" #include "ps/GameSetup/Paths.h" #include "ps/Profiler2.h" @@ -39,13 +40,12 @@ #include #include -namespace Mod +namespace { -std::vector g_ModsLoaded; -std::vector g_IncompatibleMods; -std::vector g_FailedMods; - -std::vector> g_LoadedModVersions; +/** + * Global instance of Mod, always exists. + */ +Mod g_ModInstance; bool ParseModJSON(const ScriptRequest& rq, const PIVFS& vfs, OsPath modsPath, OsPath mod, JS::MutableHandleValue json) { @@ -94,8 +94,14 @@ bool ParseModJSON(const ScriptRequest& rq, const PIVFS& vfs, OsPath modsPath, Os return Script::ParseJSON(rq, buffer.str(), json); } } +} // anonymous namespace -JS::Value GetAvailableMods(const ScriptInterface& scriptInterface) +Mod& Mod::Instance() +{ + return g_ModInstance; +} + +JS::Value Mod::GetAvailableMods(const ScriptInterface& scriptInterface) const { PROFILE2("GetAvailableMods"); @@ -144,66 +150,66 @@ JS::Value GetAvailableMods(const ScriptInterface& scriptInterface) return value.get(); } -const std::vector& GetEnabledMods() +const std::vector& Mod::GetEnabledMods() const { - return g_ModsLoaded; + return m_ModsLoaded; } -const std::vector& GetIncompatibleMods() +const std::vector& Mod::GetIncompatibleMods() const { - return g_IncompatibleMods; + return m_IncompatibleMods; } -const std::vector& GetFailedMods() +const std::vector& Mod::GetFailedMods() const { - return g_FailedMods; + return m_FailedMods; } -const std::vector& GetModsFromArguments(const CmdLineArgs& args, int flags) +const std::vector& Mod::GetModsFromArguments(const CmdLineArgs& args, int flags) { const bool initMods = (flags & INIT_MODS) == INIT_MODS; const bool addPublic = (flags & INIT_MODS_PUBLIC) == INIT_MODS_PUBLIC; if (!initMods) - return g_ModsLoaded; + return m_ModsLoaded; - g_ModsLoaded = args.GetMultiple("mod"); + m_ModsLoaded = args.GetMultiple("mod"); if (addPublic) - g_ModsLoaded.insert(g_ModsLoaded.begin(), "public"); + m_ModsLoaded.insert(m_ModsLoaded.begin(), "public"); - g_ModsLoaded.insert(g_ModsLoaded.begin(), "mod"); + m_ModsLoaded.insert(m_ModsLoaded.begin(), "mod"); - return g_ModsLoaded; + return m_ModsLoaded; } -void SetDefaultMods() +void Mod::SetDefaultMods() { - g_ModsLoaded.clear(); - g_ModsLoaded.insert(g_ModsLoaded.begin(), "mod"); + m_ModsLoaded.clear(); + m_ModsLoaded.insert(m_ModsLoaded.begin(), "mod"); } -void ClearIncompatibleMods() +void Mod::ClearIncompatibleMods() { - g_IncompatibleMods.clear(); - g_FailedMods.clear(); + m_IncompatibleMods.clear(); + m_FailedMods.clear(); } -bool CheckAndEnableMods(const ScriptInterface& scriptInterface, const std::vector& mods) +bool Mod::CheckAndEnableMods(const ScriptInterface& scriptInterface, const std::vector& mods) { ScriptRequest rq(scriptInterface); JS::RootedValue availableMods(rq.cx, GetAvailableMods(scriptInterface)); if (!AreModsCompatible(scriptInterface, mods, availableMods)) { - g_FailedMods = mods; + m_FailedMods = mods; return false; } - g_ModsLoaded = mods; + m_ModsLoaded = mods; return true; } -bool AreModsCompatible(const ScriptInterface& scriptInterface, const std::vector& mods, const JS::RootedValue& availableMods) +bool Mod::AreModsCompatible(const ScriptInterface& scriptInterface, const std::vector& mods, const JS::RootedValue& availableMods) { ScriptRequest rq(scriptInterface); std::unordered_map> modDependencies; @@ -218,12 +224,12 @@ bool AreModsCompatible(const ScriptInterface& scriptInterface, const std::vector // Requested mod is not available, fail if (!Script::HasProperty(rq, availableMods, mod.c_str())) { - g_IncompatibleMods.push_back(mod); + m_IncompatibleMods.push_back(mod); continue; } if (!Script::GetProperty(rq, availableMods, mod.c_str(), &modData)) { - g_IncompatibleMods.push_back(mod); + m_IncompatibleMods.push_back(mod); continue; } @@ -268,13 +274,13 @@ bool AreModsCompatible(const ScriptInterface& scriptInterface, const std::vector const std::unordered_map::iterator it = modNameVersions.find(modToCheck); if (it == modNameVersions.end()) { - g_IncompatibleMods.push_back(mod); + m_IncompatibleMods.push_back(mod); continue; } // 0.0.25(0ad) , <=, 0.0.24(required version) if (!CompareVersionStrings(it->second, op, versionToCheck)) { - g_IncompatibleMods.push_back(mod); + m_IncompatibleMods.push_back(mod); continue; } break; @@ -283,10 +289,10 @@ bool AreModsCompatible(const ScriptInterface& scriptInterface, const std::vector } - return g_IncompatibleMods.empty(); + return m_IncompatibleMods.empty(); } -bool CompareVersionStrings(const CStr& version, const CStr& op, const CStr& required) +bool Mod::CompareVersionStrings(const CStr& version, const CStr& op, const CStr& required) const { std::vector versionSplit; std::vector requiredSplit; @@ -320,16 +326,16 @@ bool CompareVersionStrings(const CStr& version, const CStr& op, const CStr& requ } -void CacheEnabledModVersions(const shared_ptr& scriptContext) +void Mod::CacheEnabledModVersions(const shared_ptr& scriptContext) { ScriptInterface scriptInterface("Engine", "CacheEnabledModVersions", scriptContext); ScriptRequest rq(scriptInterface); JS::RootedValue availableMods(rq.cx, GetAvailableMods(scriptInterface)); - g_LoadedModVersions.clear(); + m_LoadedModVersions.clear(); - for (const CStr& mod : g_ModsLoaded) + for (const CStr& mod : m_ModsLoaded) { // Ignore mod mod as it is irrelevant for compatibility checks if (mod == "mod") @@ -340,19 +346,19 @@ void CacheEnabledModVersions(const shared_ptr& scriptContext) if (Script::GetProperty(rq, availableMods, mod.c_str(), &modData)) Script::GetProperty(rq, modData, "version", version); - g_LoadedModVersions.push_back({mod, version}); + m_LoadedModVersions.push_back({mod, version}); } } -JS::Value GetLoadedModsWithVersions(const ScriptInterface& scriptInterface) +JS::Value Mod::GetLoadedModsWithVersions(const ScriptInterface& scriptInterface) const { ScriptRequest rq(scriptInterface); JS::RootedValue returnValue(rq.cx); - Script::ToJSVal(rq, &returnValue, g_LoadedModVersions); + Script::ToJSVal(rq, &returnValue, m_LoadedModVersions); return returnValue; } -JS::Value GetEngineInfo(const ScriptInterface& scriptInterface) +JS::Value Mod::GetEngineInfo(const ScriptInterface& scriptInterface) const { ScriptRequest rq(scriptInterface); @@ -369,4 +375,3 @@ JS::Value GetEngineInfo(const ScriptInterface& scriptInterface) return metainfo; } -} diff --git a/source/ps/Mod.h b/source/ps/Mod.h index 28150807e3..2466695f99 100644 --- a/source/ps/Mod.h +++ b/source/ps/Mod.h @@ -19,21 +19,27 @@ #define INCLUDED_MOD #include "ps/CStr.h" -#include "ps/GameSetup/CmdLineArgs.h" #include "scriptinterface/ScriptForward.h" #include +class CmdLineArgs; + extern CmdLineArgs g_CmdLineArgs; -namespace Mod -{ - extern std::vector g_ModsLoaded; +#define g_Mods (Mod::Instance()) + +class Mod +{ +public: + // Singleton-like interface. + static Mod& Instance(); + + JS::Value GetAvailableMods(const ScriptInterface& scriptInterface) const; + const std::vector& GetEnabledMods() const; + const std::vector& GetIncompatibleMods() const; + const std::vector& GetFailedMods() const; - JS::Value GetAvailableMods(const ScriptInterface& scriptInterface); - const std::vector& GetEnabledMods(); - const std::vector& GetIncompatibleMods(); - const std::vector& GetFailedMods(); /** * This reads the version numbers from the launched mods. * It caches the result, since the reading of zip files is slow and @@ -45,7 +51,7 @@ namespace Mod const std::vector& GetModsFromArguments(const CmdLineArgs& args, int flags); bool AreModsCompatible(const ScriptInterface& scriptInterface, const std::vector& mods, const JS::RootedValue& availableMods); bool CheckAndEnableMods(const ScriptInterface& scriptInterface, const std::vector& mods); - bool CompareVersionStrings(const CStr& required, const CStr& op, const CStr& version); + bool CompareVersionStrings(const CStr& required, const CStr& op, const CStr& version) const; void SetDefaultMods(); void ClearIncompatibleMods(); @@ -56,7 +62,7 @@ namespace Mod * @param scriptInterface the ScriptInterface in which to create the return data. * @return list of loaded mods with the format [[modA, versionA], [modB, versionB], ...] */ - JS::Value GetLoadedModsWithVersions(const ScriptInterface& scriptInterface); + JS::Value GetLoadedModsWithVersions(const ScriptInterface& scriptInterface) const; /** * Gets info (version and mods loaded) on the running engine @@ -64,6 +70,14 @@ namespace Mod * @param scriptInterface the ScriptInterface in which to create the return data. * @return list of objects containing data */ - JS::Value GetEngineInfo(const ScriptInterface& scriptInterface); -} + JS::Value GetEngineInfo(const ScriptInterface& scriptInterface) const; + +private: + std::vector m_ModsLoaded; + std::vector m_IncompatibleMods; + std::vector m_FailedMods; + + std::vector> m_LoadedModVersions; +}; + #endif // INCLUDED_MOD diff --git a/source/ps/Replay.cpp b/source/ps/Replay.cpp index bd19f2be89..ef9f37ac59 100644 --- a/source/ps/Replay.cpp +++ b/source/ps/Replay.cpp @@ -73,7 +73,7 @@ void CReplayLogger::StartGame(JS::MutableHandleValue attribs) // Add engine version and currently loaded mods for sanity checks when replaying Script::SetProperty(rq, attribs, "engine_version", engine_version); - JS::RootedValue mods(rq.cx, Mod::GetLoadedModsWithVersions(m_ScriptInterface)); + JS::RootedValue mods(rq.cx, g_Mods.GetLoadedModsWithVersions(m_ScriptInterface)); Script::SetProperty(rq, attribs, "mods", mods); m_Directory = createDateIndexSubdirectory(VisualReplay::GetDirectoryPath()); @@ -170,7 +170,7 @@ void CReplayPlayer::CheckReplayMods(const ScriptInterface& scriptInterface, JS:: Script::GetProperty(rq, attribs, "mods", replayMods); std::vector> enabledMods; - JS::RootedValue enabledModsJS(rq.cx, Mod::GetLoadedModsWithVersions(scriptInterface)); + JS::RootedValue enabledModsJS(rq.cx, g_Mods.GetLoadedModsWithVersions(scriptInterface)); Script::FromJSVal(rq, enabledModsJS, enabledMods); CStr warn; @@ -208,7 +208,7 @@ void CReplayPlayer::Replay(const bool serializationtest, const int rejointesttur const int heapGrowthBytesGCTrigger = 20 * 1024 * 1024; g_ScriptContext = ScriptContext::CreateContext(contextSize, heapGrowthBytesGCTrigger); - Mod::CacheEnabledModVersions(g_ScriptContext); + g_Mods.CacheEnabledModVersions(g_ScriptContext); g_Game = new CGame(false); if (serializationtest) diff --git a/source/ps/SavedGame.cpp b/source/ps/SavedGame.cpp index 200c0f523e..5f9c6ae877 100644 --- a/source/ps/SavedGame.cpp +++ b/source/ps/SavedGame.cpp @@ -81,7 +81,7 @@ Status SavedGames::Save(const CStrW& name, const CStrW& description, CSimulation WARN_RETURN(ERR::FAIL); JS::RootedValue initAttributes(rq.cx, simulation.GetInitAttributes()); - JS::RootedValue mods(rq.cx, Mod::GetLoadedModsWithVersions(simulation.GetScriptInterface())); + JS::RootedValue mods(rq.cx, g_Mods.GetLoadedModsWithVersions(simulation.GetScriptInterface())); JS::RootedValue metadata(rq.cx); diff --git a/source/ps/scripting/JSInterface_Mod.cpp b/source/ps/scripting/JSInterface_Mod.cpp index ac4e7dc518..ae81dd324b 100644 --- a/source/ps/scripting/JSInterface_Mod.cpp +++ b/source/ps/scripting/JSInterface_Mod.cpp @@ -26,10 +26,15 @@ extern void RestartEngine(); namespace JSI_Mod { +Mod* ModGetter(const ScriptRequest&, JS::CallArgs&) +{ + return &g_Mods; +} + bool SetModsAndRestartEngine(const ScriptInterface& scriptInterface, const std::vector& mods) { - Mod::ClearIncompatibleMods(); - if (!Mod::CheckAndEnableMods(scriptInterface, mods)) + g_Mods.ClearIncompatibleMods(); + if (!g_Mods.CheckAndEnableMods(scriptInterface, mods)) return false; RestartEngine(); @@ -38,16 +43,16 @@ bool SetModsAndRestartEngine(const ScriptInterface& scriptInterface, const std:: bool HasFailedMods() { - return Mod::GetFailedMods().size() > 0; + return g_Mods.GetFailedMods().size() > 0; } void RegisterScriptFunctions(const ScriptRequest& rq) { - ScriptFunction::Register<&Mod::GetEngineInfo>(rq, "GetEngineInfo"); - ScriptFunction::Register<&Mod::GetAvailableMods>(rq, "GetAvailableMods"); - ScriptFunction::Register<&Mod::GetEnabledMods>(rq, "GetEnabledMods"); + ScriptFunction::Register<&Mod::GetEngineInfo, ModGetter>(rq, "GetEngineInfo"); + ScriptFunction::Register<&Mod::GetAvailableMods, ModGetter>(rq, "GetAvailableMods"); + ScriptFunction::Register<&Mod::GetEnabledMods, ModGetter>(rq, "GetEnabledMods"); ScriptFunction::Register (rq, "HasFailedMods"); - ScriptFunction::Register<&Mod::GetFailedMods>(rq, "GetFailedMods"); + ScriptFunction::Register<&Mod::GetFailedMods, ModGetter>(rq, "GetFailedMods"); ScriptFunction::Register<&SetModsAndRestartEngine>(rq, "SetModsAndRestartEngine"); } } diff --git a/source/ps/tests/test_Mod.h b/source/ps/tests/test_Mod.h index 397aea4066..0e9ab7cc2f 100644 --- a/source/ps/tests/test_Mod.h +++ b/source/ps/tests/test_Mod.h @@ -42,45 +42,45 @@ public: CStr version = "0.0.24";// 0ad version // 0.0.24 = 0.0.24 - TS_ASSERT(Mod::CompareVersionStrings(version, eq, required)); - TS_ASSERT(!Mod::CompareVersionStrings(version, lt, required)); - TS_ASSERT(!Mod::CompareVersionStrings(version, gt, required)); - TS_ASSERT(Mod::CompareVersionStrings(version, leq, required)); - TS_ASSERT(Mod::CompareVersionStrings(version, geq, required)); + TS_ASSERT(g_Mods.CompareVersionStrings(version, eq, required)); + TS_ASSERT(!g_Mods.CompareVersionStrings(version, lt, required)); + TS_ASSERT(!g_Mods.CompareVersionStrings(version, gt, required)); + TS_ASSERT(g_Mods.CompareVersionStrings(version, leq, required)); + TS_ASSERT(g_Mods.CompareVersionStrings(version, geq, required)); // 0.0.23 <= 0.0.24 version = "0.0.23"; - TS_ASSERT(!Mod::CompareVersionStrings(version, eq, required)); - TS_ASSERT(Mod::CompareVersionStrings(version, lt, required)); - TS_ASSERT(!Mod::CompareVersionStrings(version, gt, required)); - TS_ASSERT(Mod::CompareVersionStrings(version, leq, required)); - TS_ASSERT(!Mod::CompareVersionStrings(version, geq, required)); + TS_ASSERT(!g_Mods.CompareVersionStrings(version, eq, required)); + TS_ASSERT(g_Mods.CompareVersionStrings(version, lt, required)); + TS_ASSERT(!g_Mods.CompareVersionStrings(version, gt, required)); + TS_ASSERT(g_Mods.CompareVersionStrings(version, leq, required)); + TS_ASSERT(!g_Mods.CompareVersionStrings(version, geq, required)); // 0.0.25 >= 0.0.24 version = "0.0.25"; - TS_ASSERT(!Mod::CompareVersionStrings(version, eq, required)); - TS_ASSERT(!Mod::CompareVersionStrings(version, lt, required)); - TS_ASSERT(Mod::CompareVersionStrings(version, gt, required)); - TS_ASSERT(!Mod::CompareVersionStrings(version, leq, required)); - TS_ASSERT(Mod::CompareVersionStrings(version, geq, required)); + TS_ASSERT(!g_Mods.CompareVersionStrings(version, eq, required)); + TS_ASSERT(!g_Mods.CompareVersionStrings(version, lt, required)); + TS_ASSERT(g_Mods.CompareVersionStrings(version, gt, required)); + TS_ASSERT(!g_Mods.CompareVersionStrings(version, leq, required)); + TS_ASSERT(g_Mods.CompareVersionStrings(version, geq, required)); // 0.0.9 <= 0.1.0 version = "0.0.9"; required = "0.1.0"; - TS_ASSERT(!Mod::CompareVersionStrings(version, eq, required)); - TS_ASSERT(Mod::CompareVersionStrings(version, lt, required)); - TS_ASSERT(!Mod::CompareVersionStrings(version, gt, required)); - TS_ASSERT(Mod::CompareVersionStrings(version, leq, required)); - TS_ASSERT(!Mod::CompareVersionStrings(version, geq, required)); + TS_ASSERT(!g_Mods.CompareVersionStrings(version, eq, required)); + TS_ASSERT(g_Mods.CompareVersionStrings(version, lt, required)); + TS_ASSERT(!g_Mods.CompareVersionStrings(version, gt, required)); + TS_ASSERT(g_Mods.CompareVersionStrings(version, leq, required)); + TS_ASSERT(!g_Mods.CompareVersionStrings(version, geq, required)); // 5.3 <= 5.3.0 version = "5.3"; required = "5.3.0"; - TS_ASSERT(!Mod::CompareVersionStrings(version, eq, required)); - TS_ASSERT(Mod::CompareVersionStrings(version, lt, required)); - TS_ASSERT(!Mod::CompareVersionStrings(version, gt, required)); - TS_ASSERT(Mod::CompareVersionStrings(version, leq, required)); - TS_ASSERT(!Mod::CompareVersionStrings(version, geq, required)); + TS_ASSERT(!g_Mods.CompareVersionStrings(version, eq, required)); + TS_ASSERT(g_Mods.CompareVersionStrings(version, lt, required)); + TS_ASSERT(!g_Mods.CompareVersionStrings(version, gt, required)); + TS_ASSERT(g_Mods.CompareVersionStrings(version, leq, required)); + TS_ASSERT(!g_Mods.CompareVersionStrings(version, geq, required)); } void test_compatible() @@ -148,38 +148,38 @@ public: mods.clear(); mods.push_back("public"); - Mod::ClearIncompatibleMods(); - TS_ASSERT(Mod::AreModsCompatible(script, mods, availableMods)); + g_Mods.ClearIncompatibleMods(); + TS_ASSERT(g_Mods.AreModsCompatible(script, mods, availableMods)); mods.clear(); mods.push_back("mod"); mods.push_back("public"); - Mod::ClearIncompatibleMods(); - TS_ASSERT(Mod::AreModsCompatible(script, mods, availableMods)); + g_Mods.ClearIncompatibleMods(); + TS_ASSERT(g_Mods.AreModsCompatible(script, mods, availableMods)); mods.clear(); mods.push_back("public"); mods.push_back("good"); - Mod::ClearIncompatibleMods(); - TS_ASSERT(Mod::AreModsCompatible(script, mods, availableMods)); + g_Mods.ClearIncompatibleMods(); + TS_ASSERT(g_Mods.AreModsCompatible(script, mods, availableMods)); mods.clear(); mods.push_back("public"); mods.push_back("good2"); - Mod::ClearIncompatibleMods(); - TS_ASSERT(Mod::AreModsCompatible(script, mods, availableMods)); + g_Mods.ClearIncompatibleMods(); + TS_ASSERT(g_Mods.AreModsCompatible(script, mods, availableMods)); mods.clear(); mods.push_back("public"); mods.push_back("wrong"); - Mod::ClearIncompatibleMods(); - TS_ASSERT(!Mod::AreModsCompatible(script, mods, availableMods)); + g_Mods.ClearIncompatibleMods(); + TS_ASSERT(!g_Mods.AreModsCompatible(script, mods, availableMods)); mods.clear(); mods.push_back("public"); mods.push_back("does_not_exist"); - Mod::ClearIncompatibleMods(); - TS_ASSERT(!Mod::AreModsCompatible(script, mods, availableMods)); + g_Mods.ClearIncompatibleMods(); + TS_ASSERT(!g_Mods.AreModsCompatible(script, mods, availableMods)); } };