~ubuntu-branches/ubuntu/raring/lordsawar/raring

« back to all changes in this revision

Viewing changes to src/ruinlist.h

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese, Barry deFreese, Gonéri Le Bouder
  • Date: 2008-06-17 11:15:26 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080617111526-yjyvu9df50zmpdo0
Tags: 0.0.9-1
[ Barry deFreese ]
* New upstream release.
  + Fixes gcc-4.3 builds so drop ftbfs_gcc-4.3_fix.diff.
  + Add new build-dependency for libgnet-dev.
* Add simple man page for new lordsawar-tile-editor.
* Add desktop file for lordsawar-tile-editor.
* Remove French translation on install.

[ Gonéri Le Bouder ]
* bump Debian Policy to 3.8.0. No change needed.
* fix wording in the 0.0.8-3 entry of the Debian changelog

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2000, 2001 Michael Bartl
 
2
// Copyright (C) 2001, 2003, 2004, 2005 Ulf Lorenz
 
3
// Copyright (C) 2004 John Farrell
 
4
// Copyright (C) 2007, 2008 Ben Asselstine
 
5
//
1
6
//  This program is free software; you can redistribute it and/or modify
2
7
//  it under the terms of the GNU General Public License as published by
3
8
//  the Free Software Foundation; either version 2 of the License, or
10
15
//
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
//  02110-1301, USA.
14
20
 
15
21
#ifndef RUINLIST_H
16
22
#define RUINLIST_H
17
23
 
18
24
#include "ruin.h"
19
 
#include "ObjectList.h"
 
25
#include "LocationList.h"
20
26
#include <sigc++/trackable.h>
21
27
 
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.
24
 
  */
25
 
 
26
 
class Ruinlist : public ObjectList<Ruin>, public sigc::trackable
 
28
//! A list of Ruin objects on the game map.
 
29
/** 
 
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 
 
32
 * up ruins.
 
33
 */
 
34
class Ruinlist : public LocationList<Ruin>, public sigc::trackable
27
35
{
28
36
    public:
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();
31
39
 
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);
34
42
 
35
 
        //! Explicitely deletes the singleton instance.
 
43
        //! Explicitly deletes the singleton instance.
36
44
        static void deleteInstance();
37
45
        
38
 
        
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;
41
48
 
42
 
        // Find the nearest ruin which has not been searched
 
49
        //! Find the nearest Ruin object that has not been searched.
 
50
        /**
 
51
         * Scan through all of the Ruin objects searching for the closest one
 
52
         * that has not already had a Hero successfully search it.
 
53
         *
 
54
         * @note This method does not return hidden ruins that do not belong
 
55
         *       to the active player.
 
56
         *
 
57
         * @param pos  The position on the game map to search for the nearest
 
58
         *             unsearched Ruin object from.
 
59
         *
 
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.
 
63
         */
43
64
        Ruin* getNearestUnsearchedRuin(const Vector<int>& pos);
44
 
        // Find the nearest ruin
 
65
 
 
66
        //! Find the nearest ruin.
 
67
        /**
 
68
         * Scan through all of the Ruin objects searching for the closest one.
 
69
         *
 
70
         * @note This method does not return hidden ruins that do not belong
 
71
         *       to the active player.
 
72
         *
 
73
         * @param pos  The position on the game map to search for the nearest
 
74
         *             Ruin object from.
 
75
         *
 
76
         * @return A pointer to the nearest Ruin object.  Returns NULL when 
 
77
         *         there are no Ruin object in this list.
 
78
         */
45
79
        Ruin* getNearestRuin(const Vector<int>& pos);
 
80
 
 
81
        //! Find the nearest ruin that is not too far away.
 
82
        /**
 
83
         * Scan through all of the Ruin objects searching for the closest one
 
84
         * that is no far than the given distance.
 
85
         *
 
86
         * @note This method does not return hidden ruins that do not belong
 
87
         *       to the active player.
 
88
         *
 
89
         * @param pos  The position on the game map to search for the nearest
 
90
         *             Ruin object from.
 
91
         * @param dist The number of tiles away that is deemed "too far".
 
92
         *
 
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.
 
96
         */
46
97
        Ruin* getNearestRuin(const Vector<int>& pos, int dist);
 
98
 
 
99
        //! Find the nearest Ruin object that is not obscured by fog.
 
100
        /**
 
101
         * Scan through all ruins, searching for the closest one that is
 
102
         * not covered by fog-of-war on a hidden map.
 
103
         *
 
104
         * @note This method does not return hidden ruins that do not belong
 
105
         *       to the active player.
 
106
         *
 
107
         * @param pos  The position to find the nearest ruin from.
 
108
         *
 
109
         * @return A pointer to the nearest ruin that is not obscured by fog.
 
110
         */
47
111
        Ruin* getNearestVisibleRuin(const Vector<int>& pos);
 
112
 
 
113
        //! Find the nearest ruin that is unobscured and is not too far away.
 
114
        /**
 
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.
 
118
         *
 
119
         * @note This method does not return hidden ruins that do not belong
 
120
         *       to the active player.
 
121
         *
 
122
         * @param pos  The position to find the nearest ruin from.
 
123
         * @param dist The number of tiles away that is deemed "too far".
 
124
         *
 
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.
 
128
         */
48
129
        Ruin* getNearestVisibleRuin(const Vector<int>& pos, int dist);
49
130
 
50
 
        //! Changes all ruins owned by old owner, to be owned by the new
51
 
        //! owner.
 
131
        //! Change ownership of all Ruin objects in the list.
 
132
        /**
 
133
         * Changes all ruins owned by old owner, to be owned by the new owner.
 
134
         */
52
135
        void changeOwnership(Player *old_owner, Player *new_owner);
53
136
 
54
137
    protected:
 
138
        //! Default constructor.
55
139
        Ruinlist();
 
140
 
 
141
        //! Loading constructor.
 
142
        /**
 
143
         * Make a new list of Road objects by loading it from an opened 
 
144
         * saved-game file.
 
145
         *
 
146
         * @param helper  The opened saved-game file to load the Ruin objects
 
147
         *                from.
 
148
         */
56
149
        Ruinlist(XML_Helper* helper);
57
150
 
58
151
    private:
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);
61
154
 
 
155
        //! A static pointer for the singleton instance.
62
156
        static Ruinlist* s_instance;
63
157
};
64
158