56 #include <boost/dynamic_bitset.hpp> 59 #define LOG_AIT LOG_STREAM(info, log_aitesting) 63 #define ERR_NG LOG_STREAM(err, log_engine) 64 #define LOG_NG LOG_STREAM(info, log_engine) 67 #define LOG_RG LOG_STREAM(info, log_enginerefac) 104 LOG_NG <<
"Initializing GUI... " << (SDL_GetTicks() -
ticks());
120 if(scroll_team == 0) {
125 if((loc.
x >= 0) && (loc.
y >= 0)) {
127 LOG_NG <<
"Found bad stored ui location " <<
map_start_ <<
" using side starting location " << loc;
129 LOG_NG <<
"Found bad stored ui location";
134 gui_->set_prevent_draw(
false);
135 gui_->queue_repaint();
137 gui_->fade_to({0,0,0,0}, 500);
139 gui_->set_fade({0,0,0,0});
159 _(
"This multiplayer game uses an alternative random mode, if you don't know what this message means, then " 160 "most likely someone is cheating or someone reloaded a corrupt game."));
168 LOG_NG <<
"starting main loop\n" << (SDL_GetTicks() -
ticks());
172 ERR_NG <<
"Playing game with 0 teams.";
202 boost::dynamic_bitset<> local_players;
205 for(std::size_t
i = 0;
i < local_players.size(); ++
i) {
219 for(std::size_t
i = 0;
i < local_players.size(); ++
i) {
238 LOG_NG <<
"in playsingle_controller::play_scenario()...";
251 for(
const auto& iter : level.
child_range(
"story")) {
260 gui_->labels().read(level);
269 ERR_NG <<
"Error when parsing sound_source config: bad lexical cast.";
270 ERR_NG <<
"sound_source config was: " <<
s.debug();
271 ERR_NG <<
"Skipping this sound source...";
275 LOG_NG <<
"entering try... " << (SDL_GetTicks() -
ticks());
304 return level_result::type::victory;
308 LOG_NG <<
"resuming from loaded linger state...";
315 return level_result::type::victory;
318 pump().
fire(is_victory ?
"local_victory" :
"local_defeat");
332 return level_result::type::observer_end;
339 "type",
"termination",
340 "condition",
"game over",
341 "result", is_victory ? level_result::victory : level_result::defeat,
353 const std::string& end_music =
select_music(is_victory);
362 if(res == level_result::type::result_not_set) {
363 return is_victory ? level_result::type::victory : level_result::type::defeat;
376 _(
"A network disconnection has occurred, and the game cannot continue. Do you want to save the game?"),
380 _(
"This game has been ended.\nReason: ") + e.
message +
_(
"\nDo you want to save the game?"),
384 if(dynamic_cast<const ingame_wesnothd_error*>(&e)) {
385 return level_result::type::quit;
435 LOG_NG <<
"human finished turn...";
478 gui_->queue_rerender();
479 std::string message =
_(
"It is now $name|’s turn");
517 LOG_NG <<
"beginning end-of-scenario linger";
528 gui_->get_theme().refresh_title2(
"button-endturn",
"title2");
529 gui_->queue_rerender();
546 gui_->get_theme().refresh_title2(
"button-endturn",
"title");
547 gui_->queue_rerender();
550 LOG_NG <<
"ending end-of-scenario linger";
564 gui_->set_route(
nullptr);
565 gui_->unhighlight_reach();
573 gui_->recalculate_minimap();
611 gui_->recalculate_minimap();
612 gui_->invalidate_unit();
613 gui_->invalidate_game_status();
614 gui_->invalidate_all();
622 gui_->get_chat_manager().add_chat_message(std::time(
nullptr),
"Wesnoth", 0,
623 "This side is in an idle state. To proceed with the game, the host must assign it to another controller.",
633 ERR_NG <<
"Networked team encountered by playsingle_controller.";
638 if(name ==
"ai_user_interact") {
704 if(side_num !=
gui_->viewing_side()) {
716 ERR_NG <<
"received invalid reset replay";
749 }
else if(is_unit_test) {
bool disable_auto_moves()
void end_turn(int next_player_number)
void clear()
Clears the stack of undoable (and redoable) actions.
void set_all_units_user_end_turn()
An error occurred during when trying to communicate with the wesnothd server.
bool player_type_changed_
static lg::log_domain log_aitesting("ai/testing")
std::unique_ptr< soundsource::manager > soundsources_manager_
static void display(const std::string &scenario_name, const config &story)
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)
hotkey::command_executor * get_hotkey_command_executor() override
Optionally get a command executor to handle context menu events.
std::string interpolate_variables_into_string(const std::string &str, const string_map *const symbols)
virtual const std::vector< team > & teams() const override
void heal_all_survivors()
std::map< std::string, t_string > string_map
int find_last_visible_team() const
returns 0 if no such team was found.
void sync_end_turn() override
std::unique_ptr< game_display > gui_
const unit_map & get_units() const
virtual void after_human_turn()
events::mouse_handler mouse_handler_
static manager & get_singleton()
std::unique_ptr< plugins_context > plugins_context_
bool is_skipping_replay() const
const std::string & side_name() const
level_result::type play_scenario(const config &level)
Exception used to escape form the ai or ui code to playsingle_controller::play_side.
virtual void play_side_impl() override
game_events::wml_event_pump & pump()
const int INFINITE_AUTO_SAVES
std::unique_ptr< hotkey_handler > hotkey_handler_
child_itors child_range(config_key_type key)
virtual void init_gui() override
bool objectives_changed() const
PROCESS_DATA_RESULT sync_network()
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 force_end_turn() override
void enable_replay(bool is_unit_test=false)
virtual void play_slice(bool is_delay_enabled=true)
const gamemap & get_map() const
Class for "normal" midgame saves.
bool testing()
The game is running unit tests.
config & set_snapshot(config snapshot)
void play_music_once(const std::string &file)
void append_children(const config &cfg)
Adds children from cfg.
static void log_game_end()
virtual void maybe_linger()
Contains the exception interfaces used to signal completion of a scenario, campaign or turn...
bool save_game_interactive(const std::string &message, DIALOG_TYPE dialog_type)
Save a game interactively through the savegame dialog.
static std::string _(const char *str)
void reset_current_scenario()
Reset the stats of the current scenario to the beginning.
An extension of play_controller::hotkey_handler, which has support for SP wesnoth features like white...
events::menu_handler menu_handler_
virtual void do_idle_notification()
Will handle sending a networked notification in descendent classes.
playsingle_controller(const config &level, saved_game &state_of_game, bool skip_replay)
std::unique_ptr< game_state > gamestate_
no linger overlay, show fog and shroud.
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)
virtual void check_objectives() override
virtual bool should_return_to_play_side() const override
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
std::string test_result
result to use if this is a unit test
bool has_human_sides() const
config to_config() const
Builds the snapshot config from members and their respective configs.
void show_transient_message(const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup)
Shows a transient message to the user.
bool is_regular_game_end() const
std::vector< team > & get_teams()
virtual void play_idle_loop()
bool headless()
The game is running headless.
std::shared_ptr< config > stats_
void read_stats(const config &cfg)
std::string describe_result() const
Managing the AIs lifecycle - headers TODO: Refactor history handling and internal commands...
void play_turn(side_number side)
Plays a turn for the specified side using its active AI.
static lg::log_domain log_enginerefac("enginerefac")
bool carryover_report
Should a summary of the scenario outcome be displayed?
virtual void play_network_turn()
Will handle networked turns in descendent classes.
static void log_game_start()
bool is_browsing() const override
void update_gui_to_player(const int team_index, const bool observe=false)
Changes the UI for this client to the passed side index.
Encapsulates the map of the game.
void on_replay_end(bool is_unit_test)
bool auto_shroud_updates() const
void set_end_level_data(const end_level_data &data)
Exception used to signal that the user has decided to abortt a game, and to load another game instead...
transient_end_level transient
virtual bool is_networked_mp() const
void play_scenario_main_loop()
const config & get_replay_starting_point()
const std::string & select_music(bool victory) const
void execute_gotos(mouse_handler &mousehandler, int side_num)
static constexpr std::optional< enum_type > get_enum(const std::string_view value)
Converts a string into its enum equivalent.
static map_location::DIRECTION s
std::unique_ptr< replay_controller > replay_controller_
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.
t_string get_scenario_name() const
Additional information on the game outcome which can be provided by WML.
actions::undo_list & undo_stack()
const end_level_data & get_end_level_data() const
pump_result_t 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.
virtual bool receive_from_wesnothd(config &) const
void update_viewing_player() override
compression::format save_compression_format()
void play_bell(const std::string &files)
void play_scenario_init()
playturn_network_adapter network_reader_
void play_music_config(const config &music_node, bool allow_interrupt_current_track, int i)
game_classification & classification()
void set_player_type_changed()
virtual void set_button_state()
Various functions that implement the undoing (and redoing) of in-game commands.
Standard logging facilities (interface).
void autosave(const bool disable_autosave, const int autosave_max, const int infinite_autosaves)
int current_side() const
Returns the number of the side whose turn it is.
bool is_skipping_story() const
replay_network_sender replay_sender_
std::shared_ptr< config > level
void commit_music_changes()
A config object defines a single node in a WML file, with access to child nodes.
static lg::log_domain log_engine("engine")
virtual void play_human_turn()
Thrown when a lexical_cast fails.
virtual void send_to_wesnothd(const config &, const std::string &="unknown") const
virtual void handle_generic_event(const std::string &name) override
An [end_turn] was added to the replay.
void show_objectives() const
bool init_side_done_now_
Whether we did init sides in this session (false = we did init sides before we reloaded the game)...
static std::string get_string(enum_type key)
Converts a enum to its string equivalent.