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

replace RESOURCE_NAMES where possible

This commit is contained in:
Laserlicht
2025-09-14 20:43:53 +02:00
parent 81c64ce54f
commit a54a1f8b8d
17 changed files with 76 additions and 49 deletions

View File

@@ -239,7 +239,7 @@ void CGMine::serializeJsonOptions(JsonSerializeFormat & handler)
{
JsonNode node;
for(const auto & resID : abandonedMineResources)
node.Vector().emplace_back(GameConstants::RESOURCE_NAMES[resID.getNum()]);
node.Vector().emplace_back(LIBRARY->resourceTypeHandler->getById(resID)->getJsonKey());
handler.serializeRaw("possibleResources", node, std::nullopt);
}
@@ -252,7 +252,10 @@ void CGMine::serializeJsonOptions(JsonSerializeFormat & handler)
for(const std::string & s : names)
{
int raw_res = vstd::find_pos(GameConstants::RESOURCE_NAMES, s);
std::vector<std::string> resNames;
for(auto & res : LIBRARY->resourceTypeHandler->getAllObjects())
resNames.push_back(LIBRARY->resourceTypeHandler->getById(res)->getJsonKey());
int raw_res = vstd::find_pos(resNames, s);
if(raw_res < 0)
logGlobal->error("Invalid resource name: %s", s);
else