Skip to content

Commit

Permalink
disable most mp_configure settings when force_lock_settings=yes
Browse files Browse the repository at this point in the history
When using force_lock_settings=yes that game now not only forces
use_map_settings to on, instead if doest show these options and doesn't
thouch those attributes in the scenario.
This implements http://gna.org/bugs/?23037
and might also fix some bugs related to spmp patch ( specially
https://gna.org/bugs/?23509) since force_lock_settings default to yes
for campaigns.
  • Loading branch information
gfgtdf committed Jun 12, 2015
1 parent e2bbe84 commit b8f26c4
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 229 deletions.
28 changes: 28 additions & 0 deletions src/game_initialization/configure_engine.cpp
Expand Up @@ -3,6 +3,7 @@
#include "game_config_manager.hpp"
#include "mp_game_settings.hpp"
#include "settings.hpp"
#include "tod_manager.hpp"

#include <boost/foreach.hpp>
#include <cassert>
Expand Down Expand Up @@ -201,4 +202,31 @@ const std::vector<std::string>& configure_engine::entry_point_titles() const {
return entry_point_titles_;
}

void configure_engine::write_parameters()
{
config& scenario = this->state_.get_starting_pos();
const mp_game_settings& params = this->state_.mp_settings();

if (params.random_start_time) {
if (!tod_manager::is_start_ToD(scenario["random_start_time"])) {
scenario["random_start_time"] = true;
}
}
else {
scenario["random_start_time"] = false;
}
scenario["experience_modifier"] = params.xp_modifier;
scenario["turns"] = params.num_turns;

BOOST_FOREACH(config& side, scenario.child_range("side"))
{
side["fog"] = params.fog_game;
side["shroud"] = params.shroud_game;
if (!params.use_map_settings) {
side["village_gold"] = params.village_gold;
side["village_support"] = params.village_support;
}
}
}

} //end namespace ng
2 changes: 1 addition & 1 deletion src/game_initialization/configure_engine.hpp
Expand Up @@ -107,7 +107,7 @@ class configure_engine
const mp_game_settings& get_parameters() const;

const std::vector<std::string>& entry_point_titles() const;

void write_parameters();
private:
saved_game& state_;
mp_game_settings& parameters_;
Expand Down
14 changes: 0 additions & 14 deletions src/game_initialization/connect_engine.cpp
Expand Up @@ -1069,24 +1069,10 @@ config side_engine::new_config() const
res["gold"] = gold_;
res["income"] = income_;

if (!parent_.params_.use_map_settings) {
res["fog"] = parent_.params_.fog_game;
res["shroud"] = parent_.params_.shroud_game;
}

//share view default to true here to restore the previous behavior.
res["share_view"] = res["share_view"].to_bool(true);

if (!parent_.params_.use_map_settings || res["village_gold"].empty()) {
res["village_gold"] = parent_.params_.village_gold;
}

if (!parent_.params_.use_map_settings ||
res["village_support"].empty()) {
res["village_support"] =
lexical_cast<std::string>(parent_.params_.village_support);
}

}

if (parent_.params_.use_map_settings && !parent_.params_.saved_game) {
Expand Down
17 changes: 1 addition & 16 deletions src/game_initialization/mp_game_utils.cpp
Expand Up @@ -23,7 +23,6 @@
#include "log.hpp"
#include "mp_options.hpp"
#include "savegame.hpp"
#include "tod_manager.hpp"
#include "unit_id.hpp"

#include <boost/foreach.hpp>
Expand Down Expand Up @@ -65,22 +64,8 @@ config initial_level_config(saved_game& state)
config& scenario = state.get_starting_pos();
if(!state.mp_settings().saved_game)
{
state.set_random_seed();

scenario["turns"] = params.num_turns;
if (params.random_start_time)
{
if (!tod_manager::is_start_ToD(scenario["random_start_time"]))
{
scenario["random_start_time"] = true;
}
}
else
{
scenario["random_start_time"] = false;
}

scenario["experience_modifier"] = params.xp_modifier;
state.set_random_seed();
}

if (scenario["objectives"].empty()) {
Expand Down

0 comments on commit b8f26c4

Please sign in to comment.