1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Fix string ID's road/river/terrains

This commit is contained in:
Ivan Savenko 2023-02-13 00:07:28 +02:00
parent acdb8d6e06
commit 190368e419
6 changed files with 36 additions and 23 deletions

View File

@ -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<bool> 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

View File

@ -21,12 +21,13 @@ class DLL_LINKAGE RiverType : public EntityT<RiverId>
{
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;
}

View File

@ -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<bool> 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

View File

@ -21,12 +21,13 @@ class DLL_LINKAGE RoadType : public EntityT<RoadId>
{
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;
}

View File

@ -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<int>(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

View File

@ -22,13 +22,14 @@ class DLL_LINKAGE TerrainType : public EntityT<TerrainId>
{
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;