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

Rmg water support (#751)

* Roads added to shipyard
* Load general rmg parameters from config
* Fix issue with default zone guard
* Move magic numbers related to balance to randomMap.json
This commit is contained in:
Nordsoft91
2022-06-05 09:02:58 +03:00
committed by Andrii Danylchenko
parent 5c1a66ab69
commit 5054ee011a
8 changed files with 323 additions and 128 deletions

View File

@@ -10,6 +10,7 @@
#include "StdInc.h"
#include <vstd/ContainerUtils.h>
#include <boost/bimap.hpp>
#include "CRmgTemplate.h"
#include "../mapping/CMap.h"
@@ -359,7 +360,7 @@ void ZoneOptions::serializeJson(JsonSerializeFormat & handler)
rawStrength = static_cast<decltype(rawStrength)>(zoneMonsterStrength);
rawStrength++;
}
handler.serializeEnum("monsters", rawStrength, STRENGTH);
handler.serializeEnum("monsters", rawStrength, EMonsterStrength::ZONE_NORMAL + 1, STRENGTH);
if(!handler.saving)
{
rawStrength--;
@@ -443,6 +444,11 @@ bool CRmgTemplate::isWaterContentAllowed(EWaterContent::EWaterContent waterConte
return waterContent == EWaterContent::EWaterContent::RANDOM || allowedWaterContent.count(waterContent);
}
const std::set<EWaterContent::EWaterContent> & CRmgTemplate::getWaterContentAllowed() const
{
return allowedWaterContent;
}
void CRmgTemplate::setId(const std::string & value)
{
id = value;
@@ -583,6 +589,32 @@ void CRmgTemplate::serializeJson(JsonSerializeFormat & handler)
auto connectionsData = handler.enterArray("connections");
connectionsData.serializeStruct(connections);
}
{
boost::bimap<EWaterContent::EWaterContent, std::string> enc;
enc.insert({EWaterContent::NONE, "none"});
enc.insert({EWaterContent::NORMAL, "normal"});
enc.insert({EWaterContent::ISLANDS, "islands"});
JsonNode node;
if(handler.saving)
{
node.setType(JsonNode::JsonType::DATA_VECTOR);
for(auto wc : allowedWaterContent)
{
JsonNode n;
n.String() = enc.left.at(wc);
node.Vector().push_back(n);
}
}
handler.serializeRaw("allowedWaterContent", node, boost::none);
if(!handler.saving)
{
for(auto wc : node.Vector())
{
allowedWaterContent.insert(enc.right.at(std::string(wc.String())));
}
}
}
{
auto zonesData = handler.enterStruct("zones");