2014-12-29 15:17:59 +00:00
|
|
|
namespace dk {
|
|
|
|
///-------------------------------------------------------------------------
|
|
|
|
///-------------------------------------------------------------------------
|
|
|
|
template <typename T, std::size_t D>
|
2015-01-05 17:01:28 +00:00
|
|
|
TileMapData<T, D>::TileMapData (std::unique_ptr<MapStreamBase<D>>&& parStream) :
|
|
|
|
m_mapstream(std::move(parStream))
|
2014-12-29 15:17:59 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
///-------------------------------------------------------------------------
|
|
|
|
///-------------------------------------------------------------------------
|
|
|
|
template <typename T, std::size_t D>
|
|
|
|
void TileMapData<T, D>::fetch (std::vector<T>& parOut, const coords& parFrom, const coords& parTo) {
|
2015-01-05 17:01:28 +00:00
|
|
|
DK_ASSERT(parFrom >= coords(0));
|
|
|
|
DK_ASSERT(parFrom < parTo);
|
|
|
|
DK_ASSERT(parFrom < m_mapstream->mapSize());
|
|
|
|
DK_ASSERT(parTo <= m_mapstream->mapSize());
|
|
|
|
|
|
|
|
const auto tileCount = implem::area(parTo - parFrom);
|
|
|
|
parOut.resize(tileCount);
|
|
|
|
m_mapstream->read(
|
|
|
|
reinterpret_cast<char*>(parOut.data()),
|
|
|
|
parOut.size() * sizeof(typename std::vector<T>::value_type),
|
|
|
|
parFrom,
|
|
|
|
parTo);
|
2014-12-29 15:17:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///-------------------------------------------------------------------------
|
|
|
|
///-------------------------------------------------------------------------
|
|
|
|
template <typename T, std::size_t D>
|
|
|
|
const typename TileMapData<T, D>::coords& TileMapData<T, D>::mapSize() const {
|
2015-01-05 17:01:28 +00:00
|
|
|
return m_mapstream->mapSize();
|
2014-12-29 15:17:59 +00:00
|
|
|
}
|
|
|
|
} //namespace dk
|