Fixed game configuration not being reset when starting a new game.
This commit is contained in:
parent
a976885460
commit
0188250ece
6 changed files with 8 additions and 15 deletions
|
@ -647,8 +647,7 @@ bool game_controller::init_config(const bool force)
|
|||
|
||||
load_game_cfg(force);
|
||||
|
||||
const config &cfg = game_config().child("game_config");
|
||||
game_config::load_config(cfg ? &cfg : NULL);
|
||||
game_config::load_config(game_config_.child("game_config"));
|
||||
|
||||
hotkey::deactivate_all_scopes();
|
||||
hotkey::set_scope_active(hotkey::SCOPE_GENERAL);
|
||||
|
|
|
@ -162,13 +162,8 @@ namespace game_config
|
|||
|
||||
std::vector<server_info> server_list;
|
||||
|
||||
void load_config(const config* cfg)
|
||||
void load_config(const config &v)
|
||||
{
|
||||
if(cfg == NULL)
|
||||
return;
|
||||
|
||||
const config& v = *cfg;
|
||||
|
||||
base_income = v["base_income"].to_int(2);
|
||||
village_income = v["village_income"].to_int(1);
|
||||
poison_amount = v["poison_amount"].to_int(8);
|
||||
|
|
|
@ -140,7 +140,7 @@ namespace game_config
|
|||
menu_expand, menu_contract, menu_select;
|
||||
}
|
||||
|
||||
void load_config(const config* cfg);
|
||||
void load_config(const config &cfg);
|
||||
|
||||
void add_color_info(const config& v);
|
||||
const std::vector<Uint32>& tc_info(const std::string& name);
|
||||
|
|
|
@ -69,6 +69,7 @@ static lg::log_domain log_scripting_lua("scripting/lua");
|
|||
#define ERR_LUA LOG_STREAM(err, log_scripting_lua)
|
||||
|
||||
static std::vector<config> preload_scripts;
|
||||
static config preload_config;
|
||||
|
||||
void extract_preload_scripts(config const &game_config)
|
||||
{
|
||||
|
@ -76,6 +77,7 @@ void extract_preload_scripts(config const &game_config)
|
|||
foreach (config const &cfg, game_config.child_range("lua")) {
|
||||
preload_scripts.push_back(cfg);
|
||||
}
|
||||
preload_config = game_config.child("game_config");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3262,6 +3264,7 @@ void LuaKernel::initialize()
|
|||
lua_pop(L, 2);
|
||||
|
||||
// Execute the preload scripts.
|
||||
game_config::load_config(preload_config);
|
||||
foreach (const config &cfg, preload_scripts) {
|
||||
execute(cfg["code"].str().c_str(), 0, 0);
|
||||
}
|
||||
|
|
|
@ -191,11 +191,7 @@ BOOST_AUTO_TEST_CASE(test_gui2)
|
|||
const binary_paths_manager bin_paths_manager(main_config);
|
||||
|
||||
load_language_list();
|
||||
|
||||
{
|
||||
const config &cfg = main_config.child("game_config");
|
||||
game_config::load_config(cfg ? &cfg : NULL);
|
||||
}
|
||||
game_config::load_config(main_config.child("game_config"));
|
||||
|
||||
/**** Run the tests. *****/
|
||||
test<gui2::taddon_connect>();
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace test_utils {
|
|||
unit_types.set_config(units);
|
||||
}
|
||||
|
||||
game_config::load_config(&cfg_.child("game_config"));
|
||||
game_config::load_config(cfg_.child("game_config"));
|
||||
hotkey::deactivate_all_scopes();
|
||||
hotkey::set_scope_active(hotkey::SCOPE_GENERAL);
|
||||
hotkey::set_scope_active(hotkey::SCOPE_GAME);
|
||||
|
|
Loading…
Add table
Reference in a new issue