1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-30 19:22:14 +00:00

Make mapgen chunk size a v3s16 internally

This commit is contained in:
sfan5 2025-06-27 11:26:05 +02:00
parent c413ed298e
commit 0deeb57d44
7 changed files with 62 additions and 35 deletions

View file

@ -7,7 +7,9 @@
#include "noise.h"
#include "settings.h"
#include "mapgen/mapgen_v5.h"
#include "emerge.h"
#include "util/hashing.h"
#include "irrlicht_changes/printing.h"
#include "map_settings_manager.h"
class TestMapSettingsManager : public TestBase {
@ -23,6 +25,7 @@ public:
void testMapSettingsManager();
void testMapMetaSaveLoad();
void testMapMetaFailures();
void testChunks();
};
static TestMapSettingsManager g_test_instance;
@ -32,6 +35,7 @@ void TestMapSettingsManager::runTests(IGameDef *gamedef)
TEST(testMapSettingsManager);
TEST(testMapMetaSaveLoad);
TEST(testMapMetaFailures);
TEST(testChunks);
}
////////////////////////////////////////////////////////////////////////////////
@ -141,7 +145,7 @@ void TestMapSettingsManager::testMapSettingsManager()
// Now make our Params and see if the values are correctly sourced
MapgenParams *params = mgr.makeMapgenParams();
UASSERT(params->mgtype == MAPGEN_V5);
UASSERT(params->chunksize == 5);
UASSERT(params->chunksize == v3s16(5));
UASSERT(params->water_level == 15);
UASSERT(params->seed == 1234);
UASSERT((params->flags & MG_LIGHT) == 0);
@ -246,3 +250,29 @@ void TestMapSettingsManager::testMapMetaFailures()
UASSERT(!mgr2.loadMapMeta());
}
}
void TestMapSettingsManager::testChunks()
{
v3s16 csize(5);
#define GET(x) EmergeManager::getContainingChunk(x, csize)
// origin chunk goes from (-2, -2, -2) -> (3, 3, 3) excl
UASSERTEQ(auto, GET(v3s16(-2, -2, -2)), v3s16(-2, -2, -2));
UASSERTEQ(auto, GET(v3s16(0, 0, 0)), v3s16(-2, -2, -2));
UASSERTEQ(auto, GET(v3s16(1, 1, 1)), v3s16(-2, -2, -2));
UASSERTEQ(auto, GET(v3s16(2, 2, 2)), v3s16(-2, -2, -2));
UASSERTEQ(auto, GET(v3s16(2, 3, 2)), v3s16(-2, 3, -2));
UASSERTEQ(auto, GET(v3s16(0, -3, 0)), v3s16(-2, -7, -2));
csize = v3s16(5, 2, 5);
UASSERTEQ(auto, GET(v3s16(0, 0, 0)), v3s16(-2, -1, -2));
UASSERTEQ(auto, GET(v3s16(0, 1, 0)), v3s16(-2, 1, -2));
UASSERTEQ(auto, GET(v3s16(3, 3, 3)), v3s16(3, 3, 3));
csize = v3s16(1);
UASSERTEQ(auto, GET(v3s16(1, 2, 3)), v3s16(1, 2, 3));
UASSERTEQ(auto, GET(v3s16(-3, -2, -1)), v3s16(-3, -2, -1));
#undef GET
}