The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
carryover.hpp
Go to the documentation of this file.
1 
2 #ifndef CARRYOVER_H_INCLUDED
3 #define CARRYOVER_H_INCLUDED
4 
5 class team;
6 class config;
7 #include <vector>
8 #include <string>
9 #include <set>
10 #include <boost/ptr_container/ptr_vector.hpp>
11 
12 #include "config.hpp"
13 #include "mt_rng.hpp"
15 
16 class carryover
17 {
18 public:
20  : add_ ()
21  , current_player_()
22  , gold_()
24  , recall_list_()
25  , save_id_()
26  {}
27  // Turns config from a loaded savegame into carryover_info
28  explicit carryover(const config& side);
29  carryover(const team& t, const int gold, const bool add);
31 
32  const std::string& get_save_id() const{ return save_id_; }
33  void transfer_all_gold_to(config& side_cfg);
34  void transfer_all_recruits_to(config& side_cfg);
35  void transfer_all_recalls_to(config& side_cfg);
36  const std::string to_string();
37  void to_config(config& cfg);
38 private:
39  bool add_;
41  int gold_;
42  std::set<std::string> previous_recruits_;
43  // NOTE: we store configs instead of units because units often assume or
44  // assert that various resources:: are available, which is not the
45  // case between scenarios.
46  std::vector<config> recall_list_;
49 
50  std::string get_recruits(bool erase=false);
51 };
52 
54 {
55 public:
58  , variables_()
59  , rng_()
60  , wml_menu_items_()
61  , next_scenario_()
63  {}
64  /// Turns config from a loaded savegame into carryover_info
65  /// @param from_snapshot true if cfg is a [snapshot], false if cfg is [carryover_sides(_start)]
66  explicit carryover_info(const config& cfg, bool from_snapshot = false);
67 
68  carryover* get_side(std::string save_id);
69  std::vector<carryover>& get_all_sides();
70  void add_side(const config& cfg);
71  void add_side(const team& t, const int gold, const bool add);
72  void remove_side(const std::string& id);
73 
74  void transfer_all_to(config& side_cfg);
75 
76  void transfer_to(config& level);
77 
78  void set_variables(const config& vars) { variables_ = vars; }
79  const config& get_variables() const { return variables_; }
80 
81  const rand_rng::mt_rng& rng() const { return rng_; }
82  rand_rng::mt_rng& rng() { return rng_; }
83 
84  const std::string& next_scenario() const { return next_scenario_; }
85 
86  const config to_config();
87 
88  void merge_old_carryover(const carryover_info& old_carryover);
89 private:
90  std::vector<carryover> carryover_sides_;
93  boost::ptr_vector<config> wml_menu_items_;
94  std::string next_scenario_; /**< the scenario coming next (for campaigns) */
96 };
97 
98 
99 #endif
void add_side(const config &cfg)
Definition: carryover.cpp:151
GLint level
Definition: glew.h:1220
std::vector< carryover > & get_all_sides()
Definition: carryover.cpp:147
boost::ptr_vector< config > wml_menu_items_
Definition: carryover.hpp:93
const config to_config()
Definition: carryover.cpp:234
void transfer_all_recalls_to(config &side_cfg)
Definition: carryover.cpp:84
std::string save_id_
Definition: carryover.hpp:47
void merge_old_carryover(const carryover_info &old_carryover)
Definition: carryover.cpp:265
carryover * get_side(std::string save_id)
Definition: carryover.cpp:255
config variables_
Definition: carryover.hpp:91
void transfer_to(config &level)
Definition: carryover.cpp:203
const std::string & next_scenario() const
Definition: carryover.hpp:84
GLdouble GLdouble t
Definition: glew.h:1366
Definitions for the interface to Wesnoth Markup Language (WML).
const std::string & get_save_id() const
Definition: carryover.hpp:32
std::set< std::string > previous_recruits_
Definition: carryover.hpp:42
int next_underlying_unit_id_
Definition: carryover.hpp:95
void transfer_all_to(config &side_cfg)
Definition: carryover.cpp:177
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:50
std::vector< config > recall_list_
Definition: carryover.hpp:46
config variables_
Definition: carryover.hpp:48
void erase(const std::string &key)
const rand_rng::mt_rng & rng() const
Definition: carryover.hpp:81
void transfer_all_gold_to(config &side_cfg)
Definition: carryover.cpp:58
std::vector< carryover > carryover_sides_
Definition: carryover.hpp:90
const config & get_variables() const
Definition: carryover.hpp:79
std::string current_player_
Definition: carryover.hpp:40
Declarations for a container for wml_menu_item.
std::string next_scenario_
the scenario coming next (for campaigns)
Definition: carryover.hpp:94
const std::string to_string()
Definition: carryover.cpp:101
bool add_
Definition: carryover.hpp:39
std::string get_recruits(bool erase=false)
Definition: carryover.cpp:91
void transfer_all_recruits_to(config &side_cfg)
Definition: carryover.cpp:78
void set_variables(const config &vars)
Definition: carryover.hpp:78
void remove_side(const std::string &id)
Definition: carryover.cpp:155
rand_rng::mt_rng & rng()
Definition: carryover.hpp:82
rand_rng::mt_rng rng_
Definition: carryover.hpp:92
void to_config(config &cfg)
Definition: carryover.cpp:110
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
GLsizei const GLcharARB ** string
Definition: glew.h:4503