#ifndef id3F4AB2FAA29D4A0FA87760E61F0762C0 #define id3F4AB2FAA29D4A0FA87760E61F0762C0 #include "doorkeeper/primitivetypes.hpp" #include "doorkeeper/implem/vector.hpp" #include "doorkeeper/components/basemapsource.hpp" #include #include #include #include #include #include #include namespace dkh { template class TylerMapSource : public dk::BaseMapSource { public: typedef dk::Vector coords; typedef T MapTileType; enum { MapDimensions = D }; TylerMapSource ( void ) = delete; TylerMapSource ( const TylerMapSource& ) = delete; TylerMapSource ( TylerMapSource&& ) = default; explicit TylerMapSource ( const char* parFilename ); explicit TylerMapSource ( const std::string& parFilename ); explicit TylerMapSource ( std::istream* parData ); virtual ~TylerMapSource ( void ) noexcept = default; virtual const coords& mapSize ( void ) const; virtual const coords& tileSize ( void ) const; virtual void fetch ( std::vector& parOut, const coords& parFrom, const coords& parTo ); virtual dk::MapTypes mapType ( void ) const; virtual int layersCount ( void ) const; virtual void chainedMaps ( std::vector& parOut ) const; private: void parse_map_data ( std::istream& parSrc ); std::unique_ptr m_stream; }; class InvalidMapFileException : public std::exception { }; namespace implem { struct TylerMapHeader { uint32_t signature; uint32_t file_size; uint16_t version_major; uint16_t version_minor; uint8_t layer_count; uint8_t map_type; uint8_t map_info_type; uint8_t dimensions; } __attribute__((packed, aligned(__alignof__(uint32_t)))); typedef std::map CommentMap; void read_header ( std::istream& parStream, TylerMapHeader& parHeader ); void read_comments ( std::istream& parStream, std::string& parVendor, CommentMap& parComments ); } //namespace implem } //namespace dkh #endif