2012-08-10 16:07:53 +03:00
|
|
|
/*
|
|
|
|
* CModHandler.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "JsonNode.h"
|
2012-08-10 16:07:53 +03:00
|
|
|
|
2022-12-13 03:55:54 +02:00
|
|
|
#ifdef __UCLIBC__
|
|
|
|
#undef major
|
|
|
|
#undef minor
|
|
|
|
#undef patch
|
|
|
|
#endif
|
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2012-08-10 16:07:53 +03:00
|
|
|
class CModHandler;
|
|
|
|
class CModIndentifier;
|
|
|
|
class CModInfo;
|
2012-11-13 14:52:23 +03:00
|
|
|
class JsonNode;
|
2013-04-21 15:49:26 +03:00
|
|
|
class IHandlerBase;
|
2012-08-10 16:07:53 +03:00
|
|
|
|
2012-12-03 19:00:17 +03:00
|
|
|
/// class that stores all object identifiers strings and maps them to numeric ID's
|
|
|
|
/// if possible, objects ID's should be in format <type>.<name>, camelCase e.g. "creature.grandElf"
|
2023-01-25 13:10:48 +02:00
|
|
|
class DLL_LINKAGE CIdentifierStorage
|
2012-12-03 19:00:17 +03:00
|
|
|
{
|
2014-06-15 23:25:10 +03:00
|
|
|
enum ELoadingState
|
|
|
|
{
|
|
|
|
LOADING,
|
|
|
|
FINALIZING,
|
|
|
|
FINISHED
|
|
|
|
};
|
|
|
|
|
2013-04-25 17:03:35 +03:00
|
|
|
struct ObjectCallback // entry created on ID request
|
|
|
|
{
|
|
|
|
std::string localScope; /// scope from which this ID was requested
|
|
|
|
std::string remoteScope; /// scope in which this object must be found
|
|
|
|
std::string type; /// type, e.g. creature, faction, hero, etc
|
|
|
|
std::string name; /// string ID
|
2013-06-26 14:18:27 +03:00
|
|
|
std::function<void(si32)> callback;
|
2013-12-02 14:58:02 +03:00
|
|
|
bool optional;
|
2013-04-25 17:03:35 +03:00
|
|
|
|
2023-04-03 14:14:34 +02:00
|
|
|
/// Builds callback from identifier in form "targetMod:type.name"
|
|
|
|
static ObjectCallback fromNameWithType(const std::string & scope, const std::string & fullName, const std::function<void(si32)> & callback, bool optional);
|
|
|
|
|
|
|
|
/// Builds callback from identifier in form "targetMod:name"
|
|
|
|
static ObjectCallback fromNameAndType(const std::string & scope, const std::string & type, const std::string & fullName, const std::function<void(si32)> & callback, bool optional);
|
|
|
|
|
|
|
|
private:
|
|
|
|
ObjectCallback() = default;
|
2013-04-25 17:03:35 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ObjectData // entry created on ID registration
|
|
|
|
{
|
|
|
|
si32 id;
|
|
|
|
std::string scope; /// scope in which this ID located
|
2014-02-02 17:31:56 +03:00
|
|
|
|
2017-08-23 14:15:33 +02:00
|
|
|
bool operator==(const ObjectData & other) const
|
|
|
|
{
|
|
|
|
return id == other.id && scope == other.scope;
|
|
|
|
}
|
2014-02-02 17:31:56 +03:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
2017-07-31 15:35:42 +02:00
|
|
|
h & id;
|
|
|
|
h & scope;
|
2014-02-02 17:31:56 +03:00
|
|
|
}
|
2013-04-25 17:03:35 +03:00
|
|
|
};
|
|
|
|
|
2017-08-25 08:29:34 +02:00
|
|
|
std::multimap<std::string, ObjectData> registeredObjects;
|
2013-04-25 17:03:35 +03:00
|
|
|
std::vector<ObjectCallback> scheduledRequests;
|
2012-12-03 19:00:17 +03:00
|
|
|
|
2014-06-15 23:25:10 +03:00
|
|
|
ELoadingState state;
|
|
|
|
|
2013-04-21 15:49:26 +03:00
|
|
|
/// Check if identifier can be valid (camelCase, point as separator)
|
2023-03-13 23:26:44 +02:00
|
|
|
static void checkIdentifier(std::string & ID);
|
2013-04-25 17:03:35 +03:00
|
|
|
|
|
|
|
void requestIdentifier(ObjectCallback callback);
|
|
|
|
bool resolveIdentifier(const ObjectCallback & callback);
|
2013-12-31 02:09:58 +03:00
|
|
|
std::vector<ObjectData> getPossibleIdentifiers(const ObjectCallback & callback);
|
2012-12-03 19:00:17 +03:00
|
|
|
public:
|
2014-06-15 23:25:10 +03:00
|
|
|
CIdentifierStorage();
|
2023-03-13 23:26:44 +02:00
|
|
|
virtual ~CIdentifierStorage() = default;
|
2013-12-02 14:58:02 +03:00
|
|
|
/// request identifier for specific object name.
|
|
|
|
/// Function callback will be called during ID resolution phase of loading
|
2023-03-13 23:26:44 +02:00
|
|
|
void requestIdentifier(const std::string & scope, const std::string & type, const std::string & name, const std::function<void(si32)> & callback);
|
2014-11-12 04:50:51 +02:00
|
|
|
///fullName = [remoteScope:]type.name
|
2023-03-13 23:26:44 +02:00
|
|
|
void requestIdentifier(const std::string & scope, const std::string & fullName, const std::function<void(si32)> & callback);
|
|
|
|
void requestIdentifier(const std::string & type, const JsonNode & name, const std::function<void(si32)> & callback);
|
2013-06-26 14:18:27 +03:00
|
|
|
void requestIdentifier(const JsonNode & name, const std::function<void(si32)> & callback);
|
2013-04-25 17:03:35 +03:00
|
|
|
|
2013-12-02 14:58:02 +03:00
|
|
|
/// try to request ID. If ID with such name won't be loaded, callback function will not be called
|
2023-03-13 23:26:44 +02:00
|
|
|
void tryRequestIdentifier(const std::string & scope, const std::string & type, const std::string & name, const std::function<void(si32)> & callback);
|
|
|
|
void tryRequestIdentifier(const std::string & type, const JsonNode & name, const std::function<void(si32)> & callback);
|
2013-12-02 14:58:02 +03:00
|
|
|
|
|
|
|
/// get identifier immediately. If identifier is not know and not silent call will result in error message
|
2023-04-16 19:42:56 +02:00
|
|
|
std::optional<si32> getIdentifier(const std::string & scope, const std::string & type, const std::string & name, bool silent = false);
|
|
|
|
std::optional<si32> getIdentifier(const std::string & type, const JsonNode & name, bool silent = false);
|
|
|
|
std::optional<si32> getIdentifier(const JsonNode & name, bool silent = false);
|
|
|
|
std::optional<si32> getIdentifier(const std::string & scope, const std::string & fullName, bool silent = false);
|
2013-12-02 14:58:02 +03:00
|
|
|
|
|
|
|
/// registers new object
|
2023-03-13 23:26:44 +02:00
|
|
|
void registerObject(const std::string & scope, const std::string & type, const std::string & name, si32 identifier);
|
2012-12-03 19:00:17 +03:00
|
|
|
|
|
|
|
/// called at the very end of loading to check for any missing ID's
|
2013-04-21 15:49:26 +03:00
|
|
|
void finalize();
|
2014-02-02 17:31:56 +03:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
2017-07-31 15:35:42 +02:00
|
|
|
h & registeredObjects;
|
|
|
|
h & state;
|
2014-02-02 17:31:56 +03:00
|
|
|
}
|
2013-04-21 15:49:26 +03:00
|
|
|
};
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
/// internal type to handle loading of one data type (e.g. artifacts, creatures)
|
|
|
|
class DLL_LINKAGE ContentTypeHandler
|
2013-04-21 15:49:26 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
public:
|
|
|
|
struct ModInfo
|
2013-04-21 15:49:26 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
/// mod data from this mod and for this mod
|
|
|
|
JsonNode modData;
|
|
|
|
/// mod data for this mod from other mods (patches)
|
|
|
|
JsonNode patches;
|
2013-04-21 15:49:26 +03:00
|
|
|
};
|
2017-07-20 06:08:49 +02:00
|
|
|
/// handler to which all data will be loaded
|
|
|
|
IHandlerBase * handler;
|
|
|
|
std::string objectName;
|
|
|
|
|
|
|
|
/// contains all loaded H3 data
|
|
|
|
std::vector<JsonNode> originalData;
|
|
|
|
std::map<std::string, ModInfo> modData;
|
2013-04-21 15:49:26 +03:00
|
|
|
|
2023-03-13 23:26:44 +02:00
|
|
|
ContentTypeHandler(IHandlerBase * handler, const std::string & objectName);
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
/// local version of methods in ContentHandler
|
|
|
|
/// returns true if loading was successful
|
2023-03-13 23:26:44 +02:00
|
|
|
bool preloadModData(const std::string & modName, const std::vector<std::string> & fileList, bool validate);
|
|
|
|
bool loadMod(const std::string & modName, bool validate);
|
2017-07-20 06:08:49 +02:00
|
|
|
void loadCustom();
|
|
|
|
void afterLoadFinalization();
|
|
|
|
};
|
|
|
|
|
|
|
|
/// class used to load all game data into handlers. Used only during loading
|
|
|
|
class DLL_LINKAGE CContentHandler
|
|
|
|
{
|
2013-11-11 23:11:51 +03:00
|
|
|
/// preloads all data from fileList as data from modName.
|
2023-03-13 23:26:44 +02:00
|
|
|
bool preloadModData(const std::string & modName, JsonNode modConfig, bool validate);
|
2013-11-11 23:11:51 +03:00
|
|
|
|
|
|
|
/// actually loads data in mod
|
2023-03-13 23:26:44 +02:00
|
|
|
bool loadMod(const std::string & modName, bool validate);
|
2013-11-11 23:11:51 +03:00
|
|
|
|
2013-04-21 15:49:26 +03:00
|
|
|
std::map<std::string, ContentTypeHandler> handlers;
|
|
|
|
|
2023-03-13 23:26:44 +02:00
|
|
|
public:
|
2017-07-20 06:08:49 +02:00
|
|
|
void init();
|
|
|
|
|
2013-11-08 23:36:26 +03:00
|
|
|
/// preloads all data from fileList as data from modName.
|
2013-11-11 23:11:51 +03:00
|
|
|
void preloadData(CModInfo & mod);
|
2013-04-21 15:49:26 +03:00
|
|
|
|
|
|
|
/// actually loads data in mod
|
2013-11-11 23:11:51 +03:00
|
|
|
void load(CModInfo & mod);
|
2013-07-21 17:19:29 +03:00
|
|
|
|
2016-11-13 12:38:42 +02:00
|
|
|
void loadCustom();
|
|
|
|
|
2013-07-21 17:19:29 +03:00
|
|
|
/// all data was loaded, time for final validation / integration
|
|
|
|
void afterLoadFinalization();
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
const ContentTypeHandler & operator[] (const std::string & name) const;
|
2012-12-03 19:00:17 +03:00
|
|
|
};
|
|
|
|
|
2012-12-12 14:13:57 +03:00
|
|
|
typedef std::string TModID;
|
2012-08-10 16:07:53 +03:00
|
|
|
|
|
|
|
class DLL_LINKAGE CModInfo
|
|
|
|
{
|
|
|
|
public:
|
2013-11-11 23:11:51 +03:00
|
|
|
enum EValidationStatus
|
|
|
|
{
|
|
|
|
PENDING,
|
|
|
|
FAILED,
|
|
|
|
PASSED
|
|
|
|
};
|
2022-09-17 15:43:59 +02:00
|
|
|
|
|
|
|
struct Version
|
|
|
|
{
|
|
|
|
int major = 0;
|
|
|
|
int minor = 0;
|
|
|
|
int patch = 0;
|
|
|
|
|
|
|
|
Version() = default;
|
|
|
|
Version(int mj, int mi, int p): major(mj), minor(mi), patch(p) {}
|
|
|
|
|
|
|
|
static Version GameVersion();
|
|
|
|
static Version fromString(std::string from);
|
|
|
|
std::string toString() const;
|
|
|
|
|
|
|
|
bool compatible(const Version & other, bool checkMinor = false, bool checkPatch = false) const;
|
|
|
|
bool isNull() const;
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & major;
|
|
|
|
h & minor;
|
|
|
|
h & patch;
|
|
|
|
}
|
|
|
|
};
|
2013-11-11 23:11:51 +03:00
|
|
|
|
2012-12-12 14:13:57 +03:00
|
|
|
/// identifier, identical to name of folder with mod
|
|
|
|
std::string identifier;
|
|
|
|
|
|
|
|
/// human-readable strings
|
|
|
|
std::string name;
|
|
|
|
std::string description;
|
2022-09-17 15:43:59 +02:00
|
|
|
|
|
|
|
/// version of the mod
|
|
|
|
Version version;
|
2023-02-09 15:03:49 +02:00
|
|
|
|
|
|
|
/// Base language of mod, all mod strings are assumed to be in this language
|
|
|
|
std::string baseLanguage;
|
2022-09-17 15:43:59 +02:00
|
|
|
|
2022-09-18 23:18:17 +02:00
|
|
|
/// vcmi versions compatible with the mod
|
|
|
|
|
2022-09-17 15:43:59 +02:00
|
|
|
Version vcmiCompatibleMin, vcmiCompatibleMax;
|
2012-12-12 14:13:57 +03:00
|
|
|
|
2013-01-10 21:53:49 +03:00
|
|
|
/// list of mods that should be loaded before this one
|
|
|
|
std::set <TModID> dependencies;
|
2012-12-12 14:13:57 +03:00
|
|
|
|
2013-01-10 21:53:49 +03:00
|
|
|
/// list of mods that can't be used in the same time as this one
|
|
|
|
std::set <TModID> conflicts;
|
2012-08-10 16:07:53 +03:00
|
|
|
|
2013-11-08 23:36:26 +03:00
|
|
|
/// CRC-32 checksum of the mod
|
|
|
|
ui32 checksum;
|
|
|
|
|
2013-11-11 23:11:51 +03:00
|
|
|
EValidationStatus validation;
|
|
|
|
|
|
|
|
JsonNode config;
|
|
|
|
|
2016-11-27 21:07:01 +02:00
|
|
|
CModInfo();
|
2023-03-13 23:26:44 +02:00
|
|
|
CModInfo(const std::string & identifier, const JsonNode & local, const JsonNode & config);
|
2013-11-11 23:11:51 +03:00
|
|
|
|
2014-03-15 13:57:34 +03:00
|
|
|
JsonNode saveLocalData() const;
|
2013-11-11 23:11:51 +03:00
|
|
|
void updateChecksum(ui32 newChecksum);
|
2012-08-10 16:07:53 +03:00
|
|
|
|
2023-03-14 15:59:33 +02:00
|
|
|
bool isEnabled() const;
|
|
|
|
void setEnabled(bool on);
|
|
|
|
|
2023-03-13 23:26:44 +02:00
|
|
|
static std::string getModDir(const std::string & name);
|
|
|
|
static std::string getModFile(const std::string & name);
|
2014-03-15 13:57:34 +03:00
|
|
|
|
2013-11-11 23:11:51 +03:00
|
|
|
private:
|
2023-03-14 15:59:33 +02:00
|
|
|
/// true if mod is enabled by user, e.g. in Launcher UI
|
|
|
|
bool explicitlyEnabled;
|
|
|
|
|
|
|
|
/// true if mod can be loaded - compatible and has no missing deps
|
|
|
|
bool implicitlyEnabled;
|
|
|
|
|
2013-11-11 23:11:51 +03:00
|
|
|
void loadLocalData(const JsonNode & data);
|
2012-08-10 16:07:53 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE CModHandler
|
|
|
|
{
|
2012-11-13 14:52:23 +03:00
|
|
|
std::map <TModID, CModInfo> allMods;
|
2012-12-12 14:13:57 +03:00
|
|
|
std::vector <TModID> activeMods;//active mods, in order in which they were loaded
|
2013-11-11 23:11:51 +03:00
|
|
|
CModInfo coreMod;
|
2012-08-10 16:07:53 +03:00
|
|
|
|
2023-03-13 23:26:44 +02:00
|
|
|
bool hasCircularDependency(const TModID & mod, std::set<TModID> currentList = std::set<TModID>()) const;
|
2013-01-10 21:53:49 +03:00
|
|
|
|
2021-04-10 17:23:58 +02:00
|
|
|
/**
|
|
|
|
* 1. Set apart mods with resolved dependencies from mods which have unresolved dependencies
|
|
|
|
* 2. Sort resolved mods using topological algorithm
|
|
|
|
* 3. Log all problem mods and their unresolved dependencies
|
|
|
|
*
|
|
|
|
* @param modsToResolve list of valid mod IDs (checkDependencies returned true - TODO: Clarify it.)
|
|
|
|
* @return a vector of the topologically sorted resolved mods: child nodes (dependent mods) have greater index than parents
|
|
|
|
*/
|
|
|
|
std::vector <TModID> validateAndSortDependencies(std::vector <TModID> modsToResolve) const;
|
2014-03-15 13:57:34 +03:00
|
|
|
|
2023-03-13 23:26:44 +02:00
|
|
|
std::vector<std::string> getModList(const std::string & path) const;
|
|
|
|
void loadMods(const std::string & path, const std::string & parent, const JsonNode & modSettings, bool enableMods);
|
|
|
|
void loadOneMod(std::string modName, const std::string & parent, const JsonNode & modSettings, bool enableMods);
|
|
|
|
void loadTranslation(const TModID & modName);
|
2023-02-09 19:15:39 +02:00
|
|
|
|
|
|
|
bool validateTranslations(TModID modName) const;
|
2012-12-03 19:00:17 +03:00
|
|
|
public:
|
2022-12-07 15:18:19 +02:00
|
|
|
|
|
|
|
/// returns true if scope is reserved for internal use and can not be used by mods
|
|
|
|
static bool isScopeReserved(const TModID & scope);
|
|
|
|
|
|
|
|
/// reserved scope name for referencing built-in (e.g. H3) objects
|
|
|
|
static const TModID & scopeBuiltin();
|
|
|
|
|
|
|
|
/// reserved scope name for accessing objects from any loaded mod
|
|
|
|
static const TModID & scopeGame();
|
|
|
|
|
|
|
|
/// reserved scope name for accessing object for map loading
|
|
|
|
static const TModID & scopeMap();
|
|
|
|
|
2022-09-23 13:20:11 +02:00
|
|
|
class DLL_LINKAGE Incompatibility: public std::exception
|
2022-09-17 15:43:59 +02:00
|
|
|
{
|
|
|
|
public:
|
2022-09-23 13:02:19 +02:00
|
|
|
using StringPair = std::pair<const std::string, const std::string>;
|
|
|
|
using ModList = std::list<StringPair>;
|
|
|
|
|
|
|
|
Incompatibility(ModList && _missingMods):
|
|
|
|
missingMods(std::move(_missingMods))
|
|
|
|
{
|
|
|
|
std::ostringstream _ss;
|
|
|
|
for(auto & m : missingMods)
|
|
|
|
_ss << m.first << ' ' << m.second << std::endl;
|
|
|
|
message = _ss.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char * what() const noexcept override
|
|
|
|
{
|
|
|
|
return message.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
//list of mods required to load the game
|
|
|
|
// first: mod name
|
|
|
|
// second: mod version
|
|
|
|
const ModList missingMods;
|
|
|
|
std::string message;
|
2022-09-17 15:43:59 +02:00
|
|
|
};
|
2013-04-02 20:06:43 +03:00
|
|
|
|
2012-12-03 19:00:17 +03:00
|
|
|
CIdentifierStorage identifiers;
|
|
|
|
|
2020-10-09 23:31:23 +02:00
|
|
|
std::shared_ptr<CContentHandler> content; //(!)Do not serialize
|
2017-07-20 06:08:49 +02:00
|
|
|
|
2012-12-12 14:13:57 +03:00
|
|
|
/// receives list of available mods and trying to load mod.json from all of them
|
2013-11-09 22:10:16 +03:00
|
|
|
void initializeConfig();
|
2017-07-20 06:08:49 +02:00
|
|
|
void loadMods(bool onlyEssential = false);
|
2014-03-15 13:57:34 +03:00
|
|
|
void loadModFilesystems();
|
2012-11-13 14:52:23 +03:00
|
|
|
|
2023-02-24 22:38:12 +02:00
|
|
|
/// returns ID of mod that provides selected file resource
|
|
|
|
TModID findResourceOrigin(const ResourceID & name);
|
|
|
|
|
2023-03-13 23:26:44 +02:00
|
|
|
std::string getModLanguage(const TModID & modId) const;
|
2023-02-09 15:03:49 +02:00
|
|
|
|
2023-03-13 23:26:44 +02:00
|
|
|
std::set<TModID> getModDependencies(const TModID & modId, bool & isModFound) const;
|
2013-04-25 17:03:35 +03:00
|
|
|
|
2014-03-15 13:57:34 +03:00
|
|
|
/// returns list of all (active) mods
|
|
|
|
std::vector<std::string> getAllMods();
|
|
|
|
std::vector<std::string> getActiveMods();
|
|
|
|
|
2012-11-13 14:52:23 +03:00
|
|
|
/// load content from all available mods
|
2013-11-09 22:10:16 +03:00
|
|
|
void load();
|
2017-07-20 06:08:49 +02:00
|
|
|
void afterLoad(bool onlyEssential);
|
2012-11-13 14:52:23 +03:00
|
|
|
|
2012-08-10 16:07:53 +03:00
|
|
|
CModHandler();
|
2023-03-13 23:26:44 +02:00
|
|
|
virtual ~CModHandler() = default;
|
2012-08-10 16:07:53 +03:00
|
|
|
|
2016-11-13 12:38:42 +02:00
|
|
|
static std::string normalizeIdentifier(const std::string & scope, const std::string & remoteScope, const std::string & identifier);
|
|
|
|
|
|
|
|
static void parseIdentifier(const std::string & fullIdentifier, std::string & scope, std::string & type, std::string & identifier);
|
|
|
|
|
|
|
|
static std::string makeFullIdentifier(const std::string & scope, const std::string & type, const std::string & identifier);
|
2015-11-16 16:38:42 +02:00
|
|
|
|
2012-08-10 16:07:53 +03:00
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
2022-09-17 15:43:59 +02:00
|
|
|
if(h.saving)
|
|
|
|
{
|
|
|
|
h & activeMods;
|
2022-09-18 23:18:17 +02:00
|
|
|
for(const auto & m : activeMods)
|
2022-09-17 15:43:59 +02:00
|
|
|
h & allMods[m].version;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-23 10:34:44 +02:00
|
|
|
loadMods();
|
2022-09-17 15:43:59 +02:00
|
|
|
std::vector<TModID> newActiveMods;
|
|
|
|
h & newActiveMods;
|
2022-09-23 13:02:19 +02:00
|
|
|
|
|
|
|
Incompatibility::ModList missingMods;
|
2022-09-24 11:03:46 +02:00
|
|
|
for(const auto & m : newActiveMods)
|
|
|
|
|
2022-09-17 15:43:59 +02:00
|
|
|
{
|
|
|
|
CModInfo::Version mver;
|
|
|
|
h & mver;
|
2022-09-23 13:02:19 +02:00
|
|
|
|
|
|
|
if(allMods.count(m) && (allMods[m].version.isNull() || mver.isNull() || allMods[m].version.compatible(mver)))
|
2023-03-14 15:59:33 +02:00
|
|
|
allMods[m].setEnabled(true);
|
2022-09-23 13:02:19 +02:00
|
|
|
else
|
|
|
|
missingMods.emplace_back(m, mver.toString());
|
2022-09-17 15:43:59 +02:00
|
|
|
}
|
2022-09-23 13:02:19 +02:00
|
|
|
|
|
|
|
if(!missingMods.empty())
|
|
|
|
throw Incompatibility(std::move(missingMods));
|
|
|
|
|
2022-09-17 15:43:59 +02:00
|
|
|
std::swap(activeMods, newActiveMods);
|
|
|
|
}
|
2023-03-15 21:34:29 +02:00
|
|
|
|
2017-07-31 15:35:42 +02:00
|
|
|
h & identifiers;
|
2012-08-10 16:07:53 +03:00
|
|
|
}
|
2012-08-10 18:16:42 +03:00
|
|
|
};
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|