diff options
author | Mattes D <github@xoft.cz> | 2020-04-03 08:57:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-03 08:57:01 +0200 |
commit | 01b8ed5295875262a91b60af878bf2a18c1b7aae (patch) | |
tree | 52171974791a7529a3a69f9fe20d906158765954 /tests/Generating | |
parent | Update Core (diff) | |
download | cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar.gz cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar.bz2 cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar.lz cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar.xz cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar.zst cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.zip |
Diffstat (limited to 'tests/Generating')
-rw-r--r-- | tests/Generating/BasicGeneratorTest.cpp | 28 | ||||
-rw-r--r-- | tests/Generating/CMakeLists.txt | 10 | ||||
-rw-r--r-- | tests/Generating/Stubs.cpp | 64 |
3 files changed, 69 insertions, 33 deletions
diff --git a/tests/Generating/BasicGeneratorTest.cpp b/tests/Generating/BasicGeneratorTest.cpp index c54ca6507..4b27f5344 100644 --- a/tests/Generating/BasicGeneratorTest.cpp +++ b/tests/Generating/BasicGeneratorTest.cpp @@ -175,7 +175,18 @@ static void testGenerateNether(cChunkGenerator & aDefaultNetherGen) { TEST_EQUAL_MSG(chd.GetBlockType(x, 0, z), E_BLOCK_BEDROCK, Printf("Bedrock floor at {%d, 0, %d}", x, z)); auto y = chd.GetHeight(x, z); - TEST_EQUAL(y, prevHeight); // Same height across the entire chunk + auto topBlockType = chd.GetBlockType(x, y, z); + // Skip the mushrooms generated on the top bedrock layer: + if ( + (topBlockType == E_BLOCK_BROWN_MUSHROOM) || + (topBlockType == E_BLOCK_RED_MUSHROOM) + ) + { + y -= 1; + } + TEST_EQUAL_MSG(y, prevHeight, Printf("Failed: Same height across the entire chunk, at {%d, %d}: exp %d, got %d; top block: %d", + x, z, prevHeight, y, chd.GetBlockType(x, y, z) + )) auto blockType = chd.GetBlockType(x, y, z); TEST_EQUAL_MSG(blockType, E_BLOCK_BEDROCK, Printf("Bedrock ceiling at {%d, %d, %d}: %d", x, y, z, blockType) @@ -245,6 +256,11 @@ static void checkChunkChecksums( { cChunkDesc chd(coords.mCoords); aGenerator.Generate(chd); + /* + cFile f(Printf("Repeatability_%s-%02d-%02d.raw", aDimension, coords.mCoords.m_ChunkX, coords.mCoords.m_ChunkZ), cFile::fmWrite); + f.Write(chd.GetBlockTypes(), sizeof(chd.GetBlockTypes())); + f.Close(); + */ auto checksum = chunkSHA1(chd); TEST_EQUAL_MSG(checksum, coords.mChecksum, Printf("%s chunk %s SHA1: expected %s, got %s", aDimension, coords.mCoords.ToString(), coords.mChecksum, checksum) @@ -275,11 +291,11 @@ static void testRepeatability(cChunkGenerator & aDefaultOverworldGenerator, cChu // Test the default Nether generator: std::vector<CoordsWithChecksum> netherChecksums = { - { 0, 0, "-25231a9ce4bc57eaeaf1f4ad01c32ddd5b2293e5"}, - { 1, 0, "-61ef8824b6b241b4f0e28c09505bad5d7898a8a4"}, - { 1, 1, "6b3ba6dcb18568e21b3a5aae9ea58368079fbaf8"}, - {17, 0, "1acc3a28eb1be66b3e4a256f0712a48f96085a39"}, - { 8, 1024, "6f9b96e0613ca2fd879dbb53634b511e5649627a"}, + { 0, 0, "-487001a1ada9cdd7c8b557d3ff7081881f57c660"}, + { 1, 0, "a074ac7a1f2fbf4173324e5edd792197d6a29c2"}, + { 1, 1, "5867c5121f2a259ebc2aa53ecafed93dd3d6de95"}, + {17, 0, "-300191cee5b30592f7b61cd22ea08669eba3f569"}, + { 8, 1024, "69bbda09be981f5e3adc53d0a49995aff43f1290"}, }; checkChunkChecksums(aDefaultNetherGenerator, netherChecksums, "Nether"); } diff --git a/tests/Generating/CMakeLists.txt b/tests/Generating/CMakeLists.txt index cfdae6c68..cf8e2faa0 100644 --- a/tests/Generating/CMakeLists.txt +++ b/tests/Generating/CMakeLists.txt @@ -11,9 +11,11 @@ add_definitions(-DTEST_GLOBALS=1) set (SHARED_SRCS ${CMAKE_SOURCE_DIR}/src/BiomeDef.cpp ${CMAKE_SOURCE_DIR}/src/BlockArea.cpp - ${CMAKE_SOURCE_DIR}/src/BlockID.cpp + ${CMAKE_SOURCE_DIR}/src/BlockInfo.cpp + ${CMAKE_SOURCE_DIR}/src/BlockType.cpp ${CMAKE_SOURCE_DIR}/src/Cuboid.cpp ${CMAKE_SOURCE_DIR}/src/ChunkData.cpp + ${CMAKE_SOURCE_DIR}/src/Defines.cpp ${CMAKE_SOURCE_DIR}/src/Enchantments.cpp ${CMAKE_SOURCE_DIR}/src/FastRandom.cpp ${CMAKE_SOURCE_DIR}/src/IniFile.cpp @@ -71,10 +73,12 @@ set (GENERATING_SRCS set (SHARED_HDRS ${CMAKE_SOURCE_DIR}/src/BiomeDef.h ${CMAKE_SOURCE_DIR}/src/BlockArea.h - ${CMAKE_SOURCE_DIR}/src/BlockID.h + ${CMAKE_SOURCE_DIR}/src/BlockInfo.h + ${CMAKE_SOURCE_DIR}/src/BlockType.h ${CMAKE_SOURCE_DIR}/src/Cuboid.h ${CMAKE_SOURCE_DIR}/src/ChunkData.h ${CMAKE_SOURCE_DIR}/src/ChunkDef.h + ${CMAKE_SOURCE_DIR}/src/Defines.h ${CMAKE_SOURCE_DIR}/src/Enchantments.h ${CMAKE_SOURCE_DIR}/src/FastRandom.h ${CMAKE_SOURCE_DIR}/src/Globals.h @@ -157,7 +161,7 @@ add_library(GeneratorTestingSupport STATIC ${GENERATING_HDRS} ${STUBS} ) -target_link_libraries(GeneratorTestingSupport tolualib zlib fmt::fmt) +target_link_libraries(GeneratorTestingSupport tolualib zlib fmt::fmt jsoncpp_lib_static) source_group("Stubs" FILES ${STUBS}) source_group("Generating" FILES ${GENERATING_HDRS} ${GENERATING_SRCS}) diff --git a/tests/Generating/Stubs.cpp b/tests/Generating/Stubs.cpp index 7bbd6b2da..7ccd6305e 100644 --- a/tests/Generating/Stubs.cpp +++ b/tests/Generating/Stubs.cpp @@ -93,30 +93,6 @@ extern "C" int luaopen_lxp(lua_State * a_LuaState) -void cBlockInfo::sHandlerDeleter::operator () (cBlockHandler * a_Handler) -{ - delete a_Handler; -} - - - - - -cBlockInfo::cBlockInfoArray::cBlockInfoArray() -{ - cBlockInfoArray & BlockInfos = *this; - // The piece-loading code uses the handlers for rotations, so we need valid handlers - // Insert dummy handlers: - for (size_t i = 0; i < BlockInfos.size(); i++) - { - BlockInfos[i].m_Handler.reset(new cBlockHandler(static_cast<BLOCKTYPE>(i))); - } -} - - - - - cBoundingBox::cBoundingBox(double, double, double, double, double, double) { } @@ -409,3 +385,43 @@ std::set<eMonsterType> cMobSpawner::GetAllowedMobTypes(EMCSBiome a_Biome) { return {}; } + + + + + +cItem::cItem() +{ +} + + + + + +cItem::cItem( + short a_ItemType, + char a_ItemCount, + short a_ItemDamage, + const AString & a_Enchantments, + const AString & a_CustomName, + const AStringVector & a_LoreTable +) +{ +} + + + + + +void cItem::Empty() +{ +} + + + + + +cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) +{ + return new cBlockHandler(a_BlockType); +} |