00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _MAP_H
00012 #define _MAP_H
00013
00014 #include <fstream.h>
00015 #include "mapnode.h"
00016
00017
00018
00019
00020
00021 const int FIRST= 1;
00022 const char FIELD= ';';
00023 const char SUB1= '(';
00024 const char SUB2= ')';
00025 const char EOLN= '\n';
00026
00027 class Map {
00028
00029 private:
00030
00031 int numNodes,
00032 maxX,
00033 maxY;
00034
00035 MapNode *nodes;
00036 ifstream mapFile;
00037
00038 void initialize(int *array, int size);
00039 void get_field(int, mode);
00040
00041 public:
00042 Map(void) { numNodes= 0; nodes= NULL; maxX= 0; maxY= 0; }
00043 ~Map() { delete [] nodes; }
00044
00045 bool load_map(char*);
00046 void show_map(void);
00047
00048 int max_x(void) { return maxX; }
00049 int max_y(void) { return maxY; }
00050
00051 int x(int node) { return nodes[node].x; }
00052 int y(int node) { return nodes[node].y; }
00053
00054 int first_node(void) { return FIRST; }
00055 int num_nodes(void) { return numNodes; }
00056
00057
00058 int connected_to(int, int, int= -1);
00059 int num_connections(int, int= -1);
00060 char* get_name(int node) { return nodes[node].find_name(node); }
00061
00062 int next_short(int, int, bool, bool, bool);
00063
00064 bool taxi(int node) { return nodes[node].is_link(Taxi); }
00065 bool bus(int node) { return nodes[node].is_link(Bus); }
00066 bool subway(int node) { return nodes[node].is_link(Subway); }
00067
00068 bool taxi(int fromNode, int toNode)
00069 { return nodes[fromNode].is_link(toNode, Taxi); }
00070
00071 bool bus(int fromNode, int toNode)
00072 { return nodes[fromNode].is_link(toNode, Bus); }
00073
00074 bool subway(int fromNode, int toNode)
00075 { return nodes[fromNode].is_link(toNode, Subway); }
00076
00077 vect vehicle(int fromNode, int toNode)
00078 { return nodes[fromNode].find_vector(toNode); }
00079 };
00080
00081
00082 extern Map theMap;
00083
00084
00085 #endif
00086
00087
00088
00089
00090