From ccd00df6d8e7d3e9216e715eed2ffcf547f1a385 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Tue, 25 Aug 2015 15:44:28 +0200 Subject: [PATCH] Don't pass the map size from the c++ code anymore. --- game/main.cpp | 2 +- include/doorkeeper/helpers/asciimapsource.hpp | 6 +++--- src/asciimapsource.cpp | 18 ++++++------------ test/main.cpp | 2 +- test/unit/asciimapsource.cpp | 6 +++--- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/game/main.cpp b/game/main.cpp index b7e765d..be4a7e3 100644 --- a/game/main.cpp +++ b/game/main.cpp @@ -32,7 +32,7 @@ int main() { std::cout << "Welcome to " GAME_NAME " v" << GAME_VER_MAJOR << '.' << GAME_VER_MINOR << '.' << GAME_VER_PATCH << '\n'; IntPoolType pool; - pool.opener = [](const std::string& parName) { std::cout << "Opening " << parName << std::endl; return new dkh::AsciiMapSource(parName, coords2(10, 8), dk::MapType_IsometricStaggered, coords2(64, 64)); }; + pool.opener = [](const std::string& parName) { std::cout << "Opening " << parName << std::endl; return new dkh::AsciiMapSource(parName, dk::MapType_IsometricStaggered, coords2(64, 64)); }; dkh::PushLayerMapType<2> pushers; pushers.insert(std::make_pair(dk::type_name_hash(), &Tyler2d::push_layer_void)); Tyler2d tiler(dkh::call_map_load(pool, std::string("test_level.dk"), pushers)); diff --git a/include/doorkeeper/helpers/asciimapsource.hpp b/include/doorkeeper/helpers/asciimapsource.hpp index 00fc50a..deaee25 100644 --- a/include/doorkeeper/helpers/asciimapsource.hpp +++ b/include/doorkeeper/helpers/asciimapsource.hpp @@ -41,9 +41,9 @@ namespace dkh { AsciiMapSource ( void ) = delete; AsciiMapSource ( const AsciiMapSource& ) = delete; AsciiMapSource ( AsciiMapSource&& parOther ) = default; - AsciiMapSource ( const char* parFilename, const coords& parSize, dk::MapTypes parMapType, const coords& parTileSize ); - AsciiMapSource ( const std::string& parFilename, const coords& parSize, dk::MapTypes parMapType, const coords& parTileSize ); - AsciiMapSource ( std::istream& parData, const coords& parSize, dk::MapTypes parMapType, const coords& parTileSize ); + AsciiMapSource ( const char* parFilename, dk::MapTypes parMapType, const coords& parTileSize ); + AsciiMapSource ( const std::string& parFilename, dk::MapTypes parMapType, const coords& parTileSize ); + AsciiMapSource ( std::istream& parData, dk::MapTypes parMapType, const coords& parTileSize ); virtual ~AsciiMapSource ( void ) noexcept = default; virtual const coords& mapSize ( void ) const; diff --git a/src/asciimapsource.cpp b/src/asciimapsource.cpp index 4fb0ed1..c590359 100644 --- a/src/asciimapsource.cpp +++ b/src/asciimapsource.cpp @@ -29,8 +29,8 @@ namespace dkh { ///------------------------------------------------------------------------- ///------------------------------------------------------------------------- - AsciiMapSource::AsciiMapSource (const char* parFilename, const coords& parSize, dk::MapTypes parMapType, const coords& parTileSize) : - m_mapSize(parSize), + AsciiMapSource::AsciiMapSource (const char* parFilename, dk::MapTypes parMapType, const coords& parTileSize) : + m_mapSize(0), m_pixel_conv(parTileSize), m_mapType(parMapType) { @@ -40,8 +40,8 @@ namespace dkh { ///------------------------------------------------------------------------- ///------------------------------------------------------------------------- - AsciiMapSource::AsciiMapSource (const std::string& parFilename, const coords& parSize, dk::MapTypes parMapType, const coords& parTileSize) : - m_mapSize(parSize), + AsciiMapSource::AsciiMapSource (const std::string& parFilename, dk::MapTypes parMapType, const coords& parTileSize) : + m_mapSize(0), m_pixel_conv(parTileSize), m_mapType(parMapType) { @@ -51,8 +51,8 @@ namespace dkh { ///------------------------------------------------------------------------- ///------------------------------------------------------------------------- - AsciiMapSource::AsciiMapSource (std::istream& parData, const coords& parSize, dk::MapTypes parMapType, const coords& parTileSize) : - m_mapSize(parSize), + AsciiMapSource::AsciiMapSource (std::istream& parData, dk::MapTypes parMapType, const coords& parTileSize) : + m_mapSize(0), m_pixel_conv(parTileSize), m_mapType(parMapType) { @@ -92,12 +92,6 @@ namespace dkh { //http://boost.2283326.n4.nabble.com/Possible-bug-in-line-pos-iterator-td4636592.html map_size.x() = grammar.lengths.front(); map_size.y() = m_wholedata.size() / map_size.x(); - if (map_size != m_mapSize) { - std::ostringstream oss; - oss << "Calculated map size is " << map_size << - " which is different than the expected size " << m_mapSize; - throw std::runtime_error(oss.str()); - } } const AsciiMapSource::coords& AsciiMapSource::mapSize() const { diff --git a/test/main.cpp b/test/main.cpp index cd359ab..f277abd 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -168,7 +168,7 @@ namespace { typedef dkh::AsciiMapSource::coords coords; parLayerInfo.path = parPath; - parLayerInfo.device.reset(new dkh::AsciiMapSource(parLayerInfo.path, coords(10, 6), dk::MapType_IsometricStaggered, coords(64, 64))); + parLayerInfo.device.reset(new dkh::AsciiMapSource(parLayerInfo.path, dk::MapType_IsometricStaggered, coords(64, 64))); parLayerInfo.layer = &parTiler.push_layer(parLayerInfo.device.get(), 0); } diff --git a/test/unit/asciimapsource.cpp b/test/unit/asciimapsource.cpp index 8783ccf..53dedce 100644 --- a/test/unit/asciimapsource.cpp +++ b/test/unit/asciimapsource.cpp @@ -35,7 +35,7 @@ asciimapsource::asciimapsource() : layer(nullptr) { std::istringstream iss((std::string(map_data))); - loader.reset(new dkh::AsciiMapSource(iss, coords2(map_width, map_height), dk::MapType_Isometric, coords2(tile_size))); + loader.reset(new dkh::AsciiMapSource(iss, dk::MapType_Isometric, coords2(tile_size))); layer = &tiler.push_layer(loader.get(), 0); } @@ -44,7 +44,7 @@ void asciimapsource::SetUp() { } TEST_F(asciimapsource, load) { - dk::Viewport<2> full_view(tiler, coords2(map_width, map_height), coords2(0)); + dk::Viewport<2> full_view(tiler, tiler.map_size(), coords2(0)); EXPECT_EQ(coords2(map_width, map_height), tiler.map_size()); @@ -68,7 +68,7 @@ TEST_F(asciimapsource, load) { TEST_F(asciimapsource, coordinates) { const coords2 tsize(tile_size); - dk::Viewport<2> full_view(tiler, coords2(map_width, map_height), coords2(0)); + dk::Viewport<2> full_view(tiler, tiler.map_size(), coords2(0)); dk::PixelConvSquare<2> iso_conv((tsize)); dk::PixelConvDiamond diamond_conv(tsize, true, false); dk::PixelConvDiamond diamond_conv2(tsize, true, true);