Remember modifications separately for sp and mp.

Fixes bug #23617.
This commit is contained in:
Lipka Boldizsár 2015-07-27 01:26:13 +02:00
parent 91b49198ff
commit 6d64baa207
4 changed files with 29 additions and 14 deletions

View file

@ -36,6 +36,7 @@ Version 1.13.1+dev:
* Child wesnothd processes spawned by the Host Network Game option on
Windows now display console output directly instead of using stdout.txt
and stderr.txt.
* Remember last selected modifications separately for single and multiplayer.
Version 1.13.1:
* Security fixes:

View file

@ -437,7 +437,8 @@ create_engine::create_engine(game_display& disp, saved_game& state) :
state_.mp_settings().saved_game = false;
BOOST_FOREACH (const std::string& str, preferences::modifications()) {
BOOST_FOREACH (const std::string& str, preferences::modifications(state_.classification().campaign_type ==
game_classification::CAMPAIGN_TYPE::MULTIPLAYER)) {
if (game_config_manager::get()->
game_config().find_child("modification", "id", str))
state_.mp_settings().active_mods.push_back(str);

View file

@ -67,7 +67,9 @@ std::map<std::string, preferences::acquaintance> acquaintances;
bool acquaintances_initialized = false;
std::vector<std::string> mp_modifications;
bool modifications_initialized = false;
bool mp_modifications_initialized = false;
std::vector<std::string> sp_modifications;
bool sp_modifications_initialized = false;
config option_values;
bool options_initialized = false;
@ -96,10 +98,15 @@ std::string parse_wrapped_credentials_field(const std::string& raw)
return raw.substr(1, raw.length() - 2);
}
void initialize_modifications()
void initialize_modifications(bool mp = true)
{
mp_modifications = utils::split(preferences::get("modifications"), ',');
modifications_initialized = true;
if (mp) {
mp_modifications = utils::split(preferences::get("mp_modifications"), ',');
mp_modifications_initialized = true;
} else {
sp_modifications = utils::split(preferences::get("sp_modifications"), ',');
sp_modifications_initialized = true;
}
}
} // anon namespace
@ -849,18 +856,24 @@ void set_level_type(int value)
preferences::set("mp_level_type", value);
}
const std::vector<std::string>& modifications()
const std::vector<std::string>& modifications(bool mp)
{
if (!modifications_initialized)
initialize_modifications();
if ((!mp_modifications_initialized && mp) || (!sp_modifications_initialized && !mp))
initialize_modifications(mp);
return mp_modifications;
return mp ? mp_modifications : sp_modifications;
}
void set_modifications(const std::vector<std::string>& value)
void set_modifications(const std::vector<std::string>& value, bool mp)
{
preferences::set("modifications", utils::join(value, ","));
modifications_initialized = false;
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 show_ai_moves()

View file

@ -203,8 +203,8 @@ class acquaintance;
int level_type();
void set_level_type(int value);
const std::vector<std::string>& modifications();
void set_modifications(const std::vector<std::string>& value);
const std::vector<std::string>& modifications(bool mp=true);
void set_modifications(const std::vector<std::string>& value, bool mp=true);
bool show_ai_moves();
void set_show_ai_moves(bool value);