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

« back to all changes in this revision

Viewing changes to src/vectoredunitlist.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) 2007, 2008 Ben Asselstine
 
2
//
1
3
//  This program is free software; you can redistribute it and/or modify
2
4
//  it under the terms of the GNU General Public License as published by
3
5
//  the Free Software Foundation; either version 2 of the License, or
10
12
//
11
13
//  You should have received a copy of the GNU General Public License
12
14
//  along with this program; if not, write to the Free Software
13
 
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
15
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
 
16
//  02110-1301, USA.
14
17
 
15
18
#ifndef VECTOREDUNITLIST_H
16
19
#define VECTOREDUNITLIST_H
17
20
 
18
21
#include "vectoredunit.h"
19
 
#include "ObjectList.h"
 
22
#include "LocationList.h"
20
23
#include <sigc++/trackable.h>
21
24
 
22
25
class City;
23
 
/** An object list which keeps track of all vectoredunits. It cannot do much more than
24
 
  * saving and loading the elements. Implemented as a singleton again.
25
 
  */
26
 
 
 
26
//! A list of VectoredUnit objects.
 
27
/** 
 
28
 * This class loads and saves the VectoredUnit objects in the game.  It 
 
29
 * facilitates looking up VectoredUnit objects in the list.
 
30
 *
 
31
 * This class is loaded from, and saved to the lordsawar.vectoredunitlist XML
 
32
 * entity in the saved-game file.
 
33
 *
 
34
 * Implemented as a singleton.
 
35
 */
27
36
class VectoredUnitlist : public std::list<VectoredUnit*>, public sigc::trackable
28
37
{
29
38
    public:
30
 
        //! Returns the singleton instance. Creates a new one if required.
 
39
        //! Gets the singleton instance or creates a new one.
31
40
        static VectoredUnitlist* getInstance();
32
41
 
33
 
        //! Loads the singleton instance with a savegame.
 
42
        //! Loads the VectoredUnitlist from a saved-game file.
 
43
        /**
 
44
         * Load all VectoredUnit objects in the VectoredUnitlist from a 
 
45
         * saved-game file.
 
46
         *
 
47
         * @param helper     The opened saved-game file to read from.
 
48
         *
 
49
         * @return The loaded VectoredUnitlist.
 
50
         */
34
51
        static VectoredUnitlist* getInstance(XML_Helper* helper);
35
52
 
36
 
        //! Explicitely deletes the singleton instance.
 
53
        //! Explicitly deletes the singleton instance.
37
54
        static void deleteInstance();
38
55
        
39
 
        //! updates the vectored units belonging to the player
 
56
        //! Processes all VectoredUnit objects belonging to the given Player.
40
57
        void nextTurn(Player* p);
41
58
 
42
 
        //! Save function. See XML_Helper for details.
 
59
        //! Save the list of VectoredUnit objects to a saved-game file.
43
60
        bool save(XML_Helper* helper) const;
44
61
 
45
 
        //! When destination cities get conquered, this list needs to be 
46
 
        //! cleaned up.
 
62
        //! Cull the list of VectoredUnit objects going to the given position.
 
63
        /**
 
64
         * Scan through the VectoredUnitlist for VectoredUnit objects that
 
65
         * have the given destination position on the game map.  When found, 
 
66
         * remove it from the list.
 
67
         *
 
68
         * When a planted standard is picked up by another Player's Hero this
 
69
         * method is called.
 
70
         *
 
71
         * @param pos  Any VectoredUnit object in the list that is being
 
72
         *             vectored to this tile is deleted from the list.
 
73
         */
47
74
        void removeVectoredUnitsGoingTo(Vector<int> pos);
48
 
        void removeVectoredUnitsGoingTo(City *c);
49
 
 
50
 
        //! When source cities get conquered, this list needs to be 
51
 
        //! cleaned up.
 
75
 
 
76
        //! Cull the list of VectoredUnit objects going to the given city.
 
77
        /**
 
78
         * Scan through the VectoredUnitlist for VectoredUnit objects that
 
79
         * have a destination position of the given city.  When found, remove
 
80
         * it from the list.
 
81
         *
 
82
         * This method gets called when a destination city is conquered.
 
83
         *
 
84
         * @param city  Any VectoredUnit object in the list that is being
 
85
         *              vectored to one of the tiles in this City are deleted
 
86
         *              from the list.
 
87
         */
 
88
        void removeVectoredUnitsGoingTo(City *city);
 
89
 
 
90
        //! Cull the list of VectoredUnit objects being vectored from a place.
 
91
        /**
 
92
         * Scan through the VectoredUnitlist for VectoredUnit objects that
 
93
         * have a source tile of the given position on the game map.  When 
 
94
         * found, remove the VectoredUnit object from this list.
 
95
         *
 
96
         * When a source city gets conquered, VectoredUnit objects need to be
 
97
         * deleted from this list.
 
98
         *
 
99
         * @param pos  Any VectoredUnit object in the list that is being
 
100
         *             vectored from this tile is deleted from the list.
 
101
         */
52
102
        void removeVectoredUnitsComingFrom(Vector<int> pos);
53
 
        void removeVectoredUnitsComingFrom(City *c);
54
 
 
55
 
        //! When showing info we need to know who's going to where.
56
 
        //! vectored is filled up with the results.
57
 
        void getVectoredUnitsGoingTo(Vector<int> pos, std::list<VectoredUnit*>& vectored);
58
 
        void getVectoredUnitsGoingTo(City *c, std::list<VectoredUnit*>& vectored);
59
 
 
60
 
        //! When showing info we need to know who's coming from where.
61
 
        //! vectored is filled up with the results.
62
 
        void getVectoredUnitsComingFrom(Vector<int> pos, std::list<VectoredUnit*>& vectored);
63
 
 
64
 
        //! Instead of returning the the vector, just return how many units
65
 
        //! are going to a particular destination.
 
103
 
 
104
        //! Cull the list of VectoredUnit objects coming from the given city.
 
105
        /**
 
106
         * Scan through the VectoredUnitlist for VectoredUnit objects that
 
107
         * have a source position of a tile in the given city.  When found, 
 
108
         * remove it from the list.
 
109
         *
 
110
         * This method gets called when a destination city is conquered.
 
111
         *
 
112
         * @param city  Any VectoredUnit object in the list that is being
 
113
         *              vectored to one of the tiles in this City are deleted
 
114
         *              from the list.
 
115
         */
 
116
        void removeVectoredUnitsComingFrom(City *city);
 
117
 
 
118
        //! Return the list of VectoredUnit objects with the given destination.
 
119
        /**
 
120
         * Scan through the list of VectoredUnit objects for the ones that are
 
121
         * being vectored to the given position.  Return all of the 
 
122
         * VectoredUnit objects that match.
 
123
         *
 
124
         * This method is used for showing who's going where.
 
125
         *
 
126
         * @param pos  Any VectoredUnit object in the list that is being
 
127
         *             vectored to this tile is returned.
 
128
         *
 
129
         * @param vectored  This list is filled with the VectoredUnit objects 
 
130
         *                  being vectored to the given position.
 
131
         */
 
132
        void getVectoredUnitsGoingTo(Vector<int> pos, 
 
133
                                     std::list<VectoredUnit*>& vectored);
 
134
 
 
135
        //! Return the list of VectoredUnit objects going to the given city.
 
136
        /**
 
137
         * Scan through the list of VectoredUnit objects for the ones that are
 
138
         * being vectored to the tiles on the game map assocaited with the
 
139
         * given city.  Return all of the VectoredUnit objects that match.
 
140
         *
 
141
         * This method is used for showing who's going where.
 
142
         *
 
143
         * @param city  Any VectoredUnit object in the list that is being
 
144
         *              vectored to this city is returned.
 
145
         *
 
146
         * @param vectored  This list is filled with the VectoredUnit objects 
 
147
         *                  being vectored to the given city.
 
148
         */
 
149
        void getVectoredUnitsGoingTo(City *city, 
 
150
                                     std::list<VectoredUnit*>& vectored);
 
151
 
 
152
        //! Return the list of VectoredUnit objects with the given source.
 
153
        /**
 
154
         * Scan through the list of VectoredUnit objects for the ones that are
 
155
         * being vectored from the given position.  Return all of the 
 
156
         * VectoredUnit objects that match.
 
157
         *
 
158
         * This method is used for showing who's coming from where.
 
159
         *
 
160
         * @param pos  Any VectoredUnit object in the list that is being
 
161
         *             vectored from this tile is returned.
 
162
         *
 
163
         * @param vectored  This list is filled with the VectoredUnit objects 
 
164
         *                  being vectored from the given position.
 
165
         */
 
166
        void getVectoredUnitsComingFrom(Vector<int> pos, 
 
167
                                        std::list<VectoredUnit*>& vectored);
 
168
 
 
169
        //! Return the number of VectoredUnits being vectored to a given place.
 
170
        /**
 
171
         * Scan through all of the VectoredUnit objects in the list for ones
 
172
         * that are being vectored to the given position on the game map.
 
173
         * Count all of the matching VectoredUnit objects, and return the
 
174
         * count.
 
175
         *
 
176
         * @return The number of VectoredUnit objects that are being vectored
 
177
         *         to the given position on the game map.
 
178
         */
66
179
        Uint32 getNumberOfVectoredUnitsGoingTo(Vector<int> pos);
67
180
 
68
181
        //! Change the destination of vectored units as they are "in the air".
69
 
        void changeDestination(City *c, Vector<int> new_dest);
 
182
        /**
 
183
         * Scan through all of the VectoredUnit objects in the list for the
 
184
         * ones that are being vectored to the given city.  When found,
 
185
         * change the destination to be the given destination.
 
186
         *
 
187
         * @param city     A pointer to the city to change VectoredUnit objects
 
188
         *                 from going to.
 
189
         * @param new_dest A position on the game map to change where the
 
190
         *                 VectoredUnit objects are going to.
 
191
         */
 
192
        void changeDestination(City *city, Vector<int> new_dest);
70
193
 
71
194
    protected:
 
195
 
 
196
        //! Default constructor.
72
197
        VectoredUnitlist();
 
198
        //! Loading constructor.
 
199
        VectoredUnitlist(XML_Helper* helper);
 
200
        //! Destructor.
73
201
        ~VectoredUnitlist();
74
 
        VectoredUnitlist(XML_Helper* helper);
75
202
 
76
203
    private:
77
 
        //! Loading callback. See XML_Helper as well.
 
204
 
 
205
        //! Callback for loading the VectoredUnitlist from a saved-game file.
78
206
        bool load(std::string tag, XML_Helper* helper);
79
207
 
 
208
        //! A static pointer for the singleton instance.
80
209
        static VectoredUnitlist* s_instance;
81
210
};
82
211