Get game to build again.

This commit is contained in:
King_DuckZ 2015-08-16 22:29:34 +02:00
parent b01fad0314
commit 78312526ac
10 changed files with 38 additions and 37 deletions

View file

@ -28,7 +28,7 @@ target_include_directories(${PROJECT_NAME}
#add_subdirectory(lib/sprout)
add_subdirectory(src)
#add_subdirectory(test)
#add_subdirectory(game)
add_subdirectory(game)
#add_subdirectory(tools/mapconv)
add_subdirectory(test/gtest-1.7.0)
add_subdirectory(test/unit)

View file

@ -24,7 +24,7 @@ namespace dk {
explicit Tyler ( const coords& parTileSize );
~Tyler ( void ) noexcept = default;
typename coords::value_type tiles_count ( void ) const;
typename coords::scalar_type tiles_count ( void ) const;
const coords& map_size ( void ) const { return m_size; }
template <typename T>

View file

@ -23,13 +23,13 @@ namespace dkh {
public:
typedef std::istream::pos_type pos_type;
explicit TylerMapSourceBase ( pos_type parStreamStartPos );
explicit TylerMapSourceBase ( std::istream* parStream );
~TylerMapSourceBase ( void );
dk::HashType layerTypeHash ( int parIndex ) const;
void chainedMaps ( std::vector<std::string>& parOut ) const;
dk::MapTypes mapType ( void ) const;
void parseMapHeaders ( std::istream& parSrc, uint32_t parDim, std::vector<uint32_t>& parMapDims, std::vector<uint16_t>& parTileDims );
void parseMapHeaders ( uint32_t parDim, std::vector<uint32_t>& parMapDims, std::vector<uint16_t>& parTileDims );
private:
struct LayerInfo;
@ -38,6 +38,7 @@ namespace dkh {
dk::MapTypes m_map_type;
std::map<std::string, std::string> m_comments;
std::string m_file_vendor;
std::unique_ptr<std::istream> m_stream;
pos_type m_stream_start;
};
} //namespace implem
@ -68,11 +69,9 @@ namespace dkh {
virtual dk::HashType layerTypeHash ( int parIndex ) const;
private:
void parse_map_data ( std::istream& parSrc );
void parse_map_data ( void );
virtual void fetch_raw ( char* parOut, const coords& parFrom, const coords& parTo, std::size_t parSize );
std::unique_ptr<std::istream> m_stream;
coords m_map_size;
coords m_tile_size;
uint16_t m_map_version_major;

View file

@ -27,7 +27,7 @@ namespace dk {
template <uint32_t D>
template <typename T>
void BaseMapSource<D>::fetch (std::vector<T>& parOut, const coords& parFrom, const coords& parTo) {
const auto tile_count = tile_volume(parFrom, parTo);
const auto tile_count = tile_volume<D>(parTo - parFrom + 1);
const std::size_t casted_tile_count = static_cast<std::size_t>(tile_count);
DK_ASSERT(static_cast<decltype(tile_count)>(casted_tile_count) == tile_count);

View file

@ -6,18 +6,17 @@
namespace dk {
template <uint32_t D>
typename Vector<D>::value_type tile_volume ( const Vector<D>& parFrom, const Vector<D>& parTo ) a_pure;
typename Vector<D>::scalar_type tile_volume ( const Vector<D>& parVec ) a_pure;
template <uint32_t D>
inline
typename Vector<D>::value_type tile_volume (const Vector<D>& parFrom, const Vector<D>& parTo) {
typedef typename Vector<D>::value_type scalar_type;
typename Vector<D>::scalar_type tile_volume (const Vector<D>& parVec) {
typedef typename Vector<D>::scalar_type scalar_type;
scalar_type ret_val((1));
for (uint32_t z = 0; z < D; ++z) {
const auto dist(parTo[z] - parFrom[z] + 1);
ret_val *= dist;
ret_val *= parVec[z];
}
return ret_val;
}

View file

@ -44,7 +44,7 @@ namespace dk {
///--------------------------------------------------------------------------
template <typename T, uint32_t D>
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, this->m_count, this->m_count);
}
///--------------------------------------------------------------------------

View file

@ -11,7 +11,7 @@ namespace dk {
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <uint32_t D>
typename Tyler<D>::coords::value_type Tyler<D>::tiles_count() const {
typename Tyler<D>::coords::scalar_type Tyler<D>::tiles_count() const {
typename coords::value_type retval = 1;
for (size_t d = 0; d < D; ++d) {
retval *= m_size[d];

View file

@ -1,34 +1,31 @@
namespace dkh {
template <uint32_t D>
TylerMapSource<D>::TylerMapSource (const char* parFilename) :
base_class(m_stream->tellg()),
m_stream(new std::ifstream(parFilename))
base_class(new std::ifstream(parFilename))
{
parse_map_data(*m_stream);
parse_map_data();
}
template <uint32_t D>
TylerMapSource<D>::TylerMapSource (const std::string& parFilename) :
base_class(m_stream->tellg()),
m_stream(new std::ifstream(parFilename))
base_class( new std::ifstream(parFilename))
{
parse_map_data(*m_stream);
parse_map_data();
}
template <uint32_t D>
TylerMapSource<D>::TylerMapSource (std::istream* parData) :
base_class(m_stream->tellg()),
m_stream(parData)
base_class(parData)
{
parse_map_data(*m_stream);
parse_map_data();
}
template <uint32_t D>
void TylerMapSource<D>::parse_map_data (std::istream& parSrc) {
void TylerMapSource<D>::parse_map_data() {
std::vector<uint32_t> map_dims;
std::vector<uint16_t> tile_dims;
parseMapHeaders(parSrc, D, map_dims, tile_dims);
parseMapHeaders(D, map_dims, tile_dims);
DK_ASSERT(map_dims.size() == D);
DK_ASSERT(tile_dims.size() == D);
for (std::size_t z = 0; z < D; ++z) {
@ -49,6 +46,8 @@ namespace dkh {
template <uint32_t D>
void TylerMapSource<D>::fetch_raw (char* parOut, const coords& parFrom, const coords& parTo, std::size_t parSize) {
//TODO: implement
DK_ASSERT(false);
(void)parOut;
(void)parFrom;
(void)parTo;

View file

@ -28,7 +28,7 @@ namespace dk {
typename Layer<T, D>::iterator Viewport<D>::end (Layer<T, D>& parLayer) const {
typedef typename Layer<T, D>::iterator IterType;
const auto to(m_position + m_size);
return IterType(&parLayer.m_tiles, implem::buildPastEndCoordinate(m_position, to), to, coords(0), m_tyler.map_size());
return IterType(&parLayer.m_tiles, m_tyler.map_size(), m_tyler.map_size());
}
template <uint32_t D>
@ -47,7 +47,7 @@ namespace dk {
template <typename T>
typename Layer<T, D>::const_iterator Viewport<D>::cbegin (const Layer<T, D>& parLayer) const {
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, m_tyler.map_size());
}
template <uint32_t D>
@ -55,7 +55,7 @@ namespace dk {
typename Layer<T, D>::const_iterator Viewport<D>::cend (const Layer<T, D>& parLayer) const {
typedef typename Layer<T, D>::const_iterator IterType;
const auto to(m_position + m_size);
return IterType(&parLayer.m_tiles, implem::buildPastEndCoordinate(m_position, to), to, coords(0), m_tyler.map_size());
return IterType(&parLayer.m_tiles, m_tyler.map_size(), m_tyler.map_size());
}
template <uint32_t D>

View file

@ -217,9 +217,11 @@ namespace dkh {
uint32_t data_length;
};
TylerMapSourceBase::TylerMapSourceBase (pos_type parStreamStartPos) :
m_stream_start(parStreamStartPos)
TylerMapSourceBase::TylerMapSourceBase (std::istream* parStream) :
m_stream(parStream),
m_stream_start(parStream->tellg())
{
DK_ASSERT(m_stream);
}
TylerMapSourceBase::~TylerMapSourceBase() {
@ -239,10 +241,12 @@ namespace dkh {
return m_map_type;
}
void TylerMapSourceBase::parseMapHeaders (std::istream& parSrc, uint32_t parDim, std::vector<uint32_t>& parMapDims, std::vector<uint16_t>& parTileDims) {
void TylerMapSourceBase::parseMapHeaders (uint32_t parDim, std::vector<uint32_t>& parMapDims, std::vector<uint16_t>& parTileDims) {
DK_ASSERT(m_stream);
//Read file header
implem::TylerMapHeader header;
implem::read_header(parSrc, header);
implem::read_header(*m_stream, header);
if (header.dimensions != parDim) {
throw InvalidMapDimensionsException();
@ -270,15 +274,15 @@ namespace dkh {
std::vector<uint32_t> map_dims;
std::vector<uint16_t> 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, parDim, map_dims, tile_dims);
m_stream->seekg(read_start, std::ios_base::cur);
implem::read_dimensions(*m_stream, parDim, map_dims, tile_dims);
parMapDims.swap(map_dims);
parTileDims.swap(tile_dims);
}
//Read vorbis comments
parSrc.seekg(header.comment_start + m_stream_start, std::ios_base::beg);
read_comments(parSrc, m_file_vendor, m_comments);
m_stream->seekg(header.comment_start + m_stream_start, std::ios_base::beg);
read_comments(*m_stream, m_file_vendor, m_comments);
}
void read_header (std::istream& parStream, TylerMapHeader& parHeader) {