Project Alice
Loading...
Searching...
No Matches
provinces_parsing.cpp
Go to the documentation of this file.
2#include <algorithm>
3#include <iterator>
4#include "container_types.hpp"
5
6namespace parsers {
7void default_map_file::max_provinces(association_type, int32_t value, error_handler& err, int32_t line,
9 context.state.world.province_resize(int32_t(value - 1));
10 context.original_id_to_prov_id_map.resize(value);
11 context.prov_id_to_original_id_map.resize(value - 1);
12
13 for(int32_t i = 1; i < value; ++i) {
14 context.prov_id_to_original_id_map[dcon::province_id(dcon::province_id::value_base_t(i - 1))].id = i;
15 }
16}
18 auto first_sea = std::stable_partition(context.prov_id_to_original_id_map.begin(), context.prov_id_to_original_id_map.end(),
19 [](province_data const& a) { return !(a.is_sea); });
20
21 for(size_t i = context.prov_id_to_original_id_map.size(); i-- > 0;) {
22 dcon::province_id id = dcon::province_id(dcon::province_id::value_base_t(i));
23 auto old_id = context.prov_id_to_original_id_map[id].id;
24 context.original_id_to_prov_id_map[old_id] = id;
25
26 auto name = std::string("PROV") + std::to_string(old_id);
27 auto name_id = text::find_or_add_key(context.state, name, false);
28
29 context.state.world.province_set_name(id, name_id);
30 }
31
32 auto to_first_sea = std::distance(context.prov_id_to_original_id_map.begin(), first_sea);
33 context.state.province_definitions.first_sea_province = dcon::province_id(dcon::province_id::value_base_t(to_first_sea));
34}
35
36void read_map_colors(char const* start, char const* end, error_handler& err, scenario_building_context& context) {
37 char const* cpos = parsers::csv_advance_to_next_line(start, end); // first line is always useless
38 while(cpos < end) {
39 cpos = parsers::parse_fixed_amount_csv_values<4>(cpos, end, ';', [&](std::string_view const* values) {
40 auto first_text = parsers::remove_surrounding_whitespace(values[0]);
41 if(first_text.length() > 0) {
42 auto first_value = parsers::parse_int(first_text, 0, err);
43 if(first_value == 0) {
44 // dead line
45 } else if(size_t(first_value) >= context.original_id_to_prov_id_map.size()) {
46 err.accumulated_errors += "Province id " + std::to_string(first_value) + " is too large (" + err.file_name + ")\n";
47 } else {
48 auto province_id = context.original_id_to_prov_id_map[first_value];
52 context.map_color_to_province_id.insert_or_assign(color_value, province_id);
53 }
54 }
55 });
56 }
57}
58
59void read_map_adjacency(char const* start, char const* end, error_handler& err, scenario_building_context& context) {
60 char const* cpos = parsers::csv_advance_to_next_line(start, end); // first line is always useless
61 while(cpos < end) {
62 // 2711;2721;canal;369;1
63 cpos = parsers::parse_fixed_amount_csv_values<5>(cpos, end, ';', [&](std::string_view const* values) {
64 auto first_text = parsers::remove_surrounding_whitespace(values[0]);
65 auto second_text = parsers::remove_surrounding_whitespace(values[1]);
66 if(first_text.length() > 0) {
67 // 2204;2206;sea;3001;0;Panama strait
68 auto first_value = parsers::parse_int(first_text, 0, err);
69 auto second_value = parsers::parse_int(second_text, 0, err);
70 if(first_value <= 0) {
71 // dead line
72 } else if(second_value <= 0) {
73 auto province_id_a = context.original_id_to_prov_id_map[first_value];
74 auto ttex = parsers::remove_surrounding_whitespace(values[2]);
75 if(is_fixed_token_ci(ttex.data(), ttex.data() + ttex.length(), "impassable")) {
76 context.special_impassible.push_back(province_id_a);
77 } else {
78 // dead line
79 }
80 } else if(size_t(first_value) >= context.original_id_to_prov_id_map.size()) {
81 err.accumulated_errors += "Province id " + std::to_string(first_value) + " is too large (" + err.file_name + ")\n";
82 } else if(size_t(second_value) >= context.original_id_to_prov_id_map.size()) {
83 err.accumulated_errors += "Province id " + std::to_string(first_value) + " is too large (" + err.file_name + ")\n";
84 } else {
85 auto province_id_a = context.original_id_to_prov_id_map[first_value];
86 auto province_id_b = context.original_id_to_prov_id_map[second_value];
87
88 auto ttex = parsers::remove_surrounding_whitespace(values[2]);
89 if(is_fixed_token_ci(ttex.data(), ttex.data() + ttex.length(), "sea")) {
90 auto new_rel = context.state.world.force_create_province_adjacency(province_id_a, province_id_b);
91 context.state.world.province_adjacency_set_type(new_rel, province::border::non_adjacent_bit);
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);
94 context.state.world.province_adjacency_set_type(new_rel, province::border::impassible_bit);
95 } else if(is_fixed_token_ci(ttex.data(), ttex.data() + ttex.length(), "canal")) {
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,
99
100 auto canal_id = parsers::parse_uint(parsers::remove_surrounding_whitespace(values[4]), 0, err);
101
102 if(canal_id > 0) {
103 if(context.state.province_definitions.canals.size() < canal_id) {
104 context.state.province_definitions.canals.resize(canal_id);
105 }
106 context.state.province_definitions.canals[canal_id - 1] = new_rel;
107
108 auto canal_province_id = parsers::parse_uint(parsers::remove_surrounding_whitespace(values[3]), 0, err);
109 if(context.state.province_definitions.canal_provinces.size() < canal_id) {
110 context.state.province_definitions.canal_provinces.resize(canal_id);
111 }
112 context.state.province_definitions.canal_provinces[canal_id - 1] = context.original_id_to_prov_id_map[canal_province_id];
113 } else {
114 err.accumulated_errors += "Canal in " + std::to_string(first_value) + " is invalid (" + err.file_name + ")\n";
115 }
116 }
117 }
118 }
119 });
120 }
121}
122
124 if(color.free_value == 254) {
125 auto it = context.map_of_terrain_types.find(std::string(type));
126 if(it != context.map_of_terrain_types.end()) {
127 context.ocean_terrain = it->second.id;
128 }
129 }
130
131 if(color.free_value < 0 || color.free_value >= 64)
132 return;
133
134 auto it = context.map_of_terrain_types.find(std::string(type));
135 if(it != context.map_of_terrain_types.end()) {
136 context.color_by_terrain_index[color.free_value] = it->second.color;
137 context.modifier_by_terrain_index[color.free_value] = it->second.id;
138 }
139}
140
141void make_terrain_modifier(std::string_view name, token_generator& gen, error_handler& err, scenario_building_context& context) {
142 auto name_id = text::find_or_add_key(context.state, name, false);
143
144 auto parsed_modifier = parse_terrain_modifier(gen, err, context);
145
146 auto new_modifier = context.state.world.create_modifier();
147
148 std::string gfx_name = std::string("GFX_terrainimg_") + std::string(name); // GFX_terrainimg_XXX
149 if(auto it = context.gfx_context.map_of_names.find(gfx_name); it != context.gfx_context.map_of_names.end()) {
150 context.state.province_definitions.terrain_to_gfx_map.insert_or_assign(new_modifier, it->second);
151 }
152
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);
155 context.state.world.modifier_set_desc(new_modifier, text::find_or_add_key(context.state, std::string(name) + "_desc", false));
156
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());
159
160 context.map_of_modifiers.insert_or_assign(std::string(name), new_modifier);
161 context.map_of_terrain_types.insert_or_assign(std::string(name), terrain_type{new_modifier, parsed_modifier.color.value});
162}
163
164void make_state_definition(std::string_view name, token_generator& gen, error_handler& err, scenario_building_context& context) {
165 auto name_id = text::find_or_add_key(context.state, name, false);
166 state_def_building_context new_context{ context, std::vector<dcon::province_id>{} };
167 parsers::parse_state_definition(gen, err, new_context);
168 if(new_context.provinces.empty())
169 return; //empty, tooltip metaregions
170
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)) {
175 is_region = true;
176 } else {
177 is_state = true;
178 }
179 }
180 if(is_state && is_region) {
181 err.accumulated_warnings += "State " + std::string(name) + " mixes assigned and unassigned provinces (" + err.file_name + ")\n";
182 for(const auto prov : new_context.provinces) {
183 if(context.state.world.province_get_state_from_abstract_state_membership(prov)) {
184 err.accumulated_warnings += "Province " + std::to_string(context.prov_id_to_original_id_map[prov].id) + " on state " + std::string(name) + " is already assigned to a state (" + err.file_name + ")\n";
185 }
186 }
187
188 //mixed - state and region
189 auto sdef = context.state.world.create_state_definition();
190 context.map_of_state_names.insert_or_assign(std::string(name), sdef);
191 auto rdef = context.state.world.create_region();
192 context.map_of_region_names.insert_or_assign(std::string(name), rdef);
193 for(const auto prov : new_context.provinces) {
194 context.state.world.force_create_region_membership(prov, rdef); //include first, regions take priority over states!
195 if(!context.state.world.province_get_state_from_abstract_state_membership(prov)) {
196 context.state.world.force_create_abstract_state_membership(prov, sdef); //new assignment
197 }
198 }
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();
203 context.map_of_region_names.insert_or_assign(std::string(name), rdef);
204 for(const auto prov : new_context.provinces) {
205 context.state.world.force_create_region_membership(prov, rdef);
206 }
207 context.state.world.region_set_name(rdef, name_id);
208 } else if(is_state) {
209 auto sdef = context.state.world.create_state_definition();
210 context.map_of_state_names.insert_or_assign(std::string(name), sdef);
211 for(const auto prov : new_context.provinces) {
212 context.state.world.force_create_abstract_state_membership(prov, sdef);
213 }
214 context.state.world.state_definition_set_name(sdef, name_id);
215 }
216}
217
218void make_continent_definition(std::string_view name, token_generator& gen, error_handler& err,
219 scenario_building_context& context) {
220 auto name_id = text::find_or_add_key(context.state, name, false);
221 auto new_modifier = context.state.world.create_modifier();
222
223 context.map_of_modifiers.insert_or_assign(std::string(name), new_modifier);
224
225 continent_building_context new_context{context, new_modifier};
226 context.state.world.modifier_set_name(new_modifier, name_id);
227 context.state.world.modifier_set_desc(new_modifier, text::find_or_add_key(context.state, std::string(name) + "_desc", false));
228
229 auto continent = parse_continent_definition(gen, err, new_context);
230
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());
234
235 /* [...] "The game has special logic concerning which nations automatically count as
236 interested in a crisis that references the existing continents" [...] */
237 if(is_fixed_token_ci(name.data(), name.data() + name.length(), "europe")) {
238 context.state.province_definitions.europe = new_modifier;
239 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "asia")) {
240 context.state.province_definitions.asia = new_modifier;
241 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "africa")) {
242 context.state.province_definitions.africa = new_modifier;
243 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "north_america")) {
244 context.state.province_definitions.north_america = new_modifier;
245 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "south_america")) {
246 context.state.province_definitions.south_america = new_modifier;
247 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "oceania")) {
248 context.state.province_definitions.oceania = new_modifier;
249 }
250}
251
252void make_climate_definition(std::string_view name, token_generator& gen, error_handler& err,
253 scenario_building_context& context) {
254 auto name_id = text::find_or_add_key(context.state, name, false);
255
256 auto new_modifier = [&]() {
257 if(auto it = context.map_of_modifiers.find(std::string(name)); it != context.map_of_modifiers.end())
258 return it->second;
259
260 auto new_id = context.state.world.create_modifier();
261 context.map_of_modifiers.insert_or_assign(std::string(name), new_id);
262 context.state.world.modifier_set_name(new_id, name_id);
263 context.state.world.modifier_set_desc(new_id, text::find_or_add_key(context.state, std::string(name) + "_desc", false));
264 return new_id;
265 }();
266
267 climate_building_context new_context{context, new_modifier};
268 auto climate = parse_climate_definition(gen, err, new_context);
269
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());
274 }
275 if(climate.next_to_add_n != 0) {
276 context.state.world.modifier_set_national_values(new_modifier, climate.peek_national_mod());
277 }
278}
279
280void enter_dated_block(std::string_view name, token_generator& gen, error_handler& err, province_file_context& context) {
281 auto ymd = parse_date(name, 0, err);
282 if(sys::date(ymd, context.outer_context.state.start_date) > context.outer_context.state.current_date) { // is after the start date
283 gen.discard_group();
284 } else {
285 parse_province_history_file(gen, err, context);
286 }
287}
288
289dcon::nation_id prov_parse_force_tag_owner(dcon::national_identity_id tag, dcon::data_container& world) {
290 auto fat_tag = fatten(world, tag);
291 auto tag_holder = fat_tag.get_nation_from_identity_holder();
292 if(tag_holder)
293 return tag_holder;
294
295 tag_holder = world.create_nation();
296 world.force_create_identity_holder(tag_holder, tag);
297
298 return tag_holder;
299}
300
302 province_file_context& context) {
303 context.outer_context.state.world.province_set_life_rating(context.id, uint8_t(value));
304}
305
307 province_file_context& context) {
308 context.outer_context.state.world.province_set_is_colonial(context.id, value != 0);
309}
310
312 province_file_context& context) {
313 if(auto it = context.outer_context.map_of_commodity_names.find(std::string(text));
314 it != context.outer_context.map_of_commodity_names.end()) {
315 context.outer_context.state.world.province_set_rgo(context.id, it->second);
316 } else {
317 err.accumulated_errors +=
318 std::string(text) + " is not a valid commodity name (" + err.file_name + " line " + std::to_string(line) + ")\n";
319 }
320}
321
323 return;
324}
325
327 province_file_context& context) {
328 if(auto it = context.outer_context.map_of_ident_names.find(value); it != context.outer_context.map_of_ident_names.end()) {
329 auto holder = prov_parse_force_tag_owner(it->second, context.outer_context.state.world);
330 context.outer_context.state.world.force_create_province_ownership(context.id, holder);
331 } else {
332 err.accumulated_errors += "Invalid tag " + nations::int_to_tag(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
333 }
334}
336 province_file_context& context) {
337 if(auto it = context.outer_context.map_of_ident_names.find(value); it != context.outer_context.map_of_ident_names.end()) {
338 auto holder = prov_parse_force_tag_owner(it->second, context.outer_context.state.world);
339 context.outer_context.state.world.force_create_province_control(context.id, holder);
340 } else {
341 err.accumulated_errors += "Invalid tag " + nations::int_to_tag(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
342 }
343}
344
345void province_history_file::terrain(association_type, std::string_view text, error_handler& err, int32_t line,
346 province_file_context& context) {
347 if(auto it = context.outer_context.map_of_terrain_types.find(std::string(text));
348 it != context.outer_context.map_of_terrain_types.end()) {
349 context.outer_context.state.world.province_set_terrain(context.id, it->second.id);
350 } else {
351 err.accumulated_errors += "Invalid terrain '" + std::string(text) + "' (" + err.file_name + " line " + std::to_string(line) + ")\n";
352 }
353}
354
356 province_file_context& context) {
357 if(auto it = context.outer_context.map_of_ident_names.find(value); it != context.outer_context.map_of_ident_names.end()) {
358 context.outer_context.state.world.try_create_core(context.id, it->second);
359 } else {
360 err.accumulated_errors += "Invalid tag " + nations::int_to_tag(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
361 }
362}
363
365 province_file_context& context) {
366 if(auto it = context.outer_context.map_of_ident_names.find(value); it != context.outer_context.map_of_ident_names.end()) {
367 auto core = context.outer_context.state.world.get_core_by_prov_tag_key(context.id, it->second);
368 context.outer_context.state.world.delete_core(core);
369 } else {
370 err.accumulated_errors += "Invalid tag " + nations::int_to_tag(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
371 }
372}
373
375 province_file_context& context) {
376 if(value.id) {
377 context.outer_context.state.world.province_set_party_loyalty(context.id, value.id, float(value.loyalty_value) / 100.0f);
378 }
379}
380
382 province_file_context& context) {
383 if(value.id) {
384 auto new_fac = context.outer_context.state.world.create_factory();
385 context.outer_context.state.world.factory_set_building_type(new_fac, value.id);
386 context.outer_context.state.world.factory_set_level(new_fac, uint8_t(value.level));
387 context.outer_context.state.world.force_create_factory_location(new_fac, context.id);
388 }
389}
390
392 province_file_context& context) {
393 context.outer_context.state.world.province_set_is_slave(context.id, value);
394}
395
396void province_history_file::any_value(std::string_view name, association_type, uint32_t value, error_handler& err, int32_t line,
397 province_file_context& context) {
400 context.outer_context.state.world.province_set_building_level(context.id, uint8_t(t), uint8_t(value));
401 return;
402 }
403 }
404 err.accumulated_errors += "unknown province history key " + std::string(name) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";//err.unhandled_association_key();
405}
406
408 max_employment_value = float(value);
409}
410
412 if(auto it = context.outer_context.map_of_commodity_names.find(std::string(text));
413 it != context.outer_context.map_of_commodity_names.end()) {
414 trade_good_id = it->second;
415 } else {
416 err.accumulated_errors +=
417 std::string(text) + " is not a valid commodity name (" + err.file_name + " line " + std::to_string(line) + ")\n";
418 }
419}
420
422
423};
424
426 if(value.trade_good_id) {
427 auto p = context.id;
428 context.outer_context.state.world.province_set_rgo_max_size_per_good(p, value.trade_good_id, value.max_employment_value / context.outer_context.state.defines.alice_rgo_per_size_employment);
429 context.outer_context.state.world.province_set_rgo_was_set_during_scenario_creation(p, true);
430 }
431}
432
433void make_pop_province_list(std::string_view name, token_generator& gen, error_handler& err, scenario_building_context& context) {
434 auto province_int = parse_int(name, 0, err);
435 if(province_int < 0 || size_t(province_int) >= context.original_id_to_prov_id_map.size()) {
436 err.accumulated_errors += "Province id " + std::string(name) + " is invalid (" + err.file_name + ")\n";
437 gen.discard_group();
438 } else {
439 auto province_id = context.original_id_to_prov_id_map[province_int];
440 pop_history_province_context new_context{context, province_id};
441 parse_pop_province_list(gen, err, new_context);
442 }
443}
444
445void parse_csv_pop_history_file(sys::state& state, const char* start, const char* end, error_handler& err, scenario_building_context& context) {
448
449 auto cpos = start;
450 while(cpos < end) {
451 // province-id;size;culture;religion;type;rebel-faction
452 cpos = parsers::parse_fixed_amount_csv_values<6>(cpos, end, ';', [&](std::string_view const* values) {
453 auto provid_text = parsers::remove_surrounding_whitespace(values[0]);
454 auto size_text = parsers::remove_surrounding_whitespace(values[1]);
455 auto culture_text = parsers::remove_surrounding_whitespace(values[2]);
456 auto religion_text = parsers::remove_surrounding_whitespace(values[3]);
457 auto type_text = parsers::remove_surrounding_whitespace(values[4]);
458 auto rebel_text = parsers::remove_surrounding_whitespace(values[5]);
459 if(provid_text.empty()) {
460 err.accumulated_errors += "Unspecified province id (" + err.file_name + ")\n";
461 return;
462 }
463 if(size_text.empty()) {
464 err.accumulated_errors += "Unspecified size (" + err.file_name + ")\n";
465 return;
466 }
467 if(culture_text.empty()) {
468 err.accumulated_errors += "Unspecified culture (" + err.file_name + ")\n";
469 return;
470 }
471 if(religion_text.empty()) {
472 err.accumulated_errors += "Unspecified religion (" + err.file_name + ")\n";
473 return;
474 }
475 if(type_text.empty()) {
476 err.accumulated_errors += "Unspecified type (" + err.file_name + ")\n";
477 return;
478 }
479 auto p = context.original_id_to_prov_id_map[parsers::parse_int(provid_text, 0, err)];
480 pop_history_province_context pop_context{context, p};
481 def.culture(parsers::association_type::eq_default, culture_text, err, 0, pop_context);
482 def.religion(parsers::association_type::eq_default, religion_text , err, 0, pop_context);
483 if(!rebel_text.empty()) {
484 def.rebel_type(parsers::association_type::eq_default, rebel_text, err, 0, pop_context);
485 }
486 def.size = parsers::parse_int(size_text, 0, err);
487 //def.rebel_type(parsers::association_type::eq_default, culture_text, err, 0, pop_context);
488 ppl.any_group(type_text, def, err, 0, pop_context);
489 ppl.finish(pop_context);
490 });
491 }
492}
493
494void parse_csv_province_history_file(sys::state& state, const char* start, const char* end, error_handler& err, scenario_building_context& context) {
496
497 auto cpos = start;
498 while(cpos < end) {
499 // province-id;owner;controller;core;trade_goods;life_rating;colonial;slave
500 cpos = parsers::parse_fixed_amount_csv_values<8>(cpos, end, ';', [&](std::string_view const* values) {
501 auto provid_text = parsers::remove_surrounding_whitespace(values[0]);
502 auto owner_text = parsers::remove_surrounding_whitespace(values[1]);
503 auto controller_text = parsers::remove_surrounding_whitespace(values[2]);
504 auto core_text = parsers::remove_surrounding_whitespace(values[3]);
505 auto trade_goods_text = parsers::remove_surrounding_whitespace(values[4]);
506 auto life_rating_text = parsers::remove_surrounding_whitespace(values[5]);
507 auto is_colonial_text = parsers::remove_surrounding_whitespace(values[6]);
508 auto is_slave_text = parsers::remove_surrounding_whitespace(values[7]);
509 if(provid_text.empty()) {
510 err.accumulated_errors += "Unspecified province id (" + err.file_name + ")\n";
511 return;
512 }
513 if(trade_goods_text.empty()) {
514 err.accumulated_errors += "Unspecified trade_goods (" + err.file_name + ")\n";
515 return;
516 }
517 auto p = context.original_id_to_prov_id_map[parsers::parse_int(provid_text, 0, err)];
518 province_file_context province_context{ context, p };
519 if(!owner_text.empty()) {
520 f.owner(parsers::association_type::eq_default, parsers::parse_tag(owner_text, 0, err), err, 0, province_context);
521 }
522 if(!controller_text.empty()) {
523 f.controller(parsers::association_type::eq_default, parsers::parse_tag(controller_text, 0, err), err, 0, province_context);
524 }
525 if(!core_text.empty()) {
526 f.add_core(parsers::association_type::eq_default, parsers::parse_tag(core_text, 0, err), err, 0, province_context);
527 }
528 f.trade_goods(parsers::association_type::eq_default, trade_goods_text, err, 0, province_context);
529 f.life_rating(parsers::association_type::eq_default, parsers::parse_int(life_rating_text, 0, err), err, 0, province_context);
530 f.colony(parsers::association_type::eq_default, parsers::parse_int(is_colonial_text, 0, err), err, 0, province_context);
531 f.is_slave(parsers::association_type::eq_default, parsers::parse_int(is_slave_text, 0, err), err, 0, province_context);
532 });
533 }
534}
535
536} // namespace parsers
std::string accumulated_errors
Definition: parsers.hpp:62
std::string accumulated_warnings
Definition: parsers.hpp:63
std::string file_name
Definition: parsers.hpp:61
std::string_view province_building_type_get_name(economy::province_building_type v)
Definition: economy.hpp:56
province_building_type
Definition: constants.hpp:578
std::string int_to_tag(uint32_t v)
Definition: nations.hpp:10
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)
association_type
Definition: parsers.hpp:28
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])
Definition: parsers.hpp:275
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)
Definition: parsers.cpp:253
int32_t parse_int(std::string_view content, int32_t line, error_handler &err)
Definition: parsers.cpp:226
std::string_view remove_surrounding_whitespace(std::string_view txt)
Definition: parsers.cpp:381
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)
Definition: parsers.cpp:244
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)
Definition: parsers.cpp:235
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)
Definition: parsers.cpp:368
void read_map_colors(char const *start, char const *end, error_handler &err, scenario_building_context &context)
constexpr uint8_t impassible_bit
Definition: constants.hpp:595
constexpr uint8_t non_adjacent_bit
Definition: constants.hpp:596
uint32_t pack_color(float r, float g, float b)
Definition: bmfont.cpp:118
dcon::text_key find_or_add_key(sys::state &state, std::string_view key, bool as_unicode)
Definition: text.cpp:695
uint uint32_t
uchar uint8_t
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)
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
ankerl::unordered_dense::map< std::string, dcon::modifier_id > map_of_modifiers
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
ankerl::unordered_dense::map< uint32_t, dcon::national_identity_id > map_of_ident_names
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
Definition: province.hpp:31
ankerl::unordered_dense::map< dcon::modifier_id, dcon::gfx_object_id, sys::modifier_hash > terrain_to_gfx_map
Definition: province.hpp:23
std::vector< dcon::province_adjacency_id > canals
Definition: province.hpp:21
dcon::province_id first_sea_province
Definition: province.hpp:26
dcon::modifier_id north_america
Definition: province.hpp:30
std::vector< dcon::province_id > canal_provinces
Definition: province.hpp:22
dcon::data_container world
parsing::defines defines
absolute_time_point start_date
sys::date current_date
province::global_provincial_state province_definitions