The Battle for Wesnoth  1.15.2+dev
game_config_manager.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 - 2018 by Andrius Silinskas <silinskas.andrius@gmail.com>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 #include "game_config_manager.hpp"
15 
16 #include "about.hpp"
17 #include "addon/manager.hpp"
18 #include "ai/configuration.hpp"
19 #include "cursor.hpp"
20 #include "events.hpp"
21 #include "formatter.hpp"
22 #include "game_config.hpp"
23 #include "gettext.hpp"
24 #include "game_classification.hpp"
27 #include "hotkey/hotkey_item.hpp"
29 #include "language.hpp"
30 #include "log.hpp"
31 #include "preferences/general.hpp"
33 #include "terrain/builder.hpp"
34 #include "terrain/type_data.hpp"
35 #include "units/types.hpp"
36 #include "game_version.hpp"
37 #include "theme.hpp"
38 #include "picture.hpp"
39 #include "sound.hpp"
41 
42 static lg::log_domain log_config("config");
43 #define ERR_CONFIG LOG_STREAM(err, log_config)
44 #define WRN_CONFIG LOG_STREAM(warn, log_config)
45 #define LOG_CONFIG LOG_STREAM(info, log_config)
46 
48 
50  const commandline_options& cmdline_opts,
51  const bool jump_to_editor) :
52  cmdline_opts_(cmdline_opts),
53  jump_to_editor_(jump_to_editor),
54  game_config_(),
55  old_defines_map_(),
56  paths_manager_(),
57  cache_(game_config::config_cache::instance())
58 {
59  assert(!singleton);
60  singleton = this;
61 
63  cache_.set_use_cache(false);
64  }
67  }
68 }
69 
71 {
72  assert(singleton);
73  singleton = nullptr;
74 }
75 
77  return singleton;
78 }
79 
81 {
82  // Add preproc defines according to the command line arguments.
83  game_config::scoped_preproc_define multiplayer("MULTIPLAYER",
88  game_config::scoped_preproc_define title_screen("TITLE_SCREEN",
90 
93 
95 
98 
99  // Load the standard hotkeys, then apply any player customizations.
102 
106 
107  return true;
108 }
109 
110 namespace {
111 /// returns true if every define in special is also defined in general
112 bool map_includes(const preproc_map& general, const preproc_map& special)
113 {
114  for (const preproc_map::value_type& pair : special)
115  {
116  preproc_map::const_iterator it = general.find(pair.first);
117  if (it == general.end() || it->second != pair.second) {
118  return false;
119  }
120  }
121  return true;
122 }
123 } // end anonymous namespace
124 
127 {
128  game_config::scoped_preproc_define debug_mode("DEBUG_MODE",
130 
131  // Game_config already holds requested config in memory.
132  if (!game_config_.empty()) {
133  if ((force_reload == NO_FORCE_RELOAD) && old_defines_map_ == cache_.get_preproc_map()) {
134  return;
135  }
136  if ((force_reload == NO_INCLUDE_RELOAD) && map_includes(old_defines_map_, cache_.get_preproc_map())) {
137  return;
138  }
139  }
140 
141  gui2::dialogs::loading_screen::display([this, force_reload, classification]() {
142  load_game_config(force_reload, classification);
143  });
144 }
145 
148 {
149  // Make sure that 'debug mode' symbol is set
150  // if command line parameter is selected
151  // also if we're in multiplayer and actual debug mode is disabled.
152 
153  // The loadscreen will erase the titlescreen.
154  // NOTE: even without loadscreen, needed after MP lobby.
155  try {
156  // Read all game configs.
157  // First we load all core configs, the mainline one and the ones from the addons.
158  // Validate the cores and discard the invalid.
159  // Then find the path to the selected core.
160  // Load the selected core.
161  // Handle terrains so that they are last loaded from the core.
162  // Load every compatible addon.
166 
167  // Start transaction so macros are shared.
168  game_config::config_cache_transaction main_transaction;
169 
170  config cores_cfg;
171  // Load mainline cores definition file.
172  cache_.get_config(game_config::path + "/data/cores.cfg", cores_cfg);
173 
174  // Append the $user_campaign_dir/*/cores.cfg files to the cores.
175  std::vector<std::string> user_dirs;
176  {
177  const std::string user_campaign_dir = filesystem::get_addons_dir();
178  std::vector<std::string> user_files;
179  filesystem::get_files_in_dir(user_campaign_dir, &user_files, &user_dirs,
181  }
182  for (const std::string& umc : user_dirs) {
183  const std::string cores_file = umc + "/cores.cfg";
184  if (filesystem::file_exists(cores_file)) {
185  config cores;
186  cache_.get_config(cores_file, cores);
187  cores_cfg.append(cores);
188  }
189  }
190 
191  // Validate every core
192  config valid_cores;
193  bool current_core_valid = false;
194  std::string wml_tree_root;
195  for (const config& core : cores_cfg.child_range("core")) {
196 
197  const std::string& id = core["id"];
198  if (id.empty()) {
201  _("Error validating data core."),
202  _("Found a core without id attribute.")
203  + '\n' + _("Skipping the core."));
204  });
205  continue;
206  }
207  if (*&valid_cores.find_child("core", "id", id)) {
210  _("Error validating data core."),
211  _("Core ID: ") + id
212  + '\n' + _("The ID is already in use.")
213  + '\n' + _("Skipping the core."));
214  });
215  continue;
216  }
217 
218  const std::string& path = core["path"];
222  _("Error validating data core."),
223  _("Core ID: ") + id
224  + '\n' + _("Core Path: ") + path
225  + '\n' + _("File not found.")
226  + '\n' + _("Skipping the core."));
227  });
228  continue;
229  }
230 
231  if (id == "default" && !current_core_valid) {
232  wml_tree_root = path;
233  }
234  if (id == preferences::core_id()) {
235  current_core_valid = true;
236  wml_tree_root = path;
237  }
238 
239  valid_cores.add_child("core", core); // append(core);
240  }
241 
242  if (!current_core_valid) {
245  _("Error loading core data."),
246  _("Core ID: ") + preferences::core_id()
247  + '\n' + _("Error loading the core with named id.")
248  + '\n' + _("Falling back to the default core."));
249  });
250  preferences::set_core_id("default");
251  }
252 
253  // check if we have a valid default core which should always be the case.
254  if (wml_tree_root.empty()) {
257  _("Error loading core data."),
258  _("Can't locate the default core.")
259  + '\n' + _("The game will now exit."));
260  });
261  throw;
262  }
263 
264  // Load the selected core
265  std::unique_ptr<schema_validation::schema_validator> validator;
267  validator.reset(new schema_validation::schema_validator(filesystem::get_wml_location("schema/game_config.cfg")));
268  validator->set_create_exceptions(false); // Don't crash if there's an error, just go ahead anyway
269  }
270  cache_.get_config(filesystem::get_wml_location(wml_tree_root), game_config_, validator.get());
271  game_config_.append(valid_cores);
272 
273  main_transaction.lock();
274 
275  // Put the gfx rules aside so that we can prepend the add-on
276  // rules to them.
277  config core_terrain_rules;
278  core_terrain_rules.splice_children(game_config_, "terrain_graphics");
279 
281  load_addons_cfg();
282 
283  // If multiplayer campaign is being loaded, [scenario] tags should
284  // become [multiplayer] tags and campaign's id should be added to them
285  // to allow to recognize which scenarios belongs to a loaded campaign.
286  if (classification != nullptr) {
287  if (const config& campaign = game_config().find_child("campaign", "id", classification->campaign))
288  {
289  const bool require_campaign = campaign["require_campaign"].to_bool(true);
290  for (config& scenario : game_config_.child_range("scenario"))
291  {
292  scenario["require_scenario"] = require_campaign;
293  }
294  }
295  }
296 
297  // Extract the Lua scripts at toplevel.
300 
301  // Put the gfx rules back to game config.
302  game_config_.splice_children(core_terrain_rules, "terrain_graphics");
303 
305  set_unit_data();
307 
309  tdata_ = std::make_shared<terrain_type_data>(game_config_);
312  } catch(const game::error& e) {
313  ERR_CONFIG << "Error loading game configuration files\n" << e.message << '\n';
314 
315  // Try reloading without add-ons
316  if (!game_config::no_addons) {
317  game_config::no_addons = true;
320  _("Error loading custom game configuration files. The game will try without loading add-ons."),
321  e.message);
322  });
323  load_game_config(force_reload, classification);
324  } else if (preferences::core_id() != "default") {
327  _("Error loading custom game configuration files. The game will fallback to the default core files."),
328  e.message);
329  });
330  preferences::set_core_id("default");
331  game_config::no_addons = false;
332  load_game_config(force_reload, classification);
333  } else {
336  _("Error loading default core game configuration files. The game will now exit."),
337  e.message);
338  });
339  throw;
340  }
341  }
342 
344 
345  // Set new binary paths.
347 }
348 
350 {
351  const std::string user_campaign_dir = filesystem::get_addons_dir();
352 
353  std::vector<std::string> error_log;
354  std::vector<std::string> error_addons;
355  std::vector<std::string> user_dirs;
356  std::vector<std::string> user_files;
357 
358  filesystem::get_files_in_dir(user_campaign_dir, &user_files, &user_dirs,
360 
361  // Warn player about addons using the no-longer-supported single-file format.
362  for(const std::string& file : user_files) {
363  const int size_minus_extension = file.size() - 4;
364 
365  if(file.substr(size_minus_extension, file.size()) == ".cfg") {
366  ERR_CONFIG << "error reading usermade add-on '" << file << "'\n";
367 
368  error_addons.push_back(file);
369 
370  const int userdata_loc = file.find("data/add-ons") + 5;
371  const std::string log_msg = formatter()
372  << "The format '~"
373  << file.substr(userdata_loc)
374  << "' (for single-file add-ons) is not supported anymore, use '~"
375  << file.substr(userdata_loc, size_minus_extension - userdata_loc)
376  << "/_main.cfg' instead.";
377 
378  error_log.push_back(log_msg);
379  }
380  }
381 
382  // Rerun the directory scan using filename only, to get the addon_ids more easily.
383  user_files.clear();
384  user_dirs.clear();
385 
386  filesystem::get_files_in_dir(user_campaign_dir, nullptr, &user_dirs,
388 
389  // Load the addons.
390  for(const std::string& addon_id : user_dirs) {
391  log_scope2(log_config, "Loading add-on '" + addon_id + "'");
392  const std::string addon_dir = user_campaign_dir + "/" + addon_id;
393 
394  const std::string main_cfg = addon_dir + "/_main.cfg";
395  const std::string info_cfg = addon_dir + "/_info.cfg";
396 
397  if(!filesystem::file_exists(main_cfg)) {
398  continue;
399  }
400 
401  // Try to find this addon's metadata. Author publishing info (_server.pbl) is given
402  // precedence over addon sever-generated info (_info.cfg). If neither are found, it
403  // probably means the addon was installed manually and certain defaults will be used.
404  config metadata;
405 
406  if(have_addon_pbl_info(addon_id)) {
407  // Publishing info needs to be read from disk.
408  try {
409  metadata = get_addon_pbl_info(addon_id);
410  } catch(const invalid_pbl_exception& e) {
411  const std::string log_msg = formatter()
412  << "The provided addon has an invalid pbl file"
413  << " for addon "
414  << addon_id;
415 
416  error_addons.push_back(e.message);
417  error_log.push_back(log_msg);
418  }
419  } else if(filesystem::file_exists(info_cfg)) {
420  // Addon server-generated info can be fetched from cache.
421  config temp;
422  cache_.get_config(info_cfg, temp);
423 
424  metadata = temp.child_or_empty("info");
425  }
426 
427  std::string using_core = metadata["core"];
428  if(using_core.empty()) {
429  using_core = "default";
430  }
431 
432  // Skip add-ons not matching our current core. Cores themselves should be selectable
433  // at all times, so they aren't considered here.
434  if(!metadata.empty() && metadata["type"] != "core" && using_core != preferences::core_id()) {
435  continue;
436  }
437 
438  std::string addon_title = metadata["title"].str();
439  if(addon_title.empty()) {
440  addon_title = addon_id;
441  }
442 
443  version_info addon_version(metadata["version"]);
444 
445  try {
446  std::unique_ptr<schema_validation::schema_validator> validator;
448  validator.reset(new schema_validation::schema_validator(filesystem::get_wml_location("schema/game_config.cfg")));
449  validator->set_create_exceptions(false); // Don't crash if there's an error, just go ahead anyway
450  }
451  // Load this addon from the cache to a config.
452  config umc_cfg;
453  cache_.get_config(main_cfg, umc_cfg, validator.get());
454 
455  static const std::set<std::string> tags_with_addon_id {
456  "era",
457  "modification",
458  "resource",
459  "multiplayer",
460  "scenario",
461  "campaign"
462  };
463 
464  // Annotate appropriate addon types with addon_id info.
465  for(auto child : umc_cfg.all_children_range()) {
466  if(tags_with_addon_id.count(child.key) > 0) {
467  auto& cfg = child.cfg;
468  cfg["addon_id"] = addon_id;
469  cfg["addon_title"] = addon_title;
470  // Note that this may reformat the string in a canonical form.
471  cfg["addon_version"] = addon_version.str();
472  }
473  }
474 
475  game_config_.append(std::move(umc_cfg));
476  } catch(const config::error& err) {
477  ERR_CONFIG << "error reading usermade add-on '" << main_cfg << "'" << std::endl;
478  ERR_CONFIG << err.message << '\n';
479  error_addons.push_back(main_cfg);
480  error_log.push_back(err.message);
481  } catch(const preproc_config::error& err) {
482  ERR_CONFIG << "error reading usermade add-on '" << main_cfg << "'" << std::endl;
483  ERR_CONFIG << err.message << '\n';
484  error_addons.push_back(main_cfg);
485  error_log.push_back(err.message);
486  } catch(const filesystem::io_exception&) {
487  ERR_CONFIG << "error reading usermade add-on '" << main_cfg << "'" << std::endl;
488  error_addons.push_back(main_cfg);
489  }
490  }
491 
492  if(!error_addons.empty()) {
493  const std::size_t n = error_addons.size();
494  const std::string& msg1 =
495  _n("The following add-on had errors and could not be loaded:",
496  "The following add-ons had errors and could not be loaded:",
497  n);
498  const std::string& msg2 =
499  _n("Please report this to the author or maintainer of this add-on.",
500  "Please report this to the respective authors or maintainers of these add-ons.",
501  n);
502 
503  const std::string& report = utils::join(error_log, "\n\n");
505  gui2::dialogs::wml_error::display(msg1, msg2, error_addons, report);
506  });
507  }
508 }
509 
511 {
512  config& hashes = game_config_.add_child("multiplayer_hashes");
513  for (const config &ch : game_config_.child_range("multiplayer")) {
514  hashes[ch["id"].str()] = ch.hash();
515  }
516 }
517 
519 {
520  game_config_.merge_children("units");
522  if(config &units = game_config_.child("units")) {
523  unit_types.set_config(units);
524  }
525 }
526 
528 {
529  // Rebuild addon version info cache.
531 
532  // Force a reload of configuration information.
534  old_defines_map_.clear();
537 
540 }
541 
543 {
546 }
547 
550 {
551  game_config::scoped_preproc_define difficulty(classification.difficulty,
552  !classification.difficulty.empty());
553  game_config::scoped_preproc_define campaign(classification.campaign_define,
554  !classification.campaign_define.empty());
555  game_config::scoped_preproc_define scenario(classification.scenario_define,
556  !classification.scenario_define.empty());
558  !classification.era_define.empty());
559  game_config::scoped_preproc_define multiplayer("MULTIPLAYER",
560  classification.campaign_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER);
562  classification.campaign_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER);
563 
564  //
565  // NOTE: these deques aren't used here, but the objects within are utilized as RAII helpers.
566  //
567 
568  typedef std::unique_ptr<game_config::scoped_preproc_define> define;
569 
570  std::deque<define> extra_defines;
571  for(const std::string& extra_define : classification.campaign_xtra_defines) {
572  extra_defines.emplace_back(new game_config::scoped_preproc_define(extra_define));
573  }
574 
575  std::deque<define> modification_defines;
576  for(const std::string& mod_define : classification.mod_defines) {
577  modification_defines.emplace_back(new game_config::scoped_preproc_define(mod_define, !mod_define.empty()));
578  }
579 
580  try {
582  } catch(const game::error&) {
584 
585  std::deque<define> previous_defines;
586  for(const preproc_map::value_type& preproc : old_defines_map_) {
587  previous_defines.emplace_back(new game_config::scoped_preproc_define(preproc.first));
588  }
589 
591 
592  throw;
593  }
594 
595  // This needs to be done in the main thread since this function (load_game_config_for_game)
596  // might be called from a loading screen worker thread (and currently is, in fact). If the
597  // image cache is purged from the worker thread, there's a possibility for a data race where
598  // the main thread accesses the image cache and the worker thread simultaneously clears it.
600 }
601 
603 {
604  game_config::scoped_preproc_define multiplayer("MULTIPLAYER", is_mp);
605  game_config::scoped_preproc_define test("TEST", is_test);
606  game_config::scoped_preproc_define mptest("MP_TEST", cmdline_opts_.mptest && is_mp);
607 ///During an mp game the default difficuly define is also defined so better already load it now if we alreeady must reload config cache.
609 
610  typedef std::unique_ptr<game_config::scoped_preproc_define> define;
611  try{
613  }
614  catch(const game::error&) {
616 
617  std::deque<define> previous_defines;
618  for (const preproc_map::value_type& preproc : old_defines_map_) {
619  previous_defines.emplace_back(new game_config::scoped_preproc_define(preproc.first));
620  }
621 
623 
624  throw;
625  }
626 }
void set_config(config &cfg)
Resets all data based on the provided config.
Definition: types.cpp:1117
Don&#39;t reload if the previous defines include the new defines.
config & child(config_key_type key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
Definition: config.cpp:420
bool mptest
True if –mp-test was given on the command line.
const_all_children_itors all_children_range() const
In-order iteration over all children.
Definition: config.cpp:921
void set_paths(const config &cfg)
void clear_children(T... keys)
Definition: config.hpp:479
std::string era()
Definition: game.cpp:723
Interfaces for manipulating version numbers of engine, add-ons, etc.
game_classification * classification
Definition: resources.cpp:34
void append(const config &cfg)
Append data from another config object to this one.
Definition: config.cpp:287
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
config & find_child(config_key_type key, const std::string &name, const std::string &value)
Returns the first child of tag key with a name attribute containing value.
Definition: config.cpp:836
static void set_known_themes(const config *cfg)
Definition: theme.cpp:928
void merge_children(const std::string &key)
All children with the given key will be merged into the first element with that key.
Definition: config.cpp:325
bool noaddons
True if –noaddons was given on the command line. Disables the loading of all add-ons.
Exception thrown when the WML parser fails to read a .pbl file.
Definition: manager.hpp:30
void lock()
Lock the transaction so no more macros are added.
void set_scope_active(scope s, bool set)
static bool file_exists(const bfs::path &fpath)
Definition: filesystem.cpp:266
child_itors child_range(config_key_type key)
Definition: config.cpp:362
filesystem::binary_paths_manager paths_manager_
static void progress(loading_stage stage=loading_stage::none)
const std::string DEFAULT_DIFFICULTY
The default difficulty setting for campaigns.
#define ERR_CONFIG
unit_type_data unit_types
Definition: types.cpp:1529
Don&#39;t reload if the previous defines equal the new defines.
static lg::log_domain log_config("config")
void load_config(const config &v)
static void add_color_info(const config &v, bool build_defaults)
Used to set and unset scoped defines to preproc_map.
void call_in_main_thread(const std::function< void(void)> &f)
Definition: events.cpp:869
void flush_cache()
Definition: picture.cpp:225
void clear_binary_paths_cache()
One of the realizations of serialization/validator.hpp abstract validator.
static void extract_preload_scripts(const config &game_config)
static game_config_manager * get()
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:91
void splice_children(config &src, const std::string &key)
Moves all the children with tag key from src to this.
Definition: config.cpp:626
void load_hotkeys()
Definition: general.cpp:865
std::ostringstream wrapper.
Definition: formatter.hpp:38
const std::string message
Error message to display.
Definition: manager.hpp:46
std::string campaign_define
If there is a define the campaign uses to customize data.
static UNUSEDNOWARN std::string _n(const char *str1, const char *str2, int n)
Definition: gettext.hpp:95
void set_force_valid_cache(bool force)
Enable/disable cache validation.
void set_core_id(const std::string &core_id)
Definition: general.cpp:319
static game_config_manager * singleton
std::string path
Definition: game_config.cpp:39
boost::optional< std::string > test
Non-empty if –test was given on the command line. Goes directly into test mode, into a scenario...
void init_textdomains(const config &cfg)
Initializes the list of textdomains from a configuration object.
Definition: language.cpp:303
#define log_scope2(domain, description)
Definition: log.hpp:187
bool multiplayer
True if –multiplayer was given on the command line. Goes directly into multiplayer mode...
void refresh_addon_version_info_cache()
Refreshes the per-session cache of add-on&#39;s version information structs.
Definition: manager.cpp:283
std::string campaign
The id of the campaign being played.
void deactivate_all_scopes()
log_domain & general()
Definition: log.cpp:104
config get_addon_pbl_info(const std::string &addon_name)
Gets the publish information for an add-on.
Definition: manager.cpp:79
std::string era_define
If there is a define the era uses to customize data.
void flush_cache()
Definition: sound.cpp:194
void get_config(const std::string &path, config &cfg, abstract_validator *validator=nullptr)
Gets a config object from given path.
void set_use_cache(bool use)
Enable/disable caching.
void clear_defines()
Clear stored defines map to default values.
void get_files_in_dir(const std::string &dir, std::vector< std::string > *files, std::vector< std::string > *dirs, file_name_option mode, file_filter_option filter, file_reorder_option reorder, file_tree_checksum *checksum)
Populates &#39;files&#39; with all the files and &#39;dirs&#39; with all the directories in dir.
Definition: filesystem.cpp:352
game_config_manager(const commandline_options &cmdline_opts, const bool jump_to_editor)
bool nocache
True if –nocache was given on the command line. Disables cache usage.
logger & err()
Definition: log.cpp:78
std::vector< std::string > campaign_xtra_defines
more customization of data
std::string get_wml_location(const std::string &filename, const std::string &current_dir)
Returns a complete path to the actual WML file or directory or an empty string if the file isn&#39;t pres...
bool have_addon_pbl_info(const std::string &addon_name)
Returns true if there&#39;s a local .pbl file stored for the specified add-on.
Definition: manager.cpp:74
void load_game_config_for_create(bool is_mp, bool is_test=false)
Game configuration data as global variables.
Definition: build_info.cpp:49
const preproc_map & get_preproc_map() const
An exception object used when an IO error occurs.
Definition: filesystem.hpp:48
void reset_color_info()
std::string scenario_define
If there is a define the scenario uses to customize data.
std::vector< std::string > mod_defines
If there are defines the modifications use to customize data.
Definitions related to theme-support.
const bool & debug
Definitions for the terrain builder.
static void display(const std::string &summary, const std::string &post_summary, const std::vector< std::string > &files, const std::string &details)
The display function; see modal_dialog for more information.
Definition: wml_error.hpp:43
Represents version numbers.
config & add_child(config_key_type key)
Definition: config.cpp:476
const file_tree_checksum & data_tree_checksum(bool reset=false)
Get the time at which the data/ tree was last modified at.
std::string difficulty
The difficulty level the game is being played on.
std::string core_id()
Definition: general.cpp:313
void set_about(const config &cfg)
Regenerates the credits config.
Definition: about.cpp:106
Used to share macros between cache objects You have to create transaction object to load all macros t...
static void display(std::function< void()> f)
void load_game_config_for_game(const game_classification &classification)
static void set_terrain_rules_cfg(const config &cfg)
Set the config where we will parse the global terrain rules.
Definition: builder.cpp:290
Base class for all the errors encountered by the engine.
Definition: exceptions.hpp:29
void load_hotkeys(const config &cfg, bool set_as_default)
Iterates through all hotkeys present in the config struct and creates and adds them to the hotkey lis...
std::string get_addons_dir()
Managing the AIs configuration - headers.
bool validate_core
True if –validate-core was given on the command line. Makes Wesnoth validate the core WML...
Standard logging facilities (interface).
std::string str() const
Serializes the version number into string form.
std::string message
Definition: exceptions.hpp:31
const commandline_options & cmdline_opts_
bool validcache
True if –validcache was given on the command line. Makes Wesnoth assume the cache is valid...
bool init_strings(const config &cfg)
Initializes certain English strings.
Definition: language.cpp:326
game_config::config_cache & cache_
std::map< std::string, struct preproc_define > preproc_map
#define e
Realization of serialization/validator.hpp abstract validator.
const config & child_or_empty(config_key_type key) const
Returns the first child with the given key, or an empty config if there is none.
Definition: config.cpp:453
static void init(const config &game_config)
Init the parameters of ai configuration parser.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
static map_location::DIRECTION n
bool init_game_config(FORCE_RELOAD_CONFIG force_reload)
std::string hash() const
Definition: config.cpp:1322
bool empty() const
Definition: config.cpp:884
boost::optional< std::string > validate_addon
Non-empty if –validate-addon was given on the command line. Makes Wesnoth validate an addon&#39;s WML...
const config & game_config() const
void load_game_config(FORCE_RELOAD_CONFIG force_reload, game_classification const *classification=nullptr)
void recheck_filetree_checksum()
Force cache checksum validation.
void load_game_config_with_loadscreen(FORCE_RELOAD_CONFIG force_reload, game_classification const *classification=nullptr)