From c0ba822ee46551a40ad6b43e8f56b80e27ae35b5 Mon Sep 17 00:00:00 2001 From: hop311 Date: Sat, 8 Jun 2024 00:17:25 +0100 Subject: Add GoodInstance --- src/openvic-simulation/map/Mapmode.cpp | 10 +++++++--- src/openvic-simulation/map/ProvinceInstance.cpp | 26 ++++++++++++++++++++----- src/openvic-simulation/map/ProvinceInstance.hpp | 6 +++--- 3 files changed, 31 insertions(+), 11 deletions(-) (limited to 'src/openvic-simulation/map') diff --git a/src/openvic-simulation/map/Mapmode.cpp b/src/openvic-simulation/map/Mapmode.cpp index 6f8e606..410ea2b 100644 --- a/src/openvic-simulation/map/Mapmode.cpp +++ b/src/openvic-simulation/map/Mapmode.cpp @@ -142,8 +142,8 @@ static constexpr auto shaded_mapmode(fixed_point_map_t const&(Province bool MapmodeManager::setup_mapmodes() { bool ret = true; - using mapmode_t = std::pair; - const std::vector mapmodes { + using mapmode_definition_t = std::pair; + const std::vector mapmode_definitions { { "mapmode_terrain", [](MapInstance const&, ProvinceInstance const& province) -> Mapmode::base_stripe_t { @@ -284,9 +284,13 @@ bool MapmodeManager::setup_mapmodes() { } }; - for (mapmode_t const& mapmode : mapmodes) { + mapmodes.reset(); + reserve_mapmodes(mapmode_definitions.size()); + + for (mapmode_definition_t const& mapmode : mapmode_definitions) { ret &= add_mapmode(mapmode.first, mapmode.second); } + lock_mapmodes(); return ret; diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp index ba52280..be77d6e 100644 --- a/src/openvic-simulation/map/ProvinceInstance.cpp +++ b/src/openvic-simulation/map/ProvinceInstance.cpp @@ -8,11 +8,27 @@ using namespace OpenVic; ProvinceInstance::ProvinceInstance(ProvinceDefinition const& new_province_definition) - : HasIdentifier { new_province_definition.get_identifier() }, province_definition { new_province_definition }, - terrain_type { nullptr }, life_rating { 0 }, colony_status { colony_status_t::STATE }, state { nullptr }, - owner { nullptr }, controller { nullptr }, cores {}, slave { false }, crime { nullptr }, rgo { nullptr }, - buildings { "buildings", false }, armies {}, navies {}, pops {}, total_population { 0 }, pop_type_distribution {}, - ideology_distribution {}, culture_distribution {}, religion_distribution {} {} + : HasIdentifierAndColour { new_province_definition }, + province_definition { new_province_definition }, + terrain_type { nullptr }, + life_rating { 0 }, + colony_status { colony_status_t::STATE }, + state { nullptr }, + owner { nullptr }, + controller { nullptr }, + cores {}, + slave { false }, + crime { nullptr }, + rgo { nullptr }, + buildings { "buildings", false }, + armies {}, + navies {}, + pops {}, + total_population { 0 }, + pop_type_distribution {}, + ideology_distribution {}, + culture_distribution {}, + religion_distribution {} {} bool ProvinceInstance::expand_building(size_t building_index) { BuildingInstance* building = buildings.get_item_by_index(building_index); diff --git a/src/openvic-simulation/map/ProvinceInstance.hpp b/src/openvic-simulation/map/ProvinceInstance.hpp index 3292575..beae0eb 100644 --- a/src/openvic-simulation/map/ProvinceInstance.hpp +++ b/src/openvic-simulation/map/ProvinceInstance.hpp @@ -13,7 +13,7 @@ namespace OpenVic { struct State; struct Country; struct Crime; - struct Good; + struct GoodDefinition; struct ArmyInstance; struct NavyInstance; struct Ideology; @@ -24,7 +24,7 @@ namespace OpenVic { struct IdeologyManager; struct IssueManager; - struct ProvinceInstance : HasIdentifier { + struct ProvinceInstance : HasIdentifierAndColour { friend struct MapInstance; using life_rating_t = int8_t; @@ -44,7 +44,7 @@ namespace OpenVic { bool PROPERTY(slave); Crime const* PROPERTY_RW(crime); // TODO - change this into a factory-like structure - Good const* PROPERTY(rgo); + GoodDefinition const* PROPERTY(rgo); IdentifierRegistry IDENTIFIER_REGISTRY(building); ordered_set PROPERTY(armies); ordered_set PROPERTY(navies); -- cgit v1.2.3-56-ga3b1