Added 'faction_lock' and 'leader_lock' for MultiplayerWML.
These attributes work similarly as all other lock attributes such as 'gold_lock': 'faction_lock' locks faction selection, while 'leader_lock' locks both leader and its gender selections. These attributes were added to fix #21978.
This commit is contained in:
parent
d8514c3275
commit
cef9f78468
5 changed files with 21 additions and 12 deletions
|
@ -212,6 +212,8 @@ Version 1.13.0-dev:
|
|||
* Made the error messages sent to stderr when the core data dir is
|
||||
incorrectly set more helpful.
|
||||
* Fix bug #20126: Recursive preprocessor includes cause infinite loop
|
||||
* Added 'faction_lock' and 'leader_lock' to SideWML to be used in MP Connect
|
||||
screen. Fixes bug #21978.
|
||||
|
||||
Version 1.11.11:
|
||||
* Add-ons server:
|
||||
|
|
|
@ -38,11 +38,11 @@ std::string get_RC_suffix(const std::string& unit_color, const int color)
|
|||
|
||||
|
||||
flg_manager::flg_manager(const std::vector<const config*>& era_factions,
|
||||
const config& side, const bool lock_settings, const bool saved_game,
|
||||
const int color) :
|
||||
const config& side, const bool lock_settings, const bool use_map_settings,
|
||||
const bool saved_game, const int color) :
|
||||
era_factions_(era_factions),
|
||||
side_(side),
|
||||
lock_settings_(lock_settings),
|
||||
use_map_settings_(use_map_settings),
|
||||
saved_game_(saved_game),
|
||||
has_no_recruits_(
|
||||
((side_.has_attribute("default_recruit") ?
|
||||
|
@ -50,6 +50,8 @@ flg_manager::flg_manager(const std::vector<const config*>& era_factions,
|
|||
side_["recruit"].empty()) ||
|
||||
side_["no_recruit"].to_bool()) &&
|
||||
side_["previous_recruits"].empty() && side_["extra_recruit"].empty()),
|
||||
faction_lock_(side_["faction_lock"].to_bool(lock_settings) && use_map_settings),
|
||||
leader_lock_(side_["leader_lock"].to_bool(lock_settings) && use_map_settings),
|
||||
color_(color),
|
||||
available_factions_(),
|
||||
available_leaders_(),
|
||||
|
@ -333,7 +335,7 @@ void flg_manager::update_available_leaders()
|
|||
{
|
||||
available_leaders_.clear();
|
||||
|
||||
if (!side_["no_leader"].to_bool() || !lock_settings_) {
|
||||
if (!side_["no_leader"].to_bool() || !leader_lock_) {
|
||||
// Add a default leader if there is one.
|
||||
if (!default_leader_type_.empty()) {
|
||||
available_leaders_.push_back(default_leader_type_);
|
||||
|
@ -436,7 +438,7 @@ void flg_manager::update_choosable_factions()
|
|||
{
|
||||
choosable_factions_ = available_factions_;
|
||||
|
||||
if ((!side_["faction"].empty() || !has_no_recruits_) && lock_settings_) {
|
||||
if ((!side_["faction"].empty() || !has_no_recruits_) && faction_lock_) {
|
||||
std::string faction_id;
|
||||
if (!has_no_recruits_) {
|
||||
faction_id = "Custom";
|
||||
|
@ -454,7 +456,7 @@ void flg_manager::update_choosable_leaders()
|
|||
{
|
||||
choosable_leaders_ = available_leaders_;
|
||||
|
||||
if (!default_leader_type_.empty() && lock_settings_) {
|
||||
if (!default_leader_type_.empty() && leader_lock_) {
|
||||
if (std::find(available_leaders_.begin(), available_leaders_.end(),
|
||||
default_leader_type_) != available_leaders_.end()) {
|
||||
|
||||
|
@ -468,7 +470,7 @@ void flg_manager::update_choosable_genders()
|
|||
{
|
||||
choosable_genders_ = available_genders_;
|
||||
|
||||
if (lock_settings_) {
|
||||
if (leader_lock_) {
|
||||
std::string default_gender = default_leader_gender_;
|
||||
if (default_gender.empty()) {
|
||||
default_gender = choosable_genders_.front();
|
||||
|
|
|
@ -31,8 +31,8 @@ class flg_manager
|
|||
{
|
||||
public:
|
||||
flg_manager(const std::vector<const config*>& era_factions,
|
||||
const config& side, const bool lock_settings, const bool saved_game,
|
||||
const int color);
|
||||
const config& side, const bool faction_lock, const bool leader_lock,
|
||||
const bool saved_game, const int color);
|
||||
~flg_manager();
|
||||
|
||||
void set_current_faction(const unsigned index);
|
||||
|
@ -106,10 +106,13 @@ private:
|
|||
|
||||
const config& side_;
|
||||
|
||||
const bool lock_settings_;
|
||||
const bool use_map_settings_;
|
||||
const bool saved_game_;
|
||||
const bool has_no_recruits_;
|
||||
|
||||
const bool faction_lock_;
|
||||
const bool leader_lock_;
|
||||
|
||||
const int color_;
|
||||
|
||||
// All factions which could be played by a side (including Random).
|
||||
|
|
|
@ -837,7 +837,7 @@ side_engine::side_engine(const config& cfg, connect_engine& parent_engine,
|
|||
waiting_to_choose_faction_(allow_changes_),
|
||||
chose_random_(cfg["chose_random"].to_bool(false)),
|
||||
flg_(parent_.era_factions_, cfg_, parent_.force_lock_settings_,
|
||||
parent_.params_.saved_game, color_)
|
||||
parent_.params_.use_map_settings, parent_.params_.saved_game, color_)
|
||||
{
|
||||
// Check if this side should give its control to some other side.
|
||||
const int side_cntr = cfg_["controller"].to_int(-1);
|
||||
|
|
|
@ -343,10 +343,12 @@ void wait::join_game(bool observe)
|
|||
|
||||
const bool lock_settings =
|
||||
get_scenario()["force_lock_settings"].to_bool();
|
||||
const bool use_map_settings =
|
||||
level_.child("multiplayer")["mp_use_map_settings"].to_bool();
|
||||
const bool saved_game =
|
||||
level_.child("multiplayer")["savegame"].to_bool();
|
||||
|
||||
flg_manager flg(era_factions, *side_choice, lock_settings,
|
||||
flg_manager flg(era_factions, *side_choice, lock_settings, use_map_settings,
|
||||
saved_game, color);
|
||||
|
||||
std::vector<std::string> choices;
|
||||
|
|
Loading…
Add table
Reference in a new issue