Skip to content

Commit

Permalink
add maybe_linger to playsingle/mp_controller
Browse files Browse the repository at this point in the history
  • Loading branch information
gfgtdf committed May 29, 2014
1 parent 73de2e6 commit dce39b9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
15 changes: 3 additions & 12 deletions src/playcampaign.cpp
Expand Up @@ -313,10 +313,10 @@ static LEVEL_RESULT playsingle_scenario(const config& game_config,
store_carryover(state_of_game, playcontroller, disp, end_level);
}

if (!disp.video().faked() && res != QUIT && end_level.transient.linger_mode)
if (!disp.video().faked() && res != QUIT)
{
try {
playcontroller.linger();
playcontroller.maybe_linger();
} catch(end_level_exception& e) {
if (e.result == QUIT) {
return QUIT;
Expand Down Expand Up @@ -374,16 +374,7 @@ static LEVEL_RESULT playmp_scenario(const config& game_config,

if (!disp.video().faked() && res != QUIT) {
try {
if (!end_level.transient.linger_mode) {
if(!playcontroller.is_host()) {
// If we continue without lingering we need to
// make sure the host uploads the next scenario
// before we attempt to download it.
playcontroller.wait_for_upload();
}
} else {
playcontroller.linger();
}
playcontroller.maybe_linger();
} catch(end_level_exception& e) {
if (e.result == QUIT) {
return QUIT;
Expand Down
14 changes: 14 additions & 0 deletions src/playmp_controller.cpp
Expand Up @@ -609,3 +609,17 @@ void playmp_controller::do_idle_notification()
_("This side is in an idle state. To proceed with the game, it must be assigned to another controller. You may use :droid, :control or :give_control for example."),
events::chat_handler::MESSAGE_PUBLIC, false);
}

void playmp_controller::maybe_linger()
{
if (!get_end_level_data_const().transient.linger_mode) {
if(!is_host()) {
// If we continue without lingering we need to
// make sure the host uploads the next scenario
// before we attempt to download it.
wait_for_upload();
}
} else {
linger();
}
}
8 changes: 5 additions & 3 deletions src/playmp_controller.hpp
Expand Up @@ -35,9 +35,7 @@ class playmp_controller : public playsingle_controller, public events::pump_moni
void reset_countdown();
void think_about_countdown(int ticks);
void process(events::pump_info &info);
void linger();
/** Wait for the host to upload the next scenario. */
void wait_for_upload();
void maybe_linger();
void process_oos(const std::string& err_msg) const;

protected:
Expand All @@ -58,6 +56,10 @@ class playmp_controller : public playsingle_controller, public events::pump_moni
virtual void play_network_turn();
virtual void do_idle_notification();
virtual void play_idle_loop();

void linger();
/** Wait for the host to upload the next scenario. */
void wait_for_upload();

int beep_warning_time_;
mutable bool network_processing_stopped_;
Expand Down
7 changes: 7 additions & 0 deletions src/playsingle_controller.cpp
Expand Up @@ -1087,3 +1087,10 @@ bool playsingle_controller::is_host() const
{
return turn_data_.is_host();
}

void playsingle_controller::maybe_linger()
{
if (get_end_level_data_const().transient.linger_mode) {
linger();
}
}
3 changes: 2 additions & 1 deletion src/playsingle_controller.hpp
Expand Up @@ -62,7 +62,6 @@ class playsingle_controller : public play_controller
virtual void whiteboard_bump_up_action();
virtual void whiteboard_bump_down_action();
virtual void whiteboard_suppose_dead();
void linger();

virtual void force_end_level(LEVEL_RESULT res)
{ level_result_ = res; }
Expand All @@ -72,6 +71,7 @@ class playsingle_controller : public play_controller
int turns_left, int finishing_bonus);
virtual void on_not_observer() {}
bool is_host() const ;
virtual void maybe_linger();

protected:
virtual void play_turn(bool save);
Expand Down Expand Up @@ -106,6 +106,7 @@ class playsingle_controller : public play_controller
bool turn_over_;
bool skip_next_turn_;
LEVEL_RESULT level_result_;
void linger();
};


Expand Down

0 comments on commit dce39b9

Please sign in to comment.