34 lines
1.3 KiB
C++
34 lines
1.3 KiB
C++
namespace dk {
|
|
///-------------------------------------------------------------------------
|
|
///-------------------------------------------------------------------------
|
|
template <typename T, std::size_t D>
|
|
TileMapData<T, D>::TileMapData (std::unique_ptr<MapStreamBase<D>>&& parStream) :
|
|
m_mapstream(std::move(parStream))
|
|
{
|
|
}
|
|
|
|
///-------------------------------------------------------------------------
|
|
///-------------------------------------------------------------------------
|
|
template <typename T, std::size_t D>
|
|
void TileMapData<T, D>::fetch (std::vector<T>& parOut, const coords& parFrom, const coords& parTo) {
|
|
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);
|
|
}
|
|
|
|
///-------------------------------------------------------------------------
|
|
///-------------------------------------------------------------------------
|
|
template <typename T, std::size_t D>
|
|
const typename TileMapData<T, D>::coords& TileMapData<T, D>::mapSize() const {
|
|
return m_mapstream->mapSize();
|
|
}
|
|
} //namespace dk
|