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.
This commit is contained in:
King_DuckZ 2015-01-08 12:20:17 +01:00
parent 8ead404ee8
commit 701366bf86
16 changed files with 78 additions and 69 deletions

View file

@ -8,12 +8,13 @@
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <cstdint>
namespace dk { namespace dk {
template <size_t D> template <uint32_t D>
class Viewport; class Viewport;
template <size_t D> template <uint32_t D>
class LayerBase { class LayerBase {
public: public:
typedef Vector<CoordinateScalarType, D> coords; typedef Vector<CoordinateScalarType, D> coords;
@ -37,7 +38,7 @@ namespace dk {
coords m_haveTo; coords m_haveTo;
}; };
template <typename T, size_t D> template <typename T, uint32_t D>
class Layer : public LayerBase<D> { class Layer : public LayerBase<D> {
friend class Viewport<D>; friend class Viewport<D>;

View file

@ -7,10 +7,11 @@
#include <iterator> #include <iterator>
#include <vector> #include <vector>
#include <type_traits> #include <type_traits>
#include <cstdint>
namespace dk { namespace dk {
namespace implem { namespace implem {
template <size_t D> template <uint32_t D>
size_t get_index_from_pos ( const Vector<CoordinateScalarType, D>& parPos, const Vector<CoordinateScalarType, D>& parSize ) a_pure; size_t get_index_from_pos ( const Vector<CoordinateScalarType, D>& parPos, const Vector<CoordinateScalarType, D>& parSize ) a_pure;
template <typename I, typename O> template <typename I, typename O>
@ -32,11 +33,11 @@ namespace dk {
size_t get_index_from_pos<2> ( const Vector<CoordinateScalarType, 2>& parPos, const Vector<CoordinateScalarType, 2>& parSize ) a_pure; size_t get_index_from_pos<2> ( const Vector<CoordinateScalarType, 2>& parPos, const Vector<CoordinateScalarType, 2>& parSize ) a_pure;
#endif #endif
template <size_t D> template <uint32_t D>
Vector<CoordinateScalarType, D> buildPastEndCoordinate ( const Vector<CoordinateScalarType, D>& parFrom, const Vector<CoordinateScalarType, D>& parTo ) a_pure; Vector<CoordinateScalarType, D> buildPastEndCoordinate ( const Vector<CoordinateScalarType, D>& parFrom, const Vector<CoordinateScalarType, D>& parTo ) a_pure;
} //namespace implem } //namespace implem
template <typename T, size_t D, typename T1=typename std::remove_cv<T>::type> template <typename T, uint32_t D, typename T1=typename std::remove_cv<T>::type>
class TileIterator : public boost::iterator_facade<TileIterator<T, D>, T, boost::bidirectional_traversal_tag> { class TileIterator : public boost::iterator_facade<TileIterator<T, D>, T, boost::bidirectional_traversal_tag> {
friend class boost::iterator_core_access; friend class boost::iterator_core_access;
typedef std::vector<T1> vector_type; typedef std::vector<T1> vector_type;

View file

@ -10,9 +10,10 @@
#include <iterator> #include <iterator>
#include <memory> #include <memory>
#include <algorithm> #include <algorithm>
#include <cstdint>
namespace dk { namespace dk {
template <typename T, std::size_t D> template <typename T, uint32_t D>
class TileMapData { class TileMapData {
public: public:
typedef Vector<CoordinateScalarType, D> coords; typedef Vector<CoordinateScalarType, D> coords;

View file

@ -6,12 +6,13 @@
#include <cassert> #include <cassert>
#include <ciso646> #include <ciso646>
#include <memory> #include <memory>
#include <cstdint>
namespace dk { namespace dk {
template <typename T, size_t D> template <typename T, uint32_t D>
class TileMapData; class TileMapData;
template <size_t D> template <uint32_t D>
class Tyler { class Tyler {
typedef std::unique_ptr<LayerBase<D>> LayerPtr; typedef std::unique_ptr<LayerBase<D>> LayerPtr;
typedef std::vector<LayerPtr> LayerList; typedef std::vector<LayerPtr> LayerList;

View file

@ -4,15 +4,16 @@
#include "doorkeeper/primitivetypes.hpp" #include "doorkeeper/primitivetypes.hpp"
#include "doorkeeper/components/tileiterator.hpp" #include "doorkeeper/components/tileiterator.hpp"
#include "doorkeeper/components/layer.hpp" #include "doorkeeper/components/layer.hpp"
#include <cstdint>
namespace dk { namespace dk {
template <size_t D> template <uint32_t D>
class Tyler; class Tyler;
template <typename T, size_t D> template <typename T, uint32_t D>
class Layer; class Layer;
template <size_t D> template <uint32_t D>
class Viewport { class Viewport {
public: public:
typedef Vector<CoordinateScalarType, D> coords; typedef Vector<CoordinateScalarType, D> coords;

View file

@ -1,9 +1,11 @@
#ifndef id61F9FA08290643D0A947EC0E51060BEA #ifndef id61F9FA08290643D0A947EC0E51060BEA
#define id61F9FA08290643D0A947EC0E51060BEA #define id61F9FA08290643D0A947EC0E51060BEA
#include <cstdint>
namespace dk { namespace dk {
namespace implem { namespace implem {
template <size_t D> template <uint32_t D>
CoordinateScalarType area ( const Vector<CoordinateScalarType, D>& parVec ) a_pure; CoordinateScalarType area ( const Vector<CoordinateScalarType, D>& parVec ) a_pure;
} //namespace implem } //namespace implem
} //namespace dk } //namespace dk

View file

@ -2,7 +2,7 @@ namespace dk {
namespace implem { namespace implem {
///---------------------------------------------------------------------- ///----------------------------------------------------------------------
///---------------------------------------------------------------------- ///----------------------------------------------------------------------
template <size_t D> template <uint32_t D>
CoordinateScalarType area (const Vector<CoordinateScalarType, D>& parVec) { CoordinateScalarType area (const Vector<CoordinateScalarType, D>& parVec) {
CoordinateScalarType retval(1); CoordinateScalarType retval(1);
for (size_t d = 0; d < D; ++d) { for (size_t d = 0; d < D; ++d) {

View file

@ -1,7 +1,7 @@
namespace dk { namespace dk {
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
template <size_t D> template <uint32_t D>
LayerBase<D>::LayerBase (const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize) : LayerBase<D>::LayerBase (const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize) :
m_count(parCount / (parMasterTileSize / parTileSize)), m_count(parCount / (parMasterTileSize / parTileSize)),
m_tilesize(parTileSize), m_tilesize(parTileSize),
@ -14,7 +14,7 @@ namespace dk {
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
template <size_t D> template <uint32_t D>
void LayerBase<D>::preload (const coords& parFrom, const coords& parTo) { void LayerBase<D>::preload (const coords& parFrom, const coords& parTo) {
if (parFrom < m_haveFrom or parTo > m_haveTo) { if (parFrom < m_haveFrom or parTo > m_haveTo) {
this->onPreload(parFrom, parTo); this->onPreload(parFrom, parTo);
@ -25,7 +25,7 @@ namespace dk {
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
template <typename T, size_t D> template <typename T, uint32_t D>
Layer<T, D>::Layer (const coords& parTileSize, const coords& parMasterTileSize, TileMapData<T, D>& parTilemap) : Layer<T, D>::Layer (const coords& parTileSize, const coords& parMasterTileSize, TileMapData<T, D>& parTilemap) :
LayerBase<D>(parTilemap.mapSize(), parTileSize, parMasterTileSize), LayerBase<D>(parTilemap.mapSize(), parTileSize, parMasterTileSize),
m_tilemap(parTilemap) m_tilemap(parTilemap)
@ -34,21 +34,21 @@ namespace dk {
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
template <typename T, size_t D> template <typename T, uint32_t D>
typename Layer<T, D>::iterator Layer<T, D>::begin() { typename Layer<T, D>::iterator Layer<T, D>::begin() {
return iterator(&m_tiles, coords(0), this->m_count); return iterator(&m_tiles, coords(0), this->m_count);
} }
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
template <typename T, size_t D> template <typename T, uint32_t D>
typename Layer<T, D>::iterator Layer<T, D>::end() { typename Layer<T, D>::iterator Layer<T, D>::end() {
return iterator(&m_tiles, implem::buildPastEndCoordinate<D>(coords(0), this->m_count), this->m_count); return iterator(&m_tiles, implem::buildPastEndCoordinate<D>(coords(0), this->m_count), this->m_count);
} }
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
template <typename T, size_t D> template <typename T, uint32_t D>
void Layer<T, D>::onPreload (const coords& parFrom, const coords& parTo) { void Layer<T, D>::onPreload (const coords& parFrom, const coords& parTo) {
m_tiles.clear(); m_tiles.clear();
m_tilemap.fetch(m_tiles, parFrom, parTo); m_tilemap.fetch(m_tiles, parFrom, parTo);

View file

@ -1,7 +1,7 @@
namespace dk { namespace dk {
///------------------------------------------------------------------------- ///-------------------------------------------------------------------------
///------------------------------------------------------------------------- ///-------------------------------------------------------------------------
template <std::size_t D> template <uint32_t D>
MapStreamBase<D>::MapStreamBase (const coords& parMapSize) : MapStreamBase<D>::MapStreamBase (const coords& parMapSize) :
m_mapSize(parMapSize) m_mapSize(parMapSize)
{ {
@ -9,7 +9,7 @@ namespace dk {
///------------------------------------------------------------------------- ///-------------------------------------------------------------------------
///------------------------------------------------------------------------- ///-------------------------------------------------------------------------
template <std::size_t D> template <uint32_t D>
void MapStreamBase<D>::read (char* parOut, std::size_t parOutSize, const coords& parFrom, const coords& parTo) { void MapStreamBase<D>::read (char* parOut, std::size_t parOutSize, const coords& parFrom, const coords& parTo) {
DK_ASSERT(parOut); DK_ASSERT(parOut);
DK_ASSERT(parOutSize > 0); DK_ASSERT(parOutSize > 0);

View file

@ -8,9 +8,9 @@ namespace dk {
///hardcoded in the device being passed in). The actual name could be ///hardcoded in the device being passed in). The actual name could be
///something like get_device_dimensions(). ///something like get_device_dimensions().
///--------------------------------------------------------------------- ///---------------------------------------------------------------------
template <std::size_t D, typename Device> template <uint32_t D, typename Device>
inline inline
typename std::enable_if<Device::MapDimensions == D, std::size_t>::type err_mismatching_dimension (const Device*) noexcept { typename std::enable_if<Device::MapDimensions == D, uint32_t>::type err_mismatching_dimension (const Device*) noexcept {
return Device::MapDimensions; return Device::MapDimensions;
} }
@ -22,15 +22,15 @@ namespace dk {
///being passed in). The actual name could be something like ///being passed in). The actual name could be something like
///get_device_dimensions(). ///get_device_dimensions().
///--------------------------------------------------------------------- ///---------------------------------------------------------------------
template <std::size_t D, typename Device> template <uint32_t D, typename Device>
inline inline
typename std::enable_if<HasMapDimensions<Device>::result == false, std::size_t>::type err_mismatching_dimension (const Device*) noexcept { typename std::enable_if<HasMapDimensions<Device>::result == false, uint32_t>::type err_mismatching_dimension (const Device*) noexcept {
return 0; return 0;
} }
///--------------------------------------------------------------------- ///---------------------------------------------------------------------
///--------------------------------------------------------------------- ///---------------------------------------------------------------------
template <std::size_t D, typename Device> template <uint32_t D, typename Device>
inline inline
typename std::enable_if<Device::MapDimensions == D, Vector<CoordinateScalarType, D>>::type retrieve_map_size_from_device (Device* parDevice) { typename std::enable_if<Device::MapDimensions == D, Vector<CoordinateScalarType, D>>::type retrieve_map_size_from_device (Device* parDevice) {
return parDevice->mapSize(); return parDevice->mapSize();
@ -38,7 +38,7 @@ namespace dk {
///--------------------------------------------------------------------- ///---------------------------------------------------------------------
///--------------------------------------------------------------------- ///---------------------------------------------------------------------
template <std::size_t D, typename Device> template <uint32_t D, typename Device>
inline inline
typename std::enable_if<HasMapDimensions<Device>::result == false, Vector<CoordinateScalarType, D>>::type retrieve_map_size_from_device (Device* parDevice) { typename std::enable_if<HasMapDimensions<Device>::result == false, Vector<CoordinateScalarType, D>>::type retrieve_map_size_from_device (Device* parDevice) {
return get_map_size_from_device<D>(parDevice); return get_map_size_from_device<D>(parDevice);
@ -47,7 +47,7 @@ namespace dk {
///------------------------------------------------------------------------- ///-------------------------------------------------------------------------
///------------------------------------------------------------------------- ///-------------------------------------------------------------------------
template <typename T, std::size_t D> template <typename T, uint32_t D>
template <typename Device> template <typename Device>
MapStreamRaw<T, D>::MapStreamRaw (Device& parDevice) : MapStreamRaw<T, D>::MapStreamRaw (Device& parDevice) :
MapStreamBase<D>(implem::retrieve_map_size_from_device<D>(&parDevice)), MapStreamBase<D>(implem::retrieve_map_size_from_device<D>(&parDevice)),
@ -58,7 +58,7 @@ namespace dk {
///------------------------------------------------------------------------- ///-------------------------------------------------------------------------
///------------------------------------------------------------------------- ///-------------------------------------------------------------------------
template <typename T, std::size_t D> template <typename T, uint32_t D>
std::size_t MapStreamRaw<T, D>::dataBlockRequested (char* parOut, std::size_t parOutSize, const coords& parFrom, const coords& parTo) { std::size_t MapStreamRaw<T, D>::dataBlockRequested (char* parOut, std::size_t parOutSize, const coords& parFrom, const coords& parTo) {
DK_ASSERT(parOut); DK_ASSERT(parOut);

View file

@ -1,6 +1,6 @@
namespace dk { namespace dk {
namespace implem { namespace implem {
template <size_t D> template <uint32_t D>
inline size_t get_index_from_pos (const Vector<CoordinateScalarType, D>& parPos, const Vector<CoordinateScalarType, D>& parSize) { inline size_t get_index_from_pos (const Vector<CoordinateScalarType, D>& parPos, const Vector<CoordinateScalarType, D>& parSize) {
size_t index = 0; size_t index = 0;
for (size_t d = 0; d < D; ++d) { for (size_t d = 0; d < D; ++d) {
@ -21,7 +21,7 @@ namespace dk {
} }
#endif #endif
template <size_t D> template <uint32_t D>
inline Vector<CoordinateScalarType, D> buildPastEndCoordinate (const Vector<CoordinateScalarType, D>& parFrom, const Vector<CoordinateScalarType, D>& parTo) { inline Vector<CoordinateScalarType, D> buildPastEndCoordinate (const Vector<CoordinateScalarType, D>& parFrom, const Vector<CoordinateScalarType, D>& parTo) {
Vector<CoordinateScalarType, D> retval; Vector<CoordinateScalarType, D> retval;
for (size_t d = 0; d < D - 1; ++d) { for (size_t d = 0; d < D - 1; ++d) {
@ -32,7 +32,7 @@ namespace dk {
} }
} //namespace implem } //namespace implem
template <typename T, size_t D, typename T1> template <typename T, uint32_t D, typename T1>
TileIterator<T, D, T1>::TileIterator() : TileIterator<T, D, T1>::TileIterator() :
m_pos(CoordinateScalarType()), m_pos(CoordinateScalarType()),
m_from(CoordinateScalarType()), m_from(CoordinateScalarType()),
@ -44,7 +44,7 @@ namespace dk {
{ {
} }
template <typename T, size_t D, typename T1> template <typename T, uint32_t D, typename T1>
TileIterator<T, D, T1>::TileIterator (qualif_vector_type* parData, const coords& parFrom, const coords& parTo) : TileIterator<T, D, T1>::TileIterator (qualif_vector_type* parData, const coords& parFrom, const coords& parTo) :
m_pos(parFrom), m_pos(parFrom),
m_from(parFrom), m_from(parFrom),
@ -57,7 +57,7 @@ namespace dk {
DK_ASSERT(parData); DK_ASSERT(parData);
} }
template <typename T, size_t D, typename T1> template <typename T, uint32_t D, typename T1>
TileIterator<T, D, T1>::TileIterator (qualif_vector_type* parData, const coords& parFrom, const coords& parTo, const coords& parAreaFrom, const coords& parAreaTo) : TileIterator<T, D, T1>::TileIterator (qualif_vector_type* parData, const coords& parFrom, const coords& parTo, const coords& parAreaFrom, const coords& parAreaTo) :
m_pos(parFrom), m_pos(parFrom),
m_from(parFrom), m_from(parFrom),
@ -70,7 +70,7 @@ namespace dk {
DK_ASSERT(parData); DK_ASSERT(parData);
} }
template <typename T, size_t D, typename T1> template <typename T, uint32_t D, typename T1>
TileIterator<T, D, T1>::TileIterator (qualif_vector_type* parData, const coords& parFrom, const coords& parTo, const coords& parAreaFrom, const coords& parAreaTo, const coords& parSubdiv) : TileIterator<T, D, T1>::TileIterator (qualif_vector_type* parData, const coords& parFrom, const coords& parTo, const coords& parAreaFrom, const coords& parAreaTo, const coords& parSubdiv) :
m_pos(parFrom), m_pos(parFrom),
m_from(parFrom), m_from(parFrom),
@ -83,7 +83,7 @@ namespace dk {
DK_ASSERT(parData); DK_ASSERT(parData);
} }
template <typename T, size_t D, typename T1> template <typename T, uint32_t D, typename T1>
void TileIterator<T, D, T1>::increment() { void TileIterator<T, D, T1>::increment() {
if (m_subindex < m_maxsubindex) { if (m_subindex < m_maxsubindex) {
++m_subindex; ++m_subindex;
@ -101,7 +101,7 @@ namespace dk {
++m_pos[D - 1]; ++m_pos[D - 1];
} }
template <typename T, size_t D, typename T1> template <typename T, uint32_t D, typename T1>
void TileIterator<T, D, T1>::decrement() { void TileIterator<T, D, T1>::decrement() {
if (m_maxsubindex > 0 and m_subindex == 0) { if (m_maxsubindex > 0 and m_subindex == 0) {
--m_subindex; --m_subindex;
@ -120,17 +120,17 @@ namespace dk {
++m_pos[D - 1]; ++m_pos[D - 1];
} }
template <typename T, size_t D, typename T1> template <typename T, uint32_t D, typename T1>
void TileIterator<T, D, T1>::advance (size_t parAdvance) { void TileIterator<T, D, T1>::advance (size_t parAdvance) {
//TODO: implement //TODO: implement
} }
template <typename T, size_t D, typename T1> template <typename T, uint32_t D, typename T1>
ptrdiff_t TileIterator<T, D, T1>::distance_to (const TileIterator& parOther) { ptrdiff_t TileIterator<T, D, T1>::distance_to (const TileIterator& parOther) {
return std::distance(this->get_current_index(), parOther.get_current_index()); return std::distance(this->get_current_index(), parOther.get_current_index());
} }
template <typename T, size_t D, typename T1> template <typename T, uint32_t D, typename T1>
bool TileIterator<T, D, T1>::equal (const TileIterator& parOther) const { bool TileIterator<T, D, T1>::equal (const TileIterator& parOther) const {
return m_data == parOther.m_data and m_pos == parOther.m_pos; return m_data == parOther.m_data and m_pos == parOther.m_pos;
} }

View file

@ -1,7 +1,7 @@
namespace dk { namespace dk {
///------------------------------------------------------------------------- ///-------------------------------------------------------------------------
///------------------------------------------------------------------------- ///-------------------------------------------------------------------------
template <typename T, std::size_t D> template <typename T, uint32_t D>
TileMapData<T, D>::TileMapData (std::unique_ptr<MapStreamBase<D>>&& parStream) : TileMapData<T, D>::TileMapData (std::unique_ptr<MapStreamBase<D>>&& parStream) :
m_mapstream(std::move(parStream)) m_mapstream(std::move(parStream))
{ {
@ -9,7 +9,7 @@ namespace dk {
///------------------------------------------------------------------------- ///-------------------------------------------------------------------------
///------------------------------------------------------------------------- ///-------------------------------------------------------------------------
template <typename T, std::size_t D> template <typename T, uint32_t D>
void TileMapData<T, D>::fetch (std::vector<T>& parOut, const coords& parFrom, const coords& parTo) { void TileMapData<T, D>::fetch (std::vector<T>& parOut, const coords& parFrom, const coords& parTo) {
DK_ASSERT(parFrom >= coords(0)); DK_ASSERT(parFrom >= coords(0));
DK_ASSERT(parFrom < parTo); DK_ASSERT(parFrom < parTo);
@ -27,7 +27,7 @@ namespace dk {
///------------------------------------------------------------------------- ///-------------------------------------------------------------------------
///------------------------------------------------------------------------- ///-------------------------------------------------------------------------
template <typename T, std::size_t D> template <typename T, uint32_t D>
const typename TileMapData<T, D>::coords& TileMapData<T, D>::mapSize() const { const typename TileMapData<T, D>::coords& TileMapData<T, D>::mapSize() const {
return m_mapstream->mapSize(); return m_mapstream->mapSize();
} }

View file

@ -1,7 +1,7 @@
namespace dk { namespace dk {
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
template <size_t D> template <uint32_t D>
Tyler<D>::Tyler (const coords& parSize, const coords& parTileSize) : Tyler<D>::Tyler (const coords& parSize, const coords& parTileSize) :
m_size(parSize), m_size(parSize),
m_tilesize(parTileSize) m_tilesize(parTileSize)
@ -11,7 +11,7 @@ namespace dk {
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
template <size_t D> template <uint32_t D>
typename Tyler<D>::coords::value_type Tyler<D>::tiles_count() const { typename Tyler<D>::coords::value_type Tyler<D>::tiles_count() const {
typename coords::value_type retval = 1; typename coords::value_type retval = 1;
for (size_t d = 0; d < D; ++d) { for (size_t d = 0; d < D; ++d) {
@ -22,7 +22,7 @@ namespace dk {
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
template <size_t D> template <uint32_t D>
template <typename T> template <typename T>
Layer<T, D>& Tyler<D>::push_layer (TileMapData<T, D>& parTilemap) { Layer<T, D>& Tyler<D>::push_layer (TileMapData<T, D>& parTilemap) {
auto newLayer = new Layer<T, D>(m_tilesize, m_tilesize, parTilemap); auto newLayer = new Layer<T, D>(m_tilesize, m_tilesize, parTilemap);
@ -34,7 +34,7 @@ namespace dk {
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
template <size_t D> template <uint32_t D>
template <typename T> template <typename T>
Layer<T, D>& Tyler<D>::push_layer (TileMapData<T, D>& parTilemap, const coords& parSubdiv) { 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); auto newLayer = new Layer<T, D>(m_tilesize / parSubdiv, m_tilesize, parTilemap);
@ -46,7 +46,7 @@ namespace dk {
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
template <size_t D> template <uint32_t D>
void Tyler<D>::preload (const coords& parFrom, const coords& parTo) { void Tyler<D>::preload (const coords& parFrom, const coords& parTo) {
for (auto& layer : m_layers) { for (auto& layer : m_layers) {
layer->preload(parFrom, parTo); layer->preload(parFrom, parTo);

View file

@ -1,11 +1,11 @@
namespace dk { namespace dk {
template <size_t D> template <uint32_t D>
Viewport<D>::Viewport (Tyler<D>& parTyler) : Viewport<D>::Viewport (Tyler<D>& parTyler) :
m_tyler(parTyler) m_tyler(parTyler)
{ {
} }
template <size_t D> template <uint32_t D>
Viewport<D>::Viewport (Tyler<D>& parTyler, const coords& parSize, const coords& parPos) : Viewport<D>::Viewport (Tyler<D>& parTyler, const coords& parSize, const coords& parPos) :
m_size(parSize), m_size(parSize),
m_position(parPos), m_position(parPos),
@ -16,14 +16,14 @@ namespace dk {
m_tyler.preload(m_position, m_position + m_size); m_tyler.preload(m_position, m_position + m_size);
} }
template <size_t D> template <uint32_t D>
template <typename T> template <typename T>
typename Layer<T, D>::iterator Viewport<D>::begin (Layer<T, D>& parLayer) const { typename Layer<T, D>::iterator Viewport<D>::begin (Layer<T, D>& parLayer) const {
typedef typename Layer<T, D>::iterator IterType; typedef typename Layer<T, D>::iterator IterType;
return IterType(&parLayer.m_tiles, m_position, m_position + m_size, coords(0), m_tyler.map_size()); return IterType(&parLayer.m_tiles, m_position, m_position + m_size, coords(0), m_tyler.map_size());
} }
template <size_t D> template <uint32_t D>
template <typename T> template <typename T>
typename Layer<T, D>::iterator Viewport<D>::end (Layer<T, D>& parLayer) const { typename Layer<T, D>::iterator Viewport<D>::end (Layer<T, D>& parLayer) const {
typedef typename Layer<T, D>::iterator IterType; typedef typename Layer<T, D>::iterator IterType;
@ -31,26 +31,26 @@ namespace dk {
return IterType(&parLayer.m_tiles, implem::buildPastEndCoordinate(m_position, to), to, coords(0), m_tyler.map_size()); return IterType(&parLayer.m_tiles, implem::buildPastEndCoordinate(m_position, to), to, coords(0), m_tyler.map_size());
} }
template <size_t D> template <uint32_t D>
template <typename T> template <typename T>
typename Layer<T, D>::const_iterator Viewport<D>::begin (const Layer<T, D>& parLayer) const { typename Layer<T, D>::const_iterator Viewport<D>::begin (const Layer<T, D>& parLayer) const {
return this->cbegin(parLayer); return this->cbegin(parLayer);
} }
template <size_t D> template <uint32_t D>
template <typename T> template <typename T>
typename Layer<T, D>::const_iterator Viewport<D>::end (const Layer<T, D>& parLayer) const { typename Layer<T, D>::const_iterator Viewport<D>::end (const Layer<T, D>& parLayer) const {
return this->cend(parLayer); return this->cend(parLayer);
} }
template <size_t D> template <uint32_t D>
template <typename T> template <typename T>
typename Layer<T, D>::const_iterator Viewport<D>::cbegin (const Layer<T, D>& parLayer) const { typename Layer<T, D>::const_iterator Viewport<D>::cbegin (const Layer<T, D>& parLayer) const {
typedef typename Layer<T, D>::const_iterator IterType; typedef typename Layer<T, D>::const_iterator IterType;
return IterType(&parLayer.m_tiles, m_position, m_position + m_size, coords(0), m_tyler.map_size()); return IterType(&parLayer.m_tiles, m_position, m_position + m_size, coords(0), m_tyler.map_size());
} }
template <size_t D> template <uint32_t D>
template <typename T> template <typename T>
typename Layer<T, D>::const_iterator Viewport<D>::cend (const Layer<T, D>& parLayer) const { typename Layer<T, D>::const_iterator Viewport<D>::cend (const Layer<T, D>& parLayer) const {
typedef typename Layer<T, D>::const_iterator IterType; typedef typename Layer<T, D>::const_iterator IterType;
@ -58,7 +58,7 @@ namespace dk {
return IterType(&parLayer.m_tiles, implem::buildPastEndCoordinate(m_position, to), to, coords(0), m_tyler.map_size()); return IterType(&parLayer.m_tiles, implem::buildPastEndCoordinate(m_position, to), to, coords(0), m_tyler.map_size());
} }
template <size_t D> template <uint32_t D>
void Viewport<D>::setSize (const coords& parSize) { void Viewport<D>::setSize (const coords& parSize) {
DK_ASSERT(m_position <= m_position + parSize); DK_ASSERT(m_position <= m_position + parSize);
DK_ASSERT(parSize + m_position <= m_tyler.map_size()); DK_ASSERT(parSize + m_position <= m_tyler.map_size());
@ -66,7 +66,7 @@ namespace dk {
m_tyler.preload(m_position, m_position + m_size); m_tyler.preload(m_position, m_position + m_size);
} }
template <size_t D> template <uint32_t D>
void Viewport<D>::setFrom (const coords& parFrom) { void Viewport<D>::setFrom (const coords& parFrom) {
DK_ASSERT(parFrom <= parFrom + m_size); DK_ASSERT(parFrom <= parFrom + m_size);
DK_ASSERT(m_size + parFrom <= m_tyler.map_size()); DK_ASSERT(m_size + parFrom <= m_tyler.map_size());
@ -74,7 +74,7 @@ namespace dk {
m_tyler.preload(m_position, m_position + m_size); m_tyler.preload(m_position, m_position + m_size);
} }
template <size_t D> template <uint32_t D>
void Viewport<D>::setFromSize (const coords& parFrom, const coords& parSize) { void Viewport<D>::setFromSize (const coords& parFrom, const coords& parSize) {
DK_ASSERT(parFrom <= parFrom + parSize); DK_ASSERT(parFrom <= parFrom + parSize);
DK_ASSERT(parSize + parFrom <= m_tyler.map_size()); DK_ASSERT(parSize + parFrom <= m_tyler.map_size());

View file

@ -4,9 +4,10 @@
#include "doorkeeper/primitivetypes.hpp" #include "doorkeeper/primitivetypes.hpp"
#include "doorkeeper/implem/vector.hpp" #include "doorkeeper/implem/vector.hpp"
#include <cstddef> #include <cstddef>
#include <cstdint>
namespace dk { namespace dk {
template <std::size_t D> template <uint32_t D>
class MapStreamBase { class MapStreamBase {
public: public:
typedef Vector<CoordinateScalarType, D> coords; typedef Vector<CoordinateScalarType, D> coords;

View file

@ -4,6 +4,7 @@
#include "doorkeeper/mapreaders/mapstreambase.hpp" #include "doorkeeper/mapreaders/mapstreambase.hpp"
#include "doorkeeper/implem/helpers.hpp" #include "doorkeeper/implem/helpers.hpp"
#include <cstddef> #include <cstddef>
#include <cstdint>
#include <algorithm> #include <algorithm>
#include <type_traits> #include <type_traits>
#include <istream> #include <istream>
@ -22,24 +23,24 @@ namespace dk {
}; };
}; };
template <std::size_t D, typename Device> template <uint32_t D, typename Device>
typename std::enable_if<Device::MapDimensions == D, std::size_t>::type err_mismatching_dimension ( const Device* ) noexcept a_pure; typename std::enable_if<Device::MapDimensions == D, uint32_t>::type err_mismatching_dimension ( const Device* ) noexcept a_pure;
template <std::size_t D, typename Device> template <uint32_t D, typename Device>
typename std::enable_if<HasMapDimensions<Device>::result == false, std::size_t>::type err_mismatching_dimension ( const Device* ) noexcept a_pure; typename std::enable_if<HasMapDimensions<Device>::result == false, uint32_t>::type err_mismatching_dimension ( const Device* ) noexcept a_pure;
template <std::size_t D, typename Device> template <uint32_t D, typename Device>
typename std::enable_if<Device::MapDimensions == D, Vector<CoordinateScalarType, D>>::type retrieve_map_size_from_device ( Device* parDevice ); typename std::enable_if<Device::MapDimensions == D, Vector<CoordinateScalarType, D>>::type retrieve_map_size_from_device ( Device* parDevice );
template <std::size_t D, typename Device> template <uint32_t D, typename Device>
typename std::enable_if<HasMapDimensions<Device>::result == false, Vector<CoordinateScalarType, D>>::type retrieve_map_size_from_device ( Device* parDevice ); typename std::enable_if<HasMapDimensions<Device>::result == false, Vector<CoordinateScalarType, D>>::type retrieve_map_size_from_device ( Device* parDevice );
} //namespace implem } //namespace implem
//Customization point - specialize to enable map size retrieval for Device //Customization point - specialize to enable map size retrieval for Device
template <std::size_t D, typename Device> template <uint32_t D, typename Device>
typename Device::coords get_map_size_from_device ( const Device* parDevice ); typename Device::coords get_map_size_from_device ( const Device* parDevice );
template <typename T, std::size_t D> template <typename T, uint32_t D>
class MapStreamRaw : public MapStreamBase<D> { class MapStreamRaw : public MapStreamBase<D> {
public: public:
typedef typename MapStreamBase<D>::coords coords; typedef typename MapStreamBase<D>::coords coords;