Skip to content

Commit

Permalink
Make countries converter load convoy config.
Browse files Browse the repository at this point in the history
  • Loading branch information
kingofmen committed Oct 23, 2023
1 parent 565eff0 commit 4951fe5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
8 changes: 7 additions & 1 deletion data/configurables/convoy_config.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# TODO: Import this number from the HoI mod instead of setting it here.
world_convoys = 1000
world_convoys = 2500
method_weights = {
pm_anchorage = 40
pm_basic_port = 200
pm_industrial_port = 400
pm_modern_port = 800
}
5 changes: 5 additions & 0 deletions src/hoi4_world/countries/hoi4_countries_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <ranges>

#include "external/fmt/include/fmt/format.h"
#include "src/hoi4_world/military/convoy_distributor.h"
#include "src/hoi4_world/military/convoy_distributor_builder.h"
#include "src/hoi4_world/military/division_templates_importer.h"
#include "src/hoi4_world/military/equipment_variant.h"
#include "src/hoi4_world/military/equipment_variants_importer.h"
Expand Down Expand Up @@ -78,6 +80,8 @@ std::map<std::string, Country> ConvertCountries(const vic3::World source_world,
mappers::ImportLeaderTypeMapper("configurables/leader_type_mappings.txt");
const mappers::CharacterTraitMapper character_trait_mapper =
mappers::ImportCharacterTraitMapper("configurables/character_traits.txt");
ConvoyDistributor convoys = BuildConvoyDistributor("configurables/convoy_config.txt");
convoys.CalculateStateWeights(source_world);

for (const auto& [country_number, source_country]: source_world.GetCountries())
{
Expand All @@ -97,6 +101,7 @@ std::map<std::string, Country> ConvertCountries(const vic3::World source_world,
world_mapper.culture_graphics_mapper,
leader_type_mapper,
character_trait_mapper,
convoys,
characters,
culture_queues,
debug);
Expand Down
38 changes: 34 additions & 4 deletions src/hoi4_world/countries/hoi4_countries_converter_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,22 @@ TEST(Hoi4worldCountriesCountriesConverter, CountriesAreConverted)
{1, source_country_one},
{2, source_country_two},
},
.states =
{
{1, vic3::State({.id = 1})},
{2, vic3::State({.id = 2})},
{3, vic3::State({.id = 3})},
},
.acquired_technologies =
{
{1, {"source_technology_one"}},
{2, {"source_technology_two"}},
},
.buildings = vic3::Buildings({
{1, {vic3::Building(vic3::BuildingType::Port, 1, 0, 1, std::vector<std::string>{"pm_port_3"})}},
{2, {vic3::Building(vic3::BuildingType::Port, 2, 0, 1, std::vector<std::string>{"pm_port_1"})}},
{3, {vic3::Building(vic3::BuildingType::Port, 3, 0, 1, std::vector<std::string>{"pm_port_2"})}},
}),
.culture_definitions =
{
{"culture_0", vic3::CultureDefinition({"culture_0"}, {}, {}, {})},
Expand All @@ -74,8 +85,25 @@ TEST(Hoi4worldCountriesCountriesConverter, CountriesAreConverted)
};

const States states{
.states{},
.vic3_state_ids_to_hoi4_state_ids{{1, 10}, {2, 20}},
.states{
State(10,
{
.owner = "TAG",
.provinces = {10},
}),
State(20,
{
.owner = "TWO",
.provinces = {20},
}),
State(30,
{
.owner = "TWO",
.provinces = {30},
}),
},
.vic3_state_ids_to_hoi4_state_ids{{1, 10}, {2, 20}, {3, 30}},
.hoi4_state_ids_to_owner{{10, "TAG"}, {20, "TWO"}, {30, "TWO"}},
};
const vic3::World v3World = vic3::World(options);

Expand Down Expand Up @@ -148,7 +176,8 @@ TEST(Hoi4worldCountriesCountriesConverter, CountriesAreConverted)
.character_ids = {1, 3},
.spy_ids = {4},
.starting_research_slots = 3,
.units = {}})),
.units = {},
.convoys = 100})),
testing::Pair("TWO",
Country(CountryOptions{.tag = "TWO",
.color = commonItems::Color{std::array{2, 4, 6}},
Expand All @@ -163,7 +192,8 @@ TEST(Hoi4worldCountriesCountriesConverter, CountriesAreConverted)
.graphics_block = expected_graphics_block_two,
.character_ids = {2},
.starting_research_slots = 3,
.units = {}}))));
.units = {},
.convoys = 11}))));
}

} // namespace hoi4

0 comments on commit 4951fe5

Please sign in to comment.