Planeshift
pspathnetwork.h
Go to the documentation of this file.
1 /*
2  * pspathnetwork.h
3  *
4  * Copyright (C) 2007 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 #ifndef __PSPATHNETWORK_H__
20 #define __PSPATHNETWORK_H__
21 
22 #include <csutil/array.h>
23 #include <csutil/list.h>
24 
25 #include <idal.h>
26 
27 #include "util/pspath.h"
28 
29 class Edge;
30 class Waypoint;
31 class WaypointAlias;
32 class psPath;
33 class psWorld;
34 
43 {
44 public:
45 
50  {
51  public:
55  virtual bool Filter(const Waypoint* wp) const = 0;
56  };
57 
58 
59  csPDelArray<Waypoint> waypoints;
60  csPDelArray<psPath> paths;
61 
62  csArray<csString> waypointGroupNames;
63  csArray< csList<Waypoint*> > waypointGroups;
64 
65  csWeakRef<iEngine> engine;
66  csWeakRef<iDataConnection> db;
68 
69 
73  bool Load(iEngine *engine, iDataConnection *db, psWorld * world);
74 
79  size_t AddWaypointToGroup(csString group, Waypoint * wp);
80 
84  Waypoint *FindWaypoint(int id);
85 
92  Waypoint *FindWaypoint(const char * name, WaypointAlias** alias = NULL);
93 
100  Waypoint *FindWaypoint(const csVector3& v, iSector *sector);
101 
111  Waypoint *FindNearestWaypoint(const csVector3& v,iSector *sector, float range, float * found_range = NULL);
112 
122  Waypoint *FindRandomWaypoint(const csVector3& v, iSector *sector, float range, float * found_range = NULL);
123 
134  Waypoint *FindNearestWaypoint(int group, const csVector3& v,iSector *sector, float range, float * found_range = NULL);
135 
146  Waypoint *FindRandomWaypoint(int group, const csVector3& v, iSector *sector, float range, float * found_range = NULL);
147 
151  int FindWaypointGroup(const char * groupName);
152 
156  psPathPoint* FindPathPoint(int id);
157 
167  psPathPoint* FindPoint(const psPath* path, const csVector3& pos, iSector* sector, float range, int& index);
168 
177  psPathPoint* FindNearestPoint(const psPath* path, const csVector3& v, const iSector *sector, float range);
178 
190  psPath *FindNearestPath(const csVector3& v, iSector *sector, float range, float * found_range = NULL, int * index = NULL, float * fraction = NULL);
191 
202  psPath *FindNearestPoint(const csVector3& v, iSector *sector, float range, float * found_range = NULL, int * index = NULL);
203 
207  csList<Waypoint*> FindWaypointRoute(Waypoint * start, Waypoint * end, const RouteFilter* routeFilter);
208 
212  csList<Edge*> FindEdgeRoute(Waypoint * start, Waypoint * end, const RouteFilter* routeFilter);
213 
217  size_t FindPointsInSector(iSector *sector, csList<psPathPoint*>& list);
218 
222  size_t FindWaypointsInSector(iSector *sector, csList<Waypoint*>& list);
223 
224 
228  void ListWaypoints(const char *pattern);
229 
233  void ListPaths(const char *pattern);
234 
238  psPath* FindPath(const char *name);
239 
243  psPath* FindPath(int id);
244 
248  Edge* FindEdge(const Waypoint * wp1, const Waypoint * wp2);
249 
250 
254  Waypoint* CreateWaypoint( iDataConnection *db, csString& name, csVector3& pos, csString& sectorName, float radius, csString& flags);
255 
259  Waypoint* CreateWaypoint( csString& name, csVector3& pos, csString& sectorName, float radius, csString& flags);
260 
264  psPath* CreatePath(iDataConnection *db, const csString& name, Waypoint* wp1, Waypoint* wp2, const csString& flags);
265 
269  psPath* CreatePath(iDataConnection *db, psPath * path);
270 
274  psPath* CreatePath(psPath * path);
275 
279  int GetNextWaypointCheck();
280 
284  bool Delete(psPath * path);
285 };
286 
289 #endif
psWorld is in charge of managing all regions (zone map files) and loading/unloading them as needed...
Definition: psworld.h:47
int FindWaypointGroup(const char *groupName)
Find the index for the given group name, return -1 if no group is found.
Waypoint * FindNearestWaypoint(const csVector3 &v, iSector *sector, float range, float *found_range=NULL)
Find waypoint nearest to a point in the world.
bool Load(iEngine *engine, iDataConnection *db, psWorld *world)
Load all waypoins and paths from db.
Class to hold information regarding aliases for waypoints.
Definition: waypoint.h:38
size_t FindPointsInSector(iSector *sector, csList< psPathPoint * > &list)
Get a list of points in a sector.
void ListWaypoints(const char *pattern)
List all waypoints matching pattern to console.
size_t FindWaypointsInSector(iSector *sector, csList< Waypoint * > &list)
Get a list of waypoints in a sector.
Definition: pspath.h:152
Waypoint * FindWaypoint(int id)
Find waypoint by id.
csPDelArray< Waypoint > waypoints
Definition: pspathnetwork.h:59
csWeakRef< iDataConnection > db
Definition: pspathnetwork.h:66
Represents the Edge in a PathNetwork.
Definition: edge.h:39
psPath * FindNearestPath(const csVector3 &v, iSector *sector, float range, float *found_range=NULL, int *index=NULL, float *fraction=NULL)
Find the path nearest to a point in the world.
A waypoint is a specified circle on the map with a name, location, and a list of waypoints it is conn...
Definition: waypoint.h:81
csArray< csList< Waypoint * > > waypointGroups
Definition: pspathnetwork.h:63
csPDelArray< psPath > paths
Definition: pspathnetwork.h:60
csList< Waypoint * > FindWaypointRoute(Waypoint *start, Waypoint *end, const RouteFilter *routeFilter)
Find the shortest route between waypoint start and stop.
psPath * CreatePath(iDataConnection *db, const csString &name, Waypoint *wp1, Waypoint *wp2, const csString &flags)
Create a new path/connection/link between two waypoints.
csArray< csString > waypointGroupNames
Definition: pspathnetwork.h:62
csWeakRef< iEngine > engine
Definition: pspathnetwork.h:65
psPathPoint * FindNearestPoint(const psPath *path, const csVector3 &v, const iSector *sector, float range)
Find the path nearest to a point in the world.
void ListPaths(const char *pattern)
List all paths matching pattern to console.
Edge * FindEdge(const Waypoint *wp1, const Waypoint *wp2)
Find a given edge from starting waypoint wp1 to end waypoint wp2.
Waypoint * FindRandomWaypoint(const csVector3 &v, iSector *sector, float range, float *found_range=NULL)
Find random waypoint within a given range to a point in the world.
psWorld * world
Definition: pspathnetwork.h:67
psPathPoint * FindPoint(const psPath *path, const csVector3 &pos, iSector *sector, float range, int &index)
Find the point nearest to the path.
bool Delete(psPath *path)
Delete the given path from the db.
psPath * FindPath(const char *name)
Find the named path.
virtual bool Filter(const Waypoint *wp) const =0
Called to check if a waypoint should be filters.
Template class for implementing waypoint filtering when calculating routes.
Definition: pspathnetwork.h:49
A network of Waypoint and psPath objects.
Definition: pspathnetwork.h:42
csList< Edge * > FindEdgeRoute(Waypoint *start, Waypoint *end, const RouteFilter *routeFilter)
Find the shortest route between waypoint start and stop.
Represents a point on a path between two waypoints.
Definition: pspath.h:58
int GetNextWaypointCheck()
Get next unique number for waypoint checking.
size_t AddWaypointToGroup(csString group, Waypoint *wp)
Add a new waypoint to the given group.
Waypoint * CreateWaypoint(iDataConnection *db, csString &name, csVector3 &pos, csString &sectorName, float radius, csString &flags)
Create a new waypoint and insert in db.
psPathPoint * FindPathPoint(int id)
Find path point by id.