62 #define LOG_AIT LOG_STREAM(info, log_aitesting)
66 #define ERR_NG LOG_STREAM(err, log_engine)
67 #define LOG_NG LOG_STREAM(info, log_engine)
70 #define LOG_RG LOG_STREAM(info, log_enginerefac)
75 CVideo& video,
bool skip_replay)
76 :
play_controller(level, state_of_game, game_config, tdata, video, skip_replay)
81 , turn_data_(replay_sender_, network_reader_)
82 , end_turn_(END_TURN_NONE)
83 , skip_next_turn_(
false)
86 hotkey_handler_.reset(
new hotkey_handler(*
this, saved_game_));
90 linger_ = this->is_regular_game_end();
120 LOG_NG <<
"Initializing GUI... " << (SDL_GetTicks() -
ticks()) <<
"\n";
123 if(
gamestate().first_human_team_ != -1) {
148 _(
"This multiplayer game uses an alternative random mode, if you don't know what this message means, then most likely someone is cheating or someone reloaded a corrupt game.")
156 LOG_NG <<
"starting main loop\n" << (SDL_GetTicks() -
ticks()) <<
"\n";
164 ERR_NG <<
"Playing game with 0 teams." << std::endl;
195 std::vector<bool> local_players(
gamestate().board_.teams().size(),
true);
197 for(
size_t i = 0;
i < local_players.size(); ++
i) {
201 for(
size_t i = 0;
i < local_players.size(); ++
i) {
202 (*resources::teams)[
i].set_local(local_players[
i]);
215 LOG_NG <<
"in playsingle_controller::play_scenario()...\n";
226 gui_->labels().read(level);
235 ERR_NG <<
"Error when parsing sound_source config: bad lexical cast." << std::endl;
236 ERR_NG <<
"sound_source config was: " <<
s.debug() << std::endl;
237 ERR_NG <<
"Skipping this sound source..." << std::endl;
240 LOG_NG <<
"entering try... " << (SDL_GetTicks() -
ticks()) <<
"\n";
256 0, 0,
gui_->video().getx(),
gui_->video().gety(), 0, 0, 0, 1.0,
257 gui_->video().getSurface()
278 return LEVEL_RESULT::VICTORY;
281 LOG_NG <<
"resuming from loaded linger state...\n";
287 return LEVEL_RESULT::VICTORY;
289 pump().
fire(is_victory ?
"victory" :
"defeat");
299 return LEVEL_RESULT::OBSERVER_END;
305 (
"type",
"termination")
306 (
"condition",
"game over")
307 (
"result", is_victory ?
"victory" :
"defeat")
317 if(end_music.empty() !=
true) {
321 return is_victory ? LEVEL_RESULT::VICTORY : LEVEL_RESULT::DEFEAT;
334 if(dynamic_cast<ingame_wesnothd_error*>(&e)) {
367 LOG_NG <<
"is human...\n";
381 LOG_NG <<
"human finished turn...\n";
423 gui_->redraw_everything();
424 gui_->recalculate_minimap();
443 catch (
const return_to_play_side_exception&)
466 LOG_NG <<
"beginning end-of-scenario linger\n";
474 gui_->get_theme().refresh_title2(
"button-endturn",
"title2");
475 gui_->invalidate_theme();
476 gui_->redraw_everything();
498 gui_->get_theme().refresh_title2(
"button-endturn",
"title");
499 gui_->invalidate_theme();
500 gui_->redraw_everything();
503 LOG_NG <<
"ending end-of-scenario linger\n";
508 gui_->enable_menu(
"endturn", enable);
516 gui_->set_route(
nullptr);
517 gui_->unhighlight_reach();
525 gui_->recalculate_minimap();
547 catch (return_to_play_side_exception&) {
562 gui_->recalculate_minimap();
563 gui_->invalidate_unit();
564 gui_->invalidate_game_status();
565 gui_->invalidate_all();
575 gui_->get_chat_manager().add_chat_message(time(
nullptr),
"Wesnoth", 0,
576 "This side is in an idle state. To proceed with the game, the host must assign it to another controller.",
586 ERR_NG <<
"Networked team encountered by playsingle_controller." << std::endl;
591 if (name ==
"ai_user_interact"){
649 replay_->update_viewing_player();
653 if(side_num != this->
gui_->viewing_side()) {
666 ERR_NG <<
"recieved invalid reset replay\n";
694 replay_->return_to_play_side();
bool disable_auto_moves()
void clear()
Clears the stack of undoable (and redoable) actions.
void set_all_units_user_end_turn()
static void add_observer(events::observer *event_observer)
Adds observer of game events.
An error occured during when trying to coommunicate with the wesnothd server.
child_itors child_range(const std::string &key)
bool player_type_changed_
virtual void send_to_wesnothd(const config &, const std::string &="unknown") const
virtual const unit_map & units() const
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)
std::string interpolate_variables_into_string(const std::string &str, const string_map *const symbols)
Function which will interpolate variables, starting with '$' in the string 'str' with the equivalent ...
const end_level_data & get_end_level_data_const() const
void heal_all_survivors()
virtual void after_human_turn()
events::mouse_handler mouse_handler_
virtual void handle_generic_event(const std::string &name)
void update_viewing_player()
const int INFINITE_AUTO_SAVES
bool save_game_interactive(CVideo &video, const std::string &message, gui::DIALOG_TYPE dialog_type)
Save a game interactively through the savegame dialog.
const t_string & objectives() const
PROXY_CONTROLLER proxy_controller() const
PROCESS_DATA_RESULT sync_network()
static lg::log_domain log_aitesting("aitesting")
virtual bool recieve_from_wesnothd(config &) const
bool objectives_changed() const
static config get_auto_shroud(bool turned_on)
Records that the player has toggled automatic shroud updates.
Gather statistics important for AI testing and output them.
And endturn was required eigher by the player, by the ai or by [end_turn].
void enable_replay(bool is_unit_test=false)
bool fire(const std::string &event, const entity_location &loc1=entity_location::null_entity, const entity_location &loc2=entity_location::null_entity, const config &data=config())
Function to fire an event.
void play_slice(bool is_delay_enabled=true)
virtual const std::vector< team > & teams() const
void show_transient_message(CVideo &video, const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup, const bool restore_background)
Shows a transient message to the user.
Class for "normal" midgame saves.
boost::scoped_ptr< soundsource::manager > soundsources_manager_
config & set_snapshot(config snapshot)
void play_music_once(const std::string &file)
bool is_skipping_replay() const
static void log_game_end()
virtual void maybe_linger()
Contains the exception interfaces used to signal completion of a scenario, campaign or turn...
no linger overlay, show fog and shroud.
const std::string & select_victory_music() const
An extension of play_controller::hotkey_handler, which has support for SP wesnoth features like white...
virtual void check_objectives()
events::menu_handler menu_handler_
virtual void do_idle_notification()
Will handle sending a networked notification in descendent classes.
boost::shared_ptr< config > level
GLdouble GLdouble GLdouble b
static void clear_ais()
Clears all the AIs.
game_events::t_pump & pump()
void end_turn_enable(bool enable)
This class stores all the data for a single 'side' (in game nomenclature).
bool end_turn(int side_num)
static UNUSEDNOWARN std::string _(const char *str)
virtual ~playsingle_controller()
virtual void play_side_impl()
std::map< std::string, t_string > string_map
bool auto_shroud_updates() const
int current_side() const
Returns the number of the side whose turn it is.
void draw_solid_tinted_rectangle(int x, int y, int w, int h, int r, int g, int b, double alpha, surface target)
Fills a specified rectangle area of a surface with a given color and opacity.
void show_story(CVideo &video, const std::string &scenario_name, const config::const_child_itors &story)
Shows an introduction sequence using story WML.
bool is_regular_game_end() const
static void set_ai_info(const game_info &info)
Sets AI information.
t_string get_scenario_name()
void play_music_config(const config &music_node)
playsingle_controller(const config &level, saved_game &state_of_game, const config &game_config, const tdata_cache &tdata, CVideo &video, bool skip_replay)
virtual void play_idle_loop()
Managing the AIs lifecycle - headers.
static void play_turn(side_number side)
Plays a turn for the specified side using its active AI.
static lg::log_domain log_enginerefac("enginerefac")
void reset_objectives_changed() const
virtual void play_network_turn()
Will handle networked turns in descendent classes.
static void log_game_start()
Templates and utility-routines for strings and numbers.
LEVEL_RESULT play_scenario(const config &level)
bool is_browsing() const override
hotkey::command_executor * get_hotkey_command_executor()
Get (optionally) a command executor to handle context menu events.
void update_gui_to_player(const int team_index, const bool observe=false)
Changes the UI for this client to the passed side index.
std::string describe_result() const
void on_replay_end(bool is_unit_test)
void set_end_level_data(const end_level_data &data)
transient_end_level transient
void play_scenario_main_loop()
void execute_gotos(mouse_handler &mousehandler, int side_num)
Game information for the AI.
Game configuration data as global variables.
Exception used to signal that the user has decided to abort a game, and to load another game instead...
void reset_gamestate(const config &level, int replay_pos)
Define the game's event mechanism.
#define log_scope(description)
The turn was not ended yet.
bool proceed_to_next_level
whether to proceed to the next scenario, equals is_victory in sp.
Additional information on the game outcome which can be provided by WML.
actions::undo_list & undo_stack()
void set_defeat_music_list(const std::string &list)
static void save(LexState *ls, int c)
GLuint const GLchar * name
CONTROLLER controller() const
compression::format save_compression_format()
boost::scoped_ptr< game_state > gamestate_
void play_bell(const std::string &files)
void play_scenario_init()
static void remove_observer(events::observer *event_observer)
Removes an observer of game events.
Storyscreen controller (wrapper interface).
boost::scoped_ptr< replay_controller > replay_
game_classification & classification()
virtual void set_button_state()
config to_config() const
Builds the snapshot config from members and their respective configs.
Various functions that implement the undoing (and redoing) of in-game commands.
const cursor::setter cursor_setter
Standard logging facilities (interface).
void autosave(const bool disable_autosave, const int autosave_max, const int infinite_autosaves)
GLsizei GLenum GLuint GLuint GLsizei char * message
void set_victory_music_list(const std::string &list)
boost::scoped_ptr< game_display > gui_
const std::string & select_defeat_music() const
void commit_music_changes()
virtual bool is_networked_mp() const
std::string custom_endlevel_music
Custom short music played at the end.
A config object defines a single node in a WML file, with access to child nodes.
virtual bool should_return_to_play_side()
static lg::log_domain log_engine("engine")
void update_rect(const SDL_Rect &)
virtual void play_human_turn()
Thrown when a lexical_cast fails.
GLsizei const GLcharARB ** string
void show_objectives(const std::string &scenarioname, const std::string &objectives)
int find_last_visible_team() const
returns 0 if no such team was found.
An [end_turn] was added to the replay.
bool init_side_done_now_
Whether we did init sides in this session (false = we did init sides before we reloaded the game)...