move init_side_done_ to game_state class
This commit is contained in:
parent
20fafdee28
commit
8e875b8458
5 changed files with 12 additions and 10 deletions
|
@ -52,6 +52,7 @@ game_state::game_state(const config & level, play_controller & pc, const tdata_c
|
|||
reports_(new reports()),
|
||||
lua_kernel_(),
|
||||
events_manager_(),
|
||||
init_side_done_(level["init_side_done"].to_bool(false)),
|
||||
first_human_team_(-1)
|
||||
{
|
||||
init(pc.ticks(), pc, level);
|
||||
|
@ -219,6 +220,8 @@ void game_state::set_game_display(game_display * gd)
|
|||
|
||||
void game_state::write(config& cfg) const
|
||||
{
|
||||
cfg["init_side_done"] = init_side_done_;
|
||||
|
||||
//Call the lua save_game functions
|
||||
lua_kernel_->save_game(cfg);
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ public:
|
|||
boost::scoped_ptr<reports> reports_;
|
||||
boost::scoped_ptr<game_lua_kernel> lua_kernel_;
|
||||
boost::scoped_ptr<game_events::manager> events_manager_;
|
||||
bool init_side_done_;
|
||||
bool& init_side_done() { return init_side_done_; }
|
||||
|
||||
|
||||
game_events::wmi_container& get_wml_menu_items();
|
||||
|
|
|
@ -162,7 +162,6 @@ play_controller::play_controller(const config& level, saved_game& state_of_game,
|
|||
, player_number_(level["playing_team"].to_int() + 1)
|
||||
, skip_replay_(skip_replay)
|
||||
, linger_(false)
|
||||
, init_side_done_(level["init_side_done"].to_bool(false))
|
||||
, init_side_done_now_(false)
|
||||
, ticks_(ticks)
|
||||
, victory_when_enemies_defeated_(level["victory_when_enemies_defeated"].to_bool(true))
|
||||
|
@ -347,7 +346,7 @@ void play_controller::fire_start()
|
|||
{
|
||||
tm.set_start_gold(tm.gold());
|
||||
}
|
||||
init_side_done_ = false;
|
||||
gamestate_->init_side_done() = false;
|
||||
gamestate().gamedata_.set_phase(game_data::PLAY);
|
||||
}
|
||||
|
||||
|
@ -383,7 +382,7 @@ void play_controller::maybe_do_init_side()
|
|||
* For all other sides it is recorded in replay and replay handler has to handle
|
||||
* calling do_init_side() functions.
|
||||
**/
|
||||
if (init_side_done_ || !current_team().is_local() || gamestate().gamedata_.phase() != game_data::PLAY || is_replay()) {
|
||||
if (gamestate_->init_side_done() || !current_team().is_local() || gamestate().gamedata_.phase() != game_data::PLAY || is_replay()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -400,7 +399,7 @@ void play_controller::do_init_side()
|
|||
log_scope("player turn");
|
||||
//In case we might end up calling sync:network during the side turn events,
|
||||
//and we don't want do_init_side to be called when a player drops.
|
||||
init_side_done_ = true;
|
||||
gamestate_->init_side_done() = true;
|
||||
init_side_done_now_ = true;
|
||||
|
||||
const std::string turn_num = str_cast(turn());
|
||||
|
@ -477,7 +476,6 @@ config play_controller::to_config() const
|
|||
config cfg;
|
||||
|
||||
cfg.merge_attributes(level_);
|
||||
cfg["init_side_done"] = init_side_done_;
|
||||
|
||||
gamestate().write(cfg);
|
||||
|
||||
|
@ -538,7 +536,7 @@ void play_controller::finish_side_turn()
|
|||
|
||||
mouse_handler_.deselect_hex();
|
||||
resources::gameboard->unit_id_manager().reset_fake();
|
||||
init_side_done_ = false;
|
||||
gamestate_->init_side_done() = false;
|
||||
}
|
||||
|
||||
void play_controller::finish_turn()
|
||||
|
@ -1002,7 +1000,7 @@ hotkey::command_executor * play_controller::get_hotkey_command_executor() {
|
|||
|
||||
bool play_controller::is_browsing() const
|
||||
{
|
||||
if(linger_ || !init_side_done_ || gamestate().gamedata_.phase() != game_data::PLAY) {
|
||||
if(linger_ || !gamestate_->init_side_done() || gamestate().gamedata_.phase() != game_data::PLAY) {
|
||||
return true;
|
||||
}
|
||||
const team& t = current_team();
|
||||
|
@ -1144,7 +1142,7 @@ void play_controller::play_turn()
|
|||
continue;
|
||||
}
|
||||
init_side_begin();
|
||||
if(init_side_done_) {
|
||||
if(gamestate_->init_side_done()) {
|
||||
//This is the case in a reloaded game where teh side was initilizes before saving the game.
|
||||
init_side_end();
|
||||
}
|
||||
|
|
|
@ -296,7 +296,6 @@ protected:
|
|||
int player_number_;
|
||||
bool skip_replay_;
|
||||
bool linger_;
|
||||
bool init_side_done_;
|
||||
/// whether we did init side in this session ( false = we did init side before we reloaded the game).
|
||||
bool init_side_done_now_;
|
||||
const std::string& select_victory_music() const;
|
||||
|
|
|
@ -360,7 +360,7 @@ void replay_controller::reset_replay_impl()
|
|||
|
||||
gui_->get_chat_manager().clear_chat_messages();
|
||||
player_number_ = level_["playing_team"].to_int() + 1;
|
||||
init_side_done_ = level_["init_side_done"].to_bool(false);
|
||||
gamestate_->init_side_done() = level_["init_side_done"].to_bool(false);
|
||||
skip_replay_ = false;
|
||||
gamestate().tod_manager_= tod_manager_start_;
|
||||
resources::recorder->start_replay();
|
||||
|
|
Loading…
Add table
Reference in a new issue