20 #define GETTEXT_DOMAIN "wesnoth-lib"
45 #include <boost/algorithm/string.hpp>
49 #include <boost/range/iterator_range.hpp>
54 #include <openssl/evp.h>
55 #include <openssl/err.h>
57 #include <CommonCrypto/CommonCryptor.h>
61 #define ERR_CFG LOG_STREAM(err , log_config)
62 #define DBG_CFG LOG_STREAM(debug , log_config)
65 #define ERR_FS LOG_STREAM(err, log_filesystem)
68 #define ERR_ADV LOG_STREAM(err, advanced_preferences)
73 , completed_campaigns_()
74 , encountered_units_set_()
75 , encountered_terrains_set_()
79 , options_initialized_(false)
81 , mp_modifications_initialized_(false)
83 , sp_modifications_initialized_(false)
84 , message_private_on_(false)
107 cmp[
"name"] = elem.first;
108 cmp[
"difficulty_levels"] =
utils::join(elem.second);
112 set_child(prefs_list::completed_campaigns, campaigns);
128 for(
const std::string&
line : history_id.second) {
131 cfg[
"message"] =
line;
132 history_id_cfg.
add_child(
"line", std::move(cfg));
135 history.
add_child(history_id.first, history_id_cfg);
164 }
catch(
const std::invalid_argument&
e) {
173 if(op.field == prefs_list::show_deprecation) {
174 op.cfg[
"default"] =
true;
179 std::sort(
advanced_prefs_.begin(),
advanced_prefs_.end(), [](
const auto& lhs,
const auto& rhs) { return translation::icompare(lhs.name, rhs.name) < 0; });
192 read(current_cfg, *current_stream);
195 read(old_cfg, *old_stream);
200 if(current_prefs_are_older || !current_cfg.
has_attribute(val.first)) {
220 std::set<std::string> attrs;
224 attrs.emplace(attr.first);
227 for(
const auto attr : prefs_list::values) {
241 #ifdef DEFAULT_PREFS_PATH
246 read(default_prefs, *stream);
251 read(unsynced_prefs, *stream);
256 read(synced_prefs, *stream);
286 ERR_CFG <<
"Error loading preference, message: " <<
e.what();
307 if(
auto ccc =
get_child(prefs_list::completed_campaigns)) {
310 std::vector<std::string> nd =
utils::split(cc[
"difficulty_levels"]);
311 std::copy(nd.begin(), nd.end(), std::inserter(
d,
d.begin()));
320 if(
auto history =
get_child(prefs_list::history)) {
329 for(
const config& l :
h.cfg.child_range(
"line")) {
389 write(*synced_prefs_file, synced);
396 write(*unsynced_prefs_file, unsynced);
404 if(!synced_prefs_file_existed) {
409 if(!unsynced_prefs_file_existed) {
422 std::fill(cred.username.begin(), cred.username.end(),
'\0');
423 std::fill(cred.server.begin(), cred.server.end(),
'\0');
443 ERR_CFG <<
"Invalid data in credentials file";
447 std::size_t
at = elem.find_last_of(
'@');
448 std::size_t eq = elem.find_first_of(
'=',
at + 1);
449 if(
at != std::string::npos && eq != std::string::npos) {
470 credentials_data.insert(credentials_data.end(), cred.username.begin(), cred.username.end());
471 credentials_data.push_back(
'@');
472 credentials_data.insert(credentials_data.end(), cred.server.begin(), cred.server.end());
473 credentials_data.push_back(
'=');
475 credentials_data.insert(credentials_data.end(), key_escaped.begin(), key_escaped.end());
480 credentials_file->write(
reinterpret_cast<const char*
>(encrypted.data()), encrypted.size());
486 if(!creds_file_existed) {
507 std::string
prefs::get(
const std::string& key,
const std::string& def) {
520 if (color.substr(0,4) ==
"orb_") {
521 if(color[4] >=
'0' && color[4] <=
'9') {
522 return color.substr(5);
524 return color.substr(4);
532 if (ally_color.empty())
572 if (partmoved_color.empty())
582 const unsigned x_res =
preferences_[prefs_list::xresolution].to_unsigned();
583 const unsigned y_res =
preferences_[prefs_list::yresolution].to_unsigned();
586 if(x_res == 0 || y_res == 0) {
598 preferences_[prefs_list::xresolution] = std::to_string(res.x);
599 preferences_[prefs_list::yresolution] = std::to_string(res.y);
645 return preferences_[prefs_list::keepalive_timeout].to_int(20);
650 preferences_[prefs_list::keepalive_timeout] = std::abs(seconds);
658 const std::size_t buf_size = 4096;
660 const std::size_t buf_size = 1024;
663 return preferences_[prefs_list::sound_buffer_size].to_int(buf_size);
668 const std::string new_size = std::to_string(
size);
669 if (
preferences_[prefs_list::sound_buffer_size] == new_size)
770 return preferences_[prefs_list::ui_sound].to_bool(
true);
797 return preferences_[prefs_list::message_bell].to_bool(
true);
806 if(!
sound() && ison) {
814 }
else if(
sound() && !ison) {
851 return std::clamp<int>(
preferences_[prefs_list::scroll].to_int(50), 1, 100);
861 return preferences_[prefs_list::middle_click_scrolls].to_bool(
true);
866 return preferences_[prefs_list::scroll_threshold].to_int(10);
898 alias_list[alias] = command;
909 return preferences_[prefs_list::sample_rate].to_int(44100);
925 return preferences_[prefs_list::confirm_load_save_from_different_version].to_bool(
true);
930 return preferences_[prefs_list::use_twelve_hour_clock_format].to_bool();
947 if(ach[
"content_for"].str() == content_for)
949 std::vector<std::string> ids =
utils::split(ach[
"ids"]);
950 return std::find(ids.begin(), ids.end(),
id) != ids.end();
961 if(ach[
"content_for"].str() == content_for)
963 std::vector<std::string> ids =
utils::split(ach[
"ids"]);
969 else if(std::find(ids.begin(), ids.end(),
id) == ids.end())
971 ach[
"ids"] = ach[
"ids"].str() +
"," +
id;
973 ach.remove_children(
"in_progress", [&
id](
config cfg){
return cfg[
"id"].str() ==
id;});
980 ach[
"content_for"] = content_for;
995 if(ach[
"content_for"].str() == content_for)
1000 if(in_progress[
"id"].str() ==
id)
1003 int starting_progress = in_progress[
"progress_at"].to_int();
1004 if(starting_progress >= limit) {
1005 return starting_progress;
1008 in_progress[
"progress_at"] = std::clamp(starting_progress + amount, 0, std::min(limit, max_progress));
1009 return in_progress[
"progress_at"].to_int();
1017 set_progress[
"id"] =
id;
1018 set_progress[
"progress_at"] = std::clamp(amount, 0, std::min(limit, max_progress));
1021 return child[
"progress_at"].to_int();
1033 set_progress[
"id"] =
id;
1034 set_progress[
"progress_at"] = std::clamp(amount, 0, std::min(limit, max_progress));
1036 ach[
"content_for"] = content_for;
1041 return child[
"progress_at"].to_int();
1056 if(ach[
"content_for"].str() == content_for)
1059 for(
const auto& in_progress : ach.child_range(
"in_progress"))
1061 if(in_progress[
"id"] ==
id)
1063 std::vector<std::string> sub_ids =
utils::split(in_progress[
"sub_ids"]);
1064 return std::find(sub_ids.begin(), sub_ids.end(), sub_id) != sub_ids.end();
1083 if(ach[
"content_for"].str() == content_for)
1088 if(in_progress[
"id"].str() ==
id)
1090 std::vector<std::string> sub_ids =
utils::split(ach[
"ids"]);
1092 if(std::find(sub_ids.begin(), sub_ids.end(), sub_id) == sub_ids.end())
1094 in_progress[
"sub_ids"] = in_progress[
"sub_ids"].str() +
"," + sub_id;
1097 in_progress[
"progress_at"] = sub_ids.size()+1;
1104 set_progress[
"id"] =
id;
1105 set_progress[
"sub_ids"] = sub_id;
1106 set_progress[
"progress_at"] = 1;
1107 ach.
add_child(
"in_progress", set_progress);
1116 set_progress[
"id"] =
id;
1117 set_progress[
"sub_ids"] = sub_id;
1118 set_progress[
"progress_at"] = 1;
1120 ach[
"content_for"] = content_for;
1123 ach.
add_child(
"in_progress", set_progress);
1129 return preferences_[prefs_list::show_deprecation].to_bool(def);
1134 return preferences_[prefs_list::scroll_when_mouse_outside].to_bool(def);
1139 set_child(prefs_list::dir_bookmarks, cfg);
1143 return get_child(prefs_list::dir_bookmarks);
1148 return preferences_[prefs_list::lobby_auto_open_whisper_windows].to_bool(
true);
1153 return std::max(std::size_t(1),
preferences_[prefs_list::editor_max_recent_files].to_size_t(10));
1164 auto cfg =
get_child(prefs_list::editor_recent_files);
1166 std::vector<std::string> mru;
1173 const std::string& entry = child[
"path"].str();
1174 if(!entry.empty()) {
1175 mru.push_back(entry);
1189 for(
const std::string& entry : mru)
1196 child[
"path"] = entry;
1203 set_child(prefs_list::editor_recent_files, cfg);
1223 mru.insert(mru.begin(),
path);
1231 return preferences_[prefs_list::color_cursors].to_bool(
true);
1243 return preferences_[prefs_list::unit_standing_animations].to_bool(
true);
1248 preferences_[prefs_list::unit_standing_animations] = value;
1251 d->reset_standing_animations();
1259 if (themes.empty()) {
1261 _(
"No known themes. Try changing from within an existing game."));
1268 for (std::size_t k = 0; k < themes.size(); ++k) {
1269 if(themes[k].
id ==
theme()) {
1298 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}});
1318 static const std::string null_theme =
"null";
1332 if(
theme !=
"null") {
1348 return preferences_[prefs_list::mp_server_program_name].str();
1358 std::vector<std::string> ignored;
1361 if(person.second.get_status() ==
"ignore") {
1362 ignored.push_back(person.second.get_nick());
1372 std::map<std::string, std::string> ac_nice;
1375 if(a.second.get_status() == filter) {
1376 ac_nice[a.second.get_nick()] = a.second.get_notes();
1383 std::pair<preferences::acquaintance*, bool>
prefs::add_acquaintance(
const std::string& nick,
const std::string& mode,
const std::string& notes)
1386 return std::pair(
nullptr,
false);
1390 auto [iter, added_new] =
acquaintances_.insert_or_assign(nick, new_entry);
1392 return std::pair(&iter->second, added_new);
1401 std::size_t pos = nick.find_first_of(
' ');
1403 if(pos != std::string::npos) {
1424 return it->second.get_status() ==
"friend";
1435 return it->second.get_status() ==
"ignore";
1458 if(sender !=
"server") {
1462 std::string::size_type pos = message.find(
" has logged into the lobby");
1463 if(pos == std::string::npos) {
1464 pos = message.find(
" has disconnected");
1465 if(pos == std::string::npos) {
1479 return is_friend(message.substr(0, pos));
1485 if(pref ==
"friends") {
1487 }
else if(pref ==
"all") {
1489 }
else if(pref ==
"none") {
1510 return pref_servers;
1515 std::vector<game_config::server_info> pref_servers;
1518 pref_servers.emplace_back();
1519 pref_servers.back().name = server[
"name"].str();
1520 pref_servers.back().address = server[
"address"].str();
1523 return pref_servers;
1530 for(
const auto& svinfo : value) {
1532 sv_cfg[
"name"] = svinfo.name;
1533 sv_cfg[
"address"] = svinfo.address;
1539 const std::string res =
preferences_[prefs_list::host];
1554 if(!
preferences_[prefs_list::campaign_server].empty()) {
1555 return preferences_[prefs_list::campaign_server].str();
1568 return preferences_[prefs_list::show_combat].to_bool(
true);
1599 return std::clamp<int>(
preferences_[prefs_list::mp_countdown_init_time].to_int(240), 0, 1500);
1604 preferences_[prefs_list::mp_countdown_init_time] = value;
1614 return std::clamp<int>(
preferences_[prefs_list::mp_countdown_reservoir_time].to_int(360), 30, 1500);
1619 preferences_[prefs_list::mp_countdown_reservoir_time] = value;
1629 return std::clamp<int>(
preferences_[prefs_list::mp_countdown_turn_bonus].to_int(240), 0, 300);
1634 preferences_[prefs_list::mp_countdown_turn_bonus] = value;
1644 return std::clamp<int>(
preferences_[prefs_list::mp_countdown_action_bonus], 0, 30);
1649 preferences_[prefs_list::mp_countdown_action_bonus] = value;
1674 preferences_[prefs_list::mp_village_support] = std::to_string(value);
1725 const std::string& choice =
preferences_[prefs_list::compress_saves];
1729 if(choice.empty() || choice ==
"gzip" || choice ==
"yes") {
1731 }
else if(choice ==
"bzip2") {
1733 }
else if(choice ==
"none" || choice ==
"no") {
1745 if(chat_timestamp()) {
1779 const std::string confirmation =
preferences_[prefs_list::confirm_end_turn];
1780 return confirmation ==
"green" || confirmation ==
"yes";
1785 return preferences_[prefs_list::confirm_end_turn] ==
"yellow";
1791 const std::string confirmation =
preferences_[prefs_list::confirm_end_turn];
1792 return confirmation ==
"no_moves" || confirmation.
empty();
1797 for(
const team& help_team : teams) {
1798 help_team.log_recruitable();
1805 for(
const auto& help_unit : units) {
1812 for(
const team&
t : teams) {
1876 wchar_t buffer[300];
1878 if(GetUserNameW(buffer, &
size)) {
1881 res = unicode_cast<std::string>(boost::iterator_range<wchar_t*>(buffer, buffer +
size - 1));
1884 if(
char*
const login = getenv(
"USER")) {
1895 unsigned char i = 0;
1896 std::generate(result.begin(), result.end(), [&
i]() {return
'x' ^ i++;});
1897 std::copy(
login.begin(),
login.end(), result.begin());
1898 std::copy(sysname.begin(), sysname.end(), result.begin() +
login.size());
1899 std::copy(server.begin(), server.end(), result.begin() +
login.size() + sysname.size());
1910 const unsigned char iv[] = {1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8};
1911 unsigned char encrypted_buffer[1024];
1913 if(plaintext.size() > 1008)
1915 ERR_CFG <<
"Cannot encrypt data larger than 1008 bytes.";
1918 DBG_CFG <<
"Encrypting data with length: " << plaintext.size();
1920 EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
1923 ERR_CFG <<
"AES EVP_CIPHER_CTX_new failed with error:";
1924 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
1929 if(EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, key.data(), iv) != 1)
1931 ERR_CFG <<
"AES EVP_EncryptInit_ex failed with error:";
1932 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
1933 EVP_CIPHER_CTX_free(ctx);
1937 if(EVP_EncryptUpdate(ctx, encrypted_buffer, &update_length, plaintext.data(), plaintext.size()) != 1)
1939 ERR_CFG <<
"AES EVP_EncryptUpdate failed with error:";
1940 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
1941 EVP_CIPHER_CTX_free(ctx);
1944 DBG_CFG <<
"Update length: " << update_length;
1946 if(EVP_EncryptFinal_ex(ctx, encrypted_buffer + update_length, &extra_length) != 1)
1948 ERR_CFG <<
"AES EVP_EncryptFinal failed with error:";
1949 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
1950 EVP_CIPHER_CTX_free(ctx);
1953 DBG_CFG <<
"Extra length: " << extra_length;
1955 EVP_CIPHER_CTX_free(ctx);
1957 total_length = update_length+extra_length;
1959 for(
int i = 0;
i < total_length;
i++)
1961 result.push_back(encrypted_buffer[
i]);
1964 DBG_CFG <<
"Successfully encrypted plaintext value of '" <<
utils::join(plaintext,
"") <<
"' having length " << plaintext.size();
1965 DBG_CFG <<
"For a total encrypted length of: " << total_length;
1969 size_t outWritten = 0;
1972 CCCryptorStatus ccStatus = CCCrypt(kCCDecrypt,
1974 kCCOptionPKCS7Padding,
1984 assert(ccStatus == kCCSuccess);
1985 assert(outWritten == plaintext.size());
1998 const unsigned char iv[] = {1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8};
1999 unsigned char plaintext_buffer[1024];
2001 if(encrypted.size() > 1024)
2003 ERR_CFG <<
"Cannot decrypt data larger than 1024 bytes.";
2006 DBG_CFG <<
"Decrypting data with length: " << encrypted.size();
2008 EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
2011 ERR_CFG <<
"AES EVP_CIPHER_CTX_new failed with error:";
2012 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
2017 if(EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, key.data(), iv) != 1)
2019 ERR_CFG <<
"AES EVP_DecryptInit_ex failed with error:";
2020 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
2021 EVP_CIPHER_CTX_free(ctx);
2025 if(EVP_DecryptUpdate(ctx, plaintext_buffer, &update_length, encrypted.data(), encrypted.size()) != 1)
2027 ERR_CFG <<
"AES EVP_DecryptUpdate failed with error:";
2028 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
2029 EVP_CIPHER_CTX_free(ctx);
2032 DBG_CFG <<
"Update length: " << update_length;
2034 if(EVP_DecryptFinal_ex(ctx, plaintext_buffer + update_length, &extra_length) != 1)
2036 ERR_CFG <<
"AES EVP_DecryptFinal failed with error:";
2037 ERR_CFG << ERR_error_string(ERR_get_error(), NULL);
2038 EVP_CIPHER_CTX_free(ctx);
2041 DBG_CFG <<
"Extra length: " << extra_length;
2043 EVP_CIPHER_CTX_free(ctx);
2045 total_length = update_length+extra_length;
2047 for(
int i = 0;
i < total_length;
i++)
2049 result.push_back(plaintext_buffer[
i]);
2053 DBG_CFG <<
"For a total decrypted length of: " << total_length;
2057 size_t outWritten = 0;
2060 CCCryptorStatus ccStatus = CCCrypt(kCCDecrypt,
2062 kCCOptionPKCS7Padding,
2072 assert(ccStatus == kCCSuccess);
2073 assert(outWritten == encrypted.size());
2076 while(!result.empty() && result.back() == 0) {
2087 unescaped.reserve(text.size());
2088 bool escaping =
false;
2089 for(
char c : text) {
2092 unescaped.push_back(
'\xc');
2093 }
else if(
c ==
'.') {
2094 unescaped.push_back(
'@');
2096 unescaped.push_back(
c);
2099 }
else if(
c ==
'\x1') {
2102 unescaped.push_back(
c);
2112 escaped.reserve(text.size());
2113 for(
char c : text) {
2115 escaped.push_back(
'\x1');
2116 escaped.push_back(
'\x1');
2117 }
else if(
c ==
'\xc') {
2118 escaped.push_back(
'\x1');
2119 escaped.push_back(
'\xa');
2120 }
else if(
c ==
'@') {
2121 escaped.push_back(
'\x1');
2122 escaped.push_back(
'.');
2124 escaped.push_back(
c);
2132 return preferences_[prefs_list::remember_password].to_bool();
2137 preferences_[prefs_list::remember_password] = remember;
2151 }
else if(name.size() > 2 && name.front() ==
'@' && name.back() ==
'@') {
2152 name = name.substr(1, name.size() - 2);
2154 ERR_CFG <<
"malformed user credentials (did you manually edit the preferences file?)";
2164 auto login_clean =
login;
2167 preferences_[prefs_list::login] =
'@' + login_clean +
'@';
2172 DBG_CFG <<
"Retrieving password for server: '" << server <<
"', login: '" <<
login <<
"'";
2173 auto login_clean =
login;
2179 return std::string(temp.begin(), temp.end());
2185 return cred.server == server && cred.username == login_clean;
2191 return std::string(temp.begin(), temp.end());
2196 DBG_CFG <<
"Setting password for server: '" << server <<
"', login: '" <<
login <<
"'";
2197 auto login_clean =
login;
2207 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
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.
const_all_children_itors all_children_range() const
In-order iteration over all children.
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)
attribute_map::value_type attribute
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.
void remove()
Removes 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.
std::pair< std::string, unsigned > item
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::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