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

introduce toResourceType

This commit is contained in:
Laserlicht
2025-09-15 00:08:18 +02:00
parent acd067e587
commit d808bd6412
34 changed files with 160 additions and 102 deletions

View File

@@ -165,7 +165,7 @@ std::string CGMine::getHoverText(PlayerColor player) const
std::string hoverName = CArmedInstance::getHoverText(player);
if (tempOwner != PlayerColor::NEUTRAL)
hoverName += "\n(" + MetaString::createFromTextID(LIBRARY->resourceTypeHandler->getById(producedResource.getNum())->getNameTextID()).toString() + ")";
hoverName += "\n(" + MetaString::createFromTextID(producedResource.toResource()->getNameTextID()).toString() + ")";
if(stacksCount())
{
@@ -239,7 +239,7 @@ void CGMine::serializeJsonOptions(JsonSerializeFormat & handler)
{
JsonNode node;
for(const auto & resID : abandonedMineResources)
node.Vector().emplace_back(LIBRARY->resourceTypeHandler->getById(resID)->getJsonKey());
node.Vector().emplace_back(resID.toResource()->getJsonKey());
handler.serializeRaw("possibleResources", node, std::nullopt);
}
@@ -254,7 +254,7 @@ void CGMine::serializeJsonOptions(JsonSerializeFormat & handler)
{
std::vector<std::string> resNames;
for(auto & res : LIBRARY->resourceTypeHandler->getAllObjects())
resNames.push_back(LIBRARY->resourceTypeHandler->getById(res)->getJsonKey());
resNames.push_back(res.toResource()->getJsonKey());
int raw_res = vstd::find_pos(resNames, s);
if(raw_res < 0)
logGlobal->error("Invalid resource name: %s", s);