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 auto rdef = context.state.world.create_region();
170 context.map_of_region_names.insert_or_assign(std::string(name), rdef);
171 context.state.world.region_set_name(rdef, name_id);
172 return; //empty, tooltip metaregions
173 }
174
175 bool is_state = false;
176 bool is_region = false;
177 for(const auto prov : new_context.provinces) {
178 if(context.state.world.province_get_state_from_abstract_state_membership(prov)) {
179 is_region = true;
180 } else {
181 is_state = true;
182 }
183 }
184 if(is_state && is_region) {
185 err.accumulated_warnings += "State " + std::string(name) + " mixes assigned and unassigned provinces (" + err.file_name + ")\n";
186 for(const auto prov : new_context.provinces) {
187 if(context.state.world.province_get_state_from_abstract_state_membership(prov)) {
188 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";
189 }
190 }
191
192 //mixed - state and region
193 auto sdef = context.state.world.create_state_definition();
194 context.map_of_state_names.insert_or_assign(std::string(name), sdef);
195 auto rdef = context.state.world.create_region();
196 context.map_of_region_names.insert_or_assign(std::string(name), rdef);
197 for(const auto prov : new_context.provinces) {
198 context.state.world.force_create_region_membership(prov, rdef); //include first, regions take priority over states!
199 if(!context.state.world.province_get_state_from_abstract_state_membership(prov)) {
200 context.state.world.force_create_abstract_state_membership(prov, sdef); //new assignment
201 }
202 }
203 context.state.world.state_definition_set_name(sdef, name_id);
204 context.state.world.region_set_name(rdef, name_id);
205 } else if(is_region) {
206 auto rdef = context.state.world.create_region();
207 context.map_of_region_names.insert_or_assign(std::string(name), rdef);
208 for(const auto prov : new_context.provinces) {
209 context.state.world.force_create_region_membership(prov, rdef);
210 }
211 context.state.world.region_set_name(rdef, name_id);
212 } else if(is_state) {
213 auto sdef = context.state.world.create_state_definition();
214 context.map_of_state_names.insert_or_assign(std::string(name), sdef);
215 for(const auto prov : new_context.provinces) {
216 context.state.world.force_create_abstract_state_membership(prov, sdef);
217 }
218 context.state.world.state_definition_set_name(sdef, name_id);
219 }
220}
221
222void make_continent_definition(std::string_view name, token_generator& gen, error_handler& err,
223 scenario_building_context& context) {
224 auto name_id = text::find_or_add_key(context.state, name, false);
225 auto new_modifier = context.state.world.create_modifier();
226
227 context.map_of_modifiers.insert_or_assign(std::string(name), new_modifier);
228
229 continent_building_context new_context{context, new_modifier};
230 context.state.world.modifier_set_name(new_modifier, name_id);
231 context.state.world.modifier_set_desc(new_modifier, text::find_or_add_key(context.state, std::string(name) + "_desc", false));
232
233 auto continent = parse_continent_definition(gen, err, new_context);
234
235 context.state.world.modifier_set_icon(new_modifier, uint8_t(continent.icon_index));
236 context.state.world.modifier_set_province_values(new_modifier, continent.peek_province_mod());
237 context.state.world.modifier_set_national_values(new_modifier, continent.peek_national_mod());
238
239 /* [...] "The game has special logic concerning which nations automatically count as
240 interested in a crisis that references the existing continents" [...] */
241 if(is_fixed_token_ci(name.data(), name.data() + name.length(), "europe")) {
242 context.state.province_definitions.europe = new_modifier;
243 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "asia")) {
244 context.state.province_definitions.asia = new_modifier;
245 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "africa")) {
246 context.state.province_definitions.africa = new_modifier;
247 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "north_america")) {
248 context.state.province_definitions.north_america = new_modifier;
249 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "south_america")) {
250 context.state.province_definitions.south_america = new_modifier;
251 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "oceania")) {
252 context.state.province_definitions.oceania = new_modifier;
253 }
254}
255
256void make_climate_definition(std::string_view name, token_generator& gen, error_handler& err,
257 scenario_building_context& context) {
258 auto name_id = text::find_or_add_key(context.state, name, false);
259
260 auto new_modifier = [&]() {
261 if(auto it = context.map_of_modifiers.find(std::string(name)); it != context.map_of_modifiers.end())
262 return it->second;
263
264 auto new_id = context.state.world.create_modifier();
265 context.map_of_modifiers.insert_or_assign(std::string(name), new_id);
266 context.state.world.modifier_set_name(new_id, name_id);
267 context.state.world.modifier_set_desc(new_id, text::find_or_add_key(context.state, std::string(name) + "_desc", false));
268 return new_id;
269 }();
270
271 climate_building_context new_context{context, new_modifier};
272 auto climate = parse_climate_definition(gen, err, new_context);
273
274 if(climate.icon_index != 0)
275 context.state.world.modifier_set_icon(new_modifier, uint8_t(climate.icon_index));
276 if(climate.next_to_add_p != 0) {
277 context.state.world.modifier_set_province_values(new_modifier, climate.peek_province_mod());
278 }
279 if(climate.next_to_add_n != 0) {
280 context.state.world.modifier_set_national_values(new_modifier, climate.peek_national_mod());
281 }
282}
283
284void enter_dated_block(std::string_view name, token_generator& gen, error_handler& err, province_file_context& context) {
285 auto ymd = parse_date(name, 0, err);
286 if(sys::date(ymd, context.outer_context.state.start_date) > context.outer_context.state.current_date) { // is after the start date
287 gen.discard_group();
288 } else {
289 parse_province_history_file(gen, err, context);
290 }
291}
292
293dcon::nation_id prov_parse_force_tag_owner(dcon::national_identity_id tag, dcon::data_container& world) {
294 auto fat_tag = fatten(world, tag);
295 auto tag_holder = fat_tag.get_nation_from_identity_holder();
296 if(tag_holder)
297 return tag_holder;
298
299 tag_holder = world.create_nation();
300 world.force_create_identity_holder(tag_holder, tag);
301
302 return tag_holder;
303}
304
306 province_file_context& context) {
307 context.outer_context.state.world.province_set_life_rating(context.id, uint8_t(value));
308}
309
311 province_file_context& context) {
312 context.outer_context.state.world.province_set_is_colonial(context.id, value != 0);
313}
314
316 province_file_context& context) {
317 if(auto it = context.outer_context.map_of_commodity_names.find(std::string(text));
318 it != context.outer_context.map_of_commodity_names.end()) {
319 context.outer_context.state.world.province_set_rgo(context.id, it->second);
320 } else {
321 err.accumulated_errors +=
322 std::string(text) + " is not a valid commodity name (" + err.file_name + " line " + std::to_string(line) + ")\n";
323 }
324}
325
327 return;
328}
329
331 province_file_context& context) {
332 if(auto it = context.outer_context.map_of_ident_names.find(value); it != context.outer_context.map_of_ident_names.end()) {
333 auto holder = prov_parse_force_tag_owner(it->second, context.outer_context.state.world);
334 context.outer_context.state.world.force_create_province_ownership(context.id, holder);
335 } else {
336 err.accumulated_errors += "Invalid tag " + nations::int_to_tag(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
337 }
338}
340 province_file_context& context) {
341 if(value == nations::tag_to_int('R', 'E', 'B')) {
342 // context.outer_context.state.world.province_set_nation_from_province_control(context.id, dcon::nation_id{});
343 } else if(auto it = context.outer_context.map_of_ident_names.find(value); it != context.outer_context.map_of_ident_names.end()) {
344 auto holder = prov_parse_force_tag_owner(it->second, context.outer_context.state.world);
345 context.outer_context.state.world.force_create_province_control(context.id, holder);
346 } else {
347 err.accumulated_errors += "Invalid tag " + nations::int_to_tag(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
348 }
349}
350
351void province_history_file::terrain(association_type, std::string_view text, error_handler& err, int32_t line,
352 province_file_context& context) {
353 if(auto it = context.outer_context.map_of_terrain_types.find(std::string(text));
354 it != context.outer_context.map_of_terrain_types.end()) {
355 context.outer_context.state.world.province_set_terrain(context.id, it->second.id);
356 } else {
357 err.accumulated_errors += "Invalid terrain '" + std::string(text) + "' (" + err.file_name + " line " + std::to_string(line) + ")\n";
358 }
359}
360
362 province_file_context& context) {
363 if(auto it = context.outer_context.map_of_ident_names.find(value); it != context.outer_context.map_of_ident_names.end()) {
364 context.outer_context.state.world.try_create_core(context.id, it->second);
365 } else {
366 err.accumulated_errors += "Invalid tag " + nations::int_to_tag(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
367 }
368}
369
371 province_file_context& context) {
372 if(auto it = context.outer_context.map_of_ident_names.find(value); it != context.outer_context.map_of_ident_names.end()) {
373 auto core = context.outer_context.state.world.get_core_by_prov_tag_key(context.id, it->second);
374 if(core) {
375 context.outer_context.state.world.delete_core(core);
376 } else {
377 err.accumulated_errors += "Tried to remove a non-existent core " + nations::int_to_tag(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
378 }
379 } else {
380 err.accumulated_errors += "Invalid tag " + nations::int_to_tag(value) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";
381 }
382}
383
385 province_file_context& context) {
386 if(value.id) {
387 context.outer_context.state.world.province_set_party_loyalty(context.id, value.id, float(value.loyalty_value) / 100.0f);
388 }
389}
390
392 province_file_context& context) {
393 if(value.id) {
394 auto new_fac = context.outer_context.state.world.create_factory();
395 context.outer_context.state.world.factory_set_building_type(new_fac, value.id);
396 context.outer_context.state.world.factory_set_level(new_fac, uint8_t(value.level));
397 context.outer_context.state.world.force_create_factory_location(new_fac, context.id);
398 }
399}
400
402 province_file_context& context) {
403 context.outer_context.state.world.province_set_is_slave(context.id, value);
404}
405
406void province_history_file::any_value(std::string_view name, association_type, uint32_t value, error_handler& err, int32_t line,
407 province_file_context& context) {
410 context.outer_context.state.world.province_set_building_level(context.id, uint8_t(t), uint8_t(value));
411 return;
412 }
413 }
414 err.accumulated_errors += "unknown province history key " + std::string(name) + " (" + err.file_name + " line " + std::to_string(line) + ")\n";//err.unhandled_association_key();
415}
416
418 max_employment_value = float(value);
419}
420
422 if(auto it = context.outer_context.map_of_commodity_names.find(std::string(text));
423 it != context.outer_context.map_of_commodity_names.end()) {
424 trade_good_id = it->second;
425 } else {
426 err.accumulated_errors +=
427 std::string(text) + " is not a valid commodity name (" + err.file_name + " line " + std::to_string(line) + ")\n";
428 }
429}
430
432
433};
434
436 if(value.trade_good_id) {
437 auto p = context.id;
438 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);
439 context.outer_context.state.world.province_set_rgo_was_set_during_scenario_creation(p, true);
440 }
441}
442
443void make_pop_province_list(std::string_view name, token_generator& gen, error_handler& err, scenario_building_context& context) {
444 auto province_int = parse_int(name, 0, err);
445 if(province_int < 0 || size_t(province_int) >= context.original_id_to_prov_id_map.size()) {
446 err.accumulated_errors += "Province id " + std::string(name) + " is invalid (" + err.file_name + ")\n";
447 gen.discard_group();
448 } else {
449 auto province_id = context.original_id_to_prov_id_map[province_int];
450 pop_history_province_context new_context{context, province_id};
451 parse_pop_province_list(gen, err, new_context);
452 }
453}
454
455void parse_csv_pop_history_file(sys::state& state, const char* start, const char* end, error_handler& err, scenario_building_context& context) {
458
459 auto cpos = start;
460 while(cpos < end) {
461 // province-id;size;culture;religion;type;rebel-faction
462 cpos = parsers::parse_fixed_amount_csv_values<6>(cpos, end, ';', [&](std::string_view const* values) {
463 auto provid_text = parsers::remove_surrounding_whitespace(values[0]);
464 auto size_text = parsers::remove_surrounding_whitespace(values[1]);
465 auto culture_text = parsers::remove_surrounding_whitespace(values[2]);
466 auto religion_text = parsers::remove_surrounding_whitespace(values[3]);
467 auto type_text = parsers::remove_surrounding_whitespace(values[4]);
468 auto rebel_text = parsers::remove_surrounding_whitespace(values[5]);
469 if(provid_text.empty()) {
470 err.accumulated_errors += "Unspecified province id (" + err.file_name + ")\n";
471 return;
472 }
473 if(size_text.empty()) {
474 err.accumulated_errors += "Unspecified size (" + err.file_name + ")\n";
475 return;
476 }
477 if(culture_text.empty()) {
478 err.accumulated_errors += "Unspecified culture (" + err.file_name + ")\n";
479 return;
480 }
481 if(religion_text.empty()) {
482 err.accumulated_errors += "Unspecified religion (" + err.file_name + ")\n";
483 return;
484 }
485 if(type_text.empty()) {
486 err.accumulated_errors += "Unspecified type (" + err.file_name + ")\n";
487 return;
488 }
489 auto p = context.original_id_to_prov_id_map[parsers::parse_int(provid_text, 0, err)];
490 pop_history_province_context pop_context{context, p};
491 def.culture(parsers::association_type::eq_default, culture_text, err, 0, pop_context);
492 def.religion(parsers::association_type::eq_default, religion_text , err, 0, pop_context);
493 if(!rebel_text.empty()) {
494 def.rebel_type(parsers::association_type::eq_default, rebel_text, err, 0, pop_context);
495 }
496 def.size = parsers::parse_int(size_text, 0, err);
497 //def.rebel_type(parsers::association_type::eq_default, culture_text, err, 0, pop_context);
498 ppl.any_group(type_text, def, err, 0, pop_context);
499 ppl.finish(pop_context);
500 });
501 }
502}
503
504void parse_csv_province_history_file(sys::state& state, const char* start, const char* end, error_handler& err, scenario_building_context& context) {
506
507 auto cpos = start;
508 while(cpos < end) {
509 // province-id;owner;controller;core;trade_goods;life_rating;colonial;slave
510 cpos = parsers::parse_fixed_amount_csv_values<8>(cpos, end, ';', [&](std::string_view const* values) {
511 auto provid_text = parsers::remove_surrounding_whitespace(values[0]);
512 auto owner_text = parsers::remove_surrounding_whitespace(values[1]);
513 auto controller_text = parsers::remove_surrounding_whitespace(values[2]);
514 auto core_text = parsers::remove_surrounding_whitespace(values[3]);
515 auto trade_goods_text = parsers::remove_surrounding_whitespace(values[4]);
516 auto life_rating_text = parsers::remove_surrounding_whitespace(values[5]);
517 auto is_colonial_text = parsers::remove_surrounding_whitespace(values[6]);
518 auto is_slave_text = parsers::remove_surrounding_whitespace(values[7]);
519 if(provid_text.empty()) {
520 err.accumulated_errors += "Unspecified province id (" + err.file_name + ")\n";
521 return;
522 }
523 if(trade_goods_text.empty()) {
524 err.accumulated_errors += "Unspecified trade_goods (" + err.file_name + ")\n";
525 return;
526 }
527 auto p = context.original_id_to_prov_id_map[parsers::parse_int(provid_text, 0, err)];
528 province_file_context province_context{ context, p };
529 if(!owner_text.empty()) {
530 f.owner(parsers::association_type::eq_default, parsers::parse_tag(owner_text, 0, err), err, 0, province_context);
531 }
532 if(!controller_text.empty()) {
533 f.controller(parsers::association_type::eq_default, parsers::parse_tag(controller_text, 0, err), err, 0, province_context);
534 }
535 if(!core_text.empty()) {
536 f.add_core(parsers::association_type::eq_default, parsers::parse_tag(core_text, 0, err), err, 0, province_context);
537 }
538 f.trade_goods(parsers::association_type::eq_default, trade_goods_text, err, 0, province_context);
539 f.life_rating(parsers::association_type::eq_default, parsers::parse_int(life_rating_text, 0, err), err, 0, province_context);
540 f.colony(parsers::association_type::eq_default, parsers::parse_int(is_colonial_text, 0, err), err, 0, province_context);
541 f.is_slave(parsers::association_type::eq_default, parsers::parse_int(is_slave_text, 0, err), err, 0, province_context);
542 });
543 }
544}
545
546} // 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:57
province_building_type
Definition: constants.hpp:578
std::string int_to_tag(uint32_t v)
Definition: nations.hpp:14
uint32_t tag_to_int(char first, char second, char third)
Definition: nations.hpp:11
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
Holds important data about the game world, state, and other data regarding windowing,...
dcon::data_container world
parsing::defines defines
absolute_time_point start_date
sys::date current_date
province::global_provincial_state province_definitions