parent
35e34c7331
commit
a1ee3fb26e
7 changed files with 16 additions and 15 deletions
|
@ -103,7 +103,7 @@ game_state::~game_state() {}
|
|||
static int placing_score(const config& side, const gamemap& map, const map_location& pos)
|
||||
{
|
||||
int positions = 0, liked = 0;
|
||||
const t_translation::ter_list terrain = t_translation::read_list(side["terrain_liked"]);
|
||||
const t_translation::ter_list terrain = t_translation::read_list(side["terrain_liked"].str());
|
||||
|
||||
for(int i = -8; i != 8; ++i) {
|
||||
for(int j = -8; j != +8; ++j) {
|
||||
|
|
|
@ -204,7 +204,7 @@ namespace {
|
|||
, max_temp(cfg["max_temperature"].to_int(100000))
|
||||
, min_height(cfg["min_height"].to_int(-100000))
|
||||
, max_height(cfg["max_height"].to_int(100000))
|
||||
, from(t_translation::read_list(cfg["from"]))
|
||||
, from(t_translation::read_list(cfg["from"].str()))
|
||||
, to(t_translation::NONE_TERRAIN)
|
||||
{
|
||||
const std::string& to_str = cfg["to"];
|
||||
|
@ -630,7 +630,7 @@ static map_location place_village(const t_translation::ter_map& map,
|
|||
if(l != adj_liked_cache.end()) {
|
||||
adjacent_liked = &(l->second);
|
||||
} else {
|
||||
adj_liked_cache[t] = t_translation::read_list(child["adjacent_liked"]);
|
||||
adj_liked_cache[t] = t_translation::read_list(child["adjacent_liked"].str());
|
||||
adjacent_liked = &(adj_liked_cache[t]);
|
||||
}
|
||||
|
||||
|
@ -935,7 +935,7 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
* Castle configuration tag contains a 'valid_terrain' attribute which is a
|
||||
* list of terrains that the castle may appear on.
|
||||
*/
|
||||
const t_translation::ter_list list = t_translation::read_list(castle_config["valid_terrain"]);
|
||||
const t_translation::ter_list list = t_translation::read_list(castle_config["valid_terrain"].str());
|
||||
|
||||
const is_valid_terrain terrain_tester(terrain, list);
|
||||
|
||||
|
|
|
@ -238,10 +238,10 @@ void gamemap::overlay(const gamemap& m, const config& rules_cfg, map_location lo
|
|||
for(std::size_t i = 0; i <rules.size(); ++i)
|
||||
{
|
||||
const config& cfg = rules_cfg.child("rule", i);
|
||||
rules[i].old_ = t_translation::read_list(cfg["old"]);
|
||||
rules[i].new_ = t_translation::read_list(cfg["new"]);
|
||||
rules[i].old_ = t_translation::read_list(cfg["old"].str());
|
||||
rules[i].new_ = t_translation::read_list(cfg["new"].str());
|
||||
rules[i].mode_ = cfg["layer"] == "base" ? terrain_type_data::BASE : cfg["layer"] == "overlay" ? terrain_type_data::OVERLAY : terrain_type_data::BOTH;
|
||||
const t_translation::ter_list& terrain = t_translation::read_list(cfg["terrain"]);
|
||||
const t_translation::ter_list& terrain = t_translation::read_list(cfg["terrain"].str());
|
||||
if(!terrain.empty()) {
|
||||
rules[i].terrain_ = terrain[0];
|
||||
}
|
||||
|
|
|
@ -130,24 +130,24 @@ terrain_type::terrain_type(const config& cfg) :
|
|||
def_type_.push_back(number_);
|
||||
vision_type_.push_back(number_);
|
||||
|
||||
const t_translation::ter_list& alias = t_translation::read_list(cfg["aliasof"]);
|
||||
const t_translation::ter_list& alias = t_translation::read_list(cfg["aliasof"].str());
|
||||
if(!alias.empty()) {
|
||||
mvt_type_ = alias;
|
||||
vision_type_ = alias;
|
||||
def_type_ = alias;
|
||||
}
|
||||
|
||||
const t_translation::ter_list& mvt_alias = t_translation::read_list(cfg["mvt_alias"]);
|
||||
const t_translation::ter_list& mvt_alias = t_translation::read_list(cfg["mvt_alias"].str());
|
||||
if(!mvt_alias.empty()) {
|
||||
mvt_type_ = mvt_alias;
|
||||
}
|
||||
|
||||
const t_translation::ter_list& def_alias = t_translation::read_list(cfg["def_alias"]);
|
||||
const t_translation::ter_list& def_alias = t_translation::read_list(cfg["def_alias"].str());
|
||||
if(!def_alias.empty()) {
|
||||
def_type_ = def_alias;
|
||||
}
|
||||
|
||||
const t_translation::ter_list& vision_alias = t_translation::read_list(cfg["vision_alias"]);
|
||||
const t_translation::ter_list& vision_alias = t_translation::read_list(cfg["vision_alias"].str());
|
||||
if(!vision_alias.empty()) {
|
||||
vision_type_ = vision_alias;
|
||||
}
|
||||
|
|
|
@ -209,7 +209,7 @@ std::string write_terrain_code(const terrain_code& tcode)
|
|||
return number_to_string_(tcode);
|
||||
}
|
||||
|
||||
ter_list read_list(const std::string& str, const ter_layer filler)
|
||||
ter_list read_list(utils::string_view str, const ter_layer filler)
|
||||
{
|
||||
// Handle an empty string
|
||||
ter_list result;
|
||||
|
@ -224,7 +224,7 @@ ter_list read_list(const std::string& str, const ter_layer filler)
|
|||
// Get a terrain chunk
|
||||
const std::string separators = ",";
|
||||
const std::size_t pos_separator = str.find_first_of(separators, offset);
|
||||
const std::string terrain = str.substr(offset, pos_separator - offset);
|
||||
const std::string terrain = str.substr(offset, pos_separator - offset).to_string();
|
||||
|
||||
// Process the chunk
|
||||
const terrain_code tile = string_to_number_(terrain, filler);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "exceptions.hpp"
|
||||
#include "map/location.hpp"
|
||||
#include "serialization/string_view.hpp"
|
||||
|
||||
namespace t_translation {
|
||||
|
||||
|
@ -203,7 +204,7 @@ namespace t_translation {
|
|||
*
|
||||
* @returns A vector which contains the terrain codes found in the string
|
||||
*/
|
||||
ter_list read_list(const std::string& str, const ter_layer filler = NO_LAYER);
|
||||
ter_list read_list(utils::string_view str, const ter_layer filler = NO_LAYER);
|
||||
|
||||
/**
|
||||
* Writes a list of terrains to a string, only writes the new format.
|
||||
|
|
|
@ -276,7 +276,7 @@ unit_animation::unit_animation(int start_time,
|
|||
}
|
||||
|
||||
unit_animation::unit_animation(const config& cfg,const std::string& frame_string )
|
||||
: terrain_types_(t_translation::read_list(cfg["terrain_type"]))
|
||||
: terrain_types_(t_translation::read_list(cfg["terrain_type"].str()))
|
||||
, unit_filter_()
|
||||
, secondary_unit_filter_()
|
||||
, directions_()
|
||||
|
|
Loading…
Add table
Reference in a new issue