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

Added common method to get names of hardcoded mod scopes

This commit is contained in:
Ivan Savenko
2022-12-07 15:18:19 +02:00
parent 65f9a1ffd2
commit 2cbe6bcb47
27 changed files with 119 additions and 64 deletions

View File

@@ -21,6 +21,8 @@ class Entity;
class DLL_LINKAGE IHandlerBase
{
protected:
std::string getScopeBuiltin() const;
/// Calls modhandler. Mostly needed to avoid large number of includes in headers
void registerObject(std::string scope, std::string type_name, std::string name, si32 index);
std::string normalizeIdentifier(const std::string & scope, const std::string & remoteScope, const std::string & identifier) const;
@@ -92,7 +94,7 @@ public:
void loadObject(std::string scope, std::string name, const JsonNode & data) override
{
auto object = loadFromJson(scope, data, normalizeIdentifier(scope, "core", name), objects.size());
auto object = loadFromJson(scope, data, normalizeIdentifier(scope, getScopeBuiltin(), name), objects.size());
objects.push_back(object);
@@ -102,7 +104,7 @@ public:
void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override
{
auto object = loadFromJson(scope, data, normalizeIdentifier(scope, "core", name), index);
auto object = loadFromJson(scope, data, normalizeIdentifier(scope, getScopeBuiltin(), name), index);
assert(objects[index] == nullptr); // ensure that this id was not loaded before
objects[index] = object;