The Battle for Wesnoth  1.15.3+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 
66  cache_.set_use_cache(false);
67  }
70  }
71 }
72 
74 {
75  assert(singleton);
76  singleton = nullptr;
77 }
78 
80  return singleton;
81 }
82 
84 {
85  // Add preproc defines according to the command line arguments.
86  game_config::scoped_preproc_define multiplayer("MULTIPLAYER",
91  game_config::scoped_preproc_define title_screen("TITLE_SCREEN",
93 
95 
96 
98 
99  game_config::load_config(game_config().child("game_config"));
100 
103 
104  // Load the standard hotkeys, then apply any player customizations.
107 
111 
112  return true;
113 }
114 
115 namespace {
116 /// returns true if every define in special is also defined in general
117 bool map_includes(const preproc_map& general, const preproc_map& special)
118 {
119  for (const preproc_map::value_type& pair : special)
120  {
121  preproc_map::const_iterator it = general.find(pair.first);
122  if (it == general.end() || it->second != pair.second) {
123  return false;
124  }
125  }
126  return true;
127 }
128 } // end anonymous namespace
129 
131  game_classification const*,
132  boost::optional<std::set<std::string>> active_addons)
133 {
134  if (!lg::info().dont_log(log_config)) {
135  auto& out = lg::info()(log_config);
136  out << "load_game_config: defines:";
137  for(const auto& pair : cache_.get_preproc_map()) {
138  out << pair.first << ",";
139  }
140  out << "\n add_ons:";
141  if(active_addons) {
142  for(const auto& str : *active_addons) {
143  out << str << ",";
144  }
145  }
146  else {
147  out << "\n Everything:";
148  }
149  out << "\n";
150  }
151 
152 
153  game_config::scoped_preproc_define debug_mode("DEBUG_MODE",
155 
156  bool reload_everything = true;
157  // Game_config already holds requested config in memory.
158  if (!game_config_.empty()) {
159  if ((force_reload == NO_FORCE_RELOAD) && old_defines_map_ == cache_.get_preproc_map()) {
160  reload_everything = false;
161  }
162  if ((force_reload == NO_INCLUDE_RELOAD) && map_includes(old_defines_map_, cache_.get_preproc_map())) {
163  reload_everything = false;
164  }
165  if(!reload_everything && active_addons == active_addons_) {
166  LOG_CONFIG << "load_game_config aborting\n";
167  return;
168  }
169  }
170  active_addons_ = active_addons;
171 
172  LOG_CONFIG << "load_game_config: everything:" << reload_everything << "\n";
173 
174  gui2::dialogs::loading_screen::display([this, reload_everything]() {
175  load_game_config(reload_everything);
176  });
177 }
178 
179 void game_config_manager::load_game_config(bool reload_everything)
180 {
181  // Make sure that 'debug mode' symbol is set
182  // if command line parameter is selected
183  // also if we're in multiplayer and actual debug mode is disabled.
184 
185  // The loadscreen will erase the titlescreen.
186  // NOTE: even without loadscreen, needed after MP lobby.
187  try {
188  // Read all game configs.
189  // First we load all core configs, the mainline one and the ones from the addons.
190  // Validate the cores and discard the invalid.
191  // Then find the path to the selected core.
192  // Load the selected core.
193  // Handle terrains so that they are last loaded from the core.
194  // Load every compatible addon.
195  if(reload_everything) {
199 
200  // Start transaction so macros are shared.
201  game_config::config_cache_transaction main_transaction;
202 
203  config cores_cfg;
204  // Load mainline cores definition file.
205  cache_.get_config(game_config::path + "/data/cores.cfg", cores_cfg);
206 
207  // Append the $user_campaign_dir/*/cores.cfg files to the cores.
208  std::vector<std::string> user_dirs;
209  {
210  const std::string user_campaign_dir = filesystem::get_addons_dir();
211  std::vector<std::string> user_files;
212  filesystem::get_files_in_dir(user_campaign_dir, &user_files, &user_dirs,
214  }
215  for (const std::string& umc : user_dirs) {
216  const std::string cores_file = umc + "/cores.cfg";
217  if (filesystem::file_exists(cores_file)) {
218  config cores;
219  cache_.get_config(cores_file, cores);
220  cores_cfg.append(cores);
221  }
222  }
223 
224  // Validate every core
225  config valid_cores;
226  bool current_core_valid = false;
227  std::string wml_tree_root;
228  for (const config& core : cores_cfg.child_range("core")) {
229 
230  const std::string& id = core["id"];
231  if (id.empty()) {
234  _("Error validating data core."),
235  _("Found a core without id attribute.")
236  + '\n' + _("Skipping the core."));
237  });
238  continue;
239  }
240  if (*&valid_cores.find_child("core", "id", id)) {
243  _("Error validating data core."),
244  _("Core ID: ") + id
245  + '\n' + _("The ID is already in use.")
246  + '\n' + _("Skipping the core."));
247  });
248  continue;
249  }
250 
251  const std::string& path = core["path"];
255  _("Error validating data core."),
256  _("Core ID: ") + id
257  + '\n' + _("Core Path: ") + path
258  + '\n' + _("File not found.")
259  + '\n' + _("Skipping the core."));
260  });
261  continue;
262  }
263 
264  if (id == "default" && !current_core_valid) {
265  wml_tree_root = path;
266  }
267  if (id == preferences::core_id()) {
268  current_core_valid = true;
269  wml_tree_root = path;
270  }
271 
272  valid_cores.add_child("core", core); // append(core);
273  }
274 
275  if (!current_core_valid) {
278  _("Error loading core data."),
279  _("Core ID: ") + preferences::core_id()
280  + '\n' + _("Error loading the core with named id.")
281  + '\n' + _("Falling back to the default core."));
282  });
283  preferences::set_core_id("default");
284  }
285 
286  // check if we have a valid default core which should always be the case.
287  if (wml_tree_root.empty()) {
290  _("Error loading core data."),
291  _("Can't locate the default core.")
292  + '\n' + _("The game will now exit."));
293  });
294  throw;
295  }
296 
297  // Load the selected core
298  std::unique_ptr<schema_validation::schema_validator> validator;
300  validator.reset(new schema_validation::schema_validator(filesystem::get_wml_location("schema/game_config.cfg")));
301  validator->set_create_exceptions(false); // Don't crash if there's an error, just go ahead anyway
302  }
303  cache_.get_config(filesystem::get_wml_location(wml_tree_root), game_config_, validator.get());
304  game_config_.append(valid_cores);
305 
306  main_transaction.lock();
307 
308 
310  load_addons_cfg();
311  }
312  }
313  if(active_addons_) {
315  }
316  else {
318  }
319 
320  // Extract the Lua scripts at toplevel.
322 
323 
324  set_unit_data();
326  tdata_ = std::make_shared<terrain_type_data>(game_config());
329 
331 
332 
333  //FIXME: use game_config() instead to icnlude addons
335 
336  } catch(const game::error& e) {
337  ERR_CONFIG << "Error loading game configuration files\n" << e.message << '\n';
338 
339  // Try reloading without add-ons
340  if (!game_config::no_addons) {
341  game_config::no_addons = true;
344  _("Error loading custom game configuration files. The game will try without loading add-ons."),
345  e.message);
346  });
347  load_game_config(reload_everything);
348  } else if (preferences::core_id() != "default") {
351  _("Error loading custom game configuration files. The game will fallback to the default core files."),
352  e.message);
353  });
354  preferences::set_core_id("default");
355  game_config::no_addons = false;
356  load_game_config(reload_everything);
357  } else {
360  _("Error loading default core game configuration files. The game will now exit."),
361  e.message);
362  });
363  throw;
364  }
365  }
366 
368 
369  // Set new binary paths.
371 }
372 
374 {
375  const std::string user_campaign_dir = filesystem::get_addons_dir();
376 
377  std::vector<std::string> error_log;
378  std::vector<std::string> error_addons;
379  std::vector<std::string> user_dirs;
380  std::vector<std::string> user_files;
381 
382  filesystem::get_files_in_dir(user_campaign_dir, &user_files, &user_dirs,
384 
385  // Warn player about addons using the no-longer-supported single-file format.
386  for(const std::string& file : user_files) {
387  const int size_minus_extension = file.size() - 4;
388 
389  if(file.substr(size_minus_extension, file.size()) == ".cfg") {
390  ERR_CONFIG << "error reading usermade add-on '" << file << "'\n";
391 
392  error_addons.push_back(file);
393 
394  const int userdata_loc = file.find("data/add-ons") + 5;
395  const std::string log_msg = formatter()
396  << "The format '~"
397  << file.substr(userdata_loc)
398  << "' (for single-file add-ons) is not supported anymore, use '~"
399  << file.substr(userdata_loc, size_minus_extension - userdata_loc)
400  << "/_main.cfg' instead.";
401 
402  error_log.push_back(log_msg);
403  }
404  }
405 
406  // Rerun the directory scan using filename only, to get the addon_ids more easily.
407  user_files.clear();
408  user_dirs.clear();
409 
410  filesystem::get_files_in_dir(user_campaign_dir, nullptr, &user_dirs,
412 
413  // Load the addons.
414  for(const std::string& addon_id : user_dirs) {
415  log_scope2(log_config, "Loading add-on '" + addon_id + "'");
416  const std::string addon_dir = user_campaign_dir + "/" + addon_id;
417 
418  const std::string main_cfg = addon_dir + "/_main.cfg";
419  const std::string info_cfg = addon_dir + "/_info.cfg";
420 
421  if(!filesystem::file_exists(main_cfg)) {
422  continue;
423  }
424 
425  // Try to find this addon's metadata. Author publishing info (_server.pbl) is given
426  // precedence over addon sever-generated info (_info.cfg). If neither are found, it
427  // probably means the addon was installed manually and certain defaults will be used.
428  config metadata;
429 
430  if(have_addon_pbl_info(addon_id)) {
431  // Publishing info needs to be read from disk.
432  try {
433  metadata = get_addon_pbl_info(addon_id);
434  } catch(const invalid_pbl_exception& e) {
435  const std::string log_msg = formatter()
436  << "The provided addon has an invalid pbl file"
437  << " for addon "
438  << addon_id;
439 
440  error_addons.push_back(e.message);
441  error_log.push_back(log_msg);
442  }
443  } else if(filesystem::file_exists(info_cfg)) {
444  // Addon server-generated info can be fetched from cache.
445  config temp;
446  cache_.get_config(info_cfg, temp);
447 
448  metadata = temp.child_or_empty("info");
449  }
450 
451  std::string using_core = metadata["core"];
452  if(using_core.empty()) {
453  using_core = "default";
454  }
455 
456  // Skip add-ons not matching our current core. Cores themselves should be selectable
457  // at all times, so they aren't considered here.
458  if(!metadata.empty() && metadata["type"] != "core" && using_core != preferences::core_id()) {
459  continue;
460  }
461 
462  std::string addon_title = metadata["title"].str();
463  if(addon_title.empty()) {
464  addon_title = addon_id;
465  }
466 
467  version_info addon_version(metadata["version"]);
468 
469  try {
470  std::unique_ptr<schema_validation::schema_validator> validator;
472  validator.reset(new schema_validation::schema_validator(filesystem::get_wml_location("schema/game_config.cfg")));
473  validator->set_create_exceptions(false); // Don't crash if there's an error, just go ahead anyway
474  }
475  // Load this addon from the cache to a config.
476  config umc_cfg;
477  cache_.get_config(main_cfg, umc_cfg, validator.get());
478 
479  static const std::set<std::string> tags_with_addon_id {
480  "era",
481  "modification",
482  "resource",
483  "multiplayer",
484  "scenario",
485  "campaign"
486  };
487 
488  // Annotate appropriate addon types with addon_id info.
489  for(auto child : umc_cfg.all_children_range()) {
490  if(tags_with_addon_id.count(child.key) > 0) {
491  auto& cfg = child.cfg;
492  cfg["addon_id"] = addon_id;
493  cfg["addon_title"] = addon_title;
494  // Note that this may reformat the string in a canonical form.
495  cfg["addon_version"] = addon_version.str();
496  }
497  }
498  config advancefroms;
499  for(auto& units : umc_cfg.child_range("units")) {
500  for(auto& unit_type : units.child_range("unit_type")) {
501  for(const auto& advancefrom : units.child_range("advancefrom")) {
502 
503  config modify_unit_type {
504  "type", unit_type["id"],
505  "add_advancement", advancefrom["unit"],
506  "set_experience", advancefrom["experience"]
507  };
509  "[advancefrom]",
511  {1, 17, 0},
512  _("Use [modify_unit_type]\n") + modify_unit_type.debug() + "\n [/modify_unit_type] instead in [campaign]"
513  );
514 
515  advancefroms.add_child("modify_unit_type", modify_unit_type);
516  }
517  unit_type.remove_children("advancefrom", [](const config&){return true;});
518  }
519  }
520  //hardcoded list of 1.14 advancement macros, just used for the werro mesage below.
521  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"};
522  for(auto& campaign : umc_cfg.child_range("campaign")) {
523  campaign.append_children(std::move(advancefroms));
524  for(auto str : utils::split(campaign["extra_defines"])) {
525  if(deprecated_defeines.count(str) > 0) {
526  //TODO: we could try to implement a compatabiltiy path by
527  // somehow getting the content of that macro from the
528  // cache_ object, but considering that 1) the breakage
529  // isn't that bad (just one disabled unit) and 2)
530  // it before also didn't work in all cases (see #4402)
531  // i don't think it is worth it.
533  "extra_defines=" + str,
535  {1, 15, 4},
536  _("instead, use the macro with the same name in the [campaign] tag")
537  );
538  }
539  }
540  }
541  static const std::set<std::string> entry_tags {
542  "era",
543  "modification",
544  "resource",
545  "multiplayer",
546  "scenario",
547  "campaign"
548  };
549  for (const std::string& tagname : entry_tags) {
550  game_config_.append_children_by_move(umc_cfg, tagname);
551  }
552  addon_cfgs_[addon_id] = std::move(umc_cfg);
553  } catch(const config::error& err) {
554  ERR_CONFIG << "error reading usermade add-on '" << main_cfg << "'" << std::endl;
555  ERR_CONFIG << err.message << '\n';
556  error_addons.push_back(main_cfg);
557  error_log.push_back(err.message);
558  } catch(const preproc_config::error& err) {
559  ERR_CONFIG << "error reading usermade add-on '" << main_cfg << "'" << std::endl;
560  ERR_CONFIG << err.message << '\n';
561  error_addons.push_back(main_cfg);
562  error_log.push_back(err.message);
563  } catch(const filesystem::io_exception&) {
564  ERR_CONFIG << "error reading usermade add-on '" << main_cfg << "'" << std::endl;
565  error_addons.push_back(main_cfg);
566  }
567  }
568 
569  if(!error_addons.empty()) {
570  const std::size_t n = error_addons.size();
571  const std::string& msg1 =
572  _n("The following add-on had errors and could not be loaded:",
573  "The following add-ons had errors and could not be loaded:",
574  n);
575  const std::string& msg2 =
576  _n("Please report this to the author or maintainer of this add-on.",
577  "Please report this to the respective authors or maintainers of these add-ons.",
578  n);
579 
580  const std::string& report = utils::join(error_log, "\n\n");
582  gui2::dialogs::wml_error::display(msg1, msg2, error_addons, report);
583  });
584  }
585 }
586 
588 {
589  config& hashes = game_config_.add_child("multiplayer_hashes");
590  for (const config &ch : game_config().child_range("multiplayer")) {
591  hashes[ch["id"].str()] = ch.hash();
592  }
593 }
594 
596 {
598  unit_types.set_config(game_config().merged_children_view("units"));
599 }
600 
602 {
603  // Rebuild addon version info cache.
605 
606  // Force a reload of configuration information.
608  old_defines_map_.clear();
611 
614 }
615 
617 {
620 }
621 
624  , const std::string& scenario_id)
625 {
626  game_config::scoped_preproc_define difficulty(classification.difficulty,
627  !classification.difficulty.empty());
628  game_config::scoped_preproc_define campaign(classification.campaign_define,
629  !classification.campaign_define.empty());
630  game_config::scoped_preproc_define scenario(classification.scenario_define,
631  !classification.scenario_define.empty());
633  !classification.era_define.empty());
634  game_config::scoped_preproc_define multiplayer("MULTIPLAYER",
635  classification.campaign_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER);
637  classification.campaign_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER);
638 
639  //
640  // NOTE: these deques aren't used here, but the objects within are utilized as RAII helpers.
641  //
642 
643  typedef std::unique_ptr<game_config::scoped_preproc_define> define;
644 
645  std::deque<define> extra_defines;
646  for(const std::string& extra_define : classification.campaign_xtra_defines) {
647  extra_defines.emplace_back(new game_config::scoped_preproc_define(extra_define));
648  }
649 
650  std::deque<define> modification_defines;
651  for(const std::string& mod_define : classification.mod_defines) {
652  modification_defines.emplace_back(new game_config::scoped_preproc_define(mod_define, !mod_define.empty()));
653  }
654 
655  try {
656  load_game_config_with_loadscreen(NO_FORCE_RELOAD, &classification, classification.active_addons(scenario_id));
657  } catch(const game::error&) {
659 
660  std::deque<define> previous_defines;
661  for(const preproc_map::value_type& preproc : old_defines_map_) {
662  previous_defines.emplace_back(new game_config::scoped_preproc_define(preproc.first));
663  }
664 
666 
667  throw;
668  }
669 
670  // This needs to be done in the main thread since this function (load_game_config_for_game)
671  // might be called from a loading screen worker thread (and currently is, in fact). If the
672  // image cache is purged from the worker thread, there's a possibility for a data race where
673  // the main thread accesses the image cache and the worker thread simultaneously clears it.
675 }
676 
678 {
679  game_config::scoped_preproc_define multiplayer("MULTIPLAYER", is_mp);
680  game_config::scoped_preproc_define test("TEST", is_test);
681  game_config::scoped_preproc_define mptest("MP_TEST", cmdline_opts_.mptest && is_mp);
682 ///During an mp game the default difficuly define is also defined so better already load it now if we alreeady must reload config cache.
684 
685  typedef std::unique_ptr<game_config::scoped_preproc_define> define;
686  try{
688  }
689  catch(const game::error&) {
691 
692  std::deque<define> previous_defines;
693  for (const preproc_map::value_type& preproc : old_defines_map_) {
694  previous_defines.emplace_back(new game_config::scoped_preproc_define(preproc.first));
695  }
696 
698 
699  throw;
700  }
701 }
702 void game_config_manager::set_enabled_addon(std::set<std::string> addon_ids)
703 {
704  auto& vec = game_config_view_.data();
705  vec.clear();
706  vec.push_back(game_config_);
707  for(const std::string& id : addon_ids) {
708  auto it = addon_cfgs_.find(id);
709  if(it != addon_cfgs_.end()) {
710  vec.push_back(it->second);
711  }
712  }
713 }
715 {
716 
717  auto& vec = game_config_view_.data();
718  vec.clear();
719  vec.push_back(game_config_);
720  for(const auto& pair : addon_cfgs_) {
721  vec.push_back(pair.second);
722  }
723 }
Don&#39;t reload if the previous defines include the new defines.
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: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.
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
bool noaddons
True if –noaddons was given on the command line. Disables the loading of all add-ons.
logger & info()
Definition: log.cpp:90
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.
void load_game_config_with_loadscreen(FORCE_RELOAD_CONFIG force_reload, game_classification const *classification=nullptr, boost::optional< std::set< std::string >> active_addons=boost::optional< std::set< std::string >>())
#define ERR_CONFIG
static void set_known_themes(const game_config_view *cfg)
Definition: theme.cpp:941
unit_type_data unit_types
Definition: types.cpp:1376
Don&#39;t reload if the previous defines equal the new defines.
static lg::log_domain log_config("config")
void init_textdomains(const game_config_view &cfg)
Initializes the list of textdomains from a configuration object.
Definition: language.cpp:356
std::vector< std::string > split(const std::string &val, const char c, const int flags)
Splits a (comma-)separated string into a vector of pieces.
void load_config(const config &v)
static void add_color_info(const config &v, bool build_defaults)
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 config.
Definition: about.cpp:107
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:91
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:866
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:95
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:320
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...
#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:306
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:104
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.
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:78
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()
boost::optional< std::set< std::string > > active_addons_
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:314
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:1016
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
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_
std::string hash() const
Definition: config.cpp:1335
config_array_view & data()
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...
static void extract_preload_scripts(const game_config_view &game_config)
void recheck_filetree_checksum()
Force cache checksum validation.