duncan
Mom and Dad were wrong!
|
00001 #ifndef MAP_MAP_H_ 00002 #define MAP_MAP_H_ 00003 00004 #include <vector> 00005 #include <fstream> 00006 #include <stdexcept> 00007 #include <string> 00008 #include "../network/network.h" 00009 00010 namespace map { 00011 00019 class Map { 00020 protected: 00021 size_t width_, height_; 00022 std::vector<char> map_; 00023 net::maphash_t hash_; 00024 00031 size_t encode(size_t r, size_t c) const { 00032 return r*width_+c; 00033 } 00034 00040 char tile(size_t r, size_t c) const { 00041 return map_[encode(r,c)]; 00042 } 00043 00044 static net::maphash_t hash(size_t,size_t,const std::vector<char>&); 00045 public: 00046 Map(); 00047 Map(const std::string&); 00048 virtual ~Map() {} 00049 00050 void reset(); 00051 00052 virtual bool load(const std::string&); 00053 00054 bool is_vacant(size_t,size_t) const; 00055 00056 size_t width() const; 00057 size_t height() const; 00058 00059 net::maphash_t hash(); 00060 00061 static net::maphash_t hash(const std::string&); 00062 }; 00063 00064 } // namespace 00065 00066 #endif