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

Mapgen: Add rudimentary unittests

This commit is contained in:
SmallJoker 2024-11-28 19:16:07 +01:00 committed by SmallJoker
parent c7fe2ee5c9
commit 50928b9759
5 changed files with 162 additions and 58 deletions

View file

@ -25,21 +25,7 @@ BiomeManager::BiomeManager(Server *server) :
// Create default biome to be used in case none exist
Biome *b = new Biome;
b->name = "default";
b->flags = 0;
b->depth_top = 0;
b->depth_filler = -MAX_MAP_GENERATION_LIMIT;
b->depth_water_top = 0;
b->depth_riverbed = 0;
b->min_pos = v3s16(-MAX_MAP_GENERATION_LIMIT,
-MAX_MAP_GENERATION_LIMIT, -MAX_MAP_GENERATION_LIMIT);
b->max_pos = v3s16(MAX_MAP_GENERATION_LIMIT,
MAX_MAP_GENERATION_LIMIT, MAX_MAP_GENERATION_LIMIT);
b->heat_point = 0.0;
b->humidity_point = 0.0;
b->vertical_blend = 0;
b->weight = 1.0f;
b->m_nodenames.emplace_back("mapgen_stone");
b->m_nodenames.emplace_back("mapgen_stone");
@ -64,11 +50,13 @@ void BiomeManager::clear()
{
EmergeManager *emerge = m_server->getEmergeManager();
// Remove all dangling references in Decorations
DecorationManager *decomgr = emerge->getWritableDecorationManager();
for (size_t i = 0; i != decomgr->getNumObjects(); i++) {
Decoration *deco = (Decoration *)decomgr->getRaw(i);
deco->biomes.clear();
if (emerge) {
// Remove all dangling references in Decorations
DecorationManager *decomgr = emerge->getWritableDecorationManager();
for (size_t i = 0; i != decomgr->getNumObjects(); i++) {
Decoration *deco = (Decoration *)decomgr->getRaw(i);
deco->biomes.clear();
}
}
// Don't delete the first biome
@ -299,8 +287,6 @@ ObjDef *Biome::clone() const
ObjDef::cloneTo(obj);
NodeResolver::cloneTo(obj);
obj->flags = flags;
obj->c_top = c_top;
obj->c_filler = c_filler;
obj->c_stone = c_stone;

View file

@ -19,6 +19,12 @@ class BiomeManager;
typedef u16 biome_t;
constexpr v3s16 MAX_MAP_GENERATION_LIMIT_V3(
MAX_MAP_GENERATION_LIMIT,
MAX_MAP_GENERATION_LIMIT,
MAX_MAP_GENERATION_LIMIT
);
#define BIOME_NONE ((biome_t)0)
enum BiomeType {
@ -29,32 +35,32 @@ class Biome : public ObjDef, public NodeResolver {
public:
ObjDef *clone() const;
u32 flags;
content_t c_top;
content_t c_filler;
content_t c_stone;
content_t c_water_top;
content_t c_water;
content_t c_river_water;
content_t c_riverbed;
content_t c_dust;
content_t
c_top = CONTENT_IGNORE,
c_filler = CONTENT_IGNORE,
c_stone = CONTENT_IGNORE,
c_water_top = CONTENT_IGNORE,
c_water = CONTENT_IGNORE,
c_river_water = CONTENT_IGNORE,
c_riverbed = CONTENT_IGNORE,
c_dust = CONTENT_IGNORE;
std::vector<content_t> c_cave_liquid;
content_t c_dungeon;
content_t c_dungeon_alt;
content_t c_dungeon_stair;
content_t
c_dungeon = CONTENT_IGNORE,
c_dungeon_alt = CONTENT_IGNORE,
c_dungeon_stair = CONTENT_IGNORE;
s16 depth_top;
s16 depth_filler;
s16 depth_water_top;
s16 depth_riverbed;
s16 depth_top = 0;
s16 depth_filler = -MAX_MAP_GENERATION_LIMIT;
s16 depth_water_top = 0;
s16 depth_riverbed = 0;
v3s16 min_pos;
v3s16 max_pos;
float heat_point;
float humidity_point;
s16 vertical_blend;
float weight;
v3s16 min_pos = -MAX_MAP_GENERATION_LIMIT_V3;
v3s16 max_pos = MAX_MAP_GENERATION_LIMIT_V3;
float heat_point = 0.0f;
float humidity_point = 0.0f;
s16 vertical_blend = 0;
float weight = 1.0f;
virtual void resolveNodeNames();
};