Populate active_addons_ when all add-ons are enabled.
When loading into different screens prior to actually starting or joining a game, Wesnoth loads the configs of all add-ons, otherwise it wouldn't know to display eras, campaigns, etc for selection. However starting with a4e8ac339e
, when loading all add-ons the `active_addons_` variable was no longer being populated with any of the the add-ons that were active. This meant that when checking to see if any of the active add-ons had changed it could falsely determine that nothing had changed and therefore could skip the step where it actually deactivated add-ons.
As an example of the current state prior to this fix:
* Player starts Wesnoth and joins the multiplayer lobby -> all add-ons are active, but `active_addons_` is empty.
* Player joins a game with no add-on content required -> Wesnoth checks the add-ons required for the game (none) against the contents of active_addons_ (empty).
* Wesnoth therefore determines that it doesn't need to deactivate any add-ons since it thinks no add-ons are active, when in fact all add-ons are active.
* Out of sync errors then happen if any of the players that join have add-ons installed that can globally affect other unit_types, such as [resistance_defaults], since those add-ons haven't been correctly deactivated.
The fix then is to make sure that game_config_manager::set_enabled_addon_all() correctly populates active_addons_ when it's called.
Fixes #6650
This commit is contained in:
parent
ab42d54057
commit
9b766013b2
2 changed files with 14 additions and 4 deletions
|
@ -38,6 +38,7 @@
|
|||
#include "scripting/game_lua_kernel.hpp"
|
||||
#include "serialization/schema_validator.hpp"
|
||||
#include "sound.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
#include "terrain/builder.hpp"
|
||||
#include "terrain/type_data.hpp"
|
||||
#include "theme.hpp"
|
||||
|
@ -322,17 +323,21 @@ void game_config_manager::load_game_config(bool reload_everything, const game_cl
|
|||
}
|
||||
|
||||
// only after addon configs have been loaded do we check for which addons are needed and whether they exist to be used
|
||||
LOG_CONFIG << "active_addons_ has size " << active_addons_.size() << " and contents: " << utils::join(active_addons_) << std::endl;
|
||||
if(classification) {
|
||||
LOG_CONFIG << "Enabling only some add-ons!" << std::endl;
|
||||
std::set<std::string> active_addons = classification->active_addons(scenario_id);
|
||||
// IMPORTANT: this is a significant performance optimization, particularly for the worst case example of the batched WML unit tests
|
||||
if(!reload_everything && active_addons == active_addons_) {
|
||||
LOG_CONFIG << "Configs not reloaded and active add-ons remain the same; returning early.\n";
|
||||
|
||||
LOG_CONFIG << "Configs not reloaded and active add-ons remain the same; returning early." << std::endl;
|
||||
LOG_CONFIG << "active_addons has size " << active_addons_.size() << " and contents: " << utils::join(active_addons) << std::endl;
|
||||
return;
|
||||
}
|
||||
active_addons_ = active_addons;
|
||||
set_enabled_addon(active_addons_);
|
||||
} else {
|
||||
active_addons_.clear();
|
||||
LOG_CONFIG << "Enabling all add-ons!" << std::endl;
|
||||
set_enabled_addon_all();
|
||||
}
|
||||
|
||||
|
@ -745,18 +750,24 @@ void game_config_manager::set_enabled_addon(std::set<std::string> addon_ids)
|
|||
for(const std::string& id : addon_ids) {
|
||||
auto it = addon_cfgs_.find(id);
|
||||
if(it != addon_cfgs_.end()) {
|
||||
LOG_CONFIG << "Enabling add-on " << id << std::endl;
|
||||
vec.push_back(it->second);
|
||||
} else {
|
||||
ERR_CONFIG << "Attempted to enable add-on '" << id << "' but its config could not be found" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void game_config_manager::set_enabled_addon_all()
|
||||
{
|
||||
active_addons_.clear();
|
||||
auto& vec = game_config_view_.data();
|
||||
vec.clear();
|
||||
vec.push_back(game_config_);
|
||||
|
||||
for(const auto& pair : addon_cfgs_) {
|
||||
LOG_CONFIG << "Enabling add-on " << pair.first << std::endl;
|
||||
vec.push_back(pair.second);
|
||||
active_addons_.emplace(pair.first);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "formula/callable_objects.hpp"
|
||||
#include "game_config.hpp"
|
||||
#include "game_errors.hpp" //thrown sometimes
|
||||
//#include "gettext.hpp"
|
||||
#include "language.hpp" // for string_table
|
||||
#include "log.hpp"
|
||||
#include "units/abilities.hpp"
|
||||
|
@ -1248,7 +1247,7 @@ void unit_type_data::set_config(const game_config_view& cfg)
|
|||
hide_help_all_ = hide_help["all"].to_bool();
|
||||
read_hide_help(hide_help);
|
||||
}
|
||||
DBG_UT << "Finished creatign unti types\n";
|
||||
DBG_UT << "Finished creating unit types\n";
|
||||
}
|
||||
|
||||
void unit_type_data::build_unit_type(const unit_type & ut, unit_type::BUILD_STATUS status) const
|
||||
|
|
Loading…
Add table
Reference in a new issue