The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
game_end_exceptions.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 - 2016 by Joerg Hinrichs <[email protected]>
3  wesnoth playturn Copyright (C) 2003 by David White <[email protected]>
4  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 /**
17  * @file
18  * Contains the exception interfaces used to signal
19  * completion of a scenario, campaign or turn.
20  */
21 
22 #ifndef GAME_END_EXCEPTIONS_HPP_INCLUDED
23 #define GAME_END_EXCEPTIONS_HPP_INCLUDED
24 
26 
27 #include "utils/make_enum.hpp"
28 
29 #include <string>
30 #include <exception>
31 #include <boost/optional.hpp>
32 
33 class config;
34 
35 MAKE_ENUM(LEVEL_RESULT,
36  (VICTORY, "victory")
37  (DEFEAT, "defeat")
38  (QUIT, "quit")
39  (OBSERVER_END, "observer_end")
40 )
41 
42 /**
43  * Exception used to escape form the ai or ui code to playsingle_controller::play_side.
44  * Never thrown during replays.
45  */
46 class return_to_play_side_exception : public tlua_jailbreak_exception, public std::exception
47 {
48 public:
49 
50  return_to_play_side_exception()
51  : tlua_jailbreak_exception()
52  , std::exception()
53  {
54  }
55  const char * what() const throw() { return "return_to_play_side_exception"; }
56 private:
57 
58  IMPLEMENT_LUA_JAILBREAK_EXCEPTION(return_to_play_side_exception)
59 };
60 
63  , public std::exception
64 {
65 public:
66 
69  , std::exception()
70  {
71  }
72  const char * what() const throw() { return "quit_game_exception"; }
73 private:
75 };
76 
77 /**
78  * The non-persistent part of end_level_data
79  */
81 
83 
84  bool carryover_report; /**< Should a summary of the scenario outcome be displayed? */
85  bool linger_mode; /**< Should linger mode be invoked? */
86  std::string custom_endlevel_music; /**< Custom short music played at the end. */
87  bool reveal_map; /**< Should we reveal map when game is ended? (Multiplayer only) */
88 };
89 
90 /**
91  * Additional information on the game outcome which can be provided by WML.
92  */
94 {
96 
97 
98  bool prescenario_save; /**< Should a prescenario be created the next game? */
99  bool replay_save; /**< Should a replay save be made? */
100  bool proceed_to_next_level; /**< whether to proceed to the next scenario, equals is_victory in sp. We need to save this in saves during linger mode. > */
103  void write(config& cfg) const;
104 
105  void read(const config& cfg);
106 
107  config to_config() const;
108 };
110 {
111  // Distinguish 'Quit' from 'Regular' end_level_exceptions to solve the following problem:
112  // If a player quits the game during an event after an [endlevel] occurs, the game won't
113  // Quit but continue with the [endlevel] instead.
114  throw quit_game_exception();
115 }
116 #endif /* ! GAME_END_EXCEPTIONS_HPP_INCLUDED */
void read(const config &cfg)
#define IMPLEMENT_LUA_JAILBREAK_EXCEPTION(type)
Helper macro for classes deriving from tlua_jailbreak_exception.
bool prescenario_save
Should a prescenario be created the next game?
STL namespace.
const char * what() const
bool replay_save
Should a replay save be made?
MAKE_ENUM(LEVEL_RESULT,(VICTORY,"victory")(DEFEAT,"defeat")(QUIT,"quit")(OBSERVER_END,"observer_end")) class return_to_play_side_exception
Exception used to escape form the ai or ui code to playsingle_controller::play_side.
bool reveal_map
Should we reveal map when game is ended? (Multiplayer only)
void throw_quit_game_exception()
bool linger_mode
Should linger mode be invoked?
config to_config() const
bool carryover_report
Should a summary of the scenario outcome be displayed?
The non-persistent part of end_level_data.
Base class for exceptions that want to be thrown 'through' lua.
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.
const char * what() const
std::string custom_endlevel_music
Custom short music played at the end.
void write(config &cfg) const
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
Defines the MAKE_ENUM macro.
GLsizei const GLcharARB ** string
Definition: glew.h:4503