42 #define LOG_NG LOG_STREAM(info, log_engine)
43 #define DBG_NG LOG_STREAM(debug, log_engine)
47 , network_processing_stopped_(false)
48 , blindfold_(*gui_, mp_info && mp_info->skip_replay_blindfolded)
78 LOG_NG <<
"network processing activated again";
84 LOG_NG <<
"network processing stopped";
94 if(
gui_->is_blindfolded()) {
96 LOG_NG <<
"Taking off the blindfold now";
97 gui_->queue_rerender();
124 LOG_NG <<
"playmp::play_human_turn...";
164 color_t color{255, 255, 255, SDL_ALPHA_OPAQUE};
180 bool time_left = timer->update();
196 LOG_NG <<
"playmp::play_human_turn...";
216 LOG_NG <<
"beginning end-of-scenario linger";
239 LOG_NG <<
"finished human turn";
241 LOG_NG <<
"caught load-game-exception";
248 if(
e.message ==
"") {
249 save.
save_game_interactive(
_(
"A network disconnection has occurred, and the game cannot continue. Do you want to save the game?"),
253 _(
"This game has been ended.\nReason: ") +
e.message +
_(
"\nDo you want to save the game?"),
258 LOG_NG <<
"caught network-error-exception";
263 LOG_NG <<
"ending end-of-scenario linger";
306 LOG_NG <<
"playmp::after_human_turn...";
317 LOG_NG <<
"is networked...";
336 LOG_NG <<
"finished networked...";
344 info[
"type"] =
"termination";
345 info[
"condition"] =
"out of sync";
348 std::stringstream temp_buf;
349 std::vector<std::string> err_lines =
utils::split(err_msg,
'\n');
350 temp_buf <<
_(
"The game is out of sync, and cannot continue. There are a number of reasons this could happen: this "
351 "can occur if you or another player have modified their game settings. This may mean one of the "
352 "players is attempting to cheat. It could also be due to a bug in the game, but this is less "
353 "likely.\n\nDo you want to save an error log of your game?");
355 if(!err_msg.empty()) {
356 temp_buf <<
" \n \n";
358 temp_buf << *
i <<
'\n';
371 if(name ==
"ai_user_interact") {
374 }
else if(name ==
"ai_gamestate_changed") {
376 }
else if(name ==
"host_transfer") {
391 gui_->get_chat_manager().add_chat_message(std::time(
nullptr),
"", 0,
392 _(
"This side is in an idle state. To proceed with the game, it must be assigned to another controller. You may "
393 "use :droid, :control or :give_control for example."),
402 const bool has_next_scenario
404 if(!
is_host() && has_next_scenario) {
void clear()
Clears the stack of undoable (and redoable) actions.
void undo()
Undoes the top action on the undo stack.
A config object defines a single node in a WML file, with access to child nodes.
config & add_child(config_key_type key)
virtual void play_slice(bool is_delay_enabled=true)
virtual bool attach_handler(observer *obs)
virtual bool detach_handler(observer *obs)
void set_lifetime(int lifetime, int fadeout=100)
void set_position(double xpos, double ypos)
void set_color(const color_t &color)
void set_clip_rect(const SDL_Rect &r)
void set_all_units_user_end_turn()
@ GAME_ENDED
The game has ended and the user is observing the final state "lingering" The game can be saved here.
@ TURN_PLAYING
The User is controlling the game and invoking actions The game can be saved here.
@ TURN_ENDED
The turn_end, side_turn_end etc [events] are fired next phase: TURN_STARTING_WAITING (default),...
const std::string & next_scenario() const
static void progress(loading_stage stage=loading_stage::none)
Report what is being loaded to the loading screen.
static void display(std::function< void()> f)
static void spin()
Indicate to the player that loading is progressing.
bool ignore_replay_errors_
std::vector< team > & get_teams()
std::unique_ptr< hotkey_handler > hotkey_handler_
bool is_linger_mode() const
actions::undo_list & undo_stack()
bool is_regular_game_end() const
std::unique_ptr< game_display > gui_
const end_level_data & get_end_level_data() const
int current_side() const
Returns the number of the side whose turn it is.
bool player_type_changed_
true when the controller of the currently playing side has changed.
void update_gui_to_player(const int team_index, const bool observe=false)
Changes the UI for this client to the passed side index.
void process_network_data(bool chat_only=false)
virtual ~playmp_controller()
void process_oos(const std::string &err_msg) const override
Asks the user whether to continue on an OOS error.
mp_game_metadata * mp_info_
virtual bool is_host() const override
virtual void do_idle_notification() override
Will handle sending a networked notification in descendent classes.
void maybe_linger() override
bool receive_from_wesnothd(config &cfg) const override
virtual void play_idle_loop() override
virtual void handle_generic_event(const std::string &name) override
bool network_processing_stopped_
virtual void play_human_turn() override
void send_to_wesnothd(const config &cfg, const std::string &packet_type="unknown") const override
virtual void play_linger_turn()
void send_user_choice() override
void pull_remote_choice() override
virtual void on_not_observer() override
virtual void after_human_turn() override
bool is_networked_mp() const override
virtual void play_network_turn() override
Will handle networked turns in descendent classes.
void surrender(int side_number)
void wait_for_upload()
Wait for the host to upload the next scenario.
playmp_controller(const config &level, saved_game &state_of_game, mp_game_metadata *mp_info)
void play_slice(bool is_delay_enabled=true) override
void end_turn_enable(bool enable)
std::unique_ptr< replay_controller > replay_controller_
non-null when replay mode in active, is used in singleplayer and for the "back to turn" feature in mu...
virtual void check_objectives() override
playturn_network_adapter network_reader_
Used by turn_data_.
virtual bool should_return_to_play_side() const override
replay_network_sender replay_sender_
Helper to send our actions to the server Used by turn_data_.
turn_info turn_data_
Helper to read and execute (in particular replay data/ user actions ) messsages from the server.
virtual void handle_generic_event(const std::string &name) override
bool end_turn_requested_
true iff the user has pressed the end turn button this turn.
virtual void after_human_turn()
void push_front(config &&cfg)
static bool quit()
Shows the quit confirmation if needed.
static config get_update_shroud()
Records that the player has manually updated fog/shroud.
void add_surrender(int side_number)
static void process_error(const std::string &msg)
void add_countdown_update(int value, int team)
mp_game_settings & mp_settings()
Multiplayer parameters for this game.
Class for "normal" midgame saves.
Exception used to signal that the user has decided to abortt a game, and to load another game instead...
bool save_game_interactive(const std::string &message, DIALOG_TYPE dialog_type)
Save a game interactively through the savegame dialog.
static bool run_and_store(const std::string &commandname, const config &data, bool use_undo=true, bool show=true, synced_command::error_handler_function error_handler=default_error_function)
void set_action_bonus_count(const int count)
int action_bonus_count() const
void set_countdown_time(const int amount) const
int countdown_time() const
events::generic_event & host_transfer()
static PROCESS_DATA_RESULT replay_to_process_data_result(REPLAY_RETURN replayreturn)
PROCESS_DATA_RESULT sync_network()
@ PROCESS_CANNOT_HANDLE
when we couldn't handle the given action currently.
@ PROCESS_END_LINGER
When the host uploaded the next scenario this is returned.
@ PROCESS_END_LEVEL
We found a player action in the replay that caused the game to end.
PROCESS_DATA_RESULT process_network_data_from_reader()
PROCESS_DATA_RESULT process_network_data(const config &cfg, bool chat_only=false)
bool receive_data(config &result)
Receives the next pending data pack from the server, if available.
void send_data(const configr_of &request)
Queues the given data to be sent to the server.
Contains the exception interfaces used to signal completion of a scenario, campaign or turn.
static std::string _(const char *str)
An extension of playsingle_controller::hotkey_handler, which has support for MP wesnoth features like...
Standard logging facilities (interface).
int add_floating_label(const floating_label &flabel)
add a label floating on the screen above everything else.
void turn_changed(const std::string &player_name)
compression::format save_compression_format()
bool disable_auto_moves()
std::string get_unknown_exception_type()
Utility function for finding the type of thing caught with catch(...).
std::vector< std::string > split(const config_attribute_value &val)
bool headless()
The game is running headless.
std::string::const_iterator iterator
static lg::log_domain log_engine("engine")
REPLAY_RETURN do_replay(bool one_move)
The basic class for representing 8-bit RGB or RGBA colour values.
We received invalid data from wesnothd during a game This means we cannot continue with the game but ...
int mp_countdown_turn_bonus
int mp_countdown_action_bonus
int mp_countdown_reservoir_time
An abstract description of a rectangle with integer coordinates.
Various functions that implement the undoing (and redoing) of in-game commands.