9 context.
state.
world.province_resize(int32_t(value - 1));
13 for(int32_t i = 1; i < value; ++i) {
22 dcon::province_id
id = dcon::province_id(dcon::province_id::value_base_t(i));
26 auto name = std::string(
"PROV") + std::to_string(old_id);
29 context.
state.
world.province_set_name(
id, name_id);
39 cpos = parsers::parse_fixed_amount_csv_values<4>(cpos, end,
';', [&](std::string_view
const* values) {
41 if(first_text.length() > 0) {
43 if(first_value == 0) {
63 cpos = parsers::parse_fixed_amount_csv_values<5>(cpos, end,
';', [&](std::string_view
const* values) {
66 if(first_text.length() > 0) {
70 if(first_value <= 0) {
72 }
else if(second_value <= 0) {
90 auto new_rel = context.
state.
world.force_create_province_adjacency(province_id_a, province_id_b);
92 }
else if(
is_fixed_token_ci(ttex.data(), ttex.data() + ttex.length(),
"impassable")) {
93 auto new_rel = context.
state.
world.force_create_province_adjacency(province_id_a, province_id_b);
96 auto new_rel = context.
state.
world.force_create_province_adjacency(province_id_a, province_id_b);
97 context.
state.
world.province_adjacency_set_type(new_rel,
144 auto parsed_modifier = parse_terrain_modifier(gen, err, context);
146 auto new_modifier = context.
state.
world.create_modifier();
148 std::string gfx_name = std::string(
"GFX_terrainimg_") + std::string(name);
153 context.
state.
world.modifier_set_icon(new_modifier,
uint8_t(parsed_modifier.icon_index));
154 context.
state.
world.modifier_set_name(new_modifier, name_id);
157 context.
state.
world.modifier_set_province_values(new_modifier, parsed_modifier.peek_province_mod());
158 context.
state.
world.modifier_set_national_values(new_modifier, parsed_modifier.peek_national_mod());
167 parsers::parse_state_definition(gen, err, new_context);
168 if(new_context.provinces.empty())
171 bool is_state =
false;
172 bool is_region =
false;
173 for(
const auto prov : new_context.provinces) {
174 if(context.
state.
world.province_get_state_from_abstract_state_membership(prov)) {
180 if(is_state && is_region) {
182 for(
const auto prov : new_context.provinces) {
183 if(context.
state.
world.province_get_state_from_abstract_state_membership(prov)) {
189 auto sdef = context.
state.
world.create_state_definition();
191 auto rdef = context.
state.
world.create_region();
193 for(
const auto prov : new_context.provinces) {
194 context.
state.
world.force_create_region_membership(prov, rdef);
195 if(!context.
state.
world.province_get_state_from_abstract_state_membership(prov)) {
196 context.
state.
world.force_create_abstract_state_membership(prov, sdef);
199 context.
state.
world.state_definition_set_name(sdef, name_id);
200 context.
state.
world.region_set_name(rdef, name_id);
201 }
else if(is_region) {
202 auto rdef = context.
state.
world.create_region();
204 for(
const auto prov : new_context.provinces) {
205 context.
state.
world.force_create_region_membership(prov, rdef);
207 context.
state.
world.region_set_name(rdef, name_id);
208 }
else if(is_state) {
209 auto sdef = context.
state.
world.create_state_definition();
211 for(
const auto prov : new_context.provinces) {
212 context.
state.
world.force_create_abstract_state_membership(prov, sdef);
214 context.
state.
world.state_definition_set_name(sdef, name_id);
221 auto new_modifier = context.
state.
world.create_modifier();
226 context.
state.
world.modifier_set_name(new_modifier, name_id);
229 auto continent = parse_continent_definition(gen, err, new_context);
231 context.
state.
world.modifier_set_icon(new_modifier,
uint8_t(continent.icon_index));
232 context.
state.
world.modifier_set_province_values(new_modifier, continent.peek_province_mod());
233 context.
state.
world.modifier_set_national_values(new_modifier, continent.peek_national_mod());
241 }
else if(
is_fixed_token_ci(name.data(), name.data() + name.length(),
"africa")) {
243 }
else if(
is_fixed_token_ci(name.data(), name.data() + name.length(),
"north_america")) {
245 }
else if(
is_fixed_token_ci(name.data(), name.data() + name.length(),
"south_america")) {
247 }
else if(
is_fixed_token_ci(name.data(), name.data() + name.length(),
"oceania")) {
256 auto new_modifier = [&]() {
260 auto new_id = context.
state.
world.create_modifier();
262 context.
state.
world.modifier_set_name(new_id, name_id);
268 auto climate = parse_climate_definition(gen, err, new_context);
270 if(climate.icon_index != 0)
271 context.
state.
world.modifier_set_icon(new_modifier,
uint8_t(climate.icon_index));
272 if(climate.next_to_add_p != 0) {
273 context.
state.
world.modifier_set_province_values(new_modifier, climate.peek_province_mod());
275 if(climate.next_to_add_n != 0) {
276 context.
state.
world.modifier_set_national_values(new_modifier, climate.peek_national_mod());
285 parse_province_history_file(gen, err, context);
290 auto fat_tag = fatten(world, tag);
291 auto tag_holder = fat_tag.get_nation_from_identity_holder();
295 tag_holder = world.create_nation();
296 world.force_create_identity_holder(tag_holder, tag);
318 std::string(
text) +
" is not a valid commodity name (" + err.
file_name +
" line " + std::to_string(line) +
")\n";
404 err.
accumulated_errors +=
"unknown province history key " + std::string(name) +
" (" + err.
file_name +
" line " + std::to_string(line) +
")\n";
417 std::string(
text) +
" is not a valid commodity name (" + err.
file_name +
" line " + std::to_string(line) +
")\n";
426 if(value.trade_good_id) {
434 auto province_int =
parse_int(name, 0, err);
441 parse_pop_province_list(gen, err, new_context);
452 cpos = parsers::parse_fixed_amount_csv_values<6>(cpos, end,
';', [&](std::string_view
const* values) {
459 if(provid_text.empty()) {
463 if(size_text.empty()) {
467 if(culture_text.empty()) {
471 if(religion_text.empty()) {
475 if(type_text.empty()) {
483 if(!rebel_text.empty()) {
488 ppl.
any_group(type_text, def, err, 0, pop_context);
500 cpos = parsers::parse_fixed_amount_csv_values<8>(cpos, end,
';', [&](std::string_view
const* values) {
509 if(provid_text.empty()) {
513 if(trade_goods_text.empty()) {
519 if(!owner_text.empty()) {
522 if(!controller_text.empty()) {
525 if(!core_text.empty()) {
std::string accumulated_errors
std::string accumulated_warnings
std::string_view province_building_type_get_name(economy::province_building_type v)
std::string int_to_tag(uint32_t v)
void parse_csv_pop_history_file(sys::state &state, const char *start, const char *end, error_handler &err, scenario_building_context &context)
void make_climate_definition(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
void read_map_adjacency(char const *start, char const *end, error_handler &err, scenario_building_context &context)
void parse_csv_province_history_file(sys::state &state, const char *start, const char *end, error_handler &err, scenario_building_context &context)
bool is_fixed_token_ci(char const *start, char const *end, char const (&t)[N])
void make_state_definition(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
sys::year_month_day parse_date(std::string_view content, int32_t line, error_handler &err)
int32_t parse_int(std::string_view content, int32_t line, error_handler &err)
std::string_view remove_surrounding_whitespace(std::string_view txt)
void make_pop_province_list(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
void make_terrain_modifier(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
uint32_t parse_tag(std::string_view tag, int32_t line, error_handler &err)
dcon::nation_id prov_parse_force_tag_owner(dcon::national_identity_id tag, dcon::data_container &world)
uint32_t parse_uint(std::string_view content, int32_t line, error_handler &err)
void make_continent_definition(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
void enter_dated_block(std::string_view name, token_generator &gen, error_handler &err, province_file_context &context)
char const * csv_advance_to_next_line(char const *start, char const *end)
void read_map_colors(char const *start, char const *end, error_handler &err, scenario_building_context &context)
constexpr uint8_t impassible_bit
constexpr uint8_t non_adjacent_bit
uint32_t pack_color(float r, float g, float b)
dcon::text_key find_or_add_key(sys::state &state, std::string_view key, bool as_unicode)
ankerl::unordered_dense::map< std::string, dcon::gfx_object_id > map_of_names
void finish(scenario_building_context &)
void max_provinces(association_type, int32_t value, error_handler &err, int32_t line, scenario_building_context &context)
void finish(scenario_building_context &context)
void rebel_type(association_type, std::string_view value, error_handler &err, int32_t line, pop_history_province_context &context)
void religion(association_type, std::string_view value, error_handler &err, int32_t line, pop_history_province_context &context)
void culture(association_type, std::string_view value, error_handler &err, int32_t line, pop_history_province_context &context)
void finish(pop_history_province_context &)
void any_group(std::string_view type, pop_history_definition const &def, error_handler &err, int32_t line, pop_history_province_context &context)
scenario_building_context & outer_context
void colony(association_type, uint32_t value, error_handler &err, int32_t line, province_file_context &context)
void terrain(association_type, std::string_view text, error_handler &err, int32_t line, province_file_context &context)
void state_building(pv_state_building const &value, error_handler &err, int32_t line, province_file_context &context)
void controller(association_type, uint32_t value, error_handler &err, int32_t line, province_file_context &context)
void owner(association_type, uint32_t value, error_handler &err, int32_t line, province_file_context &context)
void remove_core(association_type, uint32_t value, error_handler &err, int32_t line, province_file_context &context)
void is_slave(association_type, bool value, error_handler &err, int32_t line, province_file_context &context)
void rgo_distribution(province_rgo_ext const &value, error_handler &err, int32_t line, province_file_context &context)
void any_value(std::string_view name, association_type, uint32_t value, error_handler &err, int32_t line, province_file_context &context)
void party_loyalty(pv_party_loyalty const &value, error_handler &err, int32_t line, province_file_context &context)
void add_core(association_type, uint32_t value, error_handler &err, int32_t line, province_file_context &context)
void life_rating(association_type, uint32_t value, error_handler &err, int32_t line, province_file_context &context)
void trade_goods(association_type, std::string_view text, error_handler &err, int32_t line, province_file_context &context)
void max_employment(association_type, uint32_t value, error_handler &err, int32_t line, province_file_context &context)
void finish(province_file_context &)
void trade_good(association_type, std::string_view text, error_handler &err, int32_t line, province_file_context &context)
dcon::commodity_id trade_good_id
float max_employment_value
void entry(province_rgo_ext_desc const &value, error_handler &err, int32_t line, province_file_context &context)
ankerl::unordered_dense::map< std::string, dcon::state_definition_id > map_of_state_names
uint32_t color_by_terrain_index[64]
ankerl::unordered_dense::map< std::string, dcon::modifier_id > map_of_modifiers
dcon::modifier_id modifier_by_terrain_index[64]
std::vector< dcon::province_id > original_id_to_prov_id_map
tagged_vector< province_data, dcon::province_id > prov_id_to_original_id_map
ankerl::unordered_dense::map< std::string, terrain_type > map_of_terrain_types
ankerl::unordered_dense::map< std::string, dcon::region_id > map_of_region_names
dcon::modifier_id ocean_terrain
ankerl::unordered_dense::map< uint32_t, dcon::national_identity_id > map_of_ident_names
building_gfx_context gfx_context
ankerl::unordered_dense::map< std::string, dcon::commodity_id > map_of_commodity_names
ankerl::unordered_dense::map< uint32_t, dcon::province_id > map_color_to_province_id
std::vector< dcon::province_id > special_impassible
dcon::modifier_id south_america
ankerl::unordered_dense::map< dcon::modifier_id, dcon::gfx_object_id, sys::modifier_hash > terrain_to_gfx_map
std::vector< dcon::province_adjacency_id > canals
dcon::province_id first_sea_province
dcon::modifier_id north_america
dcon::modifier_id oceania
std::vector< dcon::province_id > canal_provinces
dcon::data_container world
absolute_time_point start_date
province::global_provincial_state province_definitions