From 9514cb9a96f674b3fdf797e6b05183af5bef0f8d Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Sat, 9 Jan 2021 03:16:45 +1100 Subject: [PATCH] Preferences/Game: code formatting --- src/preferences/game.cpp | 279 +++++++++++++++--------------- src/preferences/game.hpp | 355 +++++++++++++++++++-------------------- 2 files changed, 323 insertions(+), 311 deletions(-) diff --git a/src/preferences/game.cpp b/src/preferences/game.cpp index 27f27536ad62..f52fe0e33dd3 100644 --- a/src/preferences/game.cpp +++ b/src/preferences/game.cpp @@ -14,29 +14,29 @@ #define GETTEXT_DOMAIN "wesnoth-lib" +#include "preferences/game.hpp" #include "game_board.hpp" #include "game_display.hpp" -#include "preferences/game.hpp" #include "gettext.hpp" #include "lexical_cast.hpp" #include "log.hpp" #include "map/map.hpp" +#include "map_settings.hpp" #include "serialization/string_utils.hpp" #include "serialization/unicode_cast.hpp" -#include "map_settings.hpp" -#include "units/unit.hpp" #include "units/map.hpp" +#include "units/unit.hpp" #include "wml_exception.hpp" #include static lg::log_domain log_config("config"); -#define ERR_CFG LOG_STREAM(err , log_config) +#define ERR_CFG LOG_STREAM(err, log_config) using acquaintances_map = std::map; -namespace { - +namespace +{ bool message_private_on = false; std::map> completed_campaigns; @@ -57,7 +57,7 @@ bool options_initialized = false; void initialize_modifications(bool mp = true) { - if (mp) { + if(mp) { mp_modifications = utils::split(preferences::get("mp_modifications"), ','); mp_modifications_initialized = true; } else { @@ -66,18 +66,17 @@ void initialize_modifications(bool mp = true) } } -} // anon namespace +} // namespace -namespace preferences { - - -manager::manager() : - base() +namespace preferences +{ +manager::manager() + : base() { set_music_volume(music_volume()); set_sound_volume(sound_volume()); - if (!preferences::get("remember_timer_settings", false)) { + if(!preferences::get("remember_timer_settings", false)) { preferences::erase("mp_countdown_init_time"); preferences::erase("mp_countdown_reservoir_time"); preferences::erase("mp_countdown_turn_bonus"); @@ -97,12 +96,13 @@ manager::manager() : [/campaign] [/completed_campaigns] */ - for (const std::string &c : utils::split(preferences::get("completed_campaigns"))) { + for(const std::string& c : utils::split(preferences::get("completed_campaigns"))) { completed_campaigns[c]; // create the elements } - if (const config &ccc = preferences::get_child("completed_campaigns")) { - for (const config &cc : ccc.child_range("campaign")) { - std::set &d = completed_campaigns[cc["name"]]; + + if(const config& ccc = preferences::get_child("completed_campaigns")) { + for(const config& cc : ccc.child_range("campaign")) { + std::set& d = completed_campaigns[cc["name"]]; std::vector nd = utils::split(cc["difficulty_levels"]); std::copy(nd.begin(), nd.end(), std::inserter(d, d.begin())); } @@ -110,21 +110,19 @@ manager::manager() : encountered_units_set = utils::split_set(preferences::get("encountered_units")); - const t_translation::ter_list terrain (t_translation::read_list(preferences::get("encountered_terrain_list"))); + const t_translation::ter_list terrain(t_translation::read_list(preferences::get("encountered_terrain_list"))); encountered_terrains_set.insert(terrain.begin(), terrain.end()); - if (const config &history = preferences::get_child("history")) - { -/* Structure of the history - [history] - [history_id] - [line] - message = foobar - [/line] -*/ - for (const config::any_child &h : history.all_children_range()) - { - for (const config &l : h.cfg.child_range("line")) { + if(const config& history = preferences::get_child("history")) { + /* Structure of the history + [history] + [history_id] + [line] + message = foobar + [/line] + */ + for(const config::any_child& h : history.all_children_range()) { + for(const config& l : h.cfg.child_range("line")) { history_map[h.key].push_back(l["message"]); } } @@ -135,31 +133,31 @@ manager::~manager() { config campaigns; typedef const std::pair> cc_elem; - for (cc_elem elem : completed_campaigns) { + for(cc_elem elem : completed_campaigns) { config cmp; cmp["name"] = elem.first; cmp["difficulty_levels"] = utils::join(elem.second); campaigns.add_child("campaign", cmp); } + preferences::set_child("completed_campaigns", campaigns); preferences::set("encountered_units", utils::join(encountered_units_set)); - t_translation::ter_list terrain (encountered_terrains_set.begin(), encountered_terrains_set.end()); + t_translation::ter_list terrain(encountered_terrains_set.begin(), encountered_terrains_set.end()); preferences::set("encountered_terrain_list", t_translation::write_list(terrain)); -/* Structure of the history - [history] - [history_id] - [line] - message = foobar - [/line] -*/ + /* Structure of the history + [history] + [history_id] + [line] + message = foobar + [/line] + */ config history; typedef std::pair> hack; - for (const hack history_id : history_map) { - + for(const hack history_id : history_map) { config history_id_cfg; // [history_id] - for (const std::string& line : history_id.second) { + for(const std::string& line : history_id.second) { config cfg; // [line] cfg["message"] = line; @@ -175,9 +173,10 @@ manager::~manager() encountered_terrains_set.clear(); } -static void load_acquaintances() { +static void load_acquaintances() +{ if(acquaintances.empty()) { - for (const config &acfg : preferences::get_prefs()->child_range("acquaintance")) { + for(const config& acfg : preferences::get_prefs()->child_range("acquaintance")) { acquaintance ac = acquaintance(acfg); acquaintances[ac.get_nick()] = ac; } @@ -186,28 +185,27 @@ static void load_acquaintances() { static void save_acquaintances() { - config *cfg = preferences::get_prefs(); + config* cfg = preferences::get_prefs(); cfg->clear_children("acquaintance"); - for(std::map::iterator i = acquaintances.begin(); - i != acquaintances.end(); ++i) - { + for(std::map::iterator i = acquaintances.begin(); i != acquaintances.end(); ++i) { config& item = cfg->add_child("acquaintance"); i->second.save(item); } } -const std::map & get_acquaintances() { +const std::map& get_acquaintances() +{ load_acquaintances(); return acquaintances; } -const std::string get_ignored_delim() { +const std::string get_ignored_delim() +{ load_acquaintances(); std::vector ignored; - for(const auto& person : acquaintances) - { + for(const auto& person : acquaintances) { if(person.second.get_status() == "ignore") { ignored.push_back(person.second.get_nick()); } @@ -216,13 +214,13 @@ const std::string get_ignored_delim() { return utils::join(ignored); } -//returns acquaintances in the form nick => notes where the status = filter -std::map get_acquaintances_nice(const std::string& filter) { +// returns acquaintances in the form nick => notes where the status = filter +std::map get_acquaintances_nice(const std::string& filter) +{ load_acquaintances(); std::map ac_nice; - for(std::map::iterator i = acquaintances.begin(); i != acquaintances.end(); ++i) - { + for(std::map::iterator i = acquaintances.begin(); i != acquaintances.end(); ++i) { if(i->second.get_status() == filter) { ac_nice[i->second.get_nick()] = i->second.get_notes(); } @@ -231,7 +229,8 @@ std::map get_acquaintances_nice(const std::string& fil return ac_nice; } -std::pair add_acquaintance(const std::string& nick, const std::string& mode, const std::string& notes) +std::pair add_acquaintance( + const std::string& nick, const std::string& mode, const std::string& notes) { if(!utils::isvalid_wildcard(nick)) { return std::make_pair(nullptr, false); @@ -253,10 +252,11 @@ std::pair add_acquaintance(const std::string& return std::make_pair(&iter->second, success); } -bool remove_acquaintance(const std::string& nick) { +bool remove_acquaintance(const std::string& nick) +{ std::map::iterator i = acquaintances.find(nick); - //nick might include the notes, depending on how we're removing + // nick might include the notes, depending on how we're removing if(i == acquaintances.end()) { std::size_t pos = nick.find_first_of(' '); @@ -278,8 +278,7 @@ bool remove_acquaintance(const std::string& nick) { bool is_friend(const std::string& nick) { load_acquaintances(); - const std::map::const_iterator it = acquaintances.find(nick); + const std::map::const_iterator it = acquaintances.find(nick); if(it == acquaintances.end()) { return false; @@ -291,8 +290,7 @@ bool is_friend(const std::string& nick) bool is_ignored(const std::string& nick) { load_acquaintances(); - const std::map::const_iterator it = acquaintances.find(nick); + const std::map::const_iterator it = acquaintances.find(nick); if(it == acquaintances.end()) { return false; @@ -301,56 +299,70 @@ bool is_ignored(const std::string& nick) } } -void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level) { +void add_completed_campaign(const std::string& campaign_id, const std::string& difficulty_level) +{ completed_campaigns[campaign_id].insert(difficulty_level); } -bool is_campaign_completed(const std::string& campaign_id) { +bool is_campaign_completed(const std::string& campaign_id) +{ return completed_campaigns.count(campaign_id) != 0; } -bool is_campaign_completed(const std::string& campaign_id, const std::string &difficulty_level) { +bool is_campaign_completed(const std::string& campaign_id, const std::string& difficulty_level) +{ std::map>::iterator it = completed_campaigns.find(campaign_id); return it == completed_campaigns.end() ? false : it->second.count(difficulty_level) != 0; } -bool parse_should_show_lobby_join(const std::string &sender, const std::string &message) +bool parse_should_show_lobby_join(const std::string& sender, const std::string& message) { // If it's actually not a lobby join or leave message return true (show it). - if (sender != "server") return true; + if(sender != "server") { + return true; + } + std::string::size_type pos = message.find(" has logged into the lobby"); - if (pos == std::string::npos){ + if(pos == std::string::npos) { pos = message.find(" has disconnected"); - if (pos == std::string::npos) return true; + if(pos == std::string::npos) { + return true; + } } + int lj = lobby_joins(); - if (lj == SHOW_NONE) return false; - if (lj == SHOW_ALL) return true; + if(lj == SHOW_NONE) { + return false; + } + + if(lj == SHOW_ALL) { + return true; + } + return is_friend(message.substr(0, pos)); } int lobby_joins() { std::string pref = preferences::get("lobby_joins"); - if (pref == "friends") { + if(pref == "friends") { return SHOW_FRIENDS; - } else if (pref == "all") { + } else if(pref == "all") { return SHOW_ALL; - } else if (pref == "none") { + } else if(pref == "none") { return SHOW_NONE; } else { return SHOW_FRIENDS; } } - void _set_lobby_joins(int show) { - if (show == SHOW_FRIENDS) { + if(show == SHOW_FRIENDS) { preferences::set("lobby_joins", "friends"); - } else if (show == SHOW_ALL) { + } else if(show == SHOW_ALL) { preferences::set("lobby_joins", "all"); - } else if (show == SHOW_NONE) { + } else if(show == SHOW_NONE) { preferences::set("lobby_joins", "none"); } } @@ -365,7 +377,7 @@ std::vector user_servers_list() { std::vector pref_servers; - for(const config &server : get_prefs()->child_range("server")) { + for(const config& server : get_prefs()->child_range("server")) { pref_servers.emplace_back(); pref_servers.back().name = server["name"].str(); pref_servers.back().address = server["address"].str(); @@ -470,11 +482,13 @@ void set_shuffle_sides(bool value) preferences::set("shuffle_sides", value); } -std::string random_faction_mode(){ +std::string random_faction_mode() +{ return preferences::get("random_faction_mode"); } -void set_random_faction_mode(const std::string & value) { +void set_random_faction_mode(const std::string& value) +{ preferences::set("random_faction_mode", value); } @@ -500,12 +514,9 @@ void set_mp_server_warning_disabled(int value) void set_mp_server_program_name(const std::string& path) { - if (path.empty()) - { + if(path.empty()) { preferences::clear("mp_server_program_name"); - } - else - { + } else { preferences::set("mp_server_program_name", path); } } @@ -557,11 +568,11 @@ void set_turns(int value) const config& options() { - if (options_initialized) { + if(options_initialized) { return option_values; } - if (!preferences::get_child("options")) { + if(!preferences::get_child("options")) { // It may be an invalid config, which would cause problems in // multiplayer_create, so let's replace it with an empty but valid // config @@ -613,8 +624,7 @@ void set_countdown(bool value) int countdown_init_time() { - return utils::clamp( - lexical_cast_default(preferences::get("mp_countdown_init_time"), 270), 0, 1500); + return utils::clamp(lexical_cast_default(preferences::get("mp_countdown_init_time"), 270), 0, 1500); } void set_countdown_init_time(int value) @@ -624,8 +634,7 @@ void set_countdown_init_time(int value) int countdown_reservoir_time() { - return utils::clamp( - lexical_cast_default(preferences::get("mp_countdown_reservoir_time"), 330), 30, 1500); + return utils::clamp(lexical_cast_default(preferences::get("mp_countdown_reservoir_time"), 330), 30, 1500); } void set_countdown_reservoir_time(int value) @@ -635,8 +644,7 @@ void set_countdown_reservoir_time(int value) int countdown_turn_bonus() { - return utils::clamp( - lexical_cast_default(preferences::get("mp_countdown_turn_bonus"), 60), 0, 300); + return utils::clamp(lexical_cast_default(preferences::get("mp_countdown_turn_bonus"), 60), 0, 300); } void set_countdown_turn_bonus(int value) @@ -646,8 +654,7 @@ void set_countdown_turn_bonus(int value) int countdown_action_bonus() { - return utils::clamp( - lexical_cast_default(preferences::get("mp_countdown_action_bonus"), 13), 0, 30); + return utils::clamp(lexical_cast_default(preferences::get("mp_countdown_action_bonus"), 13), 0, 30); } void set_countdown_action_bonus(int value) @@ -717,22 +724,22 @@ void set_level_type(int value) const std::vector& modifications(bool mp) { - if ((!mp_modifications_initialized && mp) || (!sp_modifications_initialized && !mp)) + if((!mp_modifications_initialized && mp) || (!sp_modifications_initialized && !mp)) { initialize_modifications(mp); + } return mp ? mp_modifications : sp_modifications; } void set_modifications(const std::vector& value, bool mp) { - if (mp) { + if(mp) { preferences::set("mp_modifications", utils::join(value, ",")); mp_modifications_initialized = false; } else { preferences::set("sp_modifications", utils::join(value, ",")); sp_modifications_initialized = false; } - } bool skip_ai_moves() @@ -849,8 +856,7 @@ void set_message_private(bool value) compression::format save_compression_format() { - const std::string& choice = - preferences::get("compress_saves"); + const std::string& choice = preferences::get("compress_saves"); // "yes" was used in 1.11.7 and earlier; the compress_saves // option used to be a toggle for gzip in those versions. @@ -868,23 +874,26 @@ compression::format save_compression_format() return compression::GZIP; } -std::string get_chat_timestamp(const std::time_t& t) { - if (chat_timestamping()) { +std::string get_chat_timestamp(const std::time_t& t) +{ + if(chat_timestamping()) { if(preferences::use_twelve_hour_clock_format() == false) { return lg::get_timestamp(t, _("[%H:%M]")) + " "; - } - else { + } else { return lg::get_timestamp(t, _("[%I:%M %p]")) + " "; } } + return ""; } -bool chat_timestamping() { +bool chat_timestamping() +{ return preferences::get("chat_timestamp", false); } -void set_chat_timestamping(bool value) { +void set_chat_timestamping(bool value) +{ preferences::set("chat_timestamp", value); } @@ -908,27 +917,33 @@ int chat_message_aging() return lexical_cast_default(preferences::get("chat_message_aging"), 20); } -bool show_all_units_in_help() { +bool show_all_units_in_help() +{ return preferences::get("show_all_units_in_help", false); } -void set_show_all_units_in_help(bool value) { +void set_show_all_units_in_help(bool value) +{ preferences::set("show_all_units_in_help", value); } -std::set &encountered_units() { +std::set& encountered_units() +{ return encountered_units_set; } -std::set &encountered_terrains() { +std::set& encountered_terrains() +{ return encountered_terrains_set; } -std::string custom_command() { +std::string custom_command() +{ return preferences::get("custom_command"); } -void set_custom_command(const std::string& command) { +void set_custom_command(const std::string& command) +{ preferences::set("custom_command", command); } @@ -938,7 +953,8 @@ void set_custom_command(const std::string& command) { * * @todo FIXME only used for gui2. Could be used for the above histories. */ -std::vector* get_history(const std::string& id) { +std::vector* get_history(const std::string& id) +{ return &history_map[id]; } @@ -946,7 +962,7 @@ bool green_confirm() { std::string confirmation = preferences::get("confirm_end_turn"); - if (confirmation == "green" || confirmation == "yes") + if(confirmation == "green" || confirmation == "yes") return true; return false; } @@ -958,30 +974,30 @@ bool yellow_confirm() bool confirm_no_moves() { - //This is very non-intrusive so it is on by default + // This is very non-intrusive so it is on by default const std::string confirmation = preferences::get("confirm_end_turn"); return confirmation == "no_moves" || confirmation.empty(); } - -void encounter_recruitable_units(const std::vector& teams){ - for (std::vector::const_iterator help_team_it = teams.begin(); - help_team_it != teams.end(); ++help_team_it) { +void encounter_recruitable_units(const std::vector& teams) +{ + for(std::vector::const_iterator help_team_it = teams.begin(); help_team_it != teams.end(); ++help_team_it) { help_team_it->log_recruitable(); encountered_units_set.insert(help_team_it->recruits().begin(), help_team_it->recruits().end()); } } -void encounter_start_units(const unit_map& units){ - for (unit_map::const_iterator help_unit_it = units.begin(); - help_unit_it != units.end(); ++help_unit_it) { +void encounter_start_units(const unit_map& units) +{ + for(unit_map::const_iterator help_unit_it = units.begin(); help_unit_it != units.end(); ++help_unit_it) { encountered_units_set.insert(help_unit_it->type_id()); } } -static void encounter_recallable_units(const std::vector& teams){ - for (const team& t : teams) { - for (const unit_const_ptr u : t.recall_list()) { +static void encounter_recallable_units(const std::vector& teams) +{ + for(const team& t : teams) { + for(const unit_const_ptr u : t.recall_list()) { encountered_units_set.insert(u->type_id()); } } @@ -992,13 +1008,14 @@ void encounter_map_terrain(const gamemap& map) map.for_each_loc([&](const map_location& loc) { const t_translation::terrain_code terrain = map.get_terrain(loc); preferences::encountered_terrains().insert(terrain); - for (t_translation::terrain_code t : map.underlying_union_terrain(loc)) { + for(t_translation::terrain_code t : map.underlying_union_terrain(loc)) { preferences::encountered_terrains().insert(t); } }); } -void encounter_all_content(const game_board & gameboard_) { +void encounter_all_content(const game_board& gameboard_) +{ preferences::encounter_recruitable_units(gameboard_.teams()); preferences::encounter_start_units(gameboard_.units()); preferences::encounter_recallable_units(gameboard_.teams()); @@ -1019,4 +1036,4 @@ void acquaintance::save(config& item) item["notes"] = notes_; } -} // preferences namespace +} // namespace preferences diff --git a/src/preferences/game.hpp b/src/preferences/game.hpp index 4142a111ccec..39290eb4fc51 100644 --- a/src/preferences/game.hpp +++ b/src/preferences/game.hpp @@ -14,256 +14,251 @@ #pragma once -class game_board; -class gamemap; -class team; -class unit_map; - -#include "preferences/general.hpp" #include "game_config.hpp" - +#include "preferences/general.hpp" #include "serialization/compression.hpp" #include #include -namespace preferences { - -class acquaintance; +class game_board; +class gamemap; +class team; +class unit_map; - struct manager - { - manager(); - ~manager(); +namespace preferences +{ +struct manager +{ + manager(); + ~manager(); - base_manager base; - }; + base_manager base; +}; - bool parse_should_show_lobby_join(const std::string& sender, const std::string& message); - int lobby_joins(); - void _set_lobby_joins(int show); - enum LOBBY_JOINS { SHOW_NONE, SHOW_FRIENDS, SHOW_ALL }; +class acquaintance +{ +public: + acquaintance() + { + } - const std::map & get_acquaintances(); - const std::string get_ignored_delim(); - std::map get_acquaintances_nice(const std::string& filter); - std::pair add_acquaintance(const std::string& nick, const std::string& mode, const std::string& notes); - void add_completed_campaign(const std::string &campaign_id, const std::string &difficulty_level); - bool remove_acquaintance(const std::string& nick); - bool is_friend(const std::string& nick); - bool is_ignored(const std::string& nick); - bool is_campaign_completed(const std::string& campaign_id); - bool is_campaign_completed(const std::string& campaign_id, const std::string &difficulty_level); + explicit acquaintance(const config& cfg) + { + load_from_config(cfg); + } - const std::vector& builtin_servers_list(); - std::vector user_servers_list(); - void set_user_servers_list(const std::vector& value); + acquaintance(const std::string& nick, const std::string& status, const std::string& notes) + : nick_(nick) + , status_(status) + , notes_(notes) + { + } - std::string network_host(); - void set_network_host(const std::string& host); + void load_from_config(const config& cfg); - std::string campaign_server(); - void set_campaign_server(const std::string& host); + const std::string& get_nick() const { return nick_; } + const std::string& get_status() const { return status_; } + const std::string& get_notes() const { return notes_; } - bool turn_dialog(); - void set_turn_dialog(bool ison); + void save(config& cfg); - bool enable_whiteboard_mode_on_start(); - void set_enable_whiteboard_mode_on_start(bool value); +private: + /** acquaintance's MP nick */ + std::string nick_; - bool hide_whiteboard(); - void set_hide_whiteboard(bool value); + /**status (e.g., "friend", "ignore") */ + std::string status_; - bool show_combat(); + /** notes on the acquaintance */ + std::string notes_; +}; - bool allow_observers(); - void set_allow_observers(bool value); +bool parse_should_show_lobby_join(const std::string& sender, const std::string& message); +int lobby_joins(); +void _set_lobby_joins(int show); - bool shuffle_sides(); - void set_shuffle_sides(bool value); +enum LOBBY_JOINS { SHOW_NONE, SHOW_FRIENDS, SHOW_ALL }; - std::string random_faction_mode(); - void set_random_faction_mode(const std::string & value); +const std::map& get_acquaintances(); +const std::string get_ignored_delim(); +std::map get_acquaintances_nice(const std::string& filter); +std::pair add_acquaintance(const std::string& nick, const std::string& mode, const std::string& notes); +void add_completed_campaign(const std::string&campaign_id, const std::string& difficulty_level); +bool remove_acquaintance(const std::string& nick); +bool is_friend(const std::string& nick); +bool is_ignored(const std::string& nick); +bool is_campaign_completed(const std::string& campaign_id); +bool is_campaign_completed(const std::string& campaign_id, const std::string& difficulty_level); - bool use_map_settings(); - void set_use_map_settings(bool value); +const std::vector& builtin_servers_list(); +std::vector user_servers_list(); +void set_user_servers_list(const std::vector& value); - int mp_server_warning_disabled(); - void set_mp_server_warning_disabled(int value); +std::string network_host(); +void set_network_host(const std::string& host); - void set_mp_server_program_name(const std::string&); - std::string get_mp_server_program_name(); +std::string campaign_server(); +void set_campaign_server(const std::string& host); - bool random_start_time(); - void set_random_start_time(bool value); +bool turn_dialog(); +void set_turn_dialog(bool ison); - bool fog(); - void set_fog(bool value); +bool enable_whiteboard_mode_on_start(); +void set_enable_whiteboard_mode_on_start(bool value); - bool shroud(); - void set_shroud(bool value); +bool hide_whiteboard(); +void set_hide_whiteboard(bool value); - int turns(); - void set_turns(int value); +bool show_combat(); - const config& options(); - void set_options(const config& values); +bool allow_observers(); +void set_allow_observers(bool value); - bool skip_mp_replay(); - void set_skip_mp_replay(bool value); +bool shuffle_sides(); +void set_shuffle_sides(bool value); - bool blindfold_replay(); - void set_blindfold_replay(bool value); +std::string random_faction_mode(); +void set_random_faction_mode(const std::string& value); - bool countdown(); - void set_countdown(bool value); - int countdown_init_time(); - void set_countdown_init_time(int value); - int countdown_turn_bonus(); - void set_countdown_turn_bonus(int value); - int countdown_reservoir_time(); - void set_countdown_reservoir_time(int value); - int countdown_action_bonus(); - void set_countdown_action_bonus(int value); +bool use_map_settings(); +void set_use_map_settings(bool value); - int village_gold(); - void set_village_gold(int value); +int mp_server_warning_disabled(); +void set_mp_server_warning_disabled(int value); - int village_support(); - void set_village_support(int value); +void set_mp_server_program_name(const std::string&); +std::string get_mp_server_program_name(); - int xp_modifier(); - void set_xp_modifier(int value); +bool random_start_time(); +void set_random_start_time(bool value); - std::string era(); - void set_era(const std::string& value); +bool fog(); +void set_fog(bool value); - std::string level(); - void set_level(const std::string& value); - int level_type(); - void set_level_type(int value); +bool shroud(); +void set_shroud(bool value); - const std::vector& modifications(bool mp=true); - void set_modifications(const std::vector& value, bool mp=true); +int turns(); +void set_turns(int value); - bool skip_ai_moves(); - void set_skip_ai_moves(bool value); +const config& options(); +void set_options(const config& values); - void set_show_side_colors(bool value); - bool show_side_colors(); +bool skip_mp_replay(); +void set_skip_mp_replay(bool value); - bool save_replays(); - void set_save_replays(bool value); +bool blindfold_replay(); +void set_blindfold_replay(bool value); - bool delete_saves(); - void set_delete_saves(bool value); +bool countdown(); +void set_countdown(bool value); +int countdown_init_time(); +void set_countdown_init_time(int value); +int countdown_turn_bonus(); +void set_countdown_turn_bonus(int value); +int countdown_reservoir_time(); +void set_countdown_reservoir_time(int value); +int countdown_action_bonus(); +void set_countdown_action_bonus(int value); - void set_ask_delete_saves(bool value); - bool ask_delete_saves(); +int village_gold(); +void set_village_gold(int value); - void set_interrupt_when_ally_sighted(bool value); - bool interrupt_when_ally_sighted(); +int village_support(); +void set_village_support(int value); - void set_autosavemax(int value); - int autosavemax(); +int xp_modifier(); +void set_xp_modifier(int value); - const int INFINITE_AUTO_SAVES = 61; +std::string era(); +void set_era(const std::string& value); - bool show_floating_labels(); - void set_show_floating_labels(bool value); +std::string level(); +void set_level(const std::string& value); +int level_type(); +void set_level_type(int value); - bool message_private(); - void set_message_private(bool value); +const std::vector& modifications(bool mp = true); +void set_modifications(const std::vector& value, bool mp = true); - // Multiplayer functions - std::string get_chat_timestamp(const std::time_t& t); - bool chat_timestamping(); - void set_chat_timestamping(bool value); +bool skip_ai_moves(); +void set_skip_ai_moves(bool value); - int chat_lines(); - void set_chat_lines(int lines); +void set_show_side_colors(bool value); +bool show_side_colors(); - int chat_message_aging(); - void set_chat_message_aging(const int aging); +bool save_replays(); +void set_save_replays(bool value); - bool show_all_units_in_help(); - void set_show_all_units_in_help(bool value); +bool delete_saves(); +void set_delete_saves(bool value); - compression::format save_compression_format(); +void set_ask_delete_saves(bool value); +bool ask_delete_saves(); - std::set &encountered_units(); - std::set &encountered_terrains(); +void set_interrupt_when_ally_sighted(bool value); +bool interrupt_when_ally_sighted(); - std::string custom_command(); - void set_custom_command(const std::string& command); +void set_autosavemax(int value); +int autosavemax(); - std::vector* get_history(const std::string& id); +const int INFINITE_AUTO_SAVES = 61; - void set_theme(const std::string& theme); - std::string theme(); +bool show_floating_labels(); +void set_show_floating_labels(bool value); - // Ask for end turn confirmation - bool yellow_confirm(); - bool green_confirm(); - bool confirm_no_moves(); +bool message_private(); +void set_message_private(bool value); - // Add all recruitable units as encountered so that information - // about them are displayed to the user in the help system. - void encounter_recruitable_units(const std::vector& teams); - // Add all units that exist at the start to the encountered units so - // that information about them are displayed to the user in the help - // system. - void encounter_start_units(const unit_map& units); - // Add all units that are recallable as encountered units. - void encounter_recallable_units(std::vector& teams); - // Add all terrains on the map as encountered terrains. - void encounter_map_terrain(const gamemap& map); +// Multiplayer functions +std::string get_chat_timestamp(const std::time_t& t); +bool chat_timestamping(); +void set_chat_timestamping(bool value); - // Calls all of the above functions on the current game board - void encounter_all_content(const game_board & gb); +int chat_lines(); +void set_chat_lines(int lines); -class acquaintance { -public: +int chat_message_aging(); +void set_chat_message_aging(const int aging); - acquaintance() - { - } +bool show_all_units_in_help(); +void set_show_all_units_in_help(bool value); - explicit acquaintance(const config& cfg) - { - load_from_config(cfg); - } +compression::format save_compression_format(); - acquaintance( - const std::string& nick - , const std::string& status - , const std::string& notes) - : nick_(nick) - , status_(status) - , notes_(notes) - { +std::set&encountered_units(); +std::set&encountered_terrains(); - } +std::string custom_command(); +void set_custom_command(const std::string& command); - void load_from_config(const config& cfg); +std::vector* get_history(const std::string& id); - const std::string& get_nick() const { return nick_; } - const std::string& get_status() const { return status_; } - const std::string& get_notes() const { return notes_; } +void set_theme(const std::string& theme); +std::string theme(); - void save(config& cfg); +// Ask for end turn confirmation +bool yellow_confirm(); +bool green_confirm(); +bool confirm_no_moves(); -private: +// Add all recruitable units as encountered so that information +// about them are displayed to the user in the help system. +void encounter_recruitable_units(const std::vector& teams); - /** acquaintance's MP nick */ - std::string nick_; +// Add all units that exist at the start to the encountered units so +// that information about them are displayed to the user in the help +// system. +void encounter_start_units(const unit_map& units); - /**status (e.g., "friend", "ignore") */ - std::string status_; +// Add all units that are recallable as encountered units. +void encounter_recallable_units(std::vector& teams); - /** notes on the acquaintance */ - std::string notes_; +// Add all terrains on the map as encountered terrains. +void encounter_map_terrain(const gamemap& map); -}; +// Calls all of the above functions on the current game board +void encounter_all_content(const game_board& gb); -} +} // namespace preferences