The Battle for Wesnoth  1.15.7+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  game_config_view_(),
56  addon_cfgs_(),
57  active_addons_(),
58  old_defines_map_(),
59  paths_manager_(),
60  cache_(game_config::config_cache::instance())
61 {
62  assert(!singleton);
63  singleton = this;
64 
65  // All of the validation options imply --nocache, as the validation happens during cache
66  // rebuilding. If the cache isn't rebuilt, validation is silently skipped.
68  cache_.set_use_cache(false);
69  }
72  }
73 }
74 
76 {
77  assert(singleton);
78  singleton = nullptr;
79 }
80 
82  return singleton;
83 }
84 
86 {
87  // Add preproc defines according to the command line arguments.
88  game_config::scoped_preproc_define multiplayer("MULTIPLAYER",
93  game_config::scoped_preproc_define title_screen("TITLE_SCREEN",
95 
97 
98 
100 
101  game_config::load_config(game_config().child("game_config"));
102 
105 
106  // Load the standard hotkeys, then apply any player customizations.
109 
113 
114  return true;
115 }
116 
117 namespace {
118 /// returns true if every define in special is also defined in general
119 bool map_includes(const preproc_map& general, const preproc_map& special)
120 {
121  for (const preproc_map::value_type& pair : special)
122  {
123  preproc_map::const_iterator it = general.find(pair.first);
124  if (it == general.end() || it->second != pair.second) {
125  return false;
126  }
127  }
128  return true;
129 }
130 } // end anonymous namespace
131 
133  game_classification const*,
134  utils::optional<std::set<std::string>> active_addons)
135 {
136  if (!lg::info().dont_log(log_config)) {
137  auto out = formatter();
138  out << "load_game_config: defines:";
139  for(const auto& pair : cache_.get_preproc_map()) {
140  out << pair.first << ",";
141  }
142  out << "\n add_ons:";
143  if(active_addons) {
144  for(const auto& str : *active_addons) {
145  out << str << ",";
146  }
147  }
148  else {
149  out << "\n Everything:";
150  }
151  out << "\n";
152  FORCE_LOG_TO(lg::info(), log_config) << out.str();
153  }
154 
155 
156  game_config::scoped_preproc_define debug_mode("DEBUG_MODE",
158 
159  bool reload_everything = true;
160  // Game_config already holds requested config in memory.
161  if (!game_config_.empty()) {
162  if ((force_reload == NO_FORCE_RELOAD) && old_defines_map_ == cache_.get_preproc_map()) {
163  reload_everything = false;
164  }
165  if ((force_reload == NO_INCLUDE_RELOAD) && map_includes(old_defines_map_, cache_.get_preproc_map())) {
166  reload_everything = false;
167  }
168  if(!reload_everything && active_addons == active_addons_) {
169  LOG_CONFIG << "load_game_config aborting\n";
170  return;
171  }
172  }
173  active_addons_ = active_addons;
174 
175  LOG_CONFIG << "load_game_config: everything:" << reload_everything << "\n";
176 
177  gui2::dialogs::loading_screen::display([this, reload_everything]() {
178  load_game_config(reload_everything);
179  });
180 }
181 
182 void game_config_manager::load_game_config(bool reload_everything)
183 {
184  // Make sure that 'debug mode' symbol is set
185  // if command line parameter is selected
186  // also if we're in multiplayer and actual debug mode is disabled.
187 
188  // The loadscreen will erase the titlescreen.
189  // NOTE: even without loadscreen, needed after MP lobby.
190  try {
191  // Read all game configs.
192  // First we load all core configs, the mainline one and the ones from the addons.
193  // Validate the cores and discard the invalid.
194  // Then find the path to the selected core.
195  // Load the selected core.
196  // Handle terrains so that they are last loaded from the core.
197  // Load every compatible addon.
198  if(reload_everything) {
202 
203  // Start transaction so macros are shared.
204  game_config::config_cache_transaction main_transaction;
205 
206  config cores_cfg;
207  // Load mainline cores definition file.
208  cache_.get_config(game_config::path + "/data/cores.cfg", cores_cfg);
209 
210  // Append the $user_campaign_dir/*/cores.cfg files to the cores.
211  std::vector<std::string> user_dirs;
212  {
213  const std::string user_campaign_dir = filesystem::get_addons_dir();
214  std::vector<std::string> user_files;
215  filesystem::get_files_in_dir(user_campaign_dir, &user_files, &user_dirs,
217  }
218  for (const std::string& umc : user_dirs) {
219  const std::string cores_file = umc + "/cores.cfg";
220  if (filesystem::file_exists(cores_file)) {
221  config cores;
222  cache_.get_config(cores_file, cores);
223  cores_cfg.append(cores);
224  }
225  }
226 
227  // Validate every core
228  config valid_cores;
229  bool current_core_valid = false;
230  std::string wml_tree_root;
231  for (const config& core : cores_cfg.child_range("core")) {
232 
233  const std::string& id = core["id"];
234  if (id.empty()) {
237  _("Error validating data core."),
238  _("Found a core without id attribute.")
239  + '\n' + _("Skipping the core."));
240  });
241  continue;
242  }
243  if (*&valid_cores.find_child("core", "id", id)) {
246  _("Error validating data core."),
247  _("Core ID: ") + id
248  + '\n' + _("The ID is already in use.")
249  + '\n' + _("Skipping the core."));
250  });
251  continue;
252  }
253 
254  const std::string& path = core["path"];
258  _("Error validating data core."),
259  _("Core ID: ") + id
260  + '\n' + _("Core Path: ") + path
261  + '\n' + _("File not found.")
262  + '\n' + _("Skipping the core."));
263  });
264  continue;
265  }
266 
267  if (id == "default" && !current_core_valid) {
268  wml_tree_root = path;
269  }
270  if (id == preferences::core_id()) {
271  current_core_valid = true;
272  wml_tree_root = path;
273  }
274 
275  valid_cores.add_child("core", core); // append(core);
276  }
277 
278  if (!current_core_valid) {
281  _("Error loading core data."),
282  _("Core ID: ") + preferences::core_id()
283  + '\n' + _("Error loading the core with named id.")
284  + '\n' + _("Falling back to the default core."));
285  });
286  preferences::set_core_id("default");
287  }
288 
289  // check if we have a valid default core which should always be the case.
290  if (wml_tree_root.empty()) {
293  _("Error loading core data."),
294  _("Can't locate the default core.")
295  + '\n' + _("The game will now exit."));
296  });
297  throw;
298  }
299 
300  // Load the selected core
301  std::unique_ptr<schema_validation::schema_validator> validator;
303  validator.reset(new schema_validation::schema_validator(filesystem::get_wml_location("schema/game_config.cfg")));
304  validator->set_create_exceptions(false); // Don't crash if there's an error, just go ahead anyway
305  }
306  cache_.get_config(filesystem::get_wml_location(wml_tree_root), game_config_, validator.get());
307  game_config_.append(valid_cores);
308 
309  main_transaction.lock();
310 
311 
313  load_addons_cfg();
314  }
315  }
316  if(active_addons_) {
318  }
319  else {
321  }
322 
323  // Extract the Lua scripts at toplevel.
325 
326 
327  set_unit_data();
329  tdata_ = std::make_shared<terrain_type_data>(game_config());
332 
334 
335 
337 
338  } catch(const game::error& e) {
339  ERR_CONFIG << "Error loading game configuration files\n" << e.message << '\n';
340 
341  // Try reloading without add-ons
342  if (!game_config::no_addons) {
343  game_config::no_addons = true;
346  _("Error loading custom game configuration files. The game will try without loading add-ons."),
347  e.message);
348  });
349  load_game_config(reload_everything);
350  } else if (preferences::core_id() != "default") {
353  _("Error loading custom game configuration files. The game will fallback to the default core files."),
354  e.message);
355  });
356  preferences::set_core_id("default");
357  game_config::no_addons = false;
358  load_game_config(reload_everything);
359  } else {
362  _("Error loading default core game configuration files. The game will now exit."),
363  e.message);
364  });
365  throw;
366  }
367  }
368 
370 
371  // Set new binary paths.
373 }
374 
376 {
377  const std::string user_campaign_dir = filesystem::get_addons_dir();
378 
379  std::vector<std::string> error_log;
380  std::vector<std::string> error_addons;
381  std::vector<std::string> user_dirs;
382  std::vector<std::string> user_files;
383 
384  filesystem::get_files_in_dir(user_campaign_dir, &user_files, &user_dirs,
386 
387  // Warn player about addons using the no-longer-supported single-file format.
388  for(const std::string& file : user_files) {
389  const int size_minus_extension = file.size() - 4;
390 
391  if(file.substr(size_minus_extension, file.size()) == ".cfg") {
392  ERR_CONFIG << "error reading usermade add-on '" << file << "'\n";
393 
394  error_addons.push_back(file);
395 
396  const int userdata_loc = file.find("data/add-ons") + 5;
397  const std::string log_msg = formatter()
398  << "The format '~"
399  << file.substr(userdata_loc)
400  << "' (for single-file add-ons) is not supported anymore, use '~"
401  << file.substr(userdata_loc, size_minus_extension - userdata_loc)
402  << "/_main.cfg' instead.";
403 
404  error_log.push_back(log_msg);
405  }
406  }
407 
408  // Rerun the directory scan using filename only, to get the addon_ids more easily.
409  user_files.clear();
410  user_dirs.clear();
411 
412  filesystem::get_files_in_dir(user_campaign_dir, nullptr, &user_dirs,
414 
415  // Load the addons.
416  for(const std::string& addon_id : user_dirs) {
417  log_scope2(log_config, "Loading add-on '" + addon_id + "'");
418  const std::string addon_dir = user_campaign_dir + "/" + addon_id;
419 
420  const std::string main_cfg = addon_dir + "/_main.cfg";
421  const std::string info_cfg = addon_dir + "/_info.cfg";
422 
423  if(!filesystem::file_exists(main_cfg)) {
424  continue;
425  }
426 
427  // Try to find this addon's metadata. Author publishing info (_server.pbl) is given
428  // precedence over addon sever-generated info (_info.cfg). If neither are found, it
429  // probably means the addon was installed manually and certain defaults will be used.
430  config metadata;
431 
432  if(have_addon_pbl_info(addon_id)) {
433  // Publishing info needs to be read from disk.
434  try {
435  metadata = get_addon_pbl_info(addon_id);
436  } catch(const invalid_pbl_exception& e) {
437  const std::string log_msg = formatter()
438  << "The provided addon has an invalid pbl file"
439  << " for addon "
440  << addon_id;
441 
442  error_addons.push_back(e.message);
443  error_log.push_back(log_msg);
444  }
445  } else if(filesystem::file_exists(info_cfg)) {
446  // Addon server-generated info can be fetched from cache.
447  config temp;
448  cache_.get_config(info_cfg, temp);
449 
450  metadata = temp.child_or_empty("info");
451  }
452 
453  std::string using_core = metadata["core"];
454  if(using_core.empty()) {
455  using_core = "default";
456  }
457 
458  // Skip add-ons not matching our current core. Cores themselves should be selectable
459  // at all times, so they aren't considered here.
460  if(!metadata.empty() && metadata["type"] != "core" && using_core != preferences::core_id()) {
461  continue;
462  }
463 
464  std::string addon_title = metadata["title"].str();
465  if(addon_title.empty()) {
466  addon_title = addon_id;
467  }
468 
469  version_info addon_version(metadata["version"]);
470 
471  try {
472  std::unique_ptr<schema_validation::schema_validator> validator;
474  validator.reset(new schema_validation::schema_validator(filesystem::get_wml_location("schema/game_config.cfg")));
475  validator->set_create_exceptions(false); // Don't crash if there's an error, just go ahead anyway
476  }
477  // Load this addon from the cache to a config.
478  config umc_cfg;
479  cache_.get_config(main_cfg, umc_cfg, validator.get());
480 
481  static const std::set<std::string> tags_with_addon_id {
482  "era",
483  "modification",
484  "resource",
485  "multiplayer",
486  "scenario",
487  "campaign"
488  };
489 
490  // Annotate appropriate addon types with addon_id info.
491  for(auto child : umc_cfg.all_children_range()) {
492  if(tags_with_addon_id.count(child.key) > 0) {
493  auto& cfg = child.cfg;
494  cfg["addon_id"] = addon_id;
495  cfg["addon_title"] = addon_title;
496  // Note that this may reformat the string in a canonical form.
497  cfg["addon_version"] = addon_version.str();
498  }
499  }
500  config advancefroms;
501  for(auto& units : umc_cfg.child_range("units")) {
502  for(auto& unit_type : units.child_range("unit_type")) {
503  for(const auto& advancefrom : units.child_range("advancefrom")) {
504 
505  config modify_unit_type {
506  "type", unit_type["id"],
507  "add_advancement", advancefrom["unit"],
508  "set_experience", advancefrom["experience"]
509  };
511  "[advancefrom]",
513  {1, 17, 0},
514  _("Use [modify_unit_type]\n") + modify_unit_type.debug() + "\n [/modify_unit_type] instead in [campaign]"
515  );
516 
517  advancefroms.add_child("modify_unit_type", modify_unit_type);
518  }
519  unit_type.remove_children("advancefrom", [](const config&){return true;});
520  }
521  }
522  //hardcoded list of 1.14 advancement macros, just used for the werro mesage below.
523  std::set<std::string> deprecated_defeines = {"ENABLE_PARAGON", "DISABLE_GRAND_MARSHAL", "ENABLE_ARMAGEDDON_DRAKE", "ENABLE_DWARVISH_ARCANISTER", "ENABLE_DWARVISH_RUNESMITH ", "ENABLE_WOLF_ADVANCEMENT", "ENABLE_NIGHTBLADE", "ENABLE_TROLL_SHAMAN", "ENABLE_ANCIENT_LICH", "ENABLE_DEATH_KNIGHT", "ENABLE_WOSE_SHAMAN"};
524  for(auto& campaign : umc_cfg.child_range("campaign")) {
525  campaign.append_children(std::move(advancefroms));
526  for(auto str : utils::split(campaign["extra_defines"])) {
527  if(deprecated_defeines.count(str) > 0) {
528  //TODO: we could try to implement a compatabiltiy path by
529  // somehow getting the content of that macro from the
530  // cache_ object, but considering that 1) the breakage
531  // isn't that bad (just one disabled unit) and 2)
532  // it before also didn't work in all cases (see #4402)
533  // i don't think it is worth it.
535  "extra_defines=" + str,
537  {1, 15, 4},
538  _("instead, use the macro with the same name in the [campaign] tag")
539  );
540  }
541  }
542  }
543  static const std::set<std::string> entry_tags {
544  "era",
545  "modification",
546  "resource",
547  "multiplayer",
548  "scenario",
549  "campaign"
550  };
551  for (const std::string& tagname : entry_tags) {
552  game_config_.append_children_by_move(umc_cfg, tagname);
553  }
554  addon_cfgs_[addon_id] = std::move(umc_cfg);
555  } catch(const config::error& err) {
556  ERR_CONFIG << "error reading usermade add-on '" << main_cfg << "'" << std::endl;
557  ERR_CONFIG << err.message << '\n';
558  error_addons.push_back(main_cfg);
559  error_log.push_back(err.message);
560  } catch(const preproc_config::error& err) {
561  ERR_CONFIG << "error reading usermade add-on '" << main_cfg << "'" << std::endl;
562  ERR_CONFIG << err.message << '\n';
563  error_addons.push_back(main_cfg);
564  error_log.push_back(err.message);
565  } catch(const filesystem::io_exception&) {
566  ERR_CONFIG << "error reading usermade add-on '" << main_cfg << "'" << std::endl;
567  error_addons.push_back(main_cfg);
568  }
569  }
570 
573  ERR_CONFIG << "Didn’t find an add-on for --validate-addon - check whether the id has a typo" << std::endl;
574  const std::string log_msg = formatter()
575  << "Didn't find an add-on for --validate-addon - check whether the id has a typo";
576  error_log.push_back(log_msg);
577  throw game::error("Did not find an add-on for --validate-addon");
578  }
579 
580  WRN_CONFIG << "Note: for --validate-addon to find errors, you have to play (in the GUI) a game that uses the add-on.";
581  }
582 
583  if(!error_addons.empty()) {
584  const std::size_t n = error_addons.size();
585  const std::string& msg1 =
586  _n("The following add-on had errors and could not be loaded:",
587  "The following add-ons had errors and could not be loaded:",
588  n);
589  const std::string& msg2 =
590  _n("Please report this to the author or maintainer of this add-on.",
591  "Please report this to the respective authors or maintainers of these add-ons.",
592  n);
593 
594  const std::string& report = utils::join(error_log, "\n\n");
596  gui2::dialogs::wml_error::display(msg1, msg2, error_addons, report);
597  });
598  }
599 }
600 
602 {
603  config& hashes = game_config_.add_child("multiplayer_hashes");
604  for (const config &ch : game_config().child_range("multiplayer")) {
605  hashes[ch["id"].str()] = ch.hash();
606  }
607 }
608 
610 {
612  unit_types.set_config(game_config().merged_children_view("units"));
613 }
614 
616 {
617  // Rebuild addon version info cache.
619 
620  // Force a reload of configuration information.
622  old_defines_map_.clear();
625 
628 }
629 
631 {
634 }
635 
638  , const std::string& scenario_id)
639 {
640  game_config::scoped_preproc_define difficulty(classification.difficulty,
641  !classification.difficulty.empty());
642  game_config::scoped_preproc_define campaign(classification.campaign_define,
643  !classification.campaign_define.empty());
644  game_config::scoped_preproc_define scenario(classification.scenario_define,
645  !classification.scenario_define.empty());
647  !classification.era_define.empty());
648  game_config::scoped_preproc_define multiplayer("MULTIPLAYER",
649  classification.campaign_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER);
651  classification.campaign_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER);
652 
653  //
654  // NOTE: these deques aren't used here, but the objects within are utilized as RAII helpers.
655  //
656 
657  typedef std::unique_ptr<game_config::scoped_preproc_define> define;
658 
659  std::deque<define> extra_defines;
660  for(const std::string& extra_define : classification.campaign_xtra_defines) {
661  extra_defines.emplace_back(new game_config::scoped_preproc_define(extra_define));
662  }
663 
664  std::deque<define> modification_defines;
665  for(const std::string& mod_define : classification.mod_defines) {
666  modification_defines.emplace_back(new game_config::scoped_preproc_define(mod_define, !mod_define.empty()));
667  }
668 
669  try {
670  load_game_config_with_loadscreen(NO_FORCE_RELOAD, &classification, classification.active_addons(scenario_id));
671  } catch(const game::error&) {
673 
674  std::deque<define> previous_defines;
675  for(const preproc_map::value_type& preproc : old_defines_map_) {
676  previous_defines.emplace_back(new game_config::scoped_preproc_define(preproc.first));
677  }
678 
680 
681  throw;
682  }
683 
684  // This needs to be done in the main thread since this function (load_game_config_for_game)
685  // might be called from a loading screen worker thread (and currently is, in fact). If the
686  // image cache is purged from the worker thread, there's a possibility for a data race where
687  // the main thread accesses the image cache and the worker thread simultaneously clears it.
689 }
690 
692 {
693  game_config::scoped_preproc_define multiplayer("MULTIPLAYER", is_mp);
694  game_config::scoped_preproc_define test("TEST", is_test);
695  game_config::scoped_preproc_define mptest("MP_TEST", cmdline_opts_.mptest && is_mp);
696 ///During an mp game the default difficuly define is also defined so better already load it now if we alreeady must reload config cache.
698 
699  typedef std::unique_ptr<game_config::scoped_preproc_define> define;
700  try{
702  }
703  catch(const game::error&) {
705 
706  std::deque<define> previous_defines;
707  for (const preproc_map::value_type& preproc : old_defines_map_) {
708  previous_defines.emplace_back(new game_config::scoped_preproc_define(preproc.first));
709  }
710 
712 
713  throw;
714  }
715 }
716 void game_config_manager::set_enabled_addon(std::set<std::string> addon_ids)
717 {
718  auto& vec = game_config_view_.data();
719  vec.clear();
720  vec.push_back(game_config_);
721  for(const std::string& id : addon_ids) {
722  auto it = addon_cfgs_.find(id);
723  if(it != addon_cfgs_.end()) {
724  vec.push_back(it->second);
725  }
726  }
727 }
729 {
730 
731  auto& vec = game_config_view_.data();
732  vec.clear();
733  vec.push_back(game_config_);
734  for(const auto& pair : addon_cfgs_) {
735  vec.push_back(pair.second);
736  }
737 }
Don&#39;t reload if the previous defines include the new defines.
bool any_validation_option() const
True if the –validate or any of the –validate-* options are given.
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
std::string era()
Definition: game.cpp:712
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.
void append_children_by_move(config &cfg, const std::string &key)
Moves children with the given name from the given config to this one.
Definition: config.cpp:312
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
void load_game_config_with_loadscreen(FORCE_RELOAD_CONFIG force_reload, game_classification const *classification=nullptr, utils::optional< std::set< std::string >> active_addons=utils::nullopt)
static l_noret error(LoadState *S, const char *why)
Definition: lundump.cpp:39
bool noaddons
True if –noaddons was given on the command line. Disables the loading of all add-ons.
logger & info()
Definition: log.cpp:91
Exception thrown when the WML parser fails to read a .pbl file.
Definition: manager.hpp:31
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:267
static void init(const game_config_view &game_config)
Init the parameters of ai configuration parser.
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)
void load_game_config_for_game(const game_classification &classification, const std::string &scenario_id)
const std::string DEFAULT_DIFFICULTY
The default difficulty setting for campaigns.
#define ERR_CONFIG
static void set_known_themes(const game_config_view *cfg)
Definition: theme.cpp:921
unit_type_data unit_types
Definition: types.cpp:1378
utils::optional< std::string > validate_addon
Non-empty if –validate-addon was given on the command line. Makes Wesnoth validate an addon&#39;s WML...
Don&#39;t reload if the previous defines equal the new defines.
static lg::log_domain log_config("config")
std::string str
Definition: statement.cpp:110
void init_textdomains(const game_config_view &cfg)
Initializes the list of textdomains from a configuration object.
Definition: language.cpp:356
void load_config(const config &v)
A single unit type that the player may recruit.
Definition: types.hpp:44
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.
#define LOG_CONFIG
static game_config_manager * get()
void set_about(const game_config_view &cfg)
Regenerates the credits data.
Definition: about.cpp:114
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:100
std::set< std::string > active_addons(const std::string &scenario_id) const
std::string deprecated_message(const std::string &elem_name, DEP_LEVEL level, const version_info &version, const std::string &detail)
Definition: deprecation.cpp:29
void load_hotkeys()
Definition: general.cpp:864
std::ostringstream wrapper.
Definition: formatter.hpp:38
const std::string message
Error message to display.
Definition: manager.hpp:47
std::string campaign_define
If there is a define the campaign uses to customize data.
const game_config_view & game_config() const
static UNUSEDNOWARN std::string _n(const char *str1, const char *str2, int n)
Definition: gettext.hpp:104
game_config_view game_config_view_
void set_force_valid_cache(bool force)
Enable/disable cache validation.
void set_core_id(const std::string &core_id)
Definition: general.cpp:318
static game_config_manager * singleton
std::string path
Definition: game_config.cpp:39
#define log_scope2(domain, description)
Definition: log.hpp:209
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:337
static void add_color_info(const game_config_view &v, bool build_defaults)
void deactivate_all_scopes()
bool init_strings(const game_config_view &cfg)
Initializes certain English strings.
Definition: language.cpp:379
log_domain & general()
Definition: log.cpp:105
config get_addon_pbl_info(const std::string &addon_name)
Gets the publish information for an add-on.
Definition: manager.cpp:80
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.
#define FORCE_LOG_TO(logger, domain)
Definition: log.hpp:221
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:353
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:79
void set_enabled_addon(std::set< std::string > addon_ids)
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:75
void load_game_config_for_create(bool is_mp, bool is_test=false)
Game configuration data as global variables.
Definition: build_info.cpp:55
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.
utils::optional< std::set< std::string > > active_addons_
std::string difficulty
The difficulty level the game is being played on.
std::string core_id()
Definition: general.cpp:312
Used to share macros between cache objects You have to create transaction object to load all macros t...
void set_paths(const game_config_view &cfg)
static void display(std::function< void()> f)
void set_config(const game_config_view &cfg)
Resets all data based on the provided config.
Definition: types.cpp:1018
std::vector< std::string > split(const config_attribute_value &val)
Base class for all the errors encountered by the engine.
Definition: exceptions.hpp:29
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...
void load_game_config(bool reload_everything)
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...
game_config::config_cache & cache_
std::map< std::string, struct preproc_define > preproc_map
#define e
Realization of serialization/validator.hpp abstract validator.
void load_hotkeys(const game_config_view &cfg, bool set_as_default)
Iterates through all hotkeys present in the config struct and creates and adds them to the hotkey lis...
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
#define WRN_CONFIG
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
static void set_terrain_rules_cfg(const game_config_view &cfg)
Set the config where we will parse the global terrain rules.
Definition: builder.cpp:291
static map_location::DIRECTION n
bool init_game_config(FORCE_RELOAD_CONFIG force_reload)
std::map< std::string, config > addon_cfgs_
utils::optional< std::string > test
Non-empty if –test was given on the command line. Goes directly into test mode, into a scenario...
std::string hash() const
Definition: config.cpp:1335
config_array_view & data()
bool empty() const
Definition: config.cpp:884
static void extract_preload_scripts(const game_config_view &game_config)
void recheck_filetree_checksum()
Force cache checksum validation.