diff --git a/lib/RiverHandler.cpp b/lib/RiverHandler.cpp index 5fab8744b..761c632b6 100644 --- a/lib/RiverHandler.cpp +++ b/lib/RiverHandler.cpp @@ -33,11 +33,8 @@ RiverType * RiverTypeHandler::loadFromJson( RiverType * info = new RiverType; info->id = RiverId(index); - if (identifier.find(':') == std::string::npos) - info->identifier = scope + ":" + identifier; - else - info->identifier = identifier; - + info->identifier = identifier; + info->modScope = scope; info->tilesFilename = json["tilesFilename"].String(); info->shortIdentifier = json["shortIdentifier"].String(); info->deltaName = json["delta"].String(); @@ -64,9 +61,14 @@ std::vector RiverTypeHandler::getDefaultAllowed() const return {}; } +std::string RiverType::getJsonKey() const +{ + return modScope + ":" + identifier; +} + std::string RiverType::getNameTextID() const { - return TextIdentifier( "river", identifier, "name" ).get(); + return TextIdentifier( "river", modScope, identifier, "name" ).get(); } std::string RiverType::getNameTranslated() const @@ -76,7 +78,8 @@ std::string RiverType::getNameTranslated() const RiverType::RiverType(): id(River::NO_RIVER), - identifier("empty") + identifier("empty"), + modScope("core") {} VCMI_LIB_NAMESPACE_END diff --git a/lib/RiverHandler.h b/lib/RiverHandler.h index 627dde1de..a8348bd9d 100644 --- a/lib/RiverHandler.h +++ b/lib/RiverHandler.h @@ -21,12 +21,13 @@ class DLL_LINKAGE RiverType : public EntityT { friend class RiverTypeHandler; std::string identifier; + std::string modScope; RiverId id; public: int32_t getIndex() const override { return id.getNum(); } int32_t getIconIndex() const override { return 0; } - std::string getJsonKey() const override { return identifier;} + std::string getJsonKey() const override; void registerIcons(const IconRegistar & cb) const override {} RiverId getId() const override { return id;} void updateFrom(const JsonNode & data) {}; @@ -44,6 +45,7 @@ public: { h & tilesFilename; h & identifier; + h & modScope; h & deltaName; h & id; } diff --git a/lib/RoadHandler.cpp b/lib/RoadHandler.cpp index 1927808ba..d7ffbbde0 100644 --- a/lib/RoadHandler.cpp +++ b/lib/RoadHandler.cpp @@ -33,11 +33,8 @@ RoadType * RoadTypeHandler::loadFromJson( RoadType * info = new RoadType; info->id = RoadId(index); - if (identifier.find(':') == std::string::npos) - info->identifier = scope + ":" + identifier; - else - info->identifier = identifier; - + info->identifier = identifier; + info->modScope = scope; info->tilesFilename = json["tilesFilename"].String(); info->shortIdentifier = json["shortIdentifier"].String(); info->movementCost = json["moveCost"].Integer(); @@ -64,9 +61,14 @@ std::vector RoadTypeHandler::getDefaultAllowed() const return {}; } +std::string RoadType::getJsonKey() const +{ + return modScope + ":" + identifier; +} + std::string RoadType::getNameTextID() const { - return TextIdentifier( "road", identifier, "name" ).get(); + return TextIdentifier( "road", modScope, identifier, "name" ).get(); } std::string RoadType::getNameTranslated() const @@ -77,6 +79,7 @@ std::string RoadType::getNameTranslated() const RoadType::RoadType(): id(Road::NO_ROAD), identifier("empty"), + modScope("core"), movementCost(GameConstants::BASE_MOVEMENT_COST) {} VCMI_LIB_NAMESPACE_END diff --git a/lib/RoadHandler.h b/lib/RoadHandler.h index 0b84535b6..b31a886e6 100644 --- a/lib/RoadHandler.h +++ b/lib/RoadHandler.h @@ -21,12 +21,13 @@ class DLL_LINKAGE RoadType : public EntityT { friend class RoadTypeHandler; std::string identifier; + std::string modScope; RoadId id; public: int32_t getIndex() const override { return id.getNum(); } int32_t getIconIndex() const override { return 0; } - std::string getJsonKey() const override { return identifier;} + std::string getJsonKey() const override; void registerIcons(const IconRegistar & cb) const override {} RoadId getId() const override { return id;} void updateFrom(const JsonNode & data) {}; @@ -44,6 +45,7 @@ public: { h & tilesFilename; h & identifier; + h & modScope; h & id; h & movementCost; } diff --git a/lib/TerrainHandler.cpp b/lib/TerrainHandler.cpp index 96b8e79d8..42c41870a 100644 --- a/lib/TerrainHandler.cpp +++ b/lib/TerrainHandler.cpp @@ -22,12 +22,8 @@ TerrainType * TerrainTypeHandler::loadFromJson( const std::string & scope, const TerrainType * info = new TerrainType; info->id = TerrainId(index); - - if (identifier.find(':') == std::string::npos) - info->identifier = scope + ":" + identifier; - else - info->identifier = identifier; - + info->identifier = identifier; + info->modScope = scope; info->moveCost = static_cast(json["moveCost"].Integer()); info->musicFilename = json["music"].String(); info->tilesFilename = json["tiles"].String(); @@ -177,9 +173,14 @@ bool TerrainType::isTransitionRequired() const return transitionRequired; } +std::string TerrainType::getJsonKey() const +{ + return modScope + ":" + identifier; +} + std::string TerrainType::getNameTextID() const { - return TextIdentifier( "terrain", identifier, "name" ).get(); + return TextIdentifier( "terrain", modScope, identifier, "name" ).get(); } std::string TerrainType::getNameTranslated() const diff --git a/lib/TerrainHandler.h b/lib/TerrainHandler.h index 5d7ba3e1f..4dbb91fcf 100644 --- a/lib/TerrainHandler.h +++ b/lib/TerrainHandler.h @@ -22,13 +22,14 @@ class DLL_LINKAGE TerrainType : public EntityT { friend class TerrainTypeHandler; std::string identifier; + std::string modScope; TerrainId id; ui8 passabilityType; public: int32_t getIndex() const override { return id.getNum(); } int32_t getIconIndex() const override { return 0; } - std::string getJsonKey() const override { return identifier;} + std::string getJsonKey() const override; void registerIcons(const IconRegistar & cb) const override {} TerrainId getId() const override { return id;} void updateFrom(const JsonNode & data) {}; @@ -78,6 +79,7 @@ public: h & prohibitTransitions; h & minimapBlocked; h & minimapUnblocked; + h & modScope; h & identifier; h & musicFilename; h & tilesFilename;