The Battle for Wesnoth  1.17.0-dev
playsingle_controller.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2021
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * @file
17  * Logic for single-player game.
18  */
19 
21 
22 #include "actions/undo.hpp"
23 #include "ai/manager.hpp"
24 #include "ai/testing.hpp"
25 #include "display_chat_manager.hpp"
26 #include "events.hpp"
27 #include "formula/string_utils.hpp"
28 #include "game_end_exceptions.hpp"
29 #include "game_events/pump.hpp"
30 #include "gettext.hpp"
34 #include "hotkey/hotkey_item.hpp"
35 #include "log.hpp"
36 #include "map/label.hpp"
37 #include "map/map.hpp"
38 #include "playturn.hpp"
39 #include "preferences/game.hpp"
40 #include "random_deterministic.hpp"
41 #include "replay_helper.hpp"
42 #include "resources.hpp"
43 #include "savegame.hpp"
45 #include "sound.hpp"
46 #include "soundsource.hpp"
47 #include "statistics.hpp"
48 #include "synced_context.hpp"
49 #include "units/unit.hpp"
51 #include "whiteboard/manager.hpp"
52 
53 #include <boost/dynamic_bitset.hpp>
54 
55 static lg::log_domain log_aitesting("ai/testing");
56 #define LOG_AIT LOG_STREAM(info, log_aitesting)
57 // If necessary, this define can be replaced with `#define LOG_AIT std::cout` to restore previous behavior
58 
59 static lg::log_domain log_engine("engine");
60 #define ERR_NG LOG_STREAM(err, log_engine)
61 #define LOG_NG LOG_STREAM(info, log_engine)
62 
63 static lg::log_domain log_enginerefac("enginerefac");
64 #define LOG_RG LOG_STREAM(info, log_enginerefac)
65 
66 playsingle_controller::playsingle_controller(const config& level, saved_game& state_of_game, bool skip_replay)
67  : play_controller(level, state_of_game, skip_replay)
68  , cursor_setter_(cursor::NORMAL)
69  , textbox_info_()
70  , replay_sender_(*resources::recorder)
71  , network_reader_([this](config& cfg) { return receive_from_wesnothd(cfg); })
74  , skip_next_turn_(false)
75  , ai_fallback_(false)
77 {
78  // upgrade hotkey handler to the sp (whiteboard enabled) version
79  hotkey_handler_ = std::make_unique<hotkey_handler>(*this, saved_game_);
80 
81  // game may need to start in linger mode
83 
84  plugins_context_->set_accessor_string("level_result", std::bind(&playsingle_controller::describe_result, this));
85  plugins_context_->set_accessor_int("turn", std::bind(&play_controller::turn, this));
86 }
87 
89 {
90  if(!is_regular_game_end()) {
91  return "NONE";
92  } else if(get_end_level_data().is_victory) {
93  return "VICTORY";
94  } else {
95  return "DEFEAT";
96  }
97 }
98 
100 {
101  LOG_NG << "Initializing GUI... " << (SDL_GetTicks() - ticks()) << "\n";
103 
104  // Scroll to the starting position of the first team. If there is a
105  // human team, use that team; otherwise use team 1. If the map defines
106  // a starting position for the selected team, scroll to that tile. Note
107  // this often does not matter since many scenario start with messages,
108  // which will usually scroll to the speaker. Also note that the map
109  // does not necessarily define the starting positions. While usually
110  // best to use the map, the scenarion may explicitly set the positions,
111  // overriding those found in the map (if any).
112  if(map_start_.valid()) {
113  gui_->scroll_to_tile(map_start_, game_display::WARP, false);
114  LOG_NG << "Found good stored ui location " << map_start_ << "\n";
115  } else {
116  int scroll_team = gamestate().first_human_team_ + 1;
117  if(scroll_team == 0) {
118  scroll_team = 1;
119  }
120 
121  map_location loc(get_map().starting_position(scroll_team));
122  if((loc.x >= 0) && (loc.y >= 0)) {
123  gui_->scroll_to_tile(loc, game_display::WARP);
124  LOG_NG << "Found bad stored ui location " << map_start_ << " using side starting location " << loc << "\n";
125  } else {
126  LOG_NG << "Found bad stored ui location\n";
127  }
128  }
129 
130  update_locker lock_display(gui_->video(), is_skipping_replay());
132 }
133 
135 {
136  // At the beginning of the scenario, save a snapshot as replay_start
137  if(saved_game_.replay_start().empty()) {
139  }
140 
141  start_game();
142 
144  // This won't cause errors later but we should notify the user about it in case he didn't knew it.
146  // TODO: find a better title
147  _("Game Error"),
148  _("This multiplayer game uses an alternative random mode, if you don't know what this message means, then "
149  "most likely someone is cheating or someone reloaded a corrupt game."));
150  }
151 
152  return;
153 }
154 
156 {
157  LOG_NG << "starting main loop\n" << (SDL_GetTicks() - ticks()) << "\n";
158 
160  if(get_teams().empty()) {
161  ERR_NG << "Playing game with 0 teams." << std::endl;
162  }
163 
164  while(true) {
165  try {
166  play_turn();
167  if(is_regular_game_end()) {
169  return;
170  }
171  } catch(const reset_gamestate_exception& ex) {
172  //
173  // TODO:
174  //
175  // The MP replay feature still doesn't work properly (causes OOS)
176  // because:
177  //
178  // 1) The undo stack is not reset along with the gamestate (fixed).
179  // 2) The server_request_number_ is not reset along with the
180  // gamestate (fixed).
181  // 3) chat and other unsynced actions are inserted in the middle of
182  // the replay bringing the replay_pos in unorder (fixed).
183  // 4) untracked changes in side controllers are lost when resetting
184  // gamestate (fixed).
185  // 5) The game should have a stricter check for whether the loaded
186  // game is actually a parent of this game.
187  // 6) If an action was undone after a game was saved it can cause
188  // OOS if the undone action is in the snapshot of the saved
189  // game (luckily this is never the case for autosaves).
190  //
191  boost::dynamic_bitset<> local_players;
192  local_players.resize(get_teams().size(), true);
193  // Preserve side controllers, because we won't get the side controoller updates again when replaying.
194  for(std::size_t i = 0; i < local_players.size(); ++i) {
195  local_players[i] = get_teams()[i].is_local();
196  }
197 
198  if(ex.start_replay) {
199  // MP "Back to turn"
201  } else {
202  // SP replay
204  }
205 
206  reset_gamestate(*ex.level, (*ex.level)["replay_pos"]);
207 
208  for(std::size_t i = 0; i < local_players.size(); ++i) {
209  resources::gameboard->teams()[i].set_local(local_players[i]);
210  }
211 
213 
214  if(replay_controller_ == nullptr) {
215  replay_controller_ = std::make_unique<replay_controller>(*this, false, ex.level, [this]() { on_replay_end(false); });
216  }
217 
218  if(ex.start_replay) {
219  replay_controller_->play_replay();
220  }
221  }
222  } // end for loop
223 }
224 
226 {
227  LOG_NG << "in playsingle_controller::play_scenario()...\n";
228 
229  // Start music.
230  for(const config& m : level.child_range("music")) {
231  sound::play_music_config(m, true);
232  }
233 
235 
237  // Combine all the [story] tags into a single config. Handle this here since
238  // storyscreen::controller doesn't have a default constructor.
239  config cfg;
240  for(const auto& iter : level.child_range("story")) {
241  cfg.append_children(iter);
242  }
243 
244  if(!cfg.empty()) {
246  }
247  }
248 
249  gui_->labels().read(level);
250 
251  // Read sound sources
252  assert(soundsources_manager_ != nullptr);
253  for(const config& s : level.child_range("sound_source")) {
254  try {
256  soundsources_manager_->add(spec);
257  } catch(const bad_lexical_cast&) {
258  ERR_NG << "Error when parsing sound_source config: bad lexical cast." << std::endl;
259  ERR_NG << "sound_source config was: " << s.debug() << std::endl;
260  ERR_NG << "Skipping this sound source..." << std::endl;
261  }
262  }
263 
264  LOG_NG << "entering try... " << (SDL_GetTicks() - ticks()) << "\n";
265 
266  try {
268  // clears level config;
270 
271  if(!is_regular_game_end() && !linger_) {
273  }
274 
276  exit(0);
277  }
278  const bool is_victory = get_end_level_data().is_victory;
279 
280  if(gamestate().gamedata_.phase() <= game_data::PRESTART) {
281  gui_->video().clear_screen();
282  }
283 
285 
286  const end_level_data& end_level = get_end_level_data();
287 
288  if(get_teams().empty()) {
289  // store persistent teams
291 
292  // this is probably only a story scenario, i.e. has its endlevel in the prestart event
293  return LEVEL_RESULT::VICTORY;
294  }
295 
296  if(linger_) {
297  LOG_NG << "resuming from loaded linger state...\n";
298  // as carryover information is stored in the snapshot, we have to re-store it after loading a linger state
300  if(!is_observer()) {
302  }
303 
304  return LEVEL_RESULT::VICTORY;
305  }
306 
307  pump().fire(is_victory ? "local_victory" : "local_defeat");
308 
309  { // Block for set_scontext_synced_base
311  pump().fire(end_level.proceed_to_next_level ? "victory" : "defeat");
312  pump().fire("scenario_end");
313  }
314 
315  if(end_level.proceed_to_next_level) {
317  }
318 
319  if(is_observer()) {
320  gui2::show_transient_message(_("Game Over"), _("The game is over."));
321  return LEVEL_RESULT::OBSERVER_END;
322  }
323 
324  // If we're a player, and the result is victory/defeat, then send
325  // a message to notify the server of the reason for the game ending.
327  "info", config {
328  "type", "termination",
329  "condition", "game over",
330  "result", is_victory ? "victory" : "defeat",
331  },
332  });
333 
334  // Play victory music once all victory events
335  // are finished, if we aren't observers and the
336  // carryover dialog isn't disabled.
337  //
338  // Some scenario authors may use 'continue'
339  // result for something that is not story-wise
340  // a victory, so let them use [music] tags
341  // instead should they want special music.
342  const std::string& end_music = select_music(is_victory);
343  if((!is_victory || end_level.transient.carryover_report) && !end_music.empty()) {
345  sound::play_music_once(end_music);
346  }
347 
349 
350  LEVEL_RESULT res = LEVEL_RESULT::string_to_enum(end_level.test_result);
351  if(res == LEVEL_RESULT::TEST_NOT_SET) {
352  return is_victory ? LEVEL_RESULT::VICTORY : LEVEL_RESULT::DEFEAT;
353  } else {
354  return res;
355  }
356  } catch(const savegame::load_game_exception&) {
357  // Loading a new game is effectively a quit.
358  saved_game_.clear();
359  throw;
360  } catch(const wesnothd_error& e) {
361  scoped_savegame_snapshot snapshot(*this);
363  if(e.message == "") {
365  _("A network disconnection has occurred, and the game cannot continue. Do you want to save the game?"),
367  } else {
369  _("This game has been ended.\nReason: ") + e.message + _("\nDo you want to save the game?"),
371  }
372 
373  if(dynamic_cast<const ingame_wesnothd_error*>(&e)) {
374  return LEVEL_RESULT::QUIT;
375  } else {
376  throw;
377  }
378  }
379 }
380 
382 {
383  while(!should_return_to_play_side()) {
385  SDL_Delay(10);
386  }
387 }
388 
390 {
391  if(!skip_next_turn_) {
393  }
394 
395  if(replay_controller_.get() != nullptr) {
396  init_side_done_now_ = false;
397 
398  REPLAY_RETURN res = replay_controller_->play_side_impl();
399  if(res == REPLAY_FOUND_END_TURN) {
401  }
402 
404  replay_controller_.reset();
405  }
406  } else if((current_team().is_local_human() && current_team().is_proxy_human())) {
407  LOG_NG << "is human...\n";
408  // If a side is dead end the turn, but play at least side=1's
409  // turn in case all sides are dead
410  if(gamestate().board_.side_units(current_side()) == 0 && !(get_units().empty() && current_side() == 1)) {
412  }
413 
415 
416  if(end_turn_ == END_TURN_NONE) {
417  play_human_turn();
418  }
419 
422  }
423 
424  LOG_NG << "human finished turn...\n";
425  } else if(current_team().is_local_ai() || (current_team().is_local_human() && current_team().is_droid())) {
426  play_ai_turn();
427  } else if(current_team().is_network()) {
429  } else if(current_team().is_local_human() && current_team().is_idle()) {
430  end_turn_enable(false);
433 
434  if(end_turn_ == END_TURN_NONE) {
435  play_idle_loop();
436  }
437  } else {
438  // we should have skipped over empty controllers before so this shouldn't be possible
439  ERR_NG << "Found invalid side controller " << current_team().controller().to_string() << " ("
440  << current_team().proxy_controller().to_string() << ") for side " << current_team().side() << "\n";
441  }
442 }
443 
445 {
446  log_scope("player turn");
447  assert(!linger_);
449  return;
450  }
451 
453  scoped_savegame_snapshot snapshot(*this);
456  }
457 
458  if(preferences::turn_bell()) {
460  }
461 }
462 
464 {
466  blindfold b(*gui_, true); // apply a blindfold for the duration of this dialog
467  gui_->redraw_everything();
468  gui_->recalculate_minimap();
469  std::string message = _("It is now $name|’s turn");
470  utils::string_map symbols;
471  symbols["name"] = gamestate().board_.get_team(current_side()).side_name();
472  message = utils::interpolate_variables_into_string(message, &symbols);
473  gui2::show_transient_message("", message);
474  }
475 }
476 
478 {
480  return;
481  }
482 
483  try {
485  } catch(const return_to_play_side_exception&) {
486  }
487 }
488 
490 {
492 
494  execute_gotos();
495  }
496 
497  end_turn_enable(true);
498 
499  while(!should_return_to_play_side()) {
502  }
503 }
504 
506 {
507  LOG_NG << "beginning end-of-scenario linger\n";
508  linger_ = true;
509 
510  // If we need to set the status depending on the completion state
511  // the key to it is here.
512  gui_->set_game_mode(game_display::LINGER);
513 
514  // Make all of the able-to-move units' orbs consistently red
516 
517  // change the end-turn button text to its alternate label
518  gui_->get_theme().refresh_title2("button-endturn", "title2");
519  gui_->invalidate_theme();
520  gui_->redraw_everything();
521 
522  try {
523  // Same logic as single-player human turn, but
524  // *not* the same as multiplayer human turn.
525  end_turn_enable(true);
527  while(end_turn_ == END_TURN_NONE) {
528  play_slice();
529  }
530  } catch(const savegame::load_game_exception&) {
531  // Loading a new game is effectively a quit.
532  saved_game_.clear();
533  throw;
534  }
535 
536  // revert the end-turn button text to its normal label
537  gui_->get_theme().refresh_title2("button-endturn", "title");
538  gui_->invalidate_theme();
539  gui_->redraw_everything();
540  gui_->set_game_mode(game_display::RUNNING);
541 
542  LOG_NG << "ending end-of-scenario linger\n";
543 }
544 
546 {
547  gui_->enable_menu("endturn", enable);
549 }
550 
552 {
553  // Clear moves from the GUI.
554  gui_->set_route(nullptr);
555  gui_->unhighlight_reach();
556 }
557 
559 {
560  LOG_NG << "is ai...\n";
561 
562  end_turn_enable(false);
563  gui_->recalculate_minimap();
564 
565  const cursor::setter cursor_setter(cursor::WAIT);
566 
567  // Correct an oddball case where a human could have left delayed shroud
568  // updates on before giving control to the AI. (The AI does not bother
569  // with the undo stack, so it cannot delay shroud updates.)
570  team& cur_team = current_team();
571  if(!cur_team.auto_shroud_updates()) {
572  // We just took control, so the undo stack is empty. We still need
573  // to record this change for the replay though.
575  }
576 
577  undo_stack().clear();
579 
580  try {
581  try {
584  }
585  } catch(const return_to_play_side_exception&) {
586  } catch(const fallback_ai_to_human_exception&) {
588  player_type_changed_ = true;
589  ai_fallback_ = true;
590  }
591  } catch(...) {
593  throw;
594  }
595 
598  }
599 
601  gui_->recalculate_minimap();
602  gui_->invalidate_unit();
603  gui_->invalidate_game_status();
604  gui_->invalidate_all();
605 }
606 
607 /**
608  * Will handle sending a networked notification in descendent classes.
609  */
611 {
612  gui_->get_chat_manager().add_chat_message(std::time(nullptr), "Wesnoth", 0,
613  "This side is in an idle state. To proceed with the game, the host must assign it to another controller.",
615 }
616 
617 /**
618  * Will handle networked turns in descendent classes.
619  */
621 {
622  // There should be no networked sides in single-player.
623  ERR_NG << "Networked team encountered by playsingle_controller." << std::endl;
624 }
625 
626 void playsingle_controller::handle_generic_event(const std::string& name)
627 {
628  if(name == "ai_user_interact") {
629  play_slice(false);
630  }
631 }
632 
634 {
635  if(linger_) {
637  } else if(!is_browsing() && menu_handler_.end_turn(current_side())) {
639  }
640 }
641 
643 {
644  skip_next_turn_ = true;
646 }
647 
649 {
650  if(!get_teams().empty()) {
651  const team& t = get_teams()[gui_->viewing_team()];
652 
654  show_objectives();
655  }
656  }
657 }
658 
660 {
661  // mouse_handler expects at least one team for linger mode to work.
662  assert(is_regular_game_end());
663  if(get_end_level_data().transient.linger_mode && !get_teams().empty()) {
664  linger();
665  }
666 }
667 
669 {
670  // We cannot add [end_turn] to the recorder while executing another action.
672 
673  if(end_turn_ == END_TURN_REQUIRED && current_team().is_local()) {
674  // TODO: we should also send this immediately.
675  resources::recorder->end_turn(gamestate_->next_player_number_);
677  }
678 
679  assert(end_turn_ == END_TURN_SYNCED);
680  skip_next_turn_ = false;
681 
682  if(ai_fallback_) {
683  current_team().make_ai();
684  ai_fallback_ = false;
685  }
686 }
687 
689 {
690  if(replay_controller_ && replay_controller_->is_controlling_view()) {
691  replay_controller_->update_viewing_player();
692  } else if(int side_num = play_controller::find_last_visible_team()) {
693  // Update viewing team in case it has changed during the loop.
694  if(side_num != gui_->viewing_side()) {
695  update_gui_to_player(side_num - 1);
696  }
697  }
698 }
699 
701 {
702  if(replay_controller_ && replay_controller_->allow_reset_replay()) {
703  replay_controller_->stop_replay();
704  throw reset_gamestate_exception(replay_controller_->get_reset_state(), {}, false);
705  } else {
706  ERR_NG << "received invalid reset replay\n";
707  }
708 }
709 
711 {
712  replay_controller_ = std::make_unique<replay_controller>(
713  *this,
715  std::make_shared<config>(saved_game_.get_replay_starting_point()),
716  std::bind(&playsingle_controller::on_replay_end, this, is_unit_test)
717  );
718 
719  if(is_unit_test) {
720  replay_controller_->play_replay();
721  }
722 }
723 
725 {
727  return true;
728  } else if(end_turn_ == END_TURN_NONE || replay_controller_.get() != 0 || current_team().is_network()) {
729  return false;
730  } else {
731  return true;
732  }
733 }
734 
736 {
737  if(is_networked_mp()) {
739  } else if(is_unit_test) {
740  replay_controller_->return_to_play_side();
741  if(!is_regular_game_end()) {
743  e.proceed_to_next_level = false;
744  e.is_victory = false;
746  }
747  }
748 }
bool disable_auto_moves()
Definition: general.cpp:938
void empty_playlist()
Definition: sound.cpp:611
void end_turn(int next_player_number)
Definition: replay.cpp:301
void clear()
Clears the stack of undoable (and redoable) actions.
Definition: undo.cpp:220
void set_all_units_user_end_turn()
Definition: game_board.cpp:85
An error occurred during when trying to communicate with the wesnothd server.
static lg::log_domain log_aitesting("ai/testing")
int autosavemax()
Definition: game.cpp:804
std::unique_ptr< soundsource::manager > soundsources_manager_
bool turn_bell()
Definition: general.cpp:634
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)
Function which will interpolate variables, starting with &#39;$&#39; in the string &#39;str&#39; with the equivalent ...
virtual const std::vector< team > & teams() const override
Definition: game_board.hpp:84
void heal_all_survivors()
Definition: game_board.cpp:92
std::map< std::string, t_string > string_map
int find_last_visible_team() const
returns 0 if no such team was found.
std::unique_ptr< game_display > gui_
const unit_map & get_units() const
events::mouse_handler mouse_handler_
static manager & get_singleton()
Definition: manager.hpp:143
std::unique_ptr< plugins_context > plugins_context_
bool is_network() const
Definition: team.hpp:273
config & replay_start()
Definition: saved_game.hpp:123
bool is_skipping_replay() const
const std::string & side_name() const
Definition: team.hpp:319
Exception used to escape form the ai or ui code to playsingle_controller::play_side.
virtual void play_side_impl() override
Class for autosaves.
Definition: savegame.hpp:278
game_events::wml_event_pump & pump()
const int INFINITE_AUTO_SAVES
Definition: game.hpp:207
std::unique_ptr< hotkey_handler > hotkey_handler_
int first_human_team_
Definition: game_state.hpp:74
child_itors child_range(config_key_type key)
Definition: config.cpp:359
virtual void init_gui() override
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, const bool restore_background)
Shows a transient message to the user.
bool objectives_changed() const
Definition: team.hpp:252
PROCESS_DATA_RESULT sync_network()
Definition: playturn.cpp:61
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 clear()
Definition: saved_game.cpp:792
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.
Definition: savegame.hpp:251
config & set_snapshot(config snapshot)
Definition: saved_game.cpp:558
void play_music_once(const std::string &file)
Definition: sound.cpp:602
void append_children(const config &cfg)
Adds children from cfg.
Definition: config.cpp:238
static void log_game_end()
Definition: testing.cpp:102
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.
Definition: savegame.cpp:383
static std::string _(const char *str)
Definition: gettext.hpp:92
persist_manager persist_
void reset_current_scenario()
Reset the stats of the current scenario to the beginning.
Definition: statistics.cpp:796
void send_data()
Definition: playturn.cpp:80
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)
#define b
void make_human()
Definition: team.hpp:284
std::unique_ptr< game_state > gamestate_
REPLAY_RETURN
Definition: replay.hpp:155
no linger overlay, show fog and shroud.
std::string turn_bell
saved_game & saved_game_
void end_turn_enable(bool enable)
This class stores all the data for a single &#39;side&#39; (in game nomenclature).
Definition: team.hpp:71
bool end_turn(int side_num)
virtual void check_objectives() override
virtual bool should_return_to_play_side() const override
team & get_team(int i)
Definition: game_board.hpp:96
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:84
std::string test_result
result to use if this is a unit test
bool disable_autosave
bool has_human_sides() const
Definition: game_state.hpp:75
config to_config() const
Builds the snapshot config from members and their respective configs.
bool valid() const
Definition: location.hpp:88
game_board * gameboard
Definition: resources.cpp:20
bool is_regular_game_end() const
std::vector< team > & get_teams()
std::shared_ptr< config > stats_
virtual void init_gui()
void read_stats(const config &cfg)
Definition: statistics.cpp:772
std::string describe_result() const
Managing the AIs lifecycle - headers TODO: Refactor history handling and internal commands...
#define LOG_NG
replay * recorder
Definition: resources.cpp:28
void play_turn(side_number side)
Plays a turn for the specified side using its active AI.
Definition: manager.cpp:693
static lg::log_domain log_enginerefac("enginerefac")
bool carryover_report
Should a summary of the scenario outcome be displayed?
An object which will lock the display for the duration of its lifetime.
Definition: video.hpp:296
virtual void play_network_turn()
Will handle networked turns in descendent classes.
static void log_game_start()
Definition: testing.cpp:90
LEVEL_RESULT play_scenario(const config &level)
bool is_browsing() const override
bool is_observer() const
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.
Definition: location.hpp:37
void on_replay_end(bool is_unit_test)
bool auto_shroud_updates() const
Definition: team.hpp:350
void make_ai()
Definition: team.hpp:285
Sound source info class.
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...
Definition: savegame.hpp:82
transient_end_level transient
virtual bool is_networked_mp() const
const config & get_replay_starting_point()
Definition: saved_game.cpp:587
std::size_t i
Definition: function.cpp:940
const std::string & select_music(bool victory) const
map_location map_start_
void execute_gotos(mouse_handler &mousehandler, int side_num)
#define ERR_NG
static map_location::DIRECTION s
std::unique_ptr< replay_controller > replay_controller_
void reset_gamestate(const config &level, int replay_pos)
Define the game&#39;s event mechanism.
#define log_scope(description)
Definition: log.hpp:216
bool empty() const
Definition: map.hpp:444
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
static void save(LexState *ls, int c)
Definition: llex.cpp:57
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.
Definition: pump.cpp:480
virtual bool receive_from_wesnothd(config &) const
void update_viewing_player() override
compression::format save_compression_format()
Definition: game.cpp:856
void play_bell(const std::string &files)
Definition: sound.cpp:1035
game_state & gamestate()
double t
Definition: astarsearch.cpp:63
playturn_network_adapter network_reader_
void play_music_config(const config &music_node, bool allow_interrupt_current_track, int i)
Definition: sound.cpp:704
game_classification & classification()
Definition: saved_game.hpp:55
PROXY_CONTROLLER proxy_controller() const
Definition: team.hpp:293
game_board board_
Definition: game_state.hpp:46
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)
Definition: savegame.cpp:608
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::string message
Definition: exceptions.hpp:29
std::shared_ptr< config > level
#define e
std::size_t turn() const
void commit_music_changes()
Definition: sound.cpp:822
void remove_snapshot()
Definition: saved_game.cpp:576
int side() const
Definition: team.hpp:199
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:59
static lg::log_domain log_engine("engine")
bool turn_dialog()
Definition: game.cpp:429
Thrown when a lexical_cast fails.
bool empty() const
Definition: config.cpp:920
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)...
CONTROLLER controller() const
Definition: team.hpp:266