~ubuntu-branches/ubuntu/natty/spring/natty

« back to all changes in this revision

Viewing changes to rts/Sim/Path/PathManager.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Ritchie
  • Date: 2010-09-23 18:56:03 UTC
  • mfrom: (3.1.9 experimental)
  • Revision ID: james.westby@ubuntu.com-20100923185603-st97s5chplo42y7w
Tags: 0.82.5.1+dfsg1-1ubuntu1
* Latest upstream version for online play
* debian/control: Replace (rather than conflict) spring-engine
  - spring-engine will be a dummy package (LP: #612905)
  - also set maintainer to MOTU

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
 
2
 
1
3
#ifndef PATHMANAGER_H
2
4
#define PATHMANAGER_H
3
5
 
4
6
#include <map>
 
7
#include <boost/cstdint.hpp> /* Replace with <stdint.h> if appropriate */
 
8
 
5
9
#include "IPath.h"
6
 
#include <boost/cstdint.hpp> /* Replace with <stdint.h> if appropriate */
7
10
 
8
11
class CSolidObject;
9
12
class CPathFinder;
17
20
        CPathManager();
18
21
        ~CPathManager();
19
22
 
20
 
        /*
 
23
        /**
21
24
        Generate a path from startPos to the target defined by either peDef or (goalPos, goalRadius).
22
25
        If no complete path from startPos to the path target could be found, then a path getting as
23
26
        "close" as possible to target is generated.
41
44
                        Use goalRadius to define a goal area within any square could be accepted as path target.
42
45
                        If a singular goal position is wanted, then use goalRadius = 0.
43
46
        */
44
 
        unsigned int RequestPath(const MoveData* moveData, float3 startPos,
45
 
                        float3 goalPos, float goalRadius = 8, CSolidObject* caller = 0);
46
 
 
47
 
        unsigned int RequestPath(const MoveData* moveData, float3 startPos,
48
 
                        CPathFinderDef* peDef,float3 goalPos, CSolidObject* caller);
49
 
 
50
 
 
51
 
        /*
 
47
        unsigned int RequestPath(
 
48
                const MoveData* moveData,
 
49
                float3 startPos, float3 goalPos, float goalRadius = 8,
 
50
                CSolidObject* caller = 0,
 
51
                bool synced = true
 
52
        );
 
53
 
 
54
        unsigned int RequestPath(
 
55
                const MoveData* moveData,
 
56
                float3 startPos,
 
57
                CPathFinderDef* peDef,
 
58
                float3 goalPos,
 
59
                CSolidObject* caller,
 
60
                bool synced = true
 
61
        );
 
62
 
 
63
 
 
64
        /**
52
65
        Gives the next waypoint of the path.
53
 
        Gives (-1,-1,-1) in case no new waypoint could be found.
 
66
        Returns (-1,-1,-1) in case no new waypoint could be found.
54
67
        Param:
55
68
                pathId
56
69
                        The path-id returned by RequestPath.
57
70
 
58
71
                callerPos
59
72
                        The current position of the user of the path.
60
 
                        This extra information is needed to keep the path connected to it's user.
 
73
                        This extra information is needed to keep the path connected to its user.
61
74
 
62
75
                minDistance
63
76
                        Could be used to set a minimum required distance between callerPos and
67
80
 
68
81
        */
69
82
        float3 NextWaypoint(unsigned int pathId, float3 callerPos, float minDistance = 0,
70
 
                        int numRetries=0, int ownerId = 0) const;
 
83
                        int numRetries=0, int ownerId = 0, bool synced = true) const;
71
84
 
72
85
 
73
86
        /**
94
107
        void GetDetailedPathSquares(unsigned pathId, std::vector<int2>& points) const;
95
108
 
96
109
 
97
 
        /*
 
110
        /**
98
111
        Returns current estimated waypoints sorted by estimation levels
99
112
        Param:
100
113
                pathId
108
121
                std::vector<float3>& points, std::vector<int>& starts) const;
109
122
 
110
123
 
111
 
        /*
 
124
        /**
112
125
        When a path are no longer used, please call this function to release it from memory.
113
126
        Param:
114
127
                pathId
117
130
        void DeletePath(unsigned int pathId);
118
131
 
119
132
 
120
 
        /*
 
133
        /**
121
134
        Whenever there are any changes in the terrain (ex. explosions, new buildings, etc.)
122
135
        this function need to be called to keep the estimator a jour.
123
136
        Param:
130
143
        void TerrainChange(float3 upperCorner, float3 lowerCorner);
131
144
        void TerrainChange(unsigned int x1, unsigned int z1, unsigned int x2, unsigned int z2);
132
145
 
133
 
 
134
 
        /*
135
 
        Shall be called every 1/30sec during runtime.
136
 
        */
137
146
        void Update();
138
 
 
139
 
 
140
 
        /*
141
 
        Visualize all paths currently keept in the database.
142
 
        */
143
 
        void Draw();
144
 
 
145
 
 
146
 
        boost::uint32_t GetPathChecksum();
 
147
        void UpdatePath(const CSolidObject*, unsigned int);
 
148
 
 
149
 
 
150
 
 
151
        boost::uint32_t GetPathCheckSum();
147
152
 
148
153
        /** Enable/disable heat mapping */
149
154
        void SetHeatMappingEnabled(bool enabled);
150
155
        bool GetHeatMappingEnabled();
151
156
 
152
157
        void SetHeatOnSquare(int x, int y, int value, int ownerId);
153
 
        void SetHeatOnPos(float3, int value, int ownerId);
 
158
        const int GetHeatOnSquare(int x, int y);
154
159
 
155
160
        //Minimum distance between two waypoints.
156
161
        static const unsigned int PATH_RESOLUTION;
160
165
                MultiPath(const float3 start, const CPathFinderDef* peDef, const MoveData* moveData);
161
166
                ~MultiPath();
162
167
 
163
 
                //Paths
 
168
                // Paths
164
169
                IPath::Path estimatedPath2;
165
170
                IPath::Path estimatedPath;
166
171
                IPath::Path detailedPath;
 
172
                IPath::SearchResult searchResult;
167
173
 
168
174
                //Request definition
169
175
                const float3 start;
170
176
                const CPathFinderDef* peDef;
171
177
                const MoveData* moveData;
172
178
 
173
 
                //Additional information.
 
179
                // Additional information.
174
180
                float3 finalGoal;
175
181
                CSolidObject* caller;
176
182
        };
177
183
 
178
184
 
179
185
        unsigned int Store(MultiPath* path);
180
 
        void Estimate2ToEstimate(MultiPath& path, float3 startPos, int ownerId) const;
 
186
        void Estimate2ToEstimate(MultiPath& path, float3 startPos, int ownerId, bool synced) const;
181
187
        void EstimateToDetailed(MultiPath& path, float3 startPos, int ownerId) const;
182
188
 
183
189
 
189
195
        unsigned int nextPathId;
190
196
};
191
197
 
192
 
extern CPathManager *pathManager;
 
198
extern CPathManager* pathManager;
193
199
 
194
200
#endif