20 #define GETTEXT_DOMAIN "wesnoth-lib"
45 #include <boost/algorithm/string.hpp>
53 #include <openssl/evp.h>
54 #include <openssl/err.h>
56 #include <CommonCrypto/CommonCryptor.h>
60 #define ERR_CFG LOG_STREAM(err , log_config)
61 #define DBG_CFG LOG_STREAM(debug , log_config)
64 #define ERR_FS LOG_STREAM(err, log_filesystem)
67 #define ERR_ADV LOG_STREAM(err, advanced_preferences)
72 , completed_campaigns_()
73 , encountered_units_set_()
74 , encountered_terrains_set_()
78 , options_initialized_(false)
80 , mp_modifications_initialized_(false)
82 , sp_modifications_initialized_(false)
83 , message_private_on_(false)
106 cmp[
"name"] = elem.first;
107 cmp[
"difficulty_levels"] =
utils::join(elem.second);
111 set_child(prefs_list::completed_campaigns, campaigns);
127 for(
const std::string&
line : history_id.second) {
130 cfg[
"message"] =
line;
131 history_id_cfg.
add_child(
"line", std::move(cfg));
134 history.
add_child(history_id.first, history_id_cfg);
163 }
catch(
const std::invalid_argument&
e) {
172 if(op.field == prefs_list::show_deprecation) {
173 op.cfg[
"default"] =
true;
178 std::sort(
advanced_prefs_.begin(),
advanced_prefs_.end(), [](
const auto& lhs,
const auto& rhs) { return translation::icompare(lhs.name, rhs.name) < 0; });
191 read(current_cfg, *current_stream);
194 read(old_cfg, *old_stream);
199 if(current_prefs_are_older || !current_cfg.
has_attribute(key)) {
219 std::set<std::string> attrs;
223 attrs.emplace(attr.first);
226 for(
const auto attr : prefs_list::values) {
240 #ifdef DEFAULT_PREFS_PATH
245 read(default_prefs, *stream);
250 read(unsynced_prefs, *stream);
255 read(synced_prefs, *stream);
285 ERR_CFG <<
"Error loading preference, message: " <<
e.what();
306 if(
auto ccc =
get_child(prefs_list::completed_campaigns)) {
309 std::vector<std::string> nd =
utils::split(cc[
"difficulty_levels"]);
310 std::copy(nd.begin(), nd.end(), std::inserter(
d,
d.begin()));
319 if(
auto history =
get_child(prefs_list::history)) {
327 for(
const auto [key, cfg] : history->all_children_view()) {
388 write(*synced_prefs_file, synced);
395 write(*unsynced_prefs_file, unsynced);
403 if(!synced_prefs_file_existed) {
408 if(!unsynced_prefs_file_existed) {
421 std::fill(cred.username.begin(), cred.username.end(),
'\0');
422 std::fill(cred.server.begin(), cred.server.end(),
'\0');
442 ERR_CFG <<
"Invalid data in credentials file";
446 std::size_t
at = elem.find_last_of(
'@');
447 std::size_t eq = elem.find_first_of(
'=',
at + 1);
448 if(
at != std::string::npos && eq != std::string::npos) {
469 credentials_data.insert(credentials_data.end(), cred.username.begin(), cred.username.end());
470 credentials_data.push_back(
'@');
471 credentials_data.insert(credentials_data.end(), cred.server.begin(), cred.server.end());
472 credentials_data.push_back(
'=');
474 credentials_data.insert(credentials_data.end(), key_escaped.begin(), key_escaped.end());
479 credentials_file->write(
reinterpret_cast<const char*
>(encrypted.data()), encrypted.size());
485 if(!creds_file_existed) {
506 std::string
prefs::get(
const std::string& key,
const std::string& def) {
519 if (color.substr(0,4) ==
"orb_") {
520 if(color[4] >=
'0' && color[4] <=
'9') {
521 return color.substr(5);
523 return color.substr(4);
531 if (ally_color.empty())
571 if (partmoved_color.empty())
581 const unsigned x_res =
preferences_[prefs_list::xresolution].to_unsigned();
582 const unsigned y_res =
preferences_[prefs_list::yresolution].to_unsigned();
585 if(x_res == 0 || y_res == 0) {
597 preferences_[prefs_list::xresolution] = std::to_string(res.x);
598 preferences_[prefs_list::yresolution] = std::to_string(res.y);
644 return preferences_[prefs_list::keepalive_timeout].to_int(20);
649 preferences_[prefs_list::keepalive_timeout] = std::abs(seconds);
657 const std::size_t buf_size = 4096;
659 const std::size_t buf_size = 1024;
662 return preferences_[prefs_list::sound_buffer_size].to_int(buf_size);
667 const std::string new_size = std::to_string(
size);
668 if (
preferences_[prefs_list::sound_buffer_size] == new_size)
769 return preferences_[prefs_list::ui_sound].to_bool(
true);
796 return preferences_[prefs_list::message_bell].to_bool(
true);
805 if(!
sound() && ison) {
813 }
else if(
sound() && !ison) {
850 return std::clamp<int>(
preferences_[prefs_list::scroll].to_int(50), 1, 100);
860 return preferences_[prefs_list::middle_click_scrolls].to_bool(
true);
865 return preferences_[prefs_list::scroll_threshold].to_int(10);
897 alias_list[alias] = command;
908 return preferences_[prefs_list::sample_rate].to_int(44100);
924 return preferences_[prefs_list::confirm_load_save_from_different_version].to_bool(
true);
929 return preferences_[prefs_list::use_twelve_hour_clock_format].to_bool();
946 if(ach[
"content_for"].str() == content_for)
948 std::vector<std::string> ids =
utils::split(ach[
"ids"]);
949 return std::find(ids.begin(), ids.end(),
id) != ids.end();
960 if(ach[
"content_for"].str() == content_for)
962 std::vector<std::string> ids =
utils::split(ach[
"ids"]);
968 else if(std::find(ids.begin(), ids.end(),
id) == ids.end())
970 ach[
"ids"] = ach[
"ids"].str() +
"," +
id;
972 ach.remove_children(
"in_progress", [&
id](
config cfg){
return cfg[
"id"].str() ==
id;});
979 ach[
"content_for"] = content_for;
994 if(ach[
"content_for"].str() == content_for)
999 if(in_progress[
"id"].str() ==
id)
1002 int starting_progress = in_progress[
"progress_at"].to_int();
1003 if(starting_progress >= limit) {
1004 return starting_progress;
1007 in_progress[
"progress_at"] = std::clamp(starting_progress + amount, 0, std::min(limit, max_progress));
1008 return in_progress[
"progress_at"].to_int();
1016 set_progress[
"id"] =
id;
1017 set_progress[
"progress_at"] = std::clamp(amount, 0, std::min(limit, max_progress));
1020 return child[
"progress_at"].to_int();
1032 set_progress[
"id"] =
id;
1033 set_progress[
"progress_at"] = std::clamp(amount, 0, std::min(limit, max_progress));
1035 ach[
"content_for"] = content_for;
1040 return child[
"progress_at"].to_int();
1055 if(ach[
"content_for"].str() == content_for)
1058 for(
const auto& in_progress : ach.child_range(
"in_progress"))
1060 if(in_progress[
"id"] ==
id)
1062 std::vector<std::string> sub_ids =
utils::split(in_progress[
"sub_ids"]);
1063 return std::find(sub_ids.begin(), sub_ids.end(), sub_id) != sub_ids.end();
1082 if(ach[
"content_for"].str() == content_for)
1087 if(in_progress[
"id"].str() ==
id)
1089 std::vector<std::string> sub_ids =
utils::split(ach[
"ids"]);
1091 if(std::find(sub_ids.begin(), sub_ids.end(), sub_id) == sub_ids.end())
1093 in_progress[
"sub_ids"] = in_progress[
"sub_ids"].str() +
"," + sub_id;
1096 in_progress[
"progress_at"] = sub_ids.size()+1;
1103 set_progress[
"id"] =
id;
1104 set_progress[
"sub_ids"] = sub_id;
1105 set_progress[
"progress_at"] = 1;
1106 ach.
add_child(
"in_progress", set_progress);
1115 set_progress[
"id"] =
id;
1116 set_progress[
"sub_ids"] = sub_id;
1117 set_progress[
"progress_at"] = 1;
1119 ach[
"content_for"] = content_for;
1122 ach.
add_child(
"in_progress", set_progress);
1128 return preferences_[prefs_list::show_deprecation].to_bool(def);
1133 return preferences_[prefs_list::scroll_when_mouse_outside].to_bool(def);
1138 set_child(prefs_list::dir_bookmarks, cfg);
1142 return get_child(prefs_list::dir_bookmarks);
1147 return preferences_[prefs_list::lobby_auto_open_whisper_windows].to_bool(
true);
1152 return std::max(std::size_t(1),
preferences_[prefs_list::editor_max_recent_files].to_size_t(10));
1163 auto cfg =
get_child(prefs_list::editor_recent_files);
1165 std::vector<std::string> mru;
1172 const std::string& entry = child[
"path"].str();
1173 if(!entry.empty()) {
1174 mru.push_back(entry);
1188 for(
const std::string& entry : mru)
1195 child[
"path"] = entry;
1202 set_child(prefs_list::editor_recent_files, cfg);
1222 mru.insert(mru.begin(),
path);
1230 return preferences_[prefs_list::color_cursors].to_bool(
true);
1242 return preferences_[prefs_list::unit_standing_animations].to_bool(
true);
1247 preferences_[prefs_list::unit_standing_animations] = value;
1250 d->reset_standing_animations();
1258 if (themes.empty()) {
1260 _(
"No known themes. Try changing from within an existing game."));
1267 for (std::size_t k = 0; k < themes.size(); ++k) {
1268 if(themes[k].
id ==
theme()) {
1297 const std::string
msg =
VGETTEXT(
"The <b>$filename</b> server application provides multiplayer server functionality and is required for hosting local network games. It will normally be found in the same folder as the game executable.", {{
"filename",
filename}});
1317 static const std::string null_theme =
"null";
1331 if(
theme !=
"null") {
1347 return preferences_[prefs_list::mp_server_program_name].str();
1357 std::vector<std::string> ignored;
1360 if(person.second.get_status() ==
"ignore") {
1361 ignored.push_back(person.second.get_nick());
1371 std::map<std::string, std::string> ac_nice;
1374 if(a.second.get_status() == filter) {
1375 ac_nice[a.second.get_nick()] = a.second.get_notes();
1382 std::pair<preferences::acquaintance*, bool>
prefs::add_acquaintance(
const std::string& nick,
const std::string& mode,
const std::string& notes)
1385 return std::pair(
nullptr,
false);
1389 auto [iter, added_new] =
acquaintances_.insert_or_assign(nick, new_entry);
1391 return std::pair(&iter->second, added_new);
1400 std::size_t pos = nick.find_first_of(
' ');
1402 if(pos != std::string::npos) {
1423 return it->second.get_status() ==
"friend";
1434 return it->second.get_status() ==
"ignore";
1457 if(sender !=
"server") {
1461 std::string::size_type pos = message.find(
" has logged into the lobby");
1462 if(pos == std::string::npos) {
1463 pos = message.find(
" has disconnected");
1464 if(pos == std::string::npos) {
1478 return is_friend(message.substr(0, pos));
1484 if(pref ==
"friends") {
1486 }
else if(pref ==
"all") {
1488 }
else if(pref ==
"none") {
1509 return pref_servers;
1514 std::vector<game_config::server_info> pref_servers;
1517 pref_servers.emplace_back();
1518 pref_servers.back().name = server[
"name"].str();
1519 pref_servers.back().address = server[
"address"].str();
1522 return pref_servers;
1529 for(
const auto& svinfo : value) {
1531 sv_cfg[
"name"] = svinfo.name;
1532 sv_cfg[
"address"] = svinfo.address;
1538 const std::string res =
preferences_[prefs_list::host];
1553 if(!
preferences_[prefs_list::campaign_server].empty()) {
1554 return preferences_[prefs_list::campaign_server].str();
1567 return preferences_[prefs_list::show_combat].to_bool(
true);
1598 return std::clamp<int>(
preferences_[prefs_list::mp_countdown_init_time].to_int(240), 0, 1500);
1603 preferences_[prefs_list::mp_countdown_init_time] = value;
1613 return std::clamp<int>(
preferences_[prefs_list::mp_countdown_reservoir_time].to_int(360), 30, 1500);
1618 preferences_[prefs_list::mp_countdown_reservoir_time] = value;
1628 return std::clamp<int>(
preferences_[prefs_list::mp_countdown_turn_bonus].to_int(240), 0, 300);
1633 preferences_[prefs_list::mp_countdown_turn_bonus] = value;
1643 return std::clamp<int>(
preferences_[prefs_list::mp_countdown_action_bonus].to_int(), 0, 30);
1648 preferences_[prefs_list::mp_countdown_action_bonus] = value;
1673 preferences_[prefs_list::mp_village_support] = std::to_string(value);
1724 const std::string& choice =
preferences_[prefs_list::compress_saves];
1728 if(choice.empty() || choice ==
"gzip" || choice ==
"yes") {
1730 }
else if(choice ==
"bzip2") {
1732 }
else if(choice ==
"none" || choice ==
"no") {
1744 if(chat_timestamp()) {
1778 const std::string confirmation =
preferences_[prefs_list::confirm_end_turn];
1779 return confirmation ==
"green" || confirmation ==
"yes";
1784 return preferences_[prefs_list::confirm_end_turn] ==
"yellow";
1790 const std::string confirmation =
preferences_[prefs_list::confirm_end_turn];
1791 return confirmation ==
"no_moves" || confirmation.
empty();
1796 for(
const team& help_team : teams) {
1797 help_team.log_recruitable();
1804 for(
const auto& help_unit : units) {
1811 for(
const team&
t : teams) {
1874 wchar_t buffer[300];
1876 if(GetUserNameW(buffer, &
size)) {
1879 return unicode_cast<std::string>(std::wstring_view{buffer});
1882 if(
char*
const login = getenv(
"USER")) {
1893 unsigned char i = 0;
1894 std::generate(result.begin(), result.end(), [&
i]() {return
'x' ^ i++;});
1895 std::copy(
login.begin(),
login.end(), result.begin());
1896 std::copy(sysname.begin(), sysname.end(), result.begin() +
login.size());
1897 std::copy(server.begin(), server.end(), result.begin() +
login.size() + sysname.size());
1908 const unsigned char iv[] = {1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8};
1909 unsigned char encrypted_buffer[1024];
1911 if(plaintext.size() > 1008)
1913 ERR_CFG <<
"Cannot encrypt data larger than 1008 bytes.";
1916 DBG_CFG <<
"Encrypting data with length: " << plaintext.size();
1918 EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
1921 ERR_CFG <<
"AES EVP_CIPHER_CTX_new failed with error:";
1922 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
1927 if(EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, key.data(), iv) != 1)
1929 ERR_CFG <<
"AES EVP_EncryptInit_ex failed with error:";
1930 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
1931 EVP_CIPHER_CTX_free(ctx);
1935 if(EVP_EncryptUpdate(ctx, encrypted_buffer, &update_length, plaintext.data(), plaintext.size()) != 1)
1937 ERR_CFG <<
"AES EVP_EncryptUpdate failed with error:";
1938 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
1939 EVP_CIPHER_CTX_free(ctx);
1942 DBG_CFG <<
"Update length: " << update_length;
1944 if(EVP_EncryptFinal_ex(ctx, encrypted_buffer + update_length, &extra_length) != 1)
1946 ERR_CFG <<
"AES EVP_EncryptFinal failed with error:";
1947 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
1948 EVP_CIPHER_CTX_free(ctx);
1951 DBG_CFG <<
"Extra length: " << extra_length;
1953 EVP_CIPHER_CTX_free(ctx);
1955 total_length = update_length+extra_length;
1957 for(
int i = 0;
i < total_length;
i++)
1959 result.push_back(encrypted_buffer[
i]);
1962 DBG_CFG <<
"Successfully encrypted plaintext value of '" <<
utils::join(plaintext,
"") <<
"' having length " << plaintext.size();
1963 DBG_CFG <<
"For a total encrypted length of: " << total_length;
1967 size_t outWritten = 0;
1970 CCCryptorStatus ccStatus = CCCrypt(kCCDecrypt,
1972 kCCOptionPKCS7Padding,
1982 assert(ccStatus == kCCSuccess);
1983 assert(outWritten == plaintext.size());
1996 const unsigned char iv[] = {1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8};
1997 unsigned char plaintext_buffer[1024];
1999 if(encrypted.size() > 1024)
2001 ERR_CFG <<
"Cannot decrypt data larger than 1024 bytes.";
2004 DBG_CFG <<
"Decrypting data with length: " << encrypted.size();
2006 EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
2009 ERR_CFG <<
"AES EVP_CIPHER_CTX_new failed with error:";
2010 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
2015 if(EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, key.data(), iv) != 1)
2017 ERR_CFG <<
"AES EVP_DecryptInit_ex failed with error:";
2018 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
2019 EVP_CIPHER_CTX_free(ctx);
2023 if(EVP_DecryptUpdate(ctx, plaintext_buffer, &update_length, encrypted.data(), encrypted.size()) != 1)
2025 ERR_CFG <<
"AES EVP_DecryptUpdate failed with error:";
2026 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
2027 EVP_CIPHER_CTX_free(ctx);
2030 DBG_CFG <<
"Update length: " << update_length;
2032 if(EVP_DecryptFinal_ex(ctx, plaintext_buffer + update_length, &extra_length) != 1)
2034 ERR_CFG <<
"AES EVP_DecryptFinal failed with error:";
2035 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
2036 EVP_CIPHER_CTX_free(ctx);
2039 DBG_CFG <<
"Extra length: " << extra_length;
2041 EVP_CIPHER_CTX_free(ctx);
2043 total_length = update_length+extra_length;
2045 for(
int i = 0;
i < total_length;
i++)
2047 result.push_back(plaintext_buffer[
i]);
2051 DBG_CFG <<
"For a total decrypted length of: " << total_length;
2055 size_t outWritten = 0;
2058 CCCryptorStatus ccStatus = CCCrypt(kCCDecrypt,
2060 kCCOptionPKCS7Padding,
2070 assert(ccStatus == kCCSuccess);
2071 assert(outWritten == encrypted.size());
2074 while(!result.empty() && result.back() == 0) {
2085 unescaped.reserve(text.size());
2086 bool escaping =
false;
2087 for(
char c : text) {
2090 unescaped.push_back(
'\xc');
2091 }
else if(
c ==
'.') {
2092 unescaped.push_back(
'@');
2094 unescaped.push_back(
c);
2097 }
else if(
c ==
'\x1') {
2100 unescaped.push_back(
c);
2110 escaped.reserve(text.size());
2111 for(
char c : text) {
2113 escaped.push_back(
'\x1');
2114 escaped.push_back(
'\x1');
2115 }
else if(
c ==
'\xc') {
2116 escaped.push_back(
'\x1');
2117 escaped.push_back(
'\xa');
2118 }
else if(
c ==
'@') {
2119 escaped.push_back(
'\x1');
2120 escaped.push_back(
'.');
2122 escaped.push_back(
c);
2130 return preferences_[prefs_list::remember_password].to_bool();
2135 preferences_[prefs_list::remember_password] = remember;
2149 }
else if(name.size() > 2 && name.front() ==
'@' && name.back() ==
'@') {
2150 name = name.substr(1, name.size() - 2);
2152 ERR_CFG <<
"malformed user credentials (did you manually edit the preferences file?)";
2162 auto login_clean =
login;
2165 preferences_[prefs_list::login] =
'@' + login_clean +
'@';
2170 DBG_CFG <<
"Retrieving password for server: '" << server <<
"', login: '" <<
login <<
"'";
2171 auto login_clean =
login;
2177 return std::string(temp.begin(), temp.end());
2183 return cred.server == server && cred.username == login_clean;
2189 return std::string(temp.begin(), temp.end());
2194 DBG_CFG <<
"Setting password for server: '" << server <<
"', login: '" <<
login <<
"'";
2195 auto login_clean =
login;
2205 return cred.server == server && cred.username == login_clean;
Variant for storing WML attributes.
A config object defines a single node in a WML file, with access to child nodes.
const_attr_itors attribute_range() const
auto all_children_view() const
In-order iteration over all children.
void clear_children(T... keys)
bool has_attribute(config_key_type key) const
void merge_with(const config &c)
Merge config 'c' into this config, overwriting this config's values.
child_itors child_range(config_key_type key)
config & child_or_add(config_key_type key)
Returns a reference to the first child with the given key.
void remove_attribute(config_key_type key)
optional_config_impl< config > optional_child(config_key_type key, int n=0)
Equivalent to mandatory_child, but returns an empty optional if the nth child was not found.
config & add_child(config_key_type key)
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
void set_theme(const std::string &new_theme)
static display * get_singleton()
Returns the display object if a display object exists.
virtual const std::vector< team > & teams() const override
virtual const unit_map & units() const override
virtual const gamemap & map() const override
A class grating read only view to a vector of config objects, viewed as one config with all children ...
static game_config_view wrap(const config &cfg)
config_array_view child_range(config_key_type key) const
terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
void for_each_loc(const F &f) const
Encapsulates the map of the game.
const t_translation::ter_list & underlying_union_terrain(const map_location &loc) const
file_dialog & set_ok_label(const std::string &value)
Sets the OK button label.
file_dialog & set_path(const std::string &value)
Sets the initial file selection.
file_dialog & set_title(const std::string &value)
Sets the current dialog title text.
file_dialog & set_read_only(bool value)
Whether to provide user interface elements for manipulating existing objects.
file_dialog & set_filename(const std::string &value)
Sets the initial file name input but not the path.
file_dialog & set_message(const std::string &value)
Sets the current dialog instructions/message text.
bool show(const unsigned auto_close_time=0)
Shows the window.
int selected_index() const
Returns the selected item index after displaying.
void set_selected_index(int index)
Sets the initially selected item index (-1 by default).
const std::string & get_nick() const
void set_lobby_joins(pref_constants::lobby_joins show)
std::string enemy_color()
config::attribute_value get_as_attribute(const std::string &key)
void set_network_host(const std::string &host)
std::set< t_translation::terrain_code > & encountered_terrains()
bool set_music(bool ison)
void set_sound_volume(int vol)
void set_remember_password(bool remember)
const std::map< std::string, preferences::acquaintance > & get_acquaintances()
optional_const_config get_alias()
void set_turbo(bool ison)
std::string get_system_username()
bool mp_modifications_initialized_
std::map< std::string, std::vector< std::string > > history_map_
void set_addon_manager_saved_order_direction(sort_order::type value)
bool middle_click_scrolls()
int countdown_init_time()
std::set< std::string > & encountered_units()
void add_alias(const std::string &alias, const std::string &command)
void set_countdown_reservoir_time(int value)
std::vector< std::string > sp_modifications_
void clear_mp_alert_prefs()
The most recently selected add-on id from the editor.
void set_village_gold(int value)
bool confirm_load_save_from_different_version()
std::string network_host()
void clear_countdown_init_time()
std::set< std::string > unknown_unsynced_attributes_
bool set_ui_sound(bool ison)
void set_login(const std::string &login)
const std::string get_ignored_delim()
std::map< std::string, preferences::acquaintance > acquaintances_
static constexpr std::array unsynced_children_
void set_countdown_action_bonus(int value)
void encounter_recallable_units(const std::vector< team > &teams)
std::map< std::string, std::set< std::string > > completed_campaigns_
optional_const_config dir_bookmarks()
void set_theme(const std::string &theme)
void set_xp_modifier(int value)
void set_user_servers_list(const std::vector< game_config::server_info > &value)
preferences::secure_buffer build_key(const std::string &server, const std::string &login)
Fills a secure_buffer with 32 bytes of deterministically generated bytes, then overwrites it with the...
int countdown_action_bonus()
bool is_campaign_completed(const std::string &campaign_id)
void set_allied_color(const std::string &color_id)
bool get_scroll_when_mouse_outside(bool def)
void show_wesnothd_server_search()
int mouse_scroll_threshold()
Gets the threshold for when to scroll.
bool is_ignored(const std::string &nick)
std::vector< std::string > mp_modifications_
bool achievement(const std::string &content_for, const std::string &id)
std::set< std::string > unknown_synced_attributes_
void set_enemy_color(const std::string &color_id)
void set_password(const std::string &server, const std::string &login, const std::string &key)
bool sub_achievement(const std::string &content_for, const std::string &id, const std::string &sub_id)
std::vector< preferences::login_info > credentials_
std::vector< std::string > do_read_editor_mru()
void encounter_recruitable_units(const std::vector< team > &teams)
bool parse_should_show_lobby_join(const std::string &sender, const std::string &message)
int progress_achievement(const std::string &content_for, const std::string &id, int limit=999999, int max_progress=999999, int amount=0)
Increments the achievement's current progress by amount if it hasn't already been completed.
sort_order::type addon_manager_saved_order_direction()
bool set_turn_bell(bool ison)
static constexpr std::array synced_attributes_
unsigned int sample_rate()
static constexpr std::array synced_children_
void set_options(const config &values)
void set_message_private(bool value)
std::vector< game_config::server_info > user_servers_list()
optional_const_config get_child(const std::string &key)
std::string unmoved_color()
void set_music_volume(int vol)
void load_advanced_prefs(const game_config_view &gc)
std::string allied_color()
void set_show_standing_animations(bool value)
void set_show_fps(bool value)
void set_pixel_scale(const int scale)
std::size_t editor_mru_limit()
void set_color_cursors(bool value)
std::vector< preferences::option > advanced_prefs_
void encounter_start_units(const unit_map &units)
void set_countdown_turn_bonus(int value)
pref_constants::lobby_joins get_lobby_joins()
void encounter_map_terrain(const gamemap &map)
void set_village_support(int value)
preferences::secure_buffer escape(const preferences::secure_buffer &text)
std::string moved_color()
void set_font_scaling(int scale)
std::size_t sound_buffer_size()
void migrate_preferences(const std::string &prefs_dir)
void set_dir_bookmarks(const config &cfg)
std::set< t_translation::terrain_code > encountered_terrains_set_
bool set_sound(bool ison)
bool is_friend(const std::string &nick)
void set_achievement(const std::string &content_for, const std::string &id)
Marks the specified achievement as completed.
preferences::secure_buffer aes_decrypt(const preferences::secure_buffer &text, const preferences::secure_buffer &key)
Same as aes_encrypt(), except of course it takes encrypted data as an argument and returns decrypted ...
void clear_countdown_turn_bonus()
int font_scaled(int size)
void set_scroll_speed(const int scroll)
std::pair< preferences::acquaintance *, bool > add_acquaintance(const std::string &nick, const std::string &mode, const std::string ¬es)
bool options_initialized_
std::string partial_color()
preferences::secure_buffer unescape(const preferences::secure_buffer &text)
void set_resolution(const point &res)
void set_campaign_server(const std::string &host)
void set_countdown_init_time(int value)
void set_unmoved_color(const std::string &color_id)
bool remove_acquaintance(const std::string &nick)
void clear_countdown_reservoir_time()
void set_ui_volume(int vol)
const std::vector< std::string > & modifications(bool mp=true)
void do_commit_editor_mru(const std::vector< std::string > &mru)
compression::format save_compression_format()
std::vector< std::string > recent_files()
Retrieves the list of recently opened files.
std::set< std::string > encountered_units_set_
void set_bell_volume(int vol)
std::string get_mp_server_program_name()
void set_partial_color(const std::string &color_id)
void set_child(const std::string &key, const config &val)
static constexpr std::array unsynced_attributes_
std::set< std::string > all_attributes()
void set_mp_server_program_name(const std::string &)
void add_recent_files_entry(const std::string &path)
Adds an entry to the recent files list.
void set_moved_color(const std::string &color_id)
std::string get_chat_timestamp(const std::time_t &t)
void save_sample_rate(const unsigned int rate)
bool use_twelve_hour_clock_format()
static bool no_preferences_save
void set_modifications(const std::vector< std::string > &value, bool mp=true)
void set_sub_achievement(const std::string &content_for, const std::string &id, const std::string &sub_id)
Marks the specified sub-achievement as completed.
int countdown_reservoir_time()
std::set< std::string > unknown_unsynced_children_
const std::vector< game_config::server_info > & builtin_servers_list()
void reload_preferences()
std::string campaign_server()
std::set< std::string > unknown_synced_children_
int countdown_turn_bonus()
void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level)
void save_sound_buffer_size(const std::size_t size)
void encounter_all_content(const game_board &gb)
std::string password(const std::string &server, const std::string &login)
bool sp_modifications_initialized_
std::vector< std::string > * get_history(const std::string &id)
Returns a pointer to the history vector associated with given id making a new one if it doesn't exist...
preferences::secure_buffer aes_encrypt(const preferences::secure_buffer &text, const preferences::secure_buffer &key)
Encrypts the value of text using key and a hard coded IV using AES.
bool auto_open_whisper_windows()
std::map< std::string, std::string > get_acquaintances_nice(const std::string &filter)
bool get_show_deprecation(bool def)
bool show_standing_animations()
void clear_countdown_action_bonus()
This class stores all the data for a single 'side' (in game nomenclature).
static std::vector< theme_info > get_basic_theme_info(bool include_hidden=false)
Returns minimal info about saved themes, optionally including hidden ones.
Container associating units to locations.
static std::string _(const char *str)
std::string id
Text to match against addon_info.tags()
Standard logging facilities (interface).
General settings and defaults for scenarios.
void set(CURSOR_TYPE type)
Use the default parameter to reset cursors.
void fill(const SDL_Rect &rect, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
Fill an area with the given colour.
void point(int x, int y)
Draw a single point.
void line(int from_x, int from_y, int to_x, int to_y)
Draw a line.
std::time_t file_modified_time(const std::string &fname)
Get the modification time of a file.
filesystem::scoped_istream istream_file(const std::string &fname, bool treat_failure_as_error)
void copy_file(const std::string &src, const std::string &dest)
Read a file and then writes it back out.
bool delete_file(const std::string &filename)
static bool file_exists(const bfs::path &fpath)
std::string get_exe_dir()
bool is_directory(const std::string &fname)
Returns true if the given file is a directory.
std::string get_synced_prefs_file()
location of preferences file containing preferences that are synced between computers note that wesno...
std::string get_unsynced_prefs_file()
location of preferences file containing preferences that aren't synced between computers
filesystem::scoped_ostream ostream_file(const std::string &fname, std::ios_base::openmode mode, bool create_directory)
std::unique_ptr< std::istream > scoped_istream
std::string get_credentials_file()
std::string directory_name(const std::string &file)
Returns the directory name of a file, with filename stripped.
std::unique_ptr< std::ostream > scoped_ostream
std::string get_wesnothd_name()
std::string get_default_prefs_file()
std::string partial_orb_color
std::string moved_orb_color
std::string unmoved_orb_color
std::string ally_orb_color
std::string enemy_orb_color
const version_info wesnoth_version(VERSION)
std::vector< server_info > server_list
void show(const std::string &window_id, const t_string &message, const point &mouse, const SDL_Rect &source_rect)
Shows a tip.
static int music_volume()
static int sound_volume()
void show_transient_message(const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup)
Shows a transient message to the user.
void save_hotkeys(config &cfg)
Save the non-default hotkeys to the config.
void reset_default_hotkeys()
Reset all hotkeys to the defaults.
void load_custom_hotkeys(const game_config_view &cfg)
Registers all hotkeys present in this config, overwriting any matching default hotkeys.
std::string get_timestamp(const std::time_t &t, const std::string &format)
Main entry points of multiplayer mode.
const int min_window_height
const int max_pixel_scale
const std::string EMPTY_LOGIN
const int min_pixel_scale
const std::string default_addons_server
const int def_window_width
const int min_font_scaling
const int min_window_width
const int max_font_scaling
const int def_window_height
const unsigned char CREDENTIAL_SEPARATOR
static std::string at(const std::string &file, int line)
int get_village_support(const std::string &value)
Gets the village unit level support.
int get_xp_modifier(const std::string &value)
Gets the xp modifier.
int get_village_gold(const std::string &value, const game_classification *classification)
Gets the village gold.
void set_bell_volume(int vol)
void set_music_volume(int vol)
void set_UI_volume(int vol)
void set_sound_volume(int vol)
std::vector< terrain_code > ter_list
ter_list read_list(std::string_view str, const ter_layer filler)
Reads a list of terrains from a string, when reading the.
std::string write_list(const ter_list &list)
Writes a list of terrains to a string, only writes the new format.
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
void trim(std::string_view &s)
bool isvalid_wildcard(const std::string &username)
Check if the username pattern contains only valid characters.
std::size_t erase(Container &container, const Value &value)
Convenience wrapper for using std::remove on a container.
std::set< std::string > split_set(std::string_view s, char sep, const int flags)
std::string get_unknown_exception_type()
Utility function for finding the type of thing caught with catch(...).
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
std::vector< std::string > split(const config_attribute_value &val)
bool headless()
The game is running headless.
std::string::const_iterator iterator
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
void scale(size_t factor, const uint32_t *src, uint32_t *trg, int srcWidth, int srcHeight, ColorFormat colFmt, const ScalerCfg &cfg=ScalerCfg(), int yFirst=0, int yLast=std::numeric_limits< int >::max())
static lg::log_domain log_filesystem("filesystem")
static lg::log_domain advanced_preferences("advanced_preferences")
static std::string fix_orb_color_name(const std::string &color)
static lg::log_domain log_config("config")
std::shared_ptr< const unit > unit_const_ptr
void read(config &cfg, std::istream &in, abstract_validator *validator)
void write(std::ostream &out, const configr_of &cfg, unsigned int level)
std::string filename
Filename.
An exception object used when an IO error occurs.
Encapsulates the map of the game.
static std::string get_string(enum_type key)
Converts a enum to its string equivalent.
static constexpr utils::optional< enum_type > get_enum(const std::string_view value)
Converts a string into its enum equivalent.
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
static map_location::direction n