11
16
// You should have received a copy of the GNU General Public License
12
17
// along with this program; if not, write to the Free Software
13
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
#include "ObjectList.h"
25
#include "LocationList.h"
20
26
#include <sigc++/trackable.h>
22
/** An object list which keeps track of all ruins. It cannot do much more than
23
* saving and loading the elements. Implemented as a singleton again.
26
class Ruinlist : public ObjectList<Ruin>, public sigc::trackable
28
//! A list of Ruin objects on the game map.
30
* The ruinlist keeps track of the Ruin objects located on the game map. It
31
* is implemented as a singleton because many classes use it for looking
34
class Ruinlist : public LocationList<Ruin>, public sigc::trackable
29
//! Returns the singleton instance. Creates a new one if required.
37
//! Returns the singleton instance. Creates a new one if required.
30
38
static Ruinlist* getInstance();
32
//! Loads the singleton instance with a savegame.
40
//! Loads the singleton instance from the opened saved-game file.
33
41
static Ruinlist* getInstance(XML_Helper* helper);
35
//! Explicitely deletes the singleton instance.
43
//! Explicitly deletes the singleton instance.
36
44
static void deleteInstance();
39
//! Save function. See XML_Helper for details.
46
//! Save the list of Ruin objects to the opened saved-game file.
40
47
bool save(XML_Helper* helper) const;
42
// Find the nearest ruin which has not been searched
49
//! Find the nearest Ruin object that has not been searched.
51
* Scan through all of the Ruin objects searching for the closest one
52
* that has not already had a Hero successfully search it.
54
* @note This method does not return hidden ruins that do not belong
55
* to the active player.
57
* @param pos The position on the game map to search for the nearest
58
* unsearched Ruin object from.
60
* @return A pointer to the nearest Ruin object that has not been
61
* successfully searched already. Returns NULL when all Ruin
62
* objects have been searched.
43
64
Ruin* getNearestUnsearchedRuin(const Vector<int>& pos);
44
// Find the nearest ruin
66
//! Find the nearest ruin.
68
* Scan through all of the Ruin objects searching for the closest one.
70
* @note This method does not return hidden ruins that do not belong
71
* to the active player.
73
* @param pos The position on the game map to search for the nearest
76
* @return A pointer to the nearest Ruin object. Returns NULL when
77
* there are no Ruin object in this list.
45
79
Ruin* getNearestRuin(const Vector<int>& pos);
81
//! Find the nearest ruin that is not too far away.
83
* Scan through all of the Ruin objects searching for the closest one
84
* that is no far than the given distance.
86
* @note This method does not return hidden ruins that do not belong
87
* to the active player.
89
* @param pos The position on the game map to search for the nearest
91
* @param dist The number of tiles away that is deemed "too far".
93
* @return A pointer to the nearest Ruin object that isn't too far
94
* away. If all of the Ruin objects in the list are too far
95
* away, this method returns NULL.
46
97
Ruin* getNearestRuin(const Vector<int>& pos, int dist);
99
//! Find the nearest Ruin object that is not obscured by fog.
101
* Scan through all ruins, searching for the closest one that is
102
* not covered by fog-of-war on a hidden map.
104
* @note This method does not return hidden ruins that do not belong
105
* to the active player.
107
* @param pos The position to find the nearest ruin from.
109
* @return A pointer to the nearest ruin that is not obscured by fog.
47
111
Ruin* getNearestVisibleRuin(const Vector<int>& pos);
113
//! Find the nearest ruin that is unobscured and is not too far away.
115
* Scan through all the ruins, searching for the closest one that
116
* is not covered by fog-of-war on a hidden map, but is not farther
117
* away than a given distance.
119
* @note This method does not return hidden ruins that do not belong
120
* to the active player.
122
* @param pos The position to find the nearest ruin from.
123
* @param dist The number of tiles away that is deemed "too far".
125
* @return A pointer to the nearest ruin that is not obscured by fog
126
* and is within the prescribed number of tiles. Returns NULL
127
* if no ruin could be found.
48
129
Ruin* getNearestVisibleRuin(const Vector<int>& pos, int dist);
50
//! Changes all ruins owned by old owner, to be owned by the new
131
//! Change ownership of all Ruin objects in the list.
133
* Changes all ruins owned by old owner, to be owned by the new owner.
52
135
void changeOwnership(Player *old_owner, Player *new_owner);
138
//! Default constructor.
141
//! Loading constructor.
143
* Make a new list of Road objects by loading it from an opened
146
* @param helper The opened saved-game file to load the Ruin objects
56
149
Ruinlist(XML_Helper* helper);
59
//! Loading callback. See XML_Helper as well.
152
//! Loading callback for loading Ruin objects into the list.
60
153
bool load(std::string tag, XML_Helper* helper);
155
//! A static pointer for the singleton instance.
62
156
static Ruinlist* s_instance;