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

initializer lists part1

This commit is contained in:
AlexVinS
2014-10-02 19:43:46 +04:00
parent 463b9e46b3
commit 66b022f93e
20 changed files with 285 additions and 222 deletions

View File

@@ -199,8 +199,13 @@ CRmgTemplate::CSize CJsonRmgTemplateLoader::parseMapTemplateSize(const std::stri
std::vector<std::string> parts;
boost::split(parts, text, boost::is_any_of("+"));
static const std::map<std::string, int> mapSizeMapping = boost::assign::map_list_of("s", CMapHeader::MAP_SIZE_SMALL)
("m", CMapHeader::MAP_SIZE_MIDDLE)("l", CMapHeader::MAP_SIZE_LARGE)("xl", CMapHeader::MAP_SIZE_XLARGE);
static const std::map<std::string, int> mapSizeMapping =
{
{"s", CMapHeader::MAP_SIZE_SMALL},
{"m", CMapHeader::MAP_SIZE_MIDDLE},
{"l", CMapHeader::MAP_SIZE_LARGE},
{"xl", CMapHeader::MAP_SIZE_XLARGE},
};
auto it = mapSizeMapping.find(parts[0]);
if(it == mapSizeMapping.end())
{
@@ -224,9 +229,13 @@ CRmgTemplate::CSize CJsonRmgTemplateLoader::parseMapTemplateSize(const std::stri
ETemplateZoneType::ETemplateZoneType CJsonRmgTemplateLoader::parseZoneType(const std::string & type) const
{
static const std::map<std::string, ETemplateZoneType::ETemplateZoneType> zoneTypeMapping = boost::assign::map_list_of
("playerStart", ETemplateZoneType::PLAYER_START)("cpuStart", ETemplateZoneType::CPU_START)
("treasure", ETemplateZoneType::TREASURE)("junction", ETemplateZoneType::JUNCTION);
static const std::map<std::string, ETemplateZoneType::ETemplateZoneType> zoneTypeMapping =
{
{"playerStart", ETemplateZoneType::PLAYER_START},
{"cpuStart", ETemplateZoneType::CPU_START},
{"treasure", ETemplateZoneType::TREASURE},
{"junction", ETemplateZoneType::JUNCTION},
};
auto it = zoneTypeMapping.find(type);
if(it == zoneTypeMapping.end()) throw std::runtime_error("Zone type unknown.");
return it->second;
@@ -333,4 +342,4 @@ CRmgTemplateStorage::CRmgTemplateStorage()
CRmgTemplateStorage::~CRmgTemplateStorage()
{
for (auto & pair : templates) delete pair.second;
}
}