fix no_leader having no effect (#2606)

fix no_leader having no effect

fixes #2604

it previously only worked if both leader_lock and no_leader were set to yes. Now it the type= is preserved if any of the two are given, the difference bewteen those two is that no_leader only works is type= is empty. 

this also fixes some wrong parameternames in the the flg_manager ctor declaration.

This commit does not change the default value for those keys: no_leader default to yes in [side]s in [scenario] but not in multiplayer. While leader_lock defaults to the force_lock_settings key in [scenario]/[multiuplayer]
This commit is contained in:
gfgtdf 2018-03-07 12:35:27 +01:00 committed by GitHub
parent e03de8b77f
commit c64c6f513a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View file

@ -36,8 +36,8 @@ flg_manager::flg_manager(const std::vector<const config*>& era_factions,
, side_(side)
, saved_game_(saved_game)
, has_no_recruits_(get_original_recruits(side_).empty() && side_["previous_recruits"].empty())
, faction_lock_(side_["faction_lock"].to_bool(lock_settings) && (use_map_settings || lock_settings))
, leader_lock_(side_["leader_lock"].to_bool(lock_settings) && (use_map_settings || lock_settings))
, faction_lock_(side_["faction_lock"].to_bool(lock_settings))
, leader_lock_(side_["leader_lock"].to_bool(lock_settings))
, available_factions_()
, available_leaders_()
, available_genders_()
@ -80,6 +80,9 @@ flg_manager::flg_manager(const std::vector<const config*>& era_factions,
default_leader_cfg_ = nullptr;
}
}
leader_lock_ = leader_lock_ && (use_map_settings || lock_settings || default_leader_type_.empty());
faction_lock_ = faction_lock_ && (use_map_settings || lock_settings);
update_available_factions();
@ -275,7 +278,7 @@ void flg_manager::update_available_leaders()
{
available_leaders_.clear();
if(!default_leader_type_.empty() || !side_["no_leader"].to_bool() || !leader_lock_) {
if(!default_leader_type_.empty() || !(side_["no_leader"].to_bool() || leader_lock_)) {
int random_pos = 0;
// Add a default leader if there is one.

View file

@ -29,7 +29,7 @@ class flg_manager
{
public:
flg_manager(const std::vector<const config*>& era_factions,
const config& side, const bool faction_lock, const bool leader_lock, const bool saved_game);
const config& side, bool lock_settings, bool use_map_settings, bool saved_game);
void set_current_faction(const unsigned index);
void set_current_faction(const std::string& id);
@ -109,8 +109,8 @@ private:
const bool saved_game_;
const bool has_no_recruits_;
const bool faction_lock_;
const bool leader_lock_;
bool faction_lock_;
bool leader_lock_;
// All factions which could be played by a side (including Random).
std::vector<const config*> available_factions_;