The Battle for Wesnoth  1.15.5+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 
334 
335  } catch(const game::error& e) {
336  ERR_CONFIG << "Error loading game configuration files\n" << e.message << '\n';
337 
338  // Try reloading without add-ons
339  if (!game_config::no_addons) {
340  game_config::no_addons = true;
343  _("Error loading custom game configuration files. The game will try without loading add-ons."),
344  e.message);
345  });
346  load_game_config(reload_everything);
347  } else if (preferences::core_id() != "default") {
350  _("Error loading custom game configuration files. The game will fallback to the default core files."),
351  e.message);
352  });
353  preferences::set_core_id("default");
354  game_config::no_addons = false;
355  load_game_config(reload_everything);
356  } else {
359  _("Error loading default core game configuration files. The game will now exit."),
360  e.message);
361  });
362  throw;
363  }
364  }
365 
367 
368  // Set new binary paths.
370 }
371 
373 {
374  const std::string user_campaign_dir = filesystem::get_addons_dir();
375 
376  std::vector<std::string> error_log;
377  std::vector<std::string> error_addons;
378  std::vector<std::string> user_dirs;
379  std::vector<std::string> user_files;
380 
381  filesystem::get_files_in_dir(user_campaign_dir, &user_files, &user_dirs,
383 
384  // Warn player about addons using the no-longer-supported single-file format.
385  for(const std::string& file : user_files) {
386  const int size_minus_extension = file.size() - 4;
387 
388  if(file.substr(size_minus_extension, file.size()) == ".cfg") {
389  ERR_CONFIG << "error reading usermade add-on '" << file << "'\n";
390 
391  error_addons.push_back(file);
392 
393  const int userdata_loc = file.find("data/add-ons") + 5;
394  const std::string log_msg = formatter()
395  << "The format '~"
396  << file.substr(userdata_loc)
397  << "' (for single-file add-ons) is not supported anymore, use '~"
398  << file.substr(userdata_loc, size_minus_extension - userdata_loc)
399  << "/_main.cfg' instead.";
400 
401  error_log.push_back(log_msg);
402  }
403  }
404 
405  // Rerun the directory scan using filename only, to get the addon_ids more easily.
406  user_files.clear();
407  user_dirs.clear();
408 
409  filesystem::get_files_in_dir(user_campaign_dir, nullptr, &user_dirs,
411 
412  // Load the addons.
413  for(const std::string& addon_id : user_dirs) {
414  log_scope2(log_config, "Loading add-on '" + addon_id + "'");
415  const std::string addon_dir = user_campaign_dir + "/" + addon_id;
416 
417  const std::string main_cfg = addon_dir + "/_main.cfg";
418  const std::string info_cfg = addon_dir + "/_info.cfg";
419 
420  if(!filesystem::file_exists(main_cfg)) {
421  continue;
422  }
423 
424  // Try to find this addon's metadata. Author publishing info (_server.pbl) is given
425  // precedence over addon sever-generated info (_info.cfg). If neither are found, it
426  // probably means the addon was installed manually and certain defaults will be used.
427  config metadata;
428 
429  if(have_addon_pbl_info(addon_id)) {
430  // Publishing info needs to be read from disk.
431  try {
432  metadata = get_addon_pbl_info(addon_id);
433  } catch(const invalid_pbl_exception& e) {
434  const std::string log_msg = formatter()
435  << "The provided addon has an invalid pbl file"
436  << " for addon "
437  << addon_id;
438 
439  error_addons.push_back(e.message);
440  error_log.push_back(log_msg);
441  }
442  } else if(filesystem::file_exists(info_cfg)) {
443  // Addon server-generated info can be fetched from cache.
444  config temp;
445  cache_.get_config(info_cfg, temp);
446 
447  metadata = temp.child_or_empty("info");
448  }
449 
450  std::string using_core = metadata["core"];
451  if(using_core.empty()) {
452  using_core = "default";
453  }
454 
455  // Skip add-ons not matching our current core. Cores themselves should be selectable
456  // at all times, so they aren't considered here.
457  if(!metadata.empty() && metadata["type"] != "core" && using_core != preferences::core_id()) {
458  continue;
459  }
460 
461  std::string addon_title = metadata["title"].str();
462  if(addon_title.empty()) {
463  addon_title = addon_id;
464  }
465 
466  version_info addon_version(metadata["version"]);
467 
468  try {
469  std::unique_ptr<schema_validation::schema_validator> validator;
471  validator.reset(new schema_validation::schema_validator(filesystem::get_wml_location("schema/game_config.cfg")));
472  validator->set_create_exceptions(false); // Don't crash if there's an error, just go ahead anyway
473  }
474  // Load this addon from the cache to a config.
475  config umc_cfg;
476  cache_.get_config(main_cfg, umc_cfg, validator.get());
477 
478  static const std::set<std::string> tags_with_addon_id {
479  "era",
480  "modification",
481  "resource",
482  "multiplayer",
483  "scenario",
484  "campaign"
485  };
486 
487  // Annotate appropriate addon types with addon_id info.
488  for(auto child : umc_cfg.all_children_range()) {
489  if(tags_with_addon_id.count(child.key) > 0) {
490  auto& cfg = child.cfg;
491  cfg["addon_id"] = addon_id;
492  cfg["addon_title"] = addon_title;
493  // Note that this may reformat the string in a canonical form.
494  cfg["addon_version"] = addon_version.str();
495  }
496  }
497  config advancefroms;
498  for(auto& units : umc_cfg.child_range("units")) {
499  for(auto& unit_type : units.child_range("unit_type")) {
500  for(const auto& advancefrom : units.child_range("advancefrom")) {
501 
502  config modify_unit_type {
503  "type", unit_type["id"],
504  "add_advancement", advancefrom["unit"],
505  "set_experience", advancefrom["experience"]
506  };
508  "[advancefrom]",
510  {1, 17, 0},
511  _("Use [modify_unit_type]\n") + modify_unit_type.debug() + "\n [/modify_unit_type] instead in [campaign]"
512  );
513 
514  advancefroms.add_child("modify_unit_type", modify_unit_type);
515  }
516  unit_type.remove_children("advancefrom", [](const config&){return true;});
517  }
518  }
519  //hardcoded list of 1.14 advancement macros, just used for the werro mesage below.
520  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"};
521  for(auto& campaign : umc_cfg.child_range("campaign")) {
522  campaign.append_children(std::move(advancefroms));
523  for(auto str : utils::split(campaign["extra_defines"])) {
524  if(deprecated_defeines.count(str) > 0) {
525  //TODO: we could try to implement a compatabiltiy path by
526  // somehow getting the content of that macro from the
527  // cache_ object, but considering that 1) the breakage
528  // isn't that bad (just one disabled unit) and 2)
529  // it before also didn't work in all cases (see #4402)
530  // i don't think it is worth it.
532  "extra_defines=" + str,
534  {1, 15, 4},
535  _("instead, use the macro with the same name in the [campaign] tag")
536  );
537  }
538  }
539  }
540  static const std::set<std::string> entry_tags {
541  "era",
542  "modification",
543  "resource",
544  "multiplayer",
545  "scenario",
546  "campaign"
547  };
548  for (const std::string& tagname : entry_tags) {
549  game_config_.append_children_by_move(umc_cfg, tagname);
550  }
551  addon_cfgs_[addon_id] = std::move(umc_cfg);
552  } catch(const config::error& err) {
553  ERR_CONFIG << "error reading usermade add-on '" << main_cfg << "'" << std::endl;
554  ERR_CONFIG << err.message << '\n';
555  error_addons.push_back(main_cfg);
556  error_log.push_back(err.message);
557  } catch(const preproc_config::error& err) {
558  ERR_CONFIG << "error reading usermade add-on '" << main_cfg << "'" << std::endl;
559  ERR_CONFIG << err.message << '\n';
560  error_addons.push_back(main_cfg);
561  error_log.push_back(err.message);
562  } catch(const filesystem::io_exception&) {
563  ERR_CONFIG << "error reading usermade add-on '" << main_cfg << "'" << std::endl;
564  error_addons.push_back(main_cfg);
565  }
566  }
567 
568  if(!error_addons.empty()) {
569  const std::size_t n = error_addons.size();
570  const std::string& msg1 =
571  _n("The following add-on had errors and could not be loaded:",
572  "The following add-ons had errors and could not be loaded:",
573  n);
574  const std::string& msg2 =
575  _n("Please report this to the author or maintainer of this add-on.",
576  "Please report this to the respective authors or maintainers of these add-ons.",
577  n);
578 
579  const std::string& report = utils::join(error_log, "\n\n");
581  gui2::dialogs::wml_error::display(msg1, msg2, error_addons, report);
582  });
583  }
584 }
585 
587 {
588  config& hashes = game_config_.add_child("multiplayer_hashes");
589  for (const config &ch : game_config().child_range("multiplayer")) {
590  hashes[ch["id"].str()] = ch.hash();
591  }
592 }
593 
595 {
597  unit_types.set_config(game_config().merged_children_view("units"));
598 }
599 
601 {
602  // Rebuild addon version info cache.
604 
605  // Force a reload of configuration information.
607  old_defines_map_.clear();
610 
613 }
614 
616 {
619 }
620 
623  , const std::string& scenario_id)
624 {
625  game_config::scoped_preproc_define difficulty(classification.difficulty,
626  !classification.difficulty.empty());
627  game_config::scoped_preproc_define campaign(classification.campaign_define,
628  !classification.campaign_define.empty());
629  game_config::scoped_preproc_define scenario(classification.scenario_define,
630  !classification.scenario_define.empty());
632  !classification.era_define.empty());
633  game_config::scoped_preproc_define multiplayer("MULTIPLAYER",
634  classification.campaign_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER);
636  classification.campaign_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER);
637 
638  //
639  // NOTE: these deques aren't used here, but the objects within are utilized as RAII helpers.
640  //
641 
642  typedef std::unique_ptr<game_config::scoped_preproc_define> define;
643 
644  std::deque<define> extra_defines;
645  for(const std::string& extra_define : classification.campaign_xtra_defines) {
646  extra_defines.emplace_back(new game_config::scoped_preproc_define(extra_define));
647  }
648 
649  std::deque<define> modification_defines;
650  for(const std::string& mod_define : classification.mod_defines) {
651  modification_defines.emplace_back(new game_config::scoped_preproc_define(mod_define, !mod_define.empty()));
652  }
653 
654  try {
655  load_game_config_with_loadscreen(NO_FORCE_RELOAD, &classification, classification.active_addons(scenario_id));
656  } catch(const game::error&) {
658 
659  std::deque<define> previous_defines;
660  for(const preproc_map::value_type& preproc : old_defines_map_) {
661  previous_defines.emplace_back(new game_config::scoped_preproc_define(preproc.first));
662  }
663 
665 
666  throw;
667  }
668 
669  // This needs to be done in the main thread since this function (load_game_config_for_game)
670  // might be called from a loading screen worker thread (and currently is, in fact). If the
671  // image cache is purged from the worker thread, there's a possibility for a data race where
672  // the main thread accesses the image cache and the worker thread simultaneously clears it.
674 }
675 
677 {
678  game_config::scoped_preproc_define multiplayer("MULTIPLAYER", is_mp);
679  game_config::scoped_preproc_define test("TEST", is_test);
680  game_config::scoped_preproc_define mptest("MP_TEST", cmdline_opts_.mptest && is_mp);
681 ///During an mp game the default difficuly define is also defined so better already load it now if we alreeady must reload config cache.
683 
684  typedef std::unique_ptr<game_config::scoped_preproc_define> define;
685  try{
687  }
688  catch(const game::error&) {
690 
691  std::deque<define> previous_defines;
692  for (const preproc_map::value_type& preproc : old_defines_map_) {
693  previous_defines.emplace_back(new game_config::scoped_preproc_define(preproc.first));
694  }
695 
697 
698  throw;
699  }
700 }
701 void game_config_manager::set_enabled_addon(std::set<std::string> addon_ids)
702 {
703  auto& vec = game_config_view_.data();
704  vec.clear();
705  vec.push_back(game_config_);
706  for(const std::string& id : addon_ids) {
707  auto it = addon_cfgs_.find(id);
708  if(it != addon_cfgs_.end()) {
709  vec.push_back(it->second);
710  }
711  }
712 }
714 {
715 
716  auto& vec = game_config_view_.data();
717  vec.clear();
718  vec.push_back(game_config_);
719  for(const auto& pair : addon_cfgs_) {
720  vec.push_back(pair.second);
721  }
722 }
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:722
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:1378
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 config.
Definition: about.cpp:107
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: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: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: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
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: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: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
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.