Skip to content

Commit

Permalink
refactor play_controller::fire_start
Browse files Browse the repository at this point in the history
We remove a try/ctach for an exception that cannot be thrown.
We move the random mode wanring out of fire_start()
Also we use gui2::show_transient_message instead of
replay::process_error becasue the error is no OOS.
  • Loading branch information
gfgtdf committed Mar 1, 2015
1 parent 180acb0 commit 107da1f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
15 changes: 3 additions & 12 deletions src/play_controller.cpp
Expand Up @@ -37,6 +37,7 @@
#include "hotkey_handler.hpp"
#include "map_label.hpp"
#include "gettext.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "halo.hpp"
#include "hotkey/command_executor.hpp"
#include "loadscreen.hpp"
Expand Down Expand Up @@ -318,20 +319,10 @@ void play_controller::fire_start(bool execute){
init_side_done_ = false;

} else {
// FIXME: calculate it_is_a_new_turn_ correctly instead of setting it to false when reloading a game.
// it could cause missed turn events in case init_side_done_ == false.
it_is_a_new_turn_ = false;
}
if( saved_game_.classification().random_mode != "" && (network::nconnections() != 0))
{
std::string mes = _("MP game uses an alternative random mode, if you don't know what this message means, then most likeley someone is cheating or someone reloaded a corrupt game.");
gui_->get_chat_manager().add_chat_message(
time(NULL),
"game_engine",
0,
mes,
events::chat_handler::MESSAGE_PUBLIC,
preferences::message_bell());
replay::process_error(mes);
}
gamestate_.gamedata_.set_phase(game_data::PLAY);
}

Expand Down
18 changes: 10 additions & 8 deletions src/playsingle_controller.cpp
Expand Up @@ -258,16 +258,18 @@ boost::optional<LEVEL_RESULT> playsingle_controller::play_scenario_init(end_leve
init_gui();
past_prestart = true;
events::raise_draw_event();
try {
fire_start(false);
} catch (end_level_exception & e) {
return e.result;
} catch (restart_turn_exception &) {
assert(false && "caugh end_turn exception in a bad place... terminating.");
std::terminate();
}
fire_start(false);
gui_->recalculate_minimap();
}
if( saved_game_.classification().random_mode != "" && (network::nconnections() != 0)) {
// This won't cause errors later but we should notify the user about it in case he didn't knew it.
gui2::show_transient_message(
gui_->video(),
// TODO: find a better title
_("Game Error"),
_("This multiplayer game uses an alternative random mode, if you don't know what this message means, then most likeley someone is cheating or someone reloaded a corrupt game.")
);
}
return boost::none;
}

Expand Down

0 comments on commit 107da1f

Please sign in to comment.