00001 00002 #ifndef __MAP_HPP__ 00003 #define __MAP_HPP__ 00004 00005 #include <iostream> 00006 #include <sstream> 00007 00008 using namespace std; 00009 00010 #if defined( WIN32 ) && defined( TUNE ) 00011 #include <crtdbg.h> 00012 _CrtMemState startMemState; 00013 _CrtMemState endMemState; 00014 #endif 00015 00016 #include "library/tinyxml/tinyxml.h" 00017 00018 00019 00020 #include <string> 00021 00022 #include "vect2.hpp" 00023 #include "stringA.hpp" 00024 00025 00027 typedef enum { 00028 C_EMPTY = 0, 00029 C_LAND, 00030 C_DIAM, 00031 C_STONE, 00032 C_AMOEBA, 00033 C_MINEUR, 00034 C_STONE_WALL_1, 00035 C_STONE_WALL_2, 00036 C_STONE_WALL_3, 00037 C_STONE_WALL_4, 00038 C_MONSTER_RED = 16, 00039 C_MONSTER_BLUE, 00040 C_INDESTRUCTIBLE_WALL_1 = 20, 00041 C_INDESTRUCTIBLE_WALL_2, 00042 C_EXIT, 00043 00044 C_DIAM_BLUE = 25, 00045 C_DIAM_GREEN, 00046 C_DIAM_PURPLE, 00047 C_DIAM_RED, 00048 C_DIAM_YELLOW, 00049 } CASE; 00050 00052 #define NB_CASE 29 // 22 00053 00055 extern string caseStringDefinition[]; 00056 00057 00059 00062 class map 00063 { 00064 private: 00065 CASE** T; 00067 string name; 00068 unsigned short width; 00069 unsigned short height; 00070 unsigned short nbNeededDiam; 00071 00072 vect2 gateway; 00073 00074 bool readOnly; 00075 00076 void emptyT(void); 00077 void dealData(const string& data); 00078 string createData(void) const; 00079 TiXmlElement* getDifficultyTiXml(const char* difficulty) const; 00080 00081 public: 00082 00084 map(void); 00085 00087 map(const map&); 00088 00090 ~map(void); 00091 00093 void set_size(const unsigned short newWidth, const unsigned short newHeight); 00094 00096 void set_name(const string& name) { this->name = name; } 00097 00099 void set_readOnly(const bool readOnly) { this->readOnly = readOnly; } 00100 00102 void set_gateway(const vect2& gateway) { this->gateway = gateway; } 00103 00105 void set_nbNeededDiam(unsigned short nb) { this->nbNeededDiam = nb; } 00106 00108 unsigned short get_width (void) const { return width; } 00109 00111 unsigned short get_height(void) const { return height; } 00112 00114 void load(const string& fileName); 00115 00117 void save(const string& fileName) const; 00118 00120 00123 CASE* operator[](const unsigned short x) { return T[x]; } 00124 00125 }; 00126 00127 void changeFileIntoPlainText(const string& fileName); 00128 00129 #endif // __MAP_HPP__