DoorKeeper/include/doorkeeper/implem/tyler.inl
King_DuckZ 701366bf86 Replace size_t with uint32_t for template parameter D
This fixes the build on 64-bit machines, where size_t and uint32_t from vector.hpp would mismatch.
2015-01-08 12:20:17 +01:00

55 lines
2.1 KiB
C++

namespace dk {
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <uint32_t D>
Tyler<D>::Tyler (const coords& parSize, const coords& parTileSize) :
m_size(parSize),
m_tilesize(parTileSize)
{
assert(m_size.x() > 0 and m_size.y() > 0);
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <uint32_t D>
typename Tyler<D>::coords::value_type Tyler<D>::tiles_count() const {
typename coords::value_type retval = 1;
for (size_t d = 0; d < D; ++d) {
retval *= m_size[d];
}
return retval;
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <uint32_t D>
template <typename T>
Layer<T, D>& Tyler<D>::push_layer (TileMapData<T, D>& parTilemap) {
auto newLayer = new Layer<T, D>(m_tilesize, m_tilesize, parTilemap);
DK_ASSERT(newLayer->mapSize() == m_size);
DK_ASSERT(newLayer->count() == m_size);
m_layers.push_back(LayerPtr(newLayer));
return *newLayer;
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <uint32_t D>
template <typename T>
Layer<T, D>& Tyler<D>::push_layer (TileMapData<T, D>& parTilemap, const coords& parSubdiv) {
auto newLayer = new Layer<T, D>(m_tilesize / parSubdiv, m_tilesize, parTilemap);
DK_ASSERT(newLayer->mapSize() == m_size);
DK_ASSERT(newLayer->count() == m_size * parSubdiv);
m_layers.push_back(LayerPtr(newLayer));
return *newLayer;
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <uint32_t D>
void Tyler<D>::preload (const coords& parFrom, const coords& parTo) {
for (auto& layer : m_layers) {
layer->preload(parFrom, parTo);
}
}
} //namespace dk