Index: ps/trunk/source/ps/Mod.cpp =================================================================== --- ps/trunk/source/ps/Mod.cpp (revision 25545) +++ ps/trunk/source/ps/Mod.cpp (revision 25546) @@ -1,359 +1,371 @@ /* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * 0 A.D. is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with 0 A.D. If not, see . */ #include "precompiled.h" #include "ps/Mod.h" #include "i18n/L10n.h" #include "lib/file/file_system.h" #include "lib/file/vfs/vfs.h" #include "lib/utf8.h" #include "ps/Filesystem.h" #include "ps/GameSetup/GameSetup.h" #include "ps/GameSetup/Paths.h" #include "ps/Profiler2.h" #include "ps/Pyrogenesis.h" +#include "scriptinterface/JSON.h" #include "scriptinterface/Object.h" +#include "scriptinterface/ScriptExceptions.h" #include "scriptinterface/ScriptInterface.h" -#include "scriptinterface/JSON.h" #include #include #include #include #include #include namespace { /** * Global instance of Mod, always exists. */ Mod g_ModInstance; -bool ParseModJSON(const ScriptRequest& rq, const PIVFS& vfs, OsPath modsPath, OsPath mod, JS::MutableHandleValue json) +bool LoadModJSON(const PIVFS& vfs, OsPath modsPath, OsPath mod, std::string& text) { // Attempt to open mod.json first. std::ifstream modjson; modjson.open((modsPath / mod / L"mod.json").string8()); if (!modjson.is_open()) { modjson.close(); // Fallback: open the archive and read mod.json there. // This can take in the hundreds of milliseconds with large mods. vfs->Clear(); if (vfs->Mount(L"", modsPath / mod / "", VFS_MOUNT_MUST_EXIST, VFS_MIN_PRIORITY) < 0) return false; CVFSFile modinfo; if (modinfo.Load(vfs, L"mod.json", false) != PSRETURN_OK) return false; - if (!Script::ParseJSON(rq, modinfo.GetAsString(), json)) - return false; + text = modinfo.GetAsString(); // Attempt to write the mod.json file so we'll take the fast path next time. std::ofstream out_mod_json((modsPath / mod / L"mod.json").string8()); if (out_mod_json.good()) { - out_mod_json << modinfo.GetAsString(); + out_mod_json << text; out_mod_json.close(); } else { // Print a warning - we'll keep trying, which could have adverse effects. if (L10n::IsInitialised()) LOGWARNING(g_L10n.Translate("Could not write external mod.json for zipped mod '%s'. The mod should be reinstalled."), mod.string8()); else LOGWARNING("Could not write external mod.json for zipped mod '%s'. The mod should be reinstalled.", mod.string8()); } return true; } else { std::stringstream buffer; buffer << modjson.rdbuf(); - return Script::ParseJSON(rq, buffer.str(), json); + text = buffer.str(); + return true; } } + +bool ParseModJSON(const ScriptRequest& rq, const PIVFS& vfs, OsPath modsPath, OsPath mod, Mod::ModData& data) +{ + std::string text; + if (!LoadModJSON(vfs, modsPath, mod, text)) + return false; + + JS::RootedValue json(rq.cx); + if (!Script::ParseJSON(rq, text, &json)) + return false; + + data.m_Pathname = utf8_from_wstring(mod.string()); + data.m_Text = text; + + if (!Script::GetProperty(rq, json, "version", data.m_Version)) + return false; + if (!Script::GetProperty(rq, json, "name", data.m_Name)) + return false; + if (!Script::GetProperty(rq, json, "dependencies", data.m_Dependencies)) + return false; + return true; +} + } // anonymous namespace Mod& Mod::Instance() { return g_ModInstance; } -JS::Value Mod::GetAvailableMods(const ScriptInterface& scriptInterface) const +void Mod::UpdateAvailableMods(const ScriptInterface& scriptInterface) { - PROFILE2("GetAvailableMods"); + PROFILE2("UpdateAvailableMods"); const Paths paths(g_CmdLineArgs); // loop over all possible paths OsPath modPath = paths.RData()/"mods"; OsPath modUserPath = paths.UserData()/"mods"; DirectoryNames modDirs; DirectoryNames modDirsUser; GetDirectoryEntries(modPath, NULL, &modDirs); // Sort modDirs so that we can do a fast lookup below std::sort(modDirs.begin(), modDirs.end()); PIVFS vfs = CreateVfs(); ScriptRequest rq(scriptInterface); - JS::RootedValue value(rq.cx, Script::CreateObject(rq)); - for (DirectoryNames::iterator iter = modDirs.begin(); iter != modDirs.end(); ++iter) { - JS::RootedValue json(rq.cx); - if (!ParseModJSON(rq, vfs, modPath, *iter, &json)) + ModData data; + if (!ParseModJSON(rq, vfs, modPath, *iter, data)) continue; // Valid mod data, add it to our structure - Script::SetProperty(rq, value, utf8_from_wstring(iter->string()).c_str(), json); + m_AvailableMods.emplace_back(std::move(data)); } GetDirectoryEntries(modUserPath, NULL, &modDirsUser); for (DirectoryNames::iterator iter = modDirsUser.begin(); iter != modDirsUser.end(); ++iter) { // Ignore mods in the user folder if we have already found them in modDirs. if (std::binary_search(modDirs.begin(), modDirs.end(), *iter)) continue; - JS::RootedValue json(rq.cx); - if (!ParseModJSON(rq, vfs, modUserPath, *iter, &json)) + ModData data; + if (!ParseModJSON(rq, vfs, modUserPath, *iter, data)) continue; // Valid mod data, add it to our structure - Script::SetProperty(rq, value, utf8_from_wstring(iter->string()).c_str(), json); + m_AvailableMods.emplace_back(std::move(data)); } - - return value.get(); } const std::vector& Mod::GetEnabledMods() const { return m_EnabledMods; } const std::vector& Mod::GetIncompatibleMods() const { return m_IncompatibleMods; } bool Mod::EnableMods(const ScriptInterface& scriptInterface, const std::vector& mods, const bool addPublic) { m_IncompatibleMods.clear(); m_EnabledMods.clear(); std::unordered_map counts; for (const CStr& mod : mods) { // Ignore duplicates. if (counts.try_emplace(mod, 0).first->second++ > 0) continue; m_EnabledMods.emplace_back(mod); } if (addPublic && counts["public"] == 0) m_EnabledMods.insert(m_EnabledMods.begin(), "public"); if (counts["mod"] == 0) m_EnabledMods.insert(m_EnabledMods.begin(), "mod"); - ScriptRequest rq(scriptInterface); - JS::RootedValue availableMods(rq.cx, GetAvailableMods(scriptInterface)); - m_IncompatibleMods = CheckForIncompatibleMods(scriptInterface, m_EnabledMods, availableMods); + UpdateAvailableMods(scriptInterface); + + m_IncompatibleMods = CheckForIncompatibleMods(m_EnabledMods); for (const CStr& mod : m_IncompatibleMods) m_EnabledMods.erase(std::find(m_EnabledMods.begin(), m_EnabledMods.end(), mod)); - CacheEnabledModVersions(scriptInterface); - return m_IncompatibleMods.empty(); } -std::vector Mod::CheckForIncompatibleMods(const ScriptInterface& scriptInterface, const std::vector& mods, const JS::RootedValue& availableMods) const +std::vector Mod::CheckForIncompatibleMods(const std::vector& mods) const { - ScriptRequest rq(scriptInterface); std::vector incompatibleMods; std::unordered_map> modDependencies; std::unordered_map modNameVersions; for (const CStr& mod : mods) { if (mod == "mod") continue; - JS::RootedValue modData(rq.cx); + std::vector::const_iterator it = std::find_if(m_AvailableMods.begin(), m_AvailableMods.end(), + [&mod](const ModData& modData) { return modData.m_Pathname == mod; }); - // Requested mod is not available, fail - if (!Script::HasProperty(rq, availableMods, mod.c_str())) + if (it == m_AvailableMods.end()) { incompatibleMods.push_back(mod); continue; } - if (!Script::GetProperty(rq, availableMods, mod.c_str(), &modData)) - { - incompatibleMods.push_back(mod); - continue; - } - - std::vector dependencies; - CStr version; - CStr name; - Script::GetProperty(rq, modData, "dependencies", dependencies); - Script::GetProperty(rq, modData, "version", version); - Script::GetProperty(rq, modData, "name", name); - modNameVersions.emplace(name, version); - modDependencies.emplace(mod, dependencies); + modNameVersions.emplace(it->m_Name, it->m_Version); + modDependencies.emplace(it->m_Name, it->m_Dependencies); } static const std::vector toCheck = { "<=", ">=", "=", "<", ">" }; for (const CStr& mod : mods) { if (mod == "mod") continue; const std::unordered_map>::iterator res = modDependencies.find(mod); if (res == modDependencies.end()) continue; const std::vector deps = res->second; if (deps.empty()) continue; for (const CStr& dep : deps) { if (dep.empty()) continue; // 0ad<=0.0.24 for (const CStr& op : toCheck) { const int pos = dep.Find(op.c_str()); if (pos == -1) continue; //0ad const CStr modToCheck = dep.substr(0, pos); //0.0.24 const CStr versionToCheck = dep.substr(pos + op.size()); const std::unordered_map::iterator it = modNameVersions.find(modToCheck); if (it == modNameVersions.end()) { incompatibleMods.push_back(mod); continue; } // 0.0.25(0ad) , <=, 0.0.24(required version) if (!CompareVersionStrings(it->second, op, versionToCheck)) { incompatibleMods.push_back(mod); continue; } break; } } } return incompatibleMods; } bool Mod::CompareVersionStrings(const CStr& version, const CStr& op, const CStr& required) const { std::vector versionSplit; std::vector requiredSplit; static const std::string toIgnore = "-,_"; boost::split(versionSplit, version, boost::is_any_of(toIgnore), boost::token_compress_on); boost::split(requiredSplit, required, boost::is_any_of(toIgnore), boost::token_compress_on); boost::split(versionSplit, versionSplit[0], boost::is_any_of("."), boost::token_compress_on); boost::split(requiredSplit, requiredSplit[0], boost::is_any_of("."), boost::token_compress_on); const bool eq = op.Find("=") != -1; const bool lt = op.Find("<") != -1; const bool gt = op.Find(">") != -1; const size_t min = std::min(versionSplit.size(), requiredSplit.size()); for (size_t i = 0; i < min; ++i) { const int diff = versionSplit[i].ToInt() - requiredSplit[i].ToInt(); if ((gt && diff > 0) || (lt && diff < 0)) return true; if ((gt && diff < 0) || (lt && diff > 0) || (eq && diff)) return false; } const size_t versionSize = versionSplit.size(); const size_t requiredSize = requiredSplit.size(); if (versionSize == requiredSize) return eq; return versionSize < requiredSize ? lt : gt; } - -void Mod::CacheEnabledModVersions(const ScriptInterface& scriptInterface) +JS::Value Mod::GetLoadedModsWithVersions(const ScriptInterface& scriptInterface) const { - ScriptRequest rq(scriptInterface); - - JS::RootedValue availableMods(rq.cx, GetAvailableMods(scriptInterface)); - - m_LoadedModVersions.clear(); - + std::vector> loadedMods; for (const CStr& mod : m_EnabledMods) { - // Ignore mod mod as it is irrelevant for compatibility checks - if (mod == "mod") - continue; + std::vector::const_iterator it = std::find_if(m_AvailableMods.begin(), m_AvailableMods.end(), + [&mod](const ModData& modData) { return modData.m_Pathname == mod; }); - CStr version; - JS::RootedValue modData(rq.cx); - if (Script::GetProperty(rq, availableMods, mod.c_str(), &modData)) - Script::GetProperty(rq, modData, "version", version); + // This ought be impossible, but let's handle it anyways since it's not a reason to crash. + if (it == m_AvailableMods.end()) + { + LOGERROR("Unavailable mod '%s' was enabled.", mod); + continue; + } - m_LoadedModVersions.push_back({mod, version}); + loadedMods.emplace_back(std::vector{ it->m_Name, it->m_Version }); } -} - -JS::Value Mod::GetLoadedModsWithVersions(const ScriptInterface& scriptInterface) const -{ ScriptRequest rq(scriptInterface); JS::RootedValue returnValue(rq.cx); - Script::ToJSVal(rq, &returnValue, m_LoadedModVersions); + Script::ToJSVal(rq, &returnValue, loadedMods); return returnValue; } JS::Value Mod::GetEngineInfo(const ScriptInterface& scriptInterface) const { ScriptRequest rq(scriptInterface); JS::RootedValue mods(rq.cx, GetLoadedModsWithVersions(scriptInterface)); JS::RootedValue metainfo(rq.cx); Script::CreateObject( rq, &metainfo, "engine_version", engine_version, "mods", mods); Script::FreezeObject(rq, metainfo, true); return metainfo; } + +JS::Value Mod::GetAvailableMods(const ScriptRequest& rq) const +{ + JS::RootedValue ret(rq.cx, Script::CreateObject(rq)); + for (const ModData& data : m_AvailableMods) + { + JS::RootedValue json(rq.cx); + if (!Script::ParseJSON(rq, data.m_Text, &json)) + { + ScriptException::Raise(rq, "Error parsing mod.json of '%s'", data.m_Pathname.c_str()); + continue; + } + Script::SetProperty(rq, ret, data.m_Pathname.c_str(), json); + } + return ret.get(); +} Index: ps/trunk/source/ps/Mod.h =================================================================== --- ps/trunk/source/ps/Mod.h (revision 25545) +++ ps/trunk/source/ps/Mod.h (revision 25546) @@ -1,86 +1,110 @@ /* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * 0 A.D. is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with 0 A.D. If not, see . */ #ifndef INCLUDED_MOD #define INCLUDED_MOD #include "ps/CStr.h" #include "scriptinterface/ScriptForward.h" #include #define g_Mods (Mod::Instance()) class Mod { friend class TestMod; public: // Singleton-like interface. static Mod& Instance(); - JS::Value GetAvailableMods(const ScriptInterface& scriptInterface) const; const std::vector& GetEnabledMods() const; const std::vector& GetIncompatibleMods() const; /** * Enables specified mods (& mods required by the engine). * @param addPublic - if true, enable the public mod. * @return whether the mods were enabled successfully. This can fail if e.g. mods are incompatible. * If true, GetEnabledMods() should be non-empty, GetIncompatibleMods() empty. Otherwise, GetIncompatibleMods() is non-empty. */ bool EnableMods(const ScriptInterface& scriptInterface, const std::vector& mods, const bool addPublic); /** * Get the loaded mods and their version. * "user" mod and "mod" mod are ignored as they are irrelevant for compatibility checks. * * @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) const; /** * Gets info (version and mods loaded) on the running engine * * @param scriptInterface the ScriptInterface in which to create the return data. * @return list of objects containing data */ JS::Value GetEngineInfo(const ScriptInterface& scriptInterface) const; -private: /** - * This reads the version numbers from the launched mods. - * It caches the result, since the reading of zip files is slow and - * JS pages can request the version numbers too often easily. - * Make sure this is called after each MountMods call. + * Gets a dictionary of available mods and their complete, parsed mod.json data. */ - void CacheEnabledModVersions(const ScriptInterface& scriptInterface); + JS::Value GetAvailableMods(const ScriptRequest& rq) const; + + /** + * Fetches available mods and stores some metadata about them. + * This may open the zipped mod archives, depending on the situation, + * and/or try to write files to the user mod folder, + * which can be quite slow, so should be run rarely. + * TODO: if this did not need the scriptInterface to parse JSON, + * we could run it in different contexts and possibly cleaner. + */ + void UpdateAvailableMods(const ScriptInterface& scriptInterface); + + /** + * Parsed mod.json data for C++ usage. + */ + struct ModData + { + // 'Folder name' of the mod, e.g. 'public' for the main 0 A.D. mod. + CStr m_Pathname; + // "name" property in the mod.json + CStr m_Name; + + CStr m_Version; + std::vector m_Dependencies; + + // For convenience when exporting to JS, keep a record of the full file. + CStr m_Text; + }; + +private: /** * Checks a list of @a mods and returns the incompatible mods, if any. */ - std::vector CheckForIncompatibleMods(const ScriptInterface& scriptInterface, const std::vector& mods, const JS::RootedValue& availableMods) const; + std::vector CheckForIncompatibleMods(const std::vector& mods) const; bool CompareVersionStrings(const CStr& required, const CStr& op, const CStr& version) const; std::vector m_EnabledMods; // Of the currently loaded mods, these are the incompatible with the engine and cannot be loaded. std::vector m_IncompatibleMods; - std::vector> m_LoadedModVersions; + std::vector m_AvailableMods; }; #endif // INCLUDED_MOD Index: ps/trunk/source/ps/tests/test_Mod.h =================================================================== --- ps/trunk/source/ps/tests/test_Mod.h (revision 25545) +++ ps/trunk/source/ps/tests/test_Mod.h (revision 25546) @@ -1,180 +1,133 @@ /* 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 * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "lib/self_test.h" #include "ps/CLogger.h" #include "ps/Mod.h" #include "scriptinterface/JSON.h" #include "scriptinterface/ScriptInterface.h" class TestMod : public CxxTest::TestSuite { Mod m_Mods; public: void test_version_check() { CStr eq = "="; CStr lt = "<"; CStr gt = ">"; CStr leq = "<="; CStr geq = ">="; CStr required = "0.0.24";// 0ad <= required CStr version = "0.0.24";// 0ad version // 0.0.24 = 0.0.24 TS_ASSERT(m_Mods.CompareVersionStrings(version, eq, required)); TS_ASSERT(!m_Mods.CompareVersionStrings(version, lt, required)); TS_ASSERT(!m_Mods.CompareVersionStrings(version, gt, required)); TS_ASSERT(m_Mods.CompareVersionStrings(version, leq, required)); TS_ASSERT(m_Mods.CompareVersionStrings(version, geq, required)); // 0.0.23 <= 0.0.24 version = "0.0.23"; TS_ASSERT(!m_Mods.CompareVersionStrings(version, eq, required)); TS_ASSERT(m_Mods.CompareVersionStrings(version, lt, required)); TS_ASSERT(!m_Mods.CompareVersionStrings(version, gt, required)); TS_ASSERT(m_Mods.CompareVersionStrings(version, leq, required)); TS_ASSERT(!m_Mods.CompareVersionStrings(version, geq, required)); // 0.0.25 >= 0.0.24 version = "0.0.25"; TS_ASSERT(!m_Mods.CompareVersionStrings(version, eq, required)); TS_ASSERT(!m_Mods.CompareVersionStrings(version, lt, required)); TS_ASSERT(m_Mods.CompareVersionStrings(version, gt, required)); TS_ASSERT(!m_Mods.CompareVersionStrings(version, leq, required)); TS_ASSERT(m_Mods.CompareVersionStrings(version, geq, required)); // 0.0.9 <= 0.1.0 version = "0.0.9"; required = "0.1.0"; TS_ASSERT(!m_Mods.CompareVersionStrings(version, eq, required)); TS_ASSERT(m_Mods.CompareVersionStrings(version, lt, required)); TS_ASSERT(!m_Mods.CompareVersionStrings(version, gt, required)); TS_ASSERT(m_Mods.CompareVersionStrings(version, leq, required)); TS_ASSERT(!m_Mods.CompareVersionStrings(version, geq, required)); // 5.3 <= 5.3.0 version = "5.3"; required = "5.3.0"; TS_ASSERT(!m_Mods.CompareVersionStrings(version, eq, required)); TS_ASSERT(m_Mods.CompareVersionStrings(version, lt, required)); TS_ASSERT(!m_Mods.CompareVersionStrings(version, gt, required)); TS_ASSERT(m_Mods.CompareVersionStrings(version, leq, required)); TS_ASSERT(!m_Mods.CompareVersionStrings(version, geq, required)); } void test_compatible() { ScriptInterface script("Test", "Test", g_ScriptContext); ScriptRequest rq(script); JS::RootedObject obj(rq.cx, JS_NewPlainObject(rq.cx)); - CStr jsonString = "{\ - \"name\": \"0ad\",\ - \"version\" : \"0.0.25\",\ - \"label\" : \"0 A.D. Empires Ascendant\",\ - \"url\" : \"https://play0ad.com\",\ - \"description\" : \"A free, open-source, historical RTS game.\",\ - \"dependencies\" : []\ - }\ - "; - JS::RootedValue json(rq.cx); - TS_ASSERT(Script::ParseJSON(rq, jsonString, &json)); - JS_SetProperty(rq.cx, obj, "public", json); - - JS::RootedValue jsonW(rq.cx); - CStr jsonStringW = "{\ - \"name\": \"wrong\",\ - \"version\" : \"0.0.25\",\ - \"label\" : \"wrong mod\",\ - \"url\" : \"\",\ - \"description\" : \"fail\",\ - \"dependencies\" : [\"0ad=0.0.24\"]\ - }\ - "; - TS_ASSERT(Script::ParseJSON(rq, jsonStringW, &jsonW)); - JS_SetProperty(rq.cx, obj, "wrong", jsonW); - - JS::RootedValue jsonG(rq.cx); - CStr jsonStringG = "{\ - \"name\": \"good\",\ - \"version\" : \"0.0.25\",\ - \"label\" : \"good mod\",\ - \"url\" : \"\",\ - \"description\" : \"ok\",\ - \"dependencies\" : [\"0ad=0.0.25\"]\ - }\ - "; - TS_ASSERT(Script::ParseJSON(rq, jsonStringG, &jsonG)); - JS_SetProperty(rq.cx, obj, "good", jsonG); - - JS::RootedValue jsonG2(rq.cx); - CStr jsonStringG2 = "{\ - \"name\": \"good\",\ - \"version\" : \"0.0.25\",\ - \"label\" : \"good mod\",\ - \"url\" : \"\",\ - \"description\" : \"ok\",\ - \"dependencies\" : [\"0ad>=0.0.24\"]\ - }\ - "; - TS_ASSERT(Script::ParseJSON(rq, jsonStringG2, &jsonG2)); - JS_SetProperty(rq.cx, obj, "good2", jsonG2); - - JS::RootedValue availableMods(rq.cx, JS::ObjectValue(*obj)); + m_Mods.m_AvailableMods = { + Mod::ModData{ "public", "0ad", "0.0.25", {}, "" }, + Mod::ModData{ "wrong", "wrong", "0.0.1", { "0ad=0.0.24" }, "" }, + Mod::ModData{ "good", "good", "0.0.2", { "0ad=0.0.25" }, "" }, + Mod::ModData{ "good2", "good2", "0.0.4", { "0ad>=0.0.24" }, "" }, + }; std::vector mods; mods.clear(); mods.push_back("public"); - TS_ASSERT(m_Mods.CheckForIncompatibleMods(script, mods, availableMods).empty()); + TS_ASSERT(m_Mods.CheckForIncompatibleMods(mods).empty()); mods.clear(); mods.push_back("mod"); mods.push_back("public"); - TS_ASSERT(m_Mods.CheckForIncompatibleMods(script, mods, availableMods).empty()); + TS_ASSERT(m_Mods.CheckForIncompatibleMods(mods).empty()); mods.clear(); mods.push_back("public"); mods.push_back("good"); - TS_ASSERT(m_Mods.CheckForIncompatibleMods(script, mods, availableMods).empty()); + TS_ASSERT(m_Mods.CheckForIncompatibleMods(mods).empty()); mods.clear(); mods.push_back("public"); mods.push_back("good2"); - TS_ASSERT(m_Mods.CheckForIncompatibleMods(script, mods, availableMods).empty()); + TS_ASSERT(m_Mods.CheckForIncompatibleMods(mods).empty()); mods.clear(); mods.push_back("public"); mods.push_back("wrong"); - TS_ASSERT(!m_Mods.CheckForIncompatibleMods(script, mods, availableMods).empty()); + TS_ASSERT(!m_Mods.CheckForIncompatibleMods(mods).empty()); mods.clear(); mods.push_back("public"); mods.push_back("does_not_exist"); - TS_ASSERT(!m_Mods.CheckForIncompatibleMods(script, mods, availableMods).empty()); + TS_ASSERT(!m_Mods.CheckForIncompatibleMods(mods).empty()); } };