Project Alice
Loading...
Searching...
No Matches
cultures_parsing.cpp
Go to the documentation of this file.
3#include "culture.hpp"
4#include "trigger_parsing.hpp"
5
6namespace parsers {
7
8void make_religion(std::string_view name, token_generator& gen, error_handler& err, scenario_building_context& context) {
9 auto new_id = context.state.world.create_religion();
10 auto name_id = text::find_or_add_key(context.state, name, false);
11 context.state.world.religion_set_name(new_id, name_id);
12
13 context.map_of_religion_names.insert_or_assign(std::string(name), new_id);
14
15 religion_context new_context{new_id, context};
16 parse_religion_def(gen, err, new_context);
17}
18
19void make_culture_group(std::string_view name, token_generator& gen, error_handler& err, scenario_building_context& context) {
20 dcon::culture_group_id new_id = context.state.world.create_culture_group();
21 auto name_id = text::find_or_add_key(context.state, name, false);
22 context.state.world.culture_group_set_name(new_id, name_id);
23 context.state.world.culture_group_set_is_overseas(new_id, true);
24
25 context.map_of_culture_group_names.insert_or_assign(std::string(name), new_id);
26 culture_group_context new_context{new_id, context};
27 parse_culture_group(gen, err, new_context);
28}
29
30void make_culture(std::string_view name, token_generator& gen, error_handler& err, culture_group_context& context) {
31 dcon::culture_id new_id = context.outer_context.state.world.create_culture();
32 auto name_id = text::find_or_add_key(context.outer_context.state, name, false);
33 context.outer_context.state.world.culture_set_name(new_id, name_id);
34 context.outer_context.state.world.force_create_culture_group_membership(new_id, context.id);
35
36 context.outer_context.map_of_culture_names.insert_or_assign(std::string(name), new_id);
37 culture_context new_context{new_id, context.outer_context};
38 parse_culture(gen, err, new_context);
39}
40
42 names_context new_context{context.id, true, context.outer_context};
43 parse_names_list(gen, err, new_context);
44}
46 names_context new_context{context.id, false, context.outer_context};
47 parse_names_list(gen, err, new_context);
48}
49
50void register_ideology(std::string_view name, token_generator& gen, error_handler& err, ideology_group_context& context) {
51
52 dcon::ideology_id new_id = context.outer_context.state.world.create_ideology();
53 auto name_id = text::find_or_add_key(context.outer_context.state, name, false);
54
55 context.outer_context.state.world.ideology_set_name(new_id, name_id);
56 context.outer_context.map_of_ideologies.insert_or_assign(std::string(name), pending_ideology_content{gen, new_id});
57
58 context.outer_context.state.world.force_create_ideology_group_membership(new_id, context.id);
59
60 gen.discard_group();
61}
62
63void make_ideology_group(std::string_view name, token_generator& gen, error_handler& err, scenario_building_context& context) {
64 dcon::ideology_group_id new_id = context.state.world.create_ideology_group();
65 auto name_id = text::find_or_add_key(context.state, name, false);
66
67 context.state.world.ideology_group_set_name(new_id, name_id);
68 context.map_of_ideology_groups.insert_or_assign(std::string(name), new_id);
69
70 ideology_group_context new_context{context, new_id};
71 parse_ideology_group(gen, err, new_context);
72}
73
74void make_issues_group(std::string_view name, token_generator& gen, error_handler& err, scenario_building_context& context) {
75
77
78 if(is_fixed_token_ci(name.data(), name.data() + name.length(), "party_issues")) {
80 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "political_reforms")) {
82 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "social_reforms")) {
84 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "economic_reforms")) {
86 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "military_reforms")) {
88 } else {
89 err.accumulated_errors += "Unknown issue group " + std::string(name) + " in file " + err.file_name + "\n";
90 }
91
92 issue_group_context new_context(context, type);
93 parse_issues_group(gen, err, new_context);
94}
95
96void make_issue(std::string_view name, token_generator& gen, error_handler& err, issue_group_context& context) {
97
98 switch(context.issue_cat) {
99 case ::culture::issue_category::party: {
100 dcon::issue_id new_id = context.outer_context.state.world.create_issue();
101 auto name_id = text::find_or_add_key(context.outer_context.state, name, false);
102 context.outer_context.state.world.issue_set_name(new_id, name_id);
103 auto desc_id = text::find_or_add_key(context.outer_context.state, std::string(name) + "_desc", false);
104 context.outer_context.state.world.issue_set_desc(new_id, desc_id);
105 context.outer_context.map_of_iissues.insert_or_assign(std::string(name), new_id);
106
107 context.outer_context.state.culture_definitions.party_issues.push_back(new_id);
108
109 issue_context new_context{context.outer_context, new_id};
110 parse_issue(gen, err, new_context);
111 } break;
112 case ::culture::issue_category::economic: {
113 dcon::reform_id new_id = context.outer_context.state.world.create_reform();
114 auto name_id = text::find_or_add_key(context.outer_context.state, name, false);
115 context.outer_context.state.world.reform_set_name(new_id, name_id);
116 auto desc_id = text::find_or_add_key(context.outer_context.state, std::string(name) + "_desc", false);
117 context.outer_context.state.world.reform_set_desc(new_id, desc_id);
118 context.outer_context.map_of_reforms.insert_or_assign(std::string(name), new_id);
119
120 context.outer_context.state.culture_definitions.economic_issues.push_back(new_id);
121
122 reform_context new_context{context.outer_context, new_id};
123 parse_issue(gen, err, new_context);
124 } break;
125 case ::culture::issue_category::social: {
126 dcon::issue_id new_id = context.outer_context.state.world.create_issue();
127 auto name_id = text::find_or_add_key(context.outer_context.state, name, false);
128 context.outer_context.state.world.issue_set_name(new_id, name_id);
129 auto desc_id = text::find_or_add_key(context.outer_context.state, std::string(name) + "_desc", false);
130 context.outer_context.state.world.issue_set_desc(new_id, desc_id);
131 context.outer_context.map_of_iissues.insert_or_assign(std::string(name), new_id);
132
133 context.outer_context.state.culture_definitions.social_issues.push_back(new_id);
134 issue_context new_context{context.outer_context, new_id};
135 parse_issue(gen, err, new_context);
136 } break;
137 case ::culture::issue_category::political: {
138 dcon::issue_id new_id = context.outer_context.state.world.create_issue();
139 auto name_id = text::find_or_add_key(context.outer_context.state, name, false);
140 context.outer_context.state.world.issue_set_name(new_id, name_id);
141 auto desc_id = text::find_or_add_key(context.outer_context.state, std::string(name) + "_desc", false);
142 context.outer_context.state.world.issue_set_desc(new_id, desc_id);
143 context.outer_context.map_of_iissues.insert_or_assign(std::string(name), new_id);
144
146 issue_context new_context{context.outer_context, new_id};
147 parse_issue(gen, err, new_context);
148 } break;
149 case ::culture::issue_category::military: {
150 dcon::reform_id new_id = context.outer_context.state.world.create_reform();
151 auto name_id = text::find_or_add_key(context.outer_context.state, name, false);
152 context.outer_context.state.world.reform_set_name(new_id, name_id);
153 auto desc_id = text::find_or_add_key(context.outer_context.state, std::string(name) + "_desc", false);
154 context.outer_context.state.world.reform_set_desc(new_id, desc_id);
155 context.outer_context.map_of_reforms.insert_or_assign(std::string(name), new_id);
156
157 context.outer_context.state.culture_definitions.military_issues.push_back(new_id);
158
159 reform_context new_context{context.outer_context, new_id};
160 parse_issue(gen, err, new_context);
161 } break;
162 default:
163 break;
164 }
165}
166void register_option(std::string_view name, token_generator& gen, error_handler& err, issue_context& context) {
167 dcon::issue_option_id new_id = context.outer_context.state.world.create_issue_option();
168 auto name_id = text::find_or_add_key(context.outer_context.state, name, false);
169
170 auto movement_name_id = text::find_or_add_key(context.outer_context.state, std::string("movement_") + std::string(name), false);
171 context.outer_context.state.world.issue_option_set_name(new_id, name_id);
172 auto desc_id = text::find_or_add_key(context.outer_context.state, std::string(name) + "_desc", false);
173 context.outer_context.state.world.issue_option_set_desc(new_id, desc_id);
174 context.outer_context.map_of_ioptions.insert_or_assign(std::string(name), pending_option_content{gen, new_id});
175
176 context.outer_context.state.world.issue_option_set_movement_name(new_id, movement_name_id);
177
178 bool assigned = false;
179 auto& existing_options = context.outer_context.state.world.issue_get_options(context.id);
180 for(uint32_t i = 0; i < existing_options.size(); ++i) {
181 if(!(existing_options[i])) {
182 existing_options[i] = new_id;
183 assigned = true;
184 break;
185 }
186 }
187 if(!assigned) {
188 err.accumulated_errors += "Option " + std::string(name) + " in file " + err.file_name + " was the 7th or later option\n";
189 }
190
191 gen.discard_group();
192}
193void register_option(std::string_view name, token_generator& gen, error_handler& err, reform_context& context) {
194 dcon::reform_option_id new_id = context.outer_context.state.world.create_reform_option();
195 auto name_id = text::find_or_add_key(context.outer_context.state, name, false);
196 context.outer_context.state.world.reform_option_set_name(new_id, name_id);
197 auto desc_id = text::find_or_add_key(context.outer_context.state, std::string(name) + "_desc", false);
198 context.outer_context.state.world.reform_option_set_desc(new_id, desc_id);
199 context.outer_context.map_of_roptions.insert_or_assign(std::string(name), pending_roption_content{gen, new_id});
200
201 bool assigned = false;
202 auto& existing_options = context.outer_context.state.world.reform_get_options(context.id);
203 for(uint32_t i = 0; i < existing_options.size(); ++i) {
204 if(!(existing_options[i])) {
205 existing_options[i] = new_id;
206 assigned = true;
207 break;
208 }
209 }
210 if(!assigned) {
211 err.accumulated_errors += "Option " + std::string(name) + " in file " + err.file_name + " was the 7th or later option\n";
212 }
213
214 gen.discard_group();
215}
216
217void make_government(std::string_view name, token_generator& gen, error_handler& err, scenario_building_context& context) {
218 dcon::government_type_id new_id = context.state.world.create_government_type();
219
220 auto name_id = text::find_or_add_key(context.state, name, false);
221
222 context.state.world.government_type_set_name(new_id, name_id);
223 context.state.world.government_type_set_desc(new_id, text::find_or_add_key(context.state, std::string(name) + "_desc", false));
224 context.state.world.government_type_set_ruler_name(new_id, text::find_or_add_key(context.state, std::string(name) + "_ruler", false));
225 context.map_of_governments.insert_or_assign(std::string(name), new_id);
226
227 government_type_context new_context{context, new_id};
228 parse_government_type(gen, err, new_context);
229}
230
231void register_crime(std::string_view name, token_generator& gen, error_handler& err, scenario_building_context& context) {
232 dcon::crime_id new_id = dcon::crime_id(dcon::crime_id::value_base_t(context.state.culture_definitions.crimes.size()));
233 context.state.culture_definitions.crimes.emplace_back();
234
235 auto name_id = text::find_or_add_key(context.state, name, false);
236 context.state.culture_definitions.crimes[new_id].name = name_id;
237
238 context.map_of_crimes.insert_or_assign(std::string(name), pending_crime_content{gen, new_id});
239
240 gen.discard_group();
241}
242
243void register_rebel_type(std::string_view name, token_generator& gen, error_handler& err, scenario_building_context& context) {
244 dcon::rebel_type_id new_id = context.state.world.create_rebel_type();
245
246 auto name_id = text::find_or_add_key(context.state, std::string(name) + "_name", false);
247 auto desc_id = text::find_or_add_key(context.state, std::string(name) + "_desc", false);
248 auto army_id = text::find_or_add_key(context.state, std::string(name) + "_army", false);
249 auto title_id = text::find_or_add_key(context.state, std::string(name) + "_title", false);
250
251 context.state.world.rebel_type_set_name(new_id, name_id);
252 context.state.world.rebel_type_set_description(new_id, desc_id);
253 context.state.world.rebel_type_set_army_name(new_id, army_id);
254 context.state.world.rebel_type_set_title(new_id, title_id);
255
256
257 context.map_of_rebeltypes.insert_or_assign(std::string(name), pending_rebel_type_content{gen, new_id});
258
259 gen.discard_group();
260}
261
262void make_tech_folder_list(std::string_view name, token_generator& gen, error_handler& err, scenario_building_context& context) {
263
265 if(is_fixed_token_ci(name.data(), name.data() + name.length(), "army_tech")) {
267 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "navy_tech")) {
269 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "commerce_tech")) {
271 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "culture_tech")) {
273 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "industry_tech")) {
275 //non vanilla
276 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "military_theory_tech")) {
278 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "population_tech")) {
280 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "diplomacy_tech")) {
282 } else if(is_fixed_token_ci(name.data(), name.data() + name.length(), "flavor_tech")) {
284 } else {
285 err.accumulated_errors += "Unknown technology category " + std::string(name) + " in file " + err.file_name + "\n";
286 }
287
288 tech_group_context new_context{context, cat};
289 parse_tech_folder_list(gen, err, new_context);
290
291 // read sub file
292 auto root = get_root(context.state.common_fs);
293 auto tech_folder = open_directory(root, NATIVE("technologies"));
294 auto tech_file = open_file(tech_folder, simple_fs::win1250_to_native(name) + NATIVE(".txt"));
295 if(tech_file) {
296 auto content = view_contents(*tech_file);
297 err.file_name = std::string(name) + ".txt";
298 token_generator file_gen(content.data, content.data + content.file_size);
299 parse_technology_sub_file(file_gen, err, context);
300
301 context.tech_and_invention_files.emplace_back(std::move(*tech_file));
302 }
303}
304void read_school_modifier(std::string_view name, token_generator& gen, error_handler& err, scenario_building_context& context) {
305 auto name_id = text::find_or_add_key(context.state, name, false);
306 auto new_modifier = context.state.world.create_modifier();
307
308 context.map_of_modifiers.insert_or_assign(std::string(name), new_modifier);
309 context.state.world.modifier_set_name(new_modifier, name_id);
310 context.state.world.modifier_set_desc(new_modifier, text::find_or_add_key(context.state, std::string(name) + "_desc", false));
311
312 auto school = parse_modifier_base(gen, err, context);
313
314 context.state.world.modifier_set_icon(new_modifier, uint8_t(school.icon_index));
315 context.state.world.modifier_set_national_values(new_modifier, school.force_national_mod());
316}
317
318void register_technology(std::string_view name, token_generator& gen, error_handler& err, scenario_building_context& context) {
319 auto new_id = context.state.world.create_technology();
320
321 auto name_id = text::find_or_add_key(context.state, name, false);
322 context.state.world.technology_set_name(new_id, name_id);
323 context.state.world.technology_set_desc(new_id, text::find_or_add_key(context.state, std::string(name) + "_desc", false));
324
325 context.map_of_technologies.insert_or_assign(std::string(name), pending_tech_content{gen, new_id});
326
327 auto root = get_root(context.state.common_fs);
328 auto gfx = open_directory(root, NATIVE("gfx"));
329 auto pictures = open_directory(gfx, NATIVE("pictures"));
330 auto tech = open_directory(pictures, NATIVE("tech"));
331
332 std::string file_name = simple_fs::remove_double_backslashes(std::string("gfx\\pictures\\tech\\") + [&]() {
333 if(peek_file(tech, simple_fs::utf8_to_native(name) + NATIVE(".tga"))) {
334 return std::string(name) + ".tga";
335 } else if(peek_file(tech, simple_fs::utf8_to_native(name) + NATIVE(".dds"))) {
336 return std::string(name) + ".tga";
337 } else if(peek_file(tech, simple_fs::utf8_to_native(name) + NATIVE(".png"))) {
338 return std::string(name) + ".png";
339 } else {
340 return std::string("noimage.tga");
341 }
342 }());
343
344 if(auto it = context.gfx_context.map_of_names.find(file_name); it != context.gfx_context.map_of_names.end()) {
345 context.state.world.technology_set_image(new_id, it->second);
346 } else {
347 auto gfxindex = context.state.ui_defs.gfx.size();
348 context.state.ui_defs.gfx.emplace_back();
349 ui::gfx_object& new_obj = context.state.ui_defs.gfx.back();
350 auto new_gfx_id = dcon::gfx_object_id(uint16_t(gfxindex));
351
352 context.gfx_context.map_of_names.insert_or_assign(file_name, new_gfx_id);
353
354 new_obj.number_of_frames = uint8_t(1);
355
356 if(auto itb = context.gfx_context.map_of_texture_names.find(file_name);
357 itb != context.gfx_context.map_of_texture_names.end()) {
358 new_obj.primary_texture_handle = itb->second;
359 } else {
360 auto index = context.state.ui_defs.textures.size();
361 context.state.ui_defs.textures.emplace_back(context.state.add_key_win1252(file_name));
362 new_obj.primary_texture_handle = dcon::texture_id(uint16_t(index));
363 context.gfx_context.map_of_texture_names.insert_or_assign(file_name, new_obj.primary_texture_handle);
364 }
366
367 context.state.world.technology_set_image(new_id, new_gfx_id);
368 }
369
370 gen.discard_group();
371}
372
373void register_invention(std::string_view name, token_generator& gen, error_handler& err, tech_group_context& context) {
374 auto new_id = context.outer_context.state.world.create_invention();
375
376 auto name_id = text::find_or_add_key(context.outer_context.state, name, false);
377 context.outer_context.state.world.invention_set_name(new_id, name_id);
378 context.outer_context.state.world.invention_set_desc(new_id, text::find_or_add_key(context.outer_context.state, std::string(name) + "_desc", false));
379 context.outer_context.state.world.invention_set_technology_type(new_id, uint8_t(context.category));
380
381 context.outer_context.map_of_inventions.insert_or_assign(std::string(name), pending_invention_content{gen, new_id});
382 gen.discard_group();
383}
384
385void read_promotion_target(std::string_view name, token_generator& gen, error_handler& err, poptype_context& context) {
386 if(auto it = context.outer_context.map_of_poptypes.find(std::string(name)); it != context.outer_context.map_of_poptypes.end()) {
389 auto result = make_value_modifier(gen, err, t_context);
390 context.outer_context.state.world.pop_type_set_promotion(context.id, it->second, result);
391 } else {
392 err.accumulated_errors += "Unknown pop type " + std::string(name) + " in file " + err.file_name + "\n";
393 }
394}
395void read_pop_ideology(std::string_view name, token_generator& gen, error_handler& err, poptype_context& context) {
396 if(auto it = context.outer_context.map_of_ideologies.find(std::string(name));
397 it != context.outer_context.map_of_ideologies.end()) {
400 auto result = make_value_modifier(gen, err, t_context);
401 context.outer_context.state.world.pop_type_set_ideology(context.id, it->second.id, result);
402 } else {
403 err.accumulated_errors += "Unknown ideology " + std::string(name) + " in file " + err.file_name + "\n";
404 }
405}
406void read_pop_issue(std::string_view name, token_generator& gen, error_handler& err, poptype_context& context) {
407 if(auto it = context.outer_context.map_of_ioptions.find(std::string(name)); it != context.outer_context.map_of_ioptions.end()) {
410 auto result = make_value_modifier(gen, err, t_context);
411 context.outer_context.state.world.pop_type_set_issues(context.id, it->second.id, result);
412 } else {
413 err.accumulated_errors += "Unknown issue option " + std::string(name) + " in file " + err.file_name + "\n";
414 }
415}
419 auto result = make_value_modifier(gen, err, t_context);
420 context.outer_context.state.world.pop_type_set_country_migration_target(context.id, result);
421}
425 auto result = make_value_modifier(gen, err, t_context);
426 context.outer_context.state.world.pop_type_set_migration_target(context.id, result);
427}
428
430 return parse_commodity_array(gen, err, context.outer_context);
431}
432
433dcon::value_modifier_key ideology_condition(token_generator& gen, error_handler& err, individual_ideology_context& context) {
436 return make_value_modifier(gen, err, t_context);
437}
438
439void make_issue_vote_modifier(std::string_view name, token_generator& gen, error_handler& err, individual_option_context& context) {
440 if(auto it = context.outer_context.map_of_ioptions.find(std::string(name)); it != context.outer_context.map_of_ioptions.end()) {
441 auto opt = it->second.id;
442 auto parent = context.outer_context.state.world.issue_option_get_parent_issue(context.id);
443 if(parent.get_issue_type() != uint8_t(::culture::issue_type::party)) {
444 err.accumulated_errors += "attempted to set a vote modifier for a non-party issue " + std::string(context.outer_context.state.to_string_view(parent.get_name())) + " in file " + err.file_name + "\n";
445 } else {
448 auto vmod = make_value_modifier(gen, err, t_context);
449 context.outer_context.state.world.issue_option_set_support_modifiers(context.id, opt, vmod);
450 }
451 } else {
452 err.accumulated_errors += "attempted to set a vote modifier for unkown issue option " + std::string(name) + " in file " + err.file_name + "\n";
453 }
454}
455void make_issue_vote_modifier(std::string_view name, token_generator& gen, error_handler& err, individual_roption_context& context) {
456 err.accumulated_errors += "attempted to set a vote modifier for an uncivilized reform in file " + err.file_name + "\n";
457}
458
459dcon::trigger_key make_party_trigger(token_generator& gen, error_handler& err, party_context& context) {
462 return make_trigger(gen, err, t_context);
463}
464
468 return make_trigger(gen, err, t_context);
469}
470
471void read_pending_crime(dcon::crime_id id, token_generator& gen, error_handler& err, scenario_building_context& context) {
472 crime_modifier crime_body = parse_crime_modifier(gen, err, context);
473 context.state.culture_definitions.crimes[id].available_by_default = crime_body.active;
474 context.state.culture_definitions.crimes[id].trigger = crime_body.trigger;
475
476 if(crime_body.next_to_add_p != 0) {
477 auto new_modifier = context.state.world.create_modifier();
478 context.state.world.modifier_set_name(new_modifier, context.state.culture_definitions.crimes[id].name);
479 context.state.world.modifier_set_icon(new_modifier, uint8_t(crime_body.icon_index));
480
481 context.state.world.modifier_set_province_values(new_modifier, crime_body.peek_province_mod());
482 context.state.world.modifier_set_national_values(new_modifier, crime_body.peek_national_mod());
483 context.state.culture_definitions.crimes[id].modifier = new_modifier;
484 }
485}
486
490 context.outer_context.state.world.issue_option_set_allow(context.id, make_trigger(gen, err, t_context));
491}
495 return make_trigger(gen, err, t_context);
496}
500 return make_effect(gen, err, t_context);
501}
502
506 context.outer_context.state.world.reform_option_set_allow(context.id, make_trigger(gen, err, t_context));
507}
511 return make_trigger(gen, err, t_context);
512}
516 return make_effect(gen, err, t_context);
517}
518
519void read_pending_option(dcon::issue_option_id id, token_generator& gen, error_handler& err, scenario_building_context& context) {
520 individual_option_context new_context{context, id};
521 issue_option_body opt = parse_issue_option_body(gen, err, new_context);
522
523 if(opt.next_to_add_n != 0 || opt.next_to_add_p != 0) {
524 auto new_modifier = context.state.world.create_modifier();
525 context.state.world.modifier_set_name(new_modifier, context.state.world.issue_option_get_name(id));
526 context.state.world.modifier_set_icon(new_modifier, uint8_t(opt.icon_index));
527 context.state.world.modifier_set_national_values(new_modifier, opt.force_national_mod());
528 context.state.world.issue_option_set_modifier(id, new_modifier);
529 }
530}
531void read_pending_reform(dcon::reform_option_id id, token_generator& gen, error_handler& err,
532 scenario_building_context& context) {
533 individual_roption_context new_context{context, id};
534 issue_option_body opt = parse_issue_option_body(gen, err, new_context);
535
536 if(opt.next_to_add_n != 0 || opt.next_to_add_p != 0) {
537 auto new_modifier = context.state.world.create_modifier();
538 context.state.world.modifier_set_name(new_modifier, context.state.world.reform_option_get_name(id));
539 context.state.world.modifier_set_icon(new_modifier, uint8_t(opt.icon_index));
540 context.state.world.modifier_set_national_values(new_modifier, opt.force_national_mod());
541 context.state.world.reform_option_set_modifier(id, new_modifier);
542 }
543}
544
547 return make_value_modifier(gen, err, t_context);
548}
549
550dcon::value_modifier_key make_ai_chance(token_generator& gen, error_handler& err, tech_context& context) {
552 return make_value_modifier(gen, err, t_context);
553}
554void read_pending_technology(dcon::technology_id id, token_generator& gen, error_handler& err,
555 scenario_building_context& context) {
556 tech_context new_context{context, id};
557 auto modifier = parse_technology_contents(gen, err, new_context);
558
559 if(modifier.next_to_add_n != 0 || modifier.next_to_add_p != 0) {
560 auto new_modifier = context.state.world.create_modifier();
561 context.state.world.modifier_set_name(new_modifier, context.state.world.technology_get_name(id));
562 context.state.world.modifier_set_icon(new_modifier, uint8_t(modifier.icon_index));
563 context.state.world.modifier_set_national_values(new_modifier, modifier.force_national_mod());
564 context.state.world.technology_set_modifier(id, new_modifier);
565 }
566}
567
568dcon::value_modifier_key make_inv_chance(token_generator& gen, error_handler& err, invention_context& context) {
570 return make_value_modifier(gen, err, t_context);
571}
572dcon::trigger_key make_inv_limit(token_generator& gen, error_handler& err, invention_context& context) {
574 return make_trigger(gen, err, t_context);
575}
576
577void read_pending_invention(dcon::invention_id id, token_generator& gen, error_handler& err, scenario_building_context& context) {
578 invention_context new_context{context, id};
579 auto modifier = parse_invention_contents(gen, err, new_context);
580
581 if(modifier.next_to_add_n != 0 || modifier.next_to_add_p != 0) {
582 auto new_modifier = context.state.world.create_modifier();
583 context.state.world.modifier_set_name(new_modifier, context.state.world.invention_get_name(id));
584 context.state.world.modifier_set_icon(new_modifier, uint8_t(modifier.icon_index));
585 context.state.world.modifier_set_national_values(new_modifier, modifier.force_national_mod());
586 context.state.world.invention_set_modifier(id, new_modifier);
587 }
588}
589
590dcon::value_modifier_key make_reb_will_rise(token_generator& gen, error_handler& err, rebel_context& context) {
593 return make_value_modifier(gen, err, t_context);
594}
595dcon::value_modifier_key make_reb_spawn_chance(token_generator& gen, error_handler& err, rebel_context& context) {
598 return make_value_modifier(gen, err, t_context);
599}
600dcon::value_modifier_key make_reb_movement_eval(token_generator& gen, error_handler& err, rebel_context& context) {
603 return make_value_modifier(gen, err, t_context);
604}
605dcon::trigger_key make_reb_s_won_trigger(token_generator& gen, error_handler& err, rebel_context& context) {
608 return make_trigger(gen, err, t_context);
609}
613 return make_trigger(gen, err, t_context);
614}
615dcon::effect_key make_reb_s_won_effect(token_generator& gen, error_handler& err, rebel_context& context) {
618 return make_effect(gen, err, e_context);
619}
623 return make_effect(gen, err, e_context);
624}
625void read_pending_rebel_type(dcon::rebel_type_id id, token_generator& gen, error_handler& err,
626 scenario_building_context& context) {
627 rebel_context new_context{context, id};
628 parse_rebel_body(gen, err, new_context);
629}
630
631} // namespace parsers
std::string accumulated_errors
Definition: parsers.hpp:62
std::string file_name
Definition: parsers.hpp:61
tag_type emplace_back(T &&... ts)
auto size() const
tagged_vector< gfx_object, dcon::gfx_object_id > gfx
tagged_vector< dcon::text_key, dcon::texture_id > textures
issue_category
Definition: culture.hpp:177
tech_category
Definition: culture.hpp:106
void read_pop_ideology(std::string_view name, token_generator &gen, error_handler &err, poptype_context &context)
void register_crime(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
void make_issues_group(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
commodity_array stub_commodity_array(token_generator &gen, error_handler &err, poptype_context &context)
void register_technology(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
void read_pending_rebel_type(dcon::rebel_type_id id, token_generator &gen, error_handler &err, scenario_building_context &context)
void read_pop_issue(std::string_view name, token_generator &gen, error_handler &err, poptype_context &context)
dcon::trigger_key make_inv_limit(token_generator &gen, error_handler &err, invention_context &context)
dcon::trigger_key make_trigger(token_generator &gen, error_handler &err, trigger_building_context &context)
dcon::value_modifier_key make_reb_will_rise(token_generator &gen, error_handler &err, rebel_context &context)
void register_ideology(std::string_view name, token_generator &gen, error_handler &err, ideology_group_context &context)
void read_c_migration_target(token_generator &gen, error_handler &err, poptype_context &context)
dcon::value_modifier_key ideology_condition(token_generator &gen, error_handler &err, individual_ideology_context &context)
void register_invention(std::string_view name, token_generator &gen, error_handler &err, tech_group_context &context)
void read_pending_technology(dcon::technology_id id, token_generator &gen, error_handler &err, scenario_building_context &context)
void make_religion(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
void make_opt_allow(token_generator &gen, error_handler &err, individual_option_context &context)
dcon::trigger_key make_reb_enforced_trigger(token_generator &gen, error_handler &err, rebel_context &context)
dcon::trigger_key make_reb_s_won_trigger(token_generator &gen, error_handler &err, rebel_context &context)
dcon::effect_key make_reb_s_won_effect(token_generator &gen, error_handler &err, rebel_context &context)
void register_option(std::string_view name, token_generator &gen, error_handler &err, issue_context &context)
dcon::value_modifier_key make_poptype_pop_chance(token_generator &gen, error_handler &err, scenario_building_context &context)
void make_issue(std::string_view name, token_generator &gen, error_handler &err, issue_group_context &context)
void read_pending_reform(dcon::reform_option_id id, token_generator &gen, error_handler &err, scenario_building_context &context)
dcon::value_modifier_key make_ai_chance(token_generator &gen, error_handler &err, tech_context &context)
void read_pending_invention(dcon::invention_id id, token_generator &gen, error_handler &err, scenario_building_context &context)
void read_migration_target(token_generator &gen, error_handler &err, poptype_context &context)
dcon::value_modifier_key make_value_modifier(token_generator &gen, error_handler &err, trigger_building_context &context)
void read_pending_option(dcon::issue_option_id id, token_generator &gen, error_handler &err, scenario_building_context &context)
void make_issue_vote_modifier(std::string_view name, token_generator &gen, error_handler &err, individual_option_context &context)
dcon::value_modifier_key make_reb_movement_eval(token_generator &gen, error_handler &err, rebel_context &context)
void read_pending_crime(dcon::crime_id id, token_generator &gen, 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_ln_list(token_generator &gen, error_handler &err, culture_context &context)
dcon::effect_key make_execute_effect(token_generator &gen, error_handler &err, individual_option_context &context)
void make_tech_folder_list(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
dcon::trigger_key make_execute_trigger(token_generator &gen, error_handler &err, individual_option_context &context)
dcon::effect_key make_effect(token_generator &gen, error_handler &err, effect_building_context &context)
void make_culture_group(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
void read_school_modifier(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
void make_fn_list(token_generator &gen, error_handler &err, culture_context &context)
void read_promotion_target(std::string_view name, token_generator &gen, error_handler &err, poptype_context &context)
dcon::effect_key make_reb_enforce_effect(token_generator &gen, error_handler &err, rebel_context &context)
dcon::value_modifier_key make_reb_spawn_chance(token_generator &gen, error_handler &err, rebel_context &context)
dcon::trigger_key make_party_trigger(token_generator &gen, error_handler &err, party_context &context)
void make_ideology_group(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
dcon::value_modifier_key make_inv_chance(token_generator &gen, error_handler &err, invention_context &context)
void register_rebel_type(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
void make_government(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
dcon::trigger_key make_crime_trigger(token_generator &gen, error_handler &err, scenario_building_context &context)
void make_culture(std::string_view name, token_generator &gen, error_handler &err, culture_group_context &context)
native_string win1250_to_native(std::string_view data_in)
native_string utf8_to_native(std::string_view data_in)
std::string remove_double_backslashes(std::string_view data_in)
dcon::text_key find_or_add_key(sys::state &state, std::string_view key, bool as_unicode)
Definition: text.cpp:695
#define NATIVE(X)
uint uint32_t
uchar uint8_t
std::vector< dcon::issue_id > political_issues
Definition: culture.hpp:126
std::vector< dcon::reform_id > military_issues
Definition: culture.hpp:128
tagged_vector< crime_info, dcon::crime_id > crimes
Definition: culture.hpp:134
std::vector< dcon::reform_id > economic_issues
Definition: culture.hpp:129
std::vector< dcon::issue_id > party_issues
Definition: culture.hpp:125
std::vector< dcon::issue_id > social_issues
Definition: culture.hpp:127
ankerl::unordered_dense::map< std::string, dcon::gfx_object_id > map_of_names
ankerl::unordered_dense::map< std::string, dcon::texture_id > map_of_texture_names
scenario_building_context & outer_context
scenario_building_context & outer_context
scenario_building_context & outer_context
scenario_building_context & outer_context
scenario_building_context & outer_context
scenario_building_context & outer_context
scenario_building_context & outer_context
scenario_building_context & outer_context
::culture::issue_category issue_cat
sys::national_modifier_definition const & peek_national_mod() const
sys::provincial_modifier_definition const & peek_province_mod() const
scenario_building_context & outer_context
scenario_building_context & outer_context
scenario_building_context & outer_context
scenario_building_context & outer_context
ankerl::unordered_dense::map< std::string, dcon::culture_group_id > map_of_culture_group_names
ankerl::unordered_dense::map< std::string, dcon::modifier_id > map_of_modifiers
ankerl::unordered_dense::map< std::string, dcon::religion_id > map_of_religion_names
ankerl::unordered_dense::map< std::string, pending_invention_content > map_of_inventions
std::vector< simple_fs::file > tech_and_invention_files
ankerl::unordered_dense::map< std::string, pending_roption_content > map_of_roptions
ankerl::unordered_dense::map< std::string, pending_tech_content > map_of_technologies
ankerl::unordered_dense::map< std::string, dcon::pop_type_id > map_of_poptypes
ankerl::unordered_dense::map< std::string, pending_ideology_content > map_of_ideologies
ankerl::unordered_dense::map< std::string, dcon::reform_id > map_of_reforms
ankerl::unordered_dense::map< std::string, dcon::issue_id > map_of_iissues
ankerl::unordered_dense::map< std::string, pending_crime_content > map_of_crimes
ankerl::unordered_dense::map< std::string, pending_option_content > map_of_ioptions
ankerl::unordered_dense::map< std::string, pending_rebel_type_content > map_of_rebeltypes
ankerl::unordered_dense::map< std::string, dcon::culture_id > map_of_culture_names
ankerl::unordered_dense::map< std::string, dcon::government_type_id > map_of_governments
ankerl::unordered_dense::map< std::string, dcon::ideology_group_id > map_of_ideology_groups
scenario_building_context & outer_context
::culture::tech_category category
scenario_building_context & outer_context
culture::global_cultural_state culture_definitions
dcon::text_key add_key_win1252(std::string const &text)
dcon::data_container world
std::string_view to_string_view(dcon::text_key tag) const
simple_fs::file_system common_fs
ui::definitions ui_defs
dcon::texture_id primary_texture_handle
uint8_t number_of_frames