namespace dkh { template struct TylerMapSource::LayerInfo { dk::HashType hash; uint32_t data_start; uint32_t data_length; }; template TylerMapSource::TylerMapSource (const char* parFilename) : m_stream(new std::ifstream(parFilename)), m_stream_start(m_stream->tellg()) { parse_map_data(*m_stream); } template TylerMapSource::TylerMapSource (const std::string& parFilename) : m_stream(new std::ifstream(parFilename)), m_stream_start(m_stream->tellg()) { parse_map_data(*m_stream); } template TylerMapSource::TylerMapSource (std::istream* parData) : m_stream(parData), m_stream_start(m_stream->tellg()) { parse_map_data(*m_stream); } template void TylerMapSource::parse_map_data (std::istream& parSrc) { //Read file header implem::TylerMapHeader header; implem::read_header(parSrc, header); if (header.dimensions != D) { throw InvalidMapDimensionsException(); } switch (header.map_type) { case dk::MapType_IsometricStaggered: m_map_type = dk::MapType_IsometricStaggered; break; case dk::MapType_Isometric: m_map_type = dk::MapType_Isometric; break; case dk::MapType_Orthogonal: m_map_type = dk::MapType_Orthogonal; break; case dk::MapType_Hex: m_map_type = dk::MapType_Hex; break; default: throw InvalidMapFileException(); } //Read map and tile dimensions { std::vector map_dims; std::vector tile_dims; const auto read_start = (header.dimensions_start > sizeof(header) ? header.dimensions_start - sizeof(header) : sizeof(header)); parSrc.seekg(read_start, std::ios_base::cur); implem::read_dimensions(parSrc, D, map_dims, tile_dims); for (std::size_t z = 0; z < map_dims.size(); ++z) { m_map_size[z] = map_dims[z]; m_tile_size[z] = tile_dims[z]; } } //Read vorbis comments parSrc.seekg(header.comment_start + m_stream_start, std::ios_base::beg); implem::read_comments(parSrc, m_file_vendor, m_comments); } template const typename TylerMapSource::coords& TylerMapSource::mapSize() const { return m_map_size; } template const typename TylerMapSource::coords& TylerMapSource::tileSize() const { return m_tile_size; } template void TylerMapSource::fetch_raw (char* parOut, const coords& parFrom, const coords& parTo, std::size_t parSize) { (void)parOut; (void)parFrom; (void)parTo; (void)parSize; } template dk::MapTypes TylerMapSource::mapType() const { return m_map_type; } template int TylerMapSource::layersCount() const { return m_layer_count; } template void TylerMapSource::chainedMaps (std::vector& parOut) const { implem::extract_array_from_comments(parOut, "chained_map", m_comments); } template dk::HashType TylerMapSource::layerTypeHash (int parIndex) const { DK_ASSERT(parIndex >= 0); DK_ASSERT(static_cast(parIndex) < m_layers_info.size()); return m_layers_info[parIndex].hash; } } //namespace dkh