1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Split massive CModHandler class/file into multiple parts:

- IdentifierStorage is now a separate handler in VLC
- Renamed ModHandler::Incompatibility exception to ModIncompatibility
- Extracted ModScope namespace from ModHandler
- Extracted ModUtilities namespace from ModHandler
- Split CModHandler.cpp on per-class basis
- Replaced some direct members with unique_ptr to reduce header includes
This commit is contained in:
Ivan Savenko
2023-07-30 20:12:25 +03:00
parent 8ea7e91189
commit 62fddca21e
101 changed files with 1532 additions and 1279 deletions

View File

@@ -16,7 +16,6 @@
#include "../GameConstants.h"
#include "../StringConstants.h"
#include "../CGeneralTextHandler.h"
#include "../CModHandler.h"
#include "../GameSettings.h"
#include "../JsonNode.h"
#include "../CSoundBase.h"
@@ -36,7 +35,8 @@
#include "../mapObjects/MiscObjects.h"
#include "../mapObjects/CGHeroInstance.h"
#include "../mapObjects/CGTownInstance.h"
#include "../modding/IdentifierStorage.h"
#include "../modding/CModHandler.h"
VCMI_LIB_NAMESPACE_BEGIN
@@ -277,7 +277,7 @@ void CObjectClassesHandler::loadObject(std::string scope, std::string name, cons
{
auto * object = loadFromJson(scope, data, name, objects.size());
objects.push_back(object);
VLC->modh->identifiers.registerObject(scope, "object", name, object->id);
VLC->modh->getIdentifiers().registerObject(scope, "object", name, object->id);
}
void CObjectClassesHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
@@ -285,7 +285,7 @@ void CObjectClassesHandler::loadObject(std::string scope, std::string name, cons
auto * object = loadFromJson(scope, data, name, index);
assert(objects[(si32)index] == nullptr); // ensure that this id was not loaded before
objects[static_cast<si32>(index)] = object;
VLC->modh->identifiers.registerObject(scope, "object", name, object->id);
VLC->modh->getIdentifiers().registerObject(scope, "object", name, object->id);
}
void CObjectClassesHandler::loadSubObject(const std::string & identifier, JsonNode config, si32 ID, si32 subID)
@@ -325,11 +325,11 @@ TObjectTypeHandler CObjectClassesHandler::getHandlerFor(si32 type, si32 subtype)
TObjectTypeHandler CObjectClassesHandler::getHandlerFor(const std::string & scope, const std::string & type, const std::string & subtype) const
{
std::optional<si32> id = VLC->modh->identifiers.getIdentifier(scope, "object", type);
std::optional<si32> id = VLC->identifiers()->getIdentifier(scope, "object", type);
if(id)
{
auto * object = objects[id.value()];
std::optional<si32> subID = VLC->modh->identifiers.getIdentifier(scope, object->getJsonKey(), subtype);
std::optional<si32> subID = VLC->identifiers()->getIdentifier(scope, object->getJsonKey(), subtype);
if (subID)
return object->objects[subID.value()];