aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/map')
-rw-r--r--src/openvic-simulation/map/Building.cpp93
-rw-r--r--src/openvic-simulation/map/Building.hpp36
-rw-r--r--src/openvic-simulation/map/Map.cpp10
-rw-r--r--src/openvic-simulation/map/Map.hpp10
-rw-r--r--src/openvic-simulation/map/Province.cpp4
-rw-r--r--src/openvic-simulation/map/Province.hpp4
-rw-r--r--src/openvic-simulation/map/Region.cpp2
-rw-r--r--src/openvic-simulation/map/Region.hpp2
-rw-r--r--src/openvic-simulation/map/TerrainType.cpp12
-rw-r--r--src/openvic-simulation/map/TerrainType.hpp8
10 files changed, 95 insertions, 86 deletions
diff --git a/src/openvic-simulation/map/Building.cpp b/src/openvic-simulation/map/Building.cpp
index 29ee354..6f4c099 100644
--- a/src/openvic-simulation/map/Building.cpp
+++ b/src/openvic-simulation/map/Building.cpp
@@ -5,7 +5,7 @@
using namespace OpenVic;
using namespace OpenVic::NodeTools;
-Building::Building(std::string_view identifier, ARGS) : HasIdentifier { identifier }, ModifierValue { std::move(modifiers) }, type { type },
+Building::Building(std::string_view identifier, BuildingType const& type, ARGS) : HasIdentifier { identifier }, ModifierValue { std::move(modifiers) }, type { type },
on_completion { on_completion }, completion_size { completion_size }, max_level { max_level }, goods_cost { goods_cost }, cost { cost }, build_time { build_time },
visibility { visibility }, on_map { on_map }, default_enabled { default_enabled }, production_type { production_type }, pop_build_factory { pop_build_factory },
strategic_factory { strategic_factory }, advanced_factory { advanced_factory }, fort_level { fort_level }, naval_capacity { naval_capacity },
@@ -17,8 +17,8 @@ BuildingType const& Building::get_type() const {
return type;
}
-std::string_view Building::get_on_completion() const {
- return on_completion;
+std::string const& Building::get_on_completion() const {
+ return on_completion;
}
fixed_point_t Building::get_completion_size() const {
@@ -29,7 +29,7 @@ Building::level_t Building::get_max_level() const {
return max_level;
}
-std::map<const Good*, fixed_point_t> const& Building::get_goods_cost() const {
+std::map<Good const*, fixed_point_t> const& Building::get_goods_cost() const {
return goods_cost;
}
@@ -77,7 +77,7 @@ uint64_t Building::get_naval_capacity() const {
return naval_capacity;
}
-std::vector<uint64_t> const& Building::get_colonial_points() const {
+std::vector<fixed_point_t> const& Building::get_colonial_points() const {
return colonial_points;
}
@@ -105,7 +105,7 @@ bool Building::spawned_railway_track() const {
return spawn_railway_track;
}
-BuildingType::BuildingType(const std::string_view new_identifier) : HasIdentifier { new_identifier } {}
+BuildingType::BuildingType(std::string_view new_identifier) : HasIdentifier { new_identifier } {}
BuildingInstance::BuildingInstance(Building const& building) : HasIdentifier { building.get_identifier() }, building { building } {}
@@ -176,7 +176,7 @@ void BuildingInstance::tick(Date const& today) {
BuildingManager::BuildingManager() : building_types { "building types" }, buildings { "buildings" } {}
-bool BuildingManager::add_building_type(const std::string_view identifier) {
+bool BuildingManager::add_building_type(std::string_view identifier) {
if (identifier.empty()) {
Logger::error("Invalid building type identifier - empty!");
return false;
@@ -184,52 +184,72 @@ bool BuildingManager::add_building_type(const std::string_view identifier) {
return building_types.add_item({ identifier });
}
-bool BuildingManager::add_building(std::string_view identifier, ARGS) {
+bool BuildingManager::add_building(std::string_view identifier, BuildingType const* type, ARGS) {
if (identifier.empty()) {
Logger::error("Invalid building identifier - empty!");
return false;
}
+ if (type == nullptr) {
+ Logger::error("Invalid building type for ", identifier, ": null");
+ return false;
+ }
return buildings.add_item({
- identifier, type, on_completion, completion_size, max_level, goods_cost, cost, build_time, visibility, on_map, default_enabled,
- production_type, pop_build_factory, strategic_factory, advanced_factory, fort_level, naval_capacity, colonial_points, in_province, one_per_state,
+ identifier, *type, on_completion, completion_size, max_level, goods_cost, cost, build_time, visibility, on_map, default_enabled,
+ production_type, pop_build_factory, strategic_factory, advanced_factory, fort_level, naval_capacity, colonial_points, in_province, one_per_state,
colonial_range, infrastructure, movement_cost, local_ship_build, spawn_railway_track, sail, steam, capital, port, std::move(modifiers)
});
}
bool BuildingManager::load_buildings_file(GoodManager const& good_manager, ProductionTypeManager const& production_type_manager, ModifierManager const& modifier_manager, ast::NodeCPtr root) {
- bool ret = expect_dictionary([this, &good_manager, &production_type_manager, &modifier_manager](std::string_view key, ast::NodeCPtr value) -> bool {
- std::string_view type, on_completion = "", production_type;
+ bool ret = expect_dictionary_reserve_length(buildings, [this](std::string_view, ast::NodeCPtr value) -> bool {
+ return expect_key("type", expect_identifier(
+ [this](std::string_view identifier) -> bool {
+ if (!building_types.has_identifier(identifier)) {
+ return building_types.add_item({ identifier });
+ }
+ return true;
+ }
+ ))(value);
+ })(root);
+ lock_building_types();
+
+ ret &= expect_dictionary([this, &good_manager, &production_type_manager, &modifier_manager](std::string_view key, ast::NodeCPtr value) -> bool {
+ BuildingType const* type = nullptr;
+ ProductionType const* production_type = nullptr;
+ std::string_view on_completion;
fixed_point_t completion_size = 0, cost = 0, infrastructure = 0, movement_cost = 0, colonial_range = 0, local_ship_build = 0;
- Building::level_t max_level, fort_level = 0;
- std::map<const Good*, fixed_point_t> goods_cost;
- uint32_t build_days;
- bool visibility, on_map, default_enabled, pop_build_factory, strategic_factory, advanced_factory, in_province, one_per_state, spawn_railway_track, sail, steam, capital, port;
- default_enabled = pop_build_factory = strategic_factory = advanced_factory = in_province = one_per_state = spawn_railway_track = sail = steam = capital = port = false;
+ Building::level_t max_level = 0, fort_level = 0;
+ std::map<Good const*, fixed_point_t> goods_cost;
+ Timespan build_time;
+ bool visibility = false, on_map = false, default_enabled = false, pop_build_factory = false, strategic_factory = false, advanced_factory = false;
+ bool in_province = false, one_per_state = false, spawn_railway_track = false, sail = false, steam = false, capital = false, port = false;
uint64_t naval_capacity = 0;
- std::vector<uint64_t> colonial_points;
+ std::vector<fixed_point_t> colonial_points;
ModifierValue modifiers;
-
+
bool ret = modifier_manager.expect_modifier_value_and_keys(move_variable_callback(modifiers),
- "type", ONE_EXACTLY, expect_identifier(assign_variable_callback(type)),
+ "type", ONE_EXACTLY, expect_building_type_identifier(assign_variable_callback_pointer(type)),
"on_completion", ZERO_OR_ONE, expect_identifier(assign_variable_callback(on_completion)),
"completion_size", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(completion_size)),
- "max_level", ONE_EXACTLY, expect_uint(assign_variable_callback(max_level)),
- "goods_cost", ONE_EXACTLY, good_manager.expect_good_decimal_map(assign_variable_callback(goods_cost)),
+ "max_level", ONE_EXACTLY, expect_uint(assign_variable_callback_uint(max_level)),
+ "goods_cost", ONE_EXACTLY, good_manager.expect_good_decimal_map(move_variable_callback(goods_cost)),
"cost", ZERO_OR_MORE, expect_fixed_point(assign_variable_callback(cost)),
- "time", ONE_EXACTLY, expect_uint(assign_variable_callback_uint("building build time", build_days)),
+ "time", ONE_EXACTLY, expect_timespan(assign_variable_callback(build_time)),
"visibility", ONE_EXACTLY, expect_bool(assign_variable_callback(visibility)),
"onmap", ONE_EXACTLY, expect_bool(assign_variable_callback(on_map)),
"default_enabled", ZERO_OR_ONE, expect_bool(assign_variable_callback(default_enabled)),
- "production_type", ZERO_OR_ONE, expect_identifier(assign_variable_callback(production_type)),
+ "production_type", ZERO_OR_ONE, production_type_manager.expect_production_type_identifier(assign_variable_callback_pointer(production_type)),
"pop_build_factory", ZERO_OR_ONE, expect_bool(assign_variable_callback(pop_build_factory)),
"strategic_factory", ZERO_OR_ONE, expect_bool(assign_variable_callback(strategic_factory)),
"advanced_factory", ZERO_OR_ONE, expect_bool(assign_variable_callback(advanced_factory)),
- "fort_level", ZERO_OR_ONE, expect_uint(assign_variable_callback_uint("building fort level", fort_level)),
- "naval_capacity", ZERO_OR_ONE, expect_uint(assign_variable_callback_uint("building naval capacity", naval_capacity)),
- "colonial_points", ZERO_OR_ONE, expect_list(expect_uint([&colonial_points](uint64_t points) -> bool {
- return colonial_points.emplace_back(points);
- })), "province", ZERO_OR_ONE, expect_bool(assign_variable_callback(in_province)),
+ "fort_level", ZERO_OR_ONE, expect_uint(assign_variable_callback_uint(fort_level)),
+ "naval_capacity", ZERO_OR_ONE, expect_uint(assign_variable_callback_uint(naval_capacity)),
+ "colonial_points", ZERO_OR_ONE, expect_list(expect_fixed_point([&colonial_points](fixed_point_t points) -> bool {
+ colonial_points.push_back(points);
+ return true;
+ })),
+ "province", ZERO_OR_ONE, expect_bool(assign_variable_callback(in_province)),
"one_per_state", ZERO_OR_ONE, expect_bool(assign_variable_callback(one_per_state)),
"colonial_range", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(colonial_range)),
"infrastructure", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(infrastructure)),
@@ -242,25 +262,14 @@ bool BuildingManager::load_buildings_file(GoodManager const& good_manager, Produ
"port", ZERO_OR_ONE, expect_bool(assign_variable_callback(port))
)(value);
- BuildingType const* type_ref = building_types.get_item_by_identifier(type);
- if (type_ref == nullptr) {
- building_types.add_item({ type });
- type_ref = building_types.get_item_by_identifier(type);
- }
-
- Timespan build_time = Timespan(build_days);
-
- ProductionType const* production_type_ref = production_type_manager.get_production_type_by_identifier(production_type);
-
ret &= add_building(
- key, *type_ref, on_completion, completion_size, max_level, goods_cost, cost, build_time, visibility, on_map, default_enabled,
- production_type_ref, pop_build_factory, strategic_factory, advanced_factory, fort_level, naval_capacity, colonial_points, in_province,
+ key, type, on_completion, completion_size, max_level, goods_cost, cost, build_time, visibility, on_map, default_enabled,
+ production_type, pop_build_factory, strategic_factory, advanced_factory, fort_level, naval_capacity, colonial_points, in_province,
one_per_state, colonial_range, infrastructure, movement_cost, local_ship_build, spawn_railway_track, sail, steam, capital, port, std::move(modifiers)
);
return ret;
})(root);
- lock_building_types();
lock_buildings();
return ret;
diff --git a/src/openvic-simulation/map/Building.hpp b/src/openvic-simulation/map/Building.hpp
index 9b11c1c..9b445bf 100644
--- a/src/openvic-simulation/map/Building.hpp
+++ b/src/openvic-simulation/map/Building.hpp
@@ -7,10 +7,10 @@
#include "openvic-simulation/economy/ProductionType.hpp"
#include "openvic-simulation/Modifier.hpp"
-#define ARGS BuildingType const& type, std::string_view on_completion, fixed_point_t completion_size, level_t max_level, \
- std::map<const Good*, fixed_point_t> goods_cost, fixed_point_t cost, Timespan build_time, bool visibility, bool on_map, bool default_enabled, \
+#define ARGS std::string_view on_completion, fixed_point_t completion_size, level_t max_level, \
+ std::map<Good const*, fixed_point_t> goods_cost, fixed_point_t cost, Timespan build_time, bool visibility, bool on_map, bool default_enabled, \
ProductionType const* production_type, bool pop_build_factory, bool strategic_factory, bool advanced_factory, level_t fort_level, \
- uint64_t naval_capacity, std::vector<uint64_t> colonial_points, bool in_province, bool one_per_state, fixed_point_t colonial_range, \
+ uint64_t naval_capacity, std::vector<fixed_point_t> colonial_points, bool in_province, bool one_per_state, fixed_point_t colonial_range, \
fixed_point_t infrastructure, fixed_point_t movement_cost, fixed_point_t local_ship_build, bool spawn_railway_track, bool sail, bool steam, \
bool capital, bool port, ModifierValue&& modifiers
@@ -27,19 +27,19 @@ namespace OpenVic {
struct Building : HasIdentifier, ModifierValue {
friend struct BuildingManager;
- using level_t = uint8_t;
+ using level_t = int8_t;
private:
BuildingType const& type;
- const std::string_view on_completion; //probably sound played on completion
+ const std::string on_completion; //probably sound played on completion
const fixed_point_t completion_size;
const level_t max_level;
- const std::map<const Good*, fixed_point_t> goods_cost;
+ const std::map<Good const*, fixed_point_t> goods_cost;
const fixed_point_t cost;
const Timespan build_time; //time
const bool visibility;
const bool on_map; //onmap
-
+
const bool default_enabled;
ProductionType const* production_type;
const bool pop_build_factory;
@@ -49,7 +49,7 @@ namespace OpenVic {
const level_t fort_level; //probably the step-per-level
const uint64_t naval_capacity;
- const std::vector<uint64_t> colonial_points;
+ const std::vector<fixed_point_t> colonial_points;
const bool in_province; //province
const bool one_per_state;
const fixed_point_t colonial_range;
@@ -64,16 +64,16 @@ namespace OpenVic {
const bool capital; //only in naval base
const bool port; //only in naval base
- Building(std::string_view identifier, ARGS);
+ Building(std::string_view identifier, BuildingType const& type, ARGS);
public:
Building(Building&&) = default;
BuildingType const& get_type() const;
- std::string_view get_on_completion() const;
+ std::string const& get_on_completion() const;
fixed_point_t get_completion_size() const;
level_t get_max_level() const;
- std::map<const Good*, fixed_point_t> const& get_goods_cost() const;
+ std::map<Good const*, fixed_point_t> const& get_goods_cost() const;
fixed_point_t get_cost() const;
Timespan get_build_time() const;
bool has_visibility() const;
@@ -84,15 +84,15 @@ namespace OpenVic {
bool is_pop_built_factory() const;
bool is_strategic_factory() const;
bool is_advanced_factory() const;
-
+
level_t get_fort_level() const;
uint64_t get_naval_capacity() const;
- std::vector<uint64_t> const& get_colonial_points() const;
+ std::vector<fixed_point_t> const& get_colonial_points() const;
bool is_in_province() const;
bool is_one_per_state() const;
fixed_point_t get_colonial_range() const;
-
+
fixed_point_t get_infrastructure() const;
fixed_point_t get_movement_cost() const;
fixed_point_t get_local_ship_build() const;
@@ -103,7 +103,7 @@ namespace OpenVic {
friend struct BuildingManager;
private:
- BuildingType(const std::string_view new_identifier);
+ BuildingType(std::string_view new_identifier);
public:
BuildingType(BuildingType&&) = default;
@@ -119,7 +119,7 @@ namespace OpenVic {
struct BuildingInstance : HasIdentifier { //used in the actual game
friend struct BuildingManager;
using level_t = Building::level_t;
-
+
private:
Building const& building;
@@ -161,10 +161,10 @@ namespace OpenVic {
public:
BuildingManager();
- bool add_building_type(const std::string_view identifier);
+ bool add_building_type(std::string_view identifier);
IDENTIFIER_REGISTRY_ACCESSORS(BuildingType, building_type)
- bool add_building(std::string_view identifier, ARGS);
+ bool add_building(std::string_view identifier, BuildingType const* type, ARGS);
IDENTIFIER_REGISTRY_ACCESSORS(Building, building)
bool load_buildings_file(GoodManager const& good_manager, ProductionTypeManager const& production_type_manager, ModifierManager const& modifier_manager, ast::NodeCPtr root);
diff --git a/src/openvic-simulation/map/Map.cpp b/src/openvic-simulation/map/Map.cpp
index 7ecff39..386e7be 100644
--- a/src/openvic-simulation/map/Map.cpp
+++ b/src/openvic-simulation/map/Map.cpp
@@ -10,7 +10,7 @@
using namespace OpenVic;
using namespace OpenVic::NodeTools;
-Mapmode::Mapmode(const std::string_view new_identifier, index_t new_index, colour_func_t new_colour_func)
+Mapmode::Mapmode(std::string_view new_identifier, index_t new_index, colour_func_t new_colour_func)
: HasIdentifier { new_identifier },
index { new_index },
colour_func { new_colour_func } {
@@ -32,7 +32,7 @@ Map::Map() : provinces { "provinces" },
regions { "regions" },
mapmodes { "mapmodes" } {}
-bool Map::add_province(const std::string_view identifier, colour_t colour) {
+bool Map::add_province(std::string_view identifier, colour_t colour) {
if (provinces.size() >= max_provinces) {
Logger::error("The map's province list is full - maximum number of provinces is ", max_provinces, " (this can be at most ", Province::MAX_INDEX, ")");
return false;
@@ -55,7 +55,7 @@ bool Map::add_province(const std::string_view identifier, colour_t colour) {
return provinces.add_item(std::move(new_province));
}
-bool Map::set_water_province(const std::string_view identifier) {
+bool Map::set_water_province(std::string_view identifier) {
if (water_provinces.is_locked()) {
Logger::error("The map's water provinces have already been locked!");
return false;
@@ -91,7 +91,7 @@ void Map::lock_water_provinces() {
Logger::info("Locked water provinces after registering ", water_provinces.size());
}
-bool Map::add_region(const std::string_view identifier, std::vector<std::string_view> const& province_identifiers) {
+bool Map::add_region(std::string_view identifier, std::vector<std::string_view> const& province_identifiers) {
if (identifier.empty()) {
Logger::error("Invalid region identifier - empty!");
return false;
@@ -203,7 +203,7 @@ TerrainTypeManager const& Map::get_terrain_type_manager() const {
return terrain_type_manager;
}
-bool Map::add_mapmode(const std::string_view identifier, Mapmode::colour_func_t colour_func) {
+bool Map::add_mapmode(std::string_view identifier, Mapmode::colour_func_t colour_func) {
if (identifier.empty()) {
Logger::error("Invalid mapmode identifier - empty!");
return false;
diff --git a/src/openvic-simulation/map/Map.hpp b/src/openvic-simulation/map/Map.hpp
index 99c0bce..9c97960 100644
--- a/src/openvic-simulation/map/Map.hpp
+++ b/src/openvic-simulation/map/Map.hpp
@@ -21,7 +21,7 @@ namespace OpenVic {
const index_t index;
const colour_func_t colour_func;
- Mapmode(const std::string_view new_identifier, index_t new_index, colour_func_t new_colour_func);
+ Mapmode(std::string_view new_identifier, index_t new_index, colour_func_t new_colour_func);
public:
static const Mapmode ERROR_MAPMODE;
@@ -69,11 +69,11 @@ namespace OpenVic {
public:
Map();
- bool add_province(const std::string_view identifier, colour_t colour);
+ bool add_province(std::string_view identifier, colour_t colour);
IDENTIFIER_REGISTRY_ACCESSORS(Province, province)
IDENTIFIER_REGISTRY_NON_CONST_ACCESSORS(Province, province)
- bool set_water_province(const std::string_view identifier);
+ bool set_water_province(std::string_view identifier);
bool set_water_province_list(std::vector<std::string_view> const& list);
void lock_water_provinces();
@@ -92,11 +92,11 @@ namespace OpenVic {
TerrainTypeManager& get_terrain_type_manager();
TerrainTypeManager const& get_terrain_type_manager() const;
- bool add_region(const std::string_view identifier, std::vector<std::string_view> const& province_identifiers);
+ bool add_region(std::string_view identifier, std::vector<std::string_view> const& province_identifiers);
IDENTIFIER_REGISTRY_ACCESSORS(Region, region)
IDENTIFIER_REGISTRY_NON_CONST_ACCESSORS(Region, region)
- bool add_mapmode(const std::string_view identifier, Mapmode::colour_func_t colour_func);
+ bool add_mapmode(std::string_view identifier, Mapmode::colour_func_t colour_func);
IDENTIFIER_REGISTRY_ACCESSORS(Mapmode, mapmode)
Mapmode const* get_mapmode_by_index(size_t index) const;
static constexpr size_t MAPMODE_COLOUR_SIZE = 4;
diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp
index 21bdb85..fa514eb 100644
--- a/src/openvic-simulation/map/Province.cpp
+++ b/src/openvic-simulation/map/Province.cpp
@@ -3,7 +3,7 @@
using namespace OpenVic;
using namespace OpenVic::NodeTools;
-Province::Province(const std::string_view new_identifier, colour_t new_colour, index_t new_index)
+Province::Province(std::string_view new_identifier, colour_t new_colour, index_t new_index)
: HasIdentifierAndColour { new_identifier, new_colour, false, false },
index { new_index }, buildings { "buildings", false } {
assert(index != NULL_INDEX);
@@ -47,7 +47,7 @@ void Province::reset_buildings() {
buildings.reset();
}
-bool Province::expand_building(const std::string_view building_type_identifier) {
+bool Province::expand_building(std::string_view building_type_identifier) {
BuildingInstance* building = buildings.get_item_by_identifier(building_type_identifier);
if (building == nullptr) return false;
return building->expand();
diff --git a/src/openvic-simulation/map/Province.hpp b/src/openvic-simulation/map/Province.hpp
index 349c16d..e15d8d3 100644
--- a/src/openvic-simulation/map/Province.hpp
+++ b/src/openvic-simulation/map/Province.hpp
@@ -60,7 +60,7 @@ namespace OpenVic {
void _set_terrain_type(TerrainType const* type);
- Province(const std::string_view new_identifier, colour_t new_colour, index_t new_index);
+ Province(std::string_view new_identifier, colour_t new_colour, index_t new_index);
public:
Province(Province&&) = default;
@@ -76,7 +76,7 @@ namespace OpenVic {
bool add_building(BuildingInstance&& building_instance);
IDENTIFIER_REGISTRY_ACCESSORS(BuildingInstance, building)
void reset_buildings();
- bool expand_building(const std::string_view building_type_identifier);
+ bool expand_building(std::string_view building_type_identifier);
Good const* get_rgo() const;
std::string to_string() const;
diff --git a/src/openvic-simulation/map/Region.cpp b/src/openvic-simulation/map/Region.cpp
index c0422de..477dc9e 100644
--- a/src/openvic-simulation/map/Region.cpp
+++ b/src/openvic-simulation/map/Region.cpp
@@ -63,7 +63,7 @@ ProvinceSet::provinces_t const& ProvinceSet::get_provinces() const {
return provinces;
}
-Region::Region(const std::string_view new_identifier, provinces_t&& new_provinces, bool new_meta)
+Region::Region(std::string_view new_identifier, provinces_t&& new_provinces, bool new_meta)
: HasIdentifier { new_identifier }, ProvinceSet { std::move(new_provinces) }, meta { new_meta } {
lock();
}
diff --git a/src/openvic-simulation/map/Region.hpp b/src/openvic-simulation/map/Region.hpp
index d68033b..157b643 100644
--- a/src/openvic-simulation/map/Region.hpp
+++ b/src/openvic-simulation/map/Region.hpp
@@ -38,7 +38,7 @@ namespace OpenVic {
*/
const bool meta;
- Region(const std::string_view new_identifier, provinces_t&& new_provinces, bool new_meta);
+ Region(std::string_view new_identifier, provinces_t&& new_provinces, bool new_meta);
public:
Region(Region&&) = default;
diff --git a/src/openvic-simulation/map/TerrainType.cpp b/src/openvic-simulation/map/TerrainType.cpp
index e688625..2438df6 100644
--- a/src/openvic-simulation/map/TerrainType.cpp
+++ b/src/openvic-simulation/map/TerrainType.cpp
@@ -5,14 +5,14 @@
using namespace OpenVic;
using namespace OpenVic::NodeTools;
-TerrainType::TerrainType(const std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_values, bool new_is_water)
+TerrainType::TerrainType(std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_values, bool new_is_water)
: HasIdentifierAndColour { new_identifier, new_colour, true, false }, ModifierValue { std::move(new_values) }, is_water { new_is_water } {}
bool TerrainType::get_is_water() const {
return is_water;
}
-TerrainTypeMapping::TerrainTypeMapping(const std::string_view new_identifier, TerrainType const& new_type,
+TerrainTypeMapping::TerrainTypeMapping(std::string_view new_identifier, TerrainType const& new_type,
std::vector<index_t>&& new_terrain_indicies, index_t new_priority, bool new_has_texture)
: HasIdentifier { new_identifier }, type { new_type }, terrain_indicies { std::move(new_terrain_indicies) },
priority { new_priority }, has_texture { new_has_texture } {}
@@ -35,7 +35,7 @@ bool TerrainTypeMapping::get_has_texture() const {
TerrainTypeManager::TerrainTypeManager() : terrain_types { "terrain types" }, terrain_type_mappings { "terrain type mappings" } {}
-bool TerrainTypeManager::add_terrain_type(const std::string_view identifier, colour_t colour, ModifierValue&& values, bool is_water) {
+bool TerrainTypeManager::add_terrain_type(std::string_view identifier, colour_t colour, ModifierValue&& values, bool is_water) {
if (identifier.empty()) {
Logger::error("Invalid terrain type identifier - empty!");
return false;
@@ -47,7 +47,7 @@ bool TerrainTypeManager::add_terrain_type(const std::string_view identifier, col
return terrain_types.add_item({ identifier, colour, std::move(values), is_water });
}
-bool TerrainTypeManager::add_terrain_type_mapping(const std::string_view identifier, TerrainType const* type,
+bool TerrainTypeManager::add_terrain_type_mapping(std::string_view identifier, TerrainType const* type,
std::vector<TerrainTypeMapping::index_t>&& terrain_indicies, TerrainTypeMapping::index_t priority, bool has_texture) {
if (!terrain_types.is_locked()) {
Logger::error("Cannot register terrain type mappings until terrain types are locked!");
@@ -117,7 +117,7 @@ bool TerrainTypeManager::_load_terrain_type_mapping(std::string_view mapping_key
return false;
}
)),
- "priority", ZERO_OR_ONE, expect_uint(assign_variable_callback_uint("terrain type mapping priority", priority)),
+ "priority", ZERO_OR_ONE, expect_uint(assign_variable_callback_uint(priority)),
"has_texture", ZERO_OR_ONE, expect_bool(assign_variable_callback(has_texture))
)(mapping_value);
if (has_texture) {
@@ -153,7 +153,7 @@ bool TerrainTypeManager::load_terrain_types(ModifierManager const& modifier_mana
if (key == "terrain") {
if (!terrain) {
terrain = true;
- return expect_uint(assign_variable_callback_uint("terrain texture limit", terrain_texture_limit))(value);
+ return expect_uint(assign_variable_callback_uint(terrain_texture_limit))(value);
} else {
Logger::error("Duplicate terrain key!");
return false;
diff --git a/src/openvic-simulation/map/TerrainType.hpp b/src/openvic-simulation/map/TerrainType.hpp
index 0cc28c2..3b491ae 100644
--- a/src/openvic-simulation/map/TerrainType.hpp
+++ b/src/openvic-simulation/map/TerrainType.hpp
@@ -11,7 +11,7 @@ namespace OpenVic {
private:
const bool is_water;
- TerrainType(const std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_values, bool new_is_water);
+ TerrainType(std::string_view new_identifier, colour_t new_colour, ModifierValue&& new_values, bool new_is_water);
public:
TerrainType(TerrainType&&) = default;
@@ -30,7 +30,7 @@ namespace OpenVic {
const index_t priority;
const bool has_texture;
- TerrainTypeMapping(const std::string_view new_identifier, TerrainType const& new_type, std::vector<index_t>&& new_terrain_indicies, index_t new_priority, bool new_has_texture);
+ TerrainTypeMapping(std::string_view new_identifier, TerrainType const& new_type, std::vector<index_t>&& new_terrain_indicies, index_t new_priority, bool new_has_texture);
public:
TerrainTypeMapping(TerrainTypeMapping&&) = default;
@@ -56,10 +56,10 @@ namespace OpenVic {
public:
TerrainTypeManager();
- bool add_terrain_type(const std::string_view identifier, colour_t colour, ModifierValue&& values, bool is_water);
+ bool add_terrain_type(std::string_view identifier, colour_t colour, ModifierValue&& values, bool is_water);
IDENTIFIER_REGISTRY_ACCESSORS(TerrainType, terrain_type)
- bool add_terrain_type_mapping(const std::string_view identifier, TerrainType const* type,
+ bool add_terrain_type_mapping(std::string_view identifier, TerrainType const* type,
std::vector<TerrainTypeMapping::index_t>&& terrain_indicies, TerrainTypeMapping::index_t priority, bool has_texture);
IDENTIFIER_REGISTRY_ACCESSORS(TerrainTypeMapping, terrain_type_mapping)