38 #include <boost/make_shared.hpp>
41 #define ERR_CONFIG LOG_STREAM(err, log_config)
42 #define WRN_CONFIG LOG_STREAM(warn, log_config)
43 #define LOG_CONFIG LOG_STREAM(info, log_config)
50 const bool jump_to_editor) :
51 cmdline_opts_(cmdline_opts),
53 jump_to_editor_(jump_to_editor),
110 for (
const preproc_map::value_type& pair : special)
112 preproc_map::const_iterator it = general.find(pair.first);
113 if (it == general.end() || it->second != pair.second) {
171 std::vector<std::string> user_dirs;
174 std::vector<std::string> user_files;
189 bool current_core_valid =
false;
196 _(
"Error validating data core."),
197 _(
"Found a core without id attribute.")
198 +
'\n' +
_(
"Skipping the core."),
202 if (*&valid_cores.
find_child(
"core",
"id",
id)) {
204 _(
"Error validating data core."),
206 +
'\n' +
_(
"The ID is already in use.")
207 +
'\n' +
_(
"Skipping the core."),
215 _(
"Error validating data core."),
217 +
'\n' +
_(
"Core Path: ") + path
218 +
'\n' +
_(
"File not found.")
219 +
'\n' +
_(
"Skipping the core."),
224 if (
id ==
"default" && !current_core_valid) {
225 wml_tree_root =
path;
228 current_core_valid =
true;
229 wml_tree_root =
path;
235 if (!current_core_valid) {
237 _(
"Error loading core data."),
239 +
'\n' +
_(
"Error loading the core with named id.")
240 +
'\n' +
_(
"Falling back to the default core."),
246 if (wml_tree_root.empty()) {
248 _(
"Error loading core data."),
249 _(
"Can't locate the default core.")
250 +
'\n' +
_(
"The game will now exit."),
259 main_transaction.
lock();
263 config core_terrain_rules;
272 if (classification !=
nullptr) {
275 const bool require_campaign = campaign[
"require_campaign"].to_bool(
true);
278 scenario[
"require_scenario"] = require_campaign;
281 side[
"no_leader"] = side[
"no_leader"].to_bool(
true);
309 _(
"Error loading custom game configuration files. The game will try without loading add-ons."),
314 _(
"Error loading custom game configuration files. The game will fallback to the default core files."),
321 _(
"Error loading default core game configuration files. The game will now exit."),
343 std::vector<std::string> error_addons;
344 std::vector<std::string> user_dirs;
345 std::vector<std::string> user_files;
346 std::vector<addon_source> addons_to_load;
351 std::vector<std::string> error_log;
356 const int size_minus_extension = file.size() - 4;
357 if(file.substr(size_minus_extension, file.size()) ==
".cfg") {
358 const int userdata_loc = file.find(
"data/add-ons") + 5;
359 ERR_CONFIG <<
"error reading usermade add-on '"
361 error_addons.push_back(file);
362 error_log.push_back(
"The format '~" + file.substr(userdata_loc)
363 +
"' (for single-file add-ons) is not supported anymore, use '~"
364 + file.substr(userdata_loc,
365 size_minus_extension - userdata_loc)
366 +
"/_main.cfg' instead.");
379 const std::string addon_dir = user_campaign_dir +
"/" + uc;
381 const std::string main_cfg = addon_dir +
"/_main.cfg";
382 const std::string info_cfg = addon_dir +
"/_info.cfg";
394 if (core.empty()) core =
"default";
395 if ( !info_tag.
empty() &&
396 info_tag[
"type"] !=
"core" &&
405 addons_to_load.push_back(addon);
417 const char * tags_with_addon_id [] = {
"era",
"modification",
"multiplayer",
"scenario",
nullptr };
419 for (
const char **
type = tags_with_addon_id; *
type;
type++)
422 cfg[
"addon_id"] = addon.addon_id;
424 cfg[
"addon_version"] = addon.version.str();
430 ERR_CONFIG <<
"error reading usermade add-on '" << addon.main_cfg <<
"'" << std::endl;
432 error_addons.push_back(addon.main_cfg);
433 error_log.push_back(err.
message);
435 ERR_CONFIG <<
"error reading usermade add-on '" << addon.main_cfg <<
"'" << std::endl;
437 error_addons.push_back(addon.main_cfg);
438 error_log.push_back(err.
message);
440 ERR_CONFIG <<
"error reading usermade add-on '" << addon.main_cfg <<
"'" << std::endl;
441 error_addons.push_back(addon.main_cfg);
444 if(error_addons.empty() ==
false) {
445 const size_t n = error_addons.size();
447 _n(
"The following add-on had errors and could not be loaded:",
448 "The following add-ons had errors and could not be loaded:",
451 _n(
"Please report this to the author or maintainer of this add-on.",
452 "Please report this to the respective authors or maintainers of these add-ons.",
466 hashes[ch[
"id"]] = ch.
hash();
517 classification.campaign_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER);
519 classification.campaign_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER);
522 std::deque<define> extra_defines;
525 extra_defines.push_back(new_define);
527 std::deque<define> modification_defines;
530 modification_defines.push_back(new_define);
539 std::deque<define> previous_defines;
542 previous_defines.push_back(new_define);
564 std::deque<define> previous_defines;
567 previous_defines.push_back(new_define);
child_itors child_range(const std::string &key)
void set_config(config &cfg)
Resets all data based on the provided config.
Dont reload if the previous defines include the new defines.
bool mptest
True if –mp-test was given on the command line.
void set_paths(const config &cfg)
static void display(const std::string &summary, const std::string &post_summary, const std::vector< std::string > &files, const std::string &details, CVideo &video)
The display function; see tdialog for more information.
game_classification * classification
void append(const config &cfg)
Append data from another config object to this one.
static void set_known_themes(const config *cfg)
GLuint GLuint GLsizei GLenum type
void merge_children(const std::string &key)
All children with the given key will be merged into the first element with that key.
bool noaddons
True if –noaddons was given on the command line. Disables the loading of all add-ons.
void lock()
Lock the transaction so no more macros are added.
void set_scope_active(scope s, bool set)
static int report(lua_State *L, int status)
filesystem::binary_paths_manager paths_manager_
const std::string DEFAULT_DIFFICULTY
The default difficulty setting for campaigns.
game_config_manager(const commandline_options &cmdline_opts, CVideo &video, const bool jump_to_editor)
unit_type_data unit_types
Dont reload if the previous defines equal the new defines.
static lg::log_domain log_config("config")
const config & child_or_empty(const std::string &key) const
Returns the first child with the given key, or an empty config if there is none.
void clear_children(const std::string &key)
void load_config(const config &v)
version_info get_addon_version_info(const std::string &addon)
Returns a particular installed add-on's version information.
std::map< std::string, preproc_define > preproc_map
Used to set and unset scoped defines to preproc_map.
void clear_binary_paths_cache()
static void extract_preload_scripts(config const &game_config)
void load_game_config_for_editor()
static game_config_manager * get()
static UNUSEDNOWARN std::string _(const char *str)
GLsizei const char ** path
void splice_children(config &src, const std::string &key)
Moves all the children with tag key from src to this.
preproc_map old_defines_map_
void add_color_info(const config &v)
std::string campaign_define
If there is a define the campaign uses to customize data.
const preproc_map & get_preproc_map() const
void get_config(const std::string &path, config &cfg)
Gets a config object from given path.
static UNUSEDNOWARN std::string _n(const char *str1, const char *str2, int n)
const bool jump_to_editor_
config & add_child(const std::string &key)
void set_force_valid_cache(bool force)
Enable/disable cache validation.
void set_core_id(const std::string &core_id)
static game_config_manager * singleton
boost::optional< std::string > test
Non-empty if –test was given on the command line. Goes directly into test mode, into a scenario...
void init_textdomains(const config &cfg)
Initializes the list of textdomains from a configuration object.
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's version information structs.
std::string campaign
the campaign being played
void set_multiplayer_hashes()
static void display(CVideo &video, std::function< void()> f)
void deactivate_all_scopes()
std::string era_define
If there is a define the era uses to customize data.
std::string join(T const &v, const std::string &s=",")
Generates a new string joining container items in a list.
void load_game_config_for_create(bool is_mp)
void set_use_cache(bool use)
Enable/disable caching.
static void progress(const char *stage_name=nullptr)
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=nullptr, file_name_option mode=FILE_NAME_ONLY, file_filter_option filter=NO_FILTER, file_reorder_option reorder=DONT_REORDER, file_tree_checksum *checksum=nullptr)
Populates 'files' with all the files and 'dirs' with all the directories in dir.
bool nocache
True if –nocache was given on the command line. Disables cache usage.
std::vector< std::string > campaign_xtra_defines
more customization of data
std::string get_wml_location(const std::string &filename, const std::string ¤t_dir=std::string())
Returns a complete path to the actual WML file or directory or an empty string if the file isn't pres...
Game configuration data as global variables.
An exception object used when an IO error occurs.
const config & game_config() const
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.
Definitions for the terrain builder.
Represents version numbers.
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.
void set_about(const config &cfg)
Used to share macros between cache objects You have to create transaction object to load all macros t...
void load_game_config_for_game(const game_classification &classification)
static void set_terrain_rules_cfg(const config &cfg)
Set the config where we will parse the global terrain rules.
Base class for all the errors encountered by the engine.
void load_hotkeys(const config &cfg, bool set_as_default)
Iterates through all hotkeys present in the config struct and creates and adds them to the hotkey lis...
std::string get_addons_dir()
Managing the AIs configuration - headers.
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
config & find_child(const std::string &key, const std::string &name, const std::string &value)
Returns the first child of tag key with a name attribute containing value.
Standard logging facilities (interface).
const commandline_options & cmdline_opts_
bool validcache
True if –validcache was given on the command line. Makes Wesnoth assume the cache is valid...
bool init_strings(const config &cfg)
Initializes certain English strings.
game_config::config_cache & cache_
void reload_changed_game_config()
static void init(const config &game_config)
Init the parameters of ai configuration parser.
A config object defines a single node in a WML file, with access to child nodes.
Interfaces for manipulating version numbers of engine, add-ons, etc.
bool init_game_config(FORCE_RELOAD_CONFIG force_reload)
bool file_exists(const std::string &name)
Returns true if a file or directory with such name already exists.
GLsizei const GLcharARB ** string
void load_game_config(FORCE_RELOAD_CONFIG force_reload, game_classification const *classification=nullptr)
void recheck_filetree_checksum()
Force cache checksum validation.
void load_game_config_with_loadscreen(FORCE_RELOAD_CONFIG force_reload, game_classification const *classification=nullptr)