1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

fix mine handler for rmg

This commit is contained in:
Laserlicht
2025-09-29 01:01:54 +02:00
parent 5ae4db60e3
commit 07659e3b25
3 changed files with 12 additions and 31 deletions

View File

@@ -251,35 +251,7 @@ void CGMine::serializeJsonOptions(JsonSerializeFormat & handler)
CArmedInstance::serializeJsonOptions(handler);
serializeJsonOwner(handler);
if(isAbandoned())
{
if(handler.saving)
{
JsonNode node;
for(const auto & resID : abandonedMineResources)
node.Vector().emplace_back(resID.toResource()->getJsonKey());
handler.serializeRaw("possibleResources", node, std::nullopt);
}
else
{
auto guard = handler.enterArray("possibleResources");
const JsonNode & node = handler.getCurrent();
auto names = node.convertTo<std::vector<std::string>>();
for(const std::string & s : names)
{
std::vector<std::string> resNames;
for(auto & res : LIBRARY->resourceTypeHandler->getAllObjects())
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);
else
abandonedMineResources.emplace(raw_res);
}
}
}
handler.serializeIdArray<GameResID>("possibleResources", abandonedMineResources);
}
bool CGTeleport::isEntrance() const