00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef mapalgorithmsH
00019 #define mapalgorithmsH
00020
00021 #include "typen.h"
00022 #include "vehicle.h"
00023 #include "loki/Functor.h"
00024 #include "loki/Typelist.h"
00025
00028 class SearchFields {
00029 protected:
00030 GameMap* gamemap;
00031 MapCoordinate startPos;
00032 bool cancelSearch;
00033 int firstDistance, lastDistance;
00034 int dist;
00035 virtual void testfield ( const MapCoordinate& pos ) = 0;
00036 public:
00037 SearchFields ( GameMap* _gamemap );
00038 void initsearch ( const MapCoordinate& startPosition, int _firstDistance, int _lastDistance );
00039 virtual void startsearch ( void );
00040 virtual ~SearchFields() {};
00041 };
00042
00043 typedef Loki::Functor<void, LOKI_TYPELIST_1(const MapCoordinate&) > FieldIterationFunctor;
00044 extern void circularFieldIterator( GameMap* gamemap, const MapCoordinate& center, int startDist, int stopDist, FieldIterationFunctor functor );
00045
00046
00050 class tdrawgettempline {
00051 int freefields;
00052 int num;
00053 int sx, sy;
00054
00055 static int initialized;
00056 static double dirs[ sidenum ];
00057 static double offset;
00058
00059 void init ( void );
00060
00061 protected:
00062 GameMap* gamemap;
00063
00064 public:
00065 int tempsum;
00066 tdrawgettempline ( int _freefields, GameMap* _gamemap );
00067
00068 void start ( int x1, int y1, int x2, int y2 );
00069
00070 virtual void putpix8 ( int x, int y );
00071 double winkel ( int x, int y );
00072 int winkelcomp ( double w1, double w2 );
00073 virtual ~tdrawgettempline() {};
00074 };
00075
00077 extern void getnextfield(int & x,
00078 int & y,
00079 int direc);
00080
00082 extern MapCoordinate3D getNeighbouringFieldCoordinate( const MapCoordinate3D& pos, int direc);
00083 extern MapCoordinate getNeighbouringFieldCoordinate( const MapCoordinate & pos, int direc);
00084
00085
00089 extern int getdirection( int x1,
00090 int y1,
00091 int x2,
00092 int y2);
00093 extern int getdirection( const MapCoordinate& start, const MapCoordinate& dest );
00094
00096 extern int beeline ( int x1, int y1, int x2, int y2 );
00097
00099 extern int beeline ( const Vehicle* a, const Vehicle* b );
00100
00102 extern int beeline ( const MapCoordinate& a, const MapCoordinate& b );
00103
00105 class WindMovement {
00106 int wm[6];
00107 public:
00108 WindMovement ( const Vehicle* vehicle );
00109 int getDist ( int dir );
00110 };
00111
00112
00113 #endif
00114