move is_host_ to playturn.hpp
This commit is contained in:
parent
472c0cda45
commit
73de2e684a
8 changed files with 23 additions and 11 deletions
|
@ -123,7 +123,6 @@ play_controller::play_controller(const config& level, game_state& state_of_game,
|
|||
player_number_(1),
|
||||
first_player_(level_["playing_team"].to_int() + 1),
|
||||
start_turn_(tod_manager_.turn()), // tod_manager_ constructed above
|
||||
is_host_(true),
|
||||
skip_replay_(skip_replay),
|
||||
linger_(false),
|
||||
it_is_a_new_turn_(true),
|
||||
|
|
|
@ -251,7 +251,6 @@ protected:
|
|||
int player_number_;
|
||||
int first_player_;
|
||||
unsigned int start_turn_;
|
||||
bool is_host_;
|
||||
bool skip_replay_;
|
||||
bool linger_;
|
||||
bool it_is_a_new_turn_;
|
||||
|
|
|
@ -45,7 +45,7 @@ playmp_controller::playmp_controller(const config& level,
|
|||
network_processing_stopped_(false),
|
||||
blindfold_(*resources::screen,blindfold_replay_)
|
||||
{
|
||||
is_host_ = is_host;
|
||||
turn_data_.set_host(is_host);
|
||||
turn_data_.host_transfer().attach_handler(this);
|
||||
// We stop quick replay if play isn't yet past turn 1
|
||||
if ( replay_last_turn_ <= 1)
|
||||
|
@ -170,7 +170,7 @@ void playmp_controller::play_human_turn(){
|
|||
show_turn_dialog();
|
||||
execute_gotos();
|
||||
|
||||
if (!linger_ || is_host_) {
|
||||
if (!linger_ || is_host()) {
|
||||
end_turn_enable(true);
|
||||
}
|
||||
while(!end_turn_) {
|
||||
|
@ -282,7 +282,7 @@ void playmp_controller::play_idle_loop()
|
|||
void playmp_controller::set_end_scenario_button()
|
||||
{
|
||||
// Modify the end-turn button
|
||||
if (! is_host_) {
|
||||
if (! is_host()) {
|
||||
gui::button* btn_end = gui_->find_action_button("button-endturn");
|
||||
btn_end->enable(false);
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ void playmp_controller::wait_for_upload()
|
|||
{
|
||||
// If the host is here we'll never leave since we wait for the host to
|
||||
// upload the next scenario.
|
||||
assert(!is_host_);
|
||||
assert(!is_host());
|
||||
|
||||
config cfg;
|
||||
network_reader_.set_source(playturn_network_adapter::get_source_from_config(cfg));
|
||||
|
@ -556,7 +556,6 @@ void playmp_controller::handle_generic_event(const std::string& name){
|
|||
turn_data_.send_data();
|
||||
}
|
||||
else if (name == "host_transfer"){
|
||||
is_host_ = true;
|
||||
if (linger_){
|
||||
end_turn_enable(true);
|
||||
gui_->invalidate_theme();
|
||||
|
@ -577,7 +576,7 @@ bool playmp_controller::can_execute_command(const hotkey::hotkey_command& cmd, i
|
|||
{
|
||||
bool has_next_scenario = !resources::gamedata->next_scenario().empty() &&
|
||||
resources::gamedata->next_scenario() != "null";
|
||||
return is_host_ || !has_next_scenario;
|
||||
return is_host() || !has_next_scenario;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -28,8 +28,6 @@ public:
|
|||
bool skip_replay, bool blindfold_replay, bool is_host);
|
||||
virtual ~playmp_controller();
|
||||
|
||||
bool is_host() const { return is_host_; }
|
||||
|
||||
static unsigned int replay_last_turn() { return replay_last_turn_; }
|
||||
static void set_replay_last_turn(unsigned int turn);
|
||||
|
||||
|
|
|
@ -1082,3 +1082,8 @@ bool playsingle_controller::can_execute_command(const hotkey::hotkey_command& cm
|
|||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
bool playsingle_controller::is_host() const
|
||||
{
|
||||
return turn_data_.is_host();
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ public:
|
|||
int remaining_gold, int finishing_bonus_per_turn,
|
||||
int turns_left, int finishing_bonus);
|
||||
virtual void on_not_observer() {}
|
||||
bool is_host() const ;
|
||||
|
||||
protected:
|
||||
virtual void play_turn(bool save);
|
||||
|
|
|
@ -41,7 +41,8 @@ static lg::log_domain log_network("network");
|
|||
turn_info::turn_info(replay_network_sender &replay_sender,playturn_network_adapter &network_reader) :
|
||||
replay_sender_(replay_sender),
|
||||
host_transfer_("host_transfer"),
|
||||
network_reader_(network_reader)
|
||||
network_reader_(network_reader),
|
||||
is_host_(true)
|
||||
{
|
||||
/**
|
||||
* We do network sync so [init_side] is transferred to network hosts
|
||||
|
@ -375,6 +376,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
|
|||
//If this client becomes the new host, notify the play_controller object about it
|
||||
else if (const config &cfg_host_transfer = cfg.child("host_transfer")){
|
||||
if (cfg_host_transfer["value"] == "1") {
|
||||
is_host_ = true;
|
||||
host_transfer_.notify_observers();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,9 @@ class replay_network_sender;
|
|||
#include "playturn_network_adapter.hpp"
|
||||
#include "replay.hpp"
|
||||
|
||||
/**
|
||||
TODO: rename this class since it isn't that much related to turns.
|
||||
*/
|
||||
class turn_info
|
||||
{
|
||||
public:
|
||||
|
@ -58,6 +61,10 @@ public:
|
|||
PROCESS_DATA_RESULT process_network_data_from_reader(bool skip_replay);
|
||||
|
||||
events::generic_event& host_transfer() { return host_transfer_; }
|
||||
|
||||
|
||||
bool is_host() const { return is_host_; }
|
||||
void set_host(bool val) { is_host_ = val; }
|
||||
private:
|
||||
static void change_controller(const std::string& side, const std::string& controller);
|
||||
static void change_side_controller(const std::string& side, const std::string& player);
|
||||
|
@ -73,6 +80,8 @@ private:
|
|||
events::generic_event host_transfer_;
|
||||
|
||||
playturn_network_adapter& network_reader_;
|
||||
|
||||
bool is_host_;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue