class EmergeThread;
class INodeDefManager;
class Settings;
-//class ManualMapVoxelManipulator;
class BiomeManager;
class OreManager;
GenElement *GenElementManager::update(u32 id, GenElement *elem)
{
if (id >= m_elements.size())
- return false;
+ return NULL;
GenElement *old_elem = m_elements[id];
m_elements[id] = elem;
}
// Calculate biomes
- BiomeNoiseInput binput;
- binput.mapsize = v2s16(csize.X, csize.Z);
- binput.heat_map = noise_heat->result;
- binput.humidity_map = noise_humidity->result;
- binput.height_map = heightmap;
- bmgr->calcBiomes(&binput, biomemap);
+ bmgr->calcBiomes(csize.X, csize.Z, noise_heat->result,
+ noise_humidity->result, heightmap, biomemap);
// Actually place the biome-specific nodes
generateBiomes();
}
-BiomeType MapgenV6::getBiome(v2s16 p) {
+BiomeV6Type MapgenV6::getBiome(v2s16 p) {
int index = (p.Y - node_min.Z) * ystride + (p.X - node_min.X);
return getBiome(index, p);
}
}
-BiomeType MapgenV6::getBiome(int index, v2s16 p)
+BiomeV6Type MapgenV6::getBiome(int index, v2s16 p)
{
// Just do something very simple as for now
/*double d = noise2d_perlin(
if (surface_y > stone_surface_max_y)
stone_surface_max_y = surface_y;
- BiomeType bt = getBiome(index, v2s16(x, z));
+ BiomeV6Type bt = getBiome(index, v2s16(x, z));
// Fill ground with stone
v3s16 em = vm->m_area.getExtent();
if (surface_y == vm->m_area.MinEdge.Y - 1)
continue;
- BiomeType bt = getBiome(index, v2s16(x, z));
+ BiomeV6Type bt = getBiome(index, v2s16(x, z));
addnode = (bt == BT_DESERT) ? n_desert_sand : n_dirt;
if (bt == BT_DESERT && surface_y + mud_add_amount <= water_level + 1) {
extern FlagDesc flagdesc_mapgen_v6[];
-enum BiomeType
+enum BiomeV6Type
{
BT_NORMAL,
BT_DESERT
virtual float getMudAmount(int index);
bool getHaveBeach(v2s16 p);
bool getHaveBeach(int index);
- BiomeType getBiome(v2s16 p);
- BiomeType getBiome(int index, v2s16 p);
+ BiomeV6Type getBiome(v2s16 p);
+ BiomeV6Type getBiome(int index, v2s16 p);
u32 get_blockseed(u64 seed, v3s16 p);
updateHeightmap(node_min, node_max);
// Calculate biomes
- BiomeNoiseInput binput;
- binput.mapsize = v2s16(csize.X, csize.Z);
- binput.heat_map = noise_heat->result;
- binput.humidity_map = noise_humidity->result;
- binput.height_map = heightmap;
- bmgr->calcBiomes(&binput, biomemap);
+ bmgr->calcBiomes(csize.X, csize.Z, noise_heat->result,
+ noise_humidity->result, heightmap, biomemap);
// Actually place the biome-specific nodes and what not
generateBiomes();
// just a PoC, obviously needs optimization later on (precalculate this)
-void BiomeManager::calcBiomes(BiomeNoiseInput *input, u8 *biomeid_map)
+void BiomeManager::calcBiomes(s16 sx, s16 sy, float *heat_map,
+ float *humidity_map, s16 *height_map, u8 *biomeid_map)
{
int i = 0;
- for (int y = 0; y != input->mapsize.Y; y++) {
- for (int x = 0; x != input->mapsize.X; x++, i++) {
- float heat = (input->heat_map[i] + 1) * 50;
- float humidity = (input->humidity_map[i] + 1) * 50;
- biomeid_map[i] = getBiome(heat, humidity, input->height_map[i])->id;
+ for (int y = 0; y != sy; y++) {
+ for (int x = 0; x != sx; x++, i++) {
+ float heat = (heat_map[i] + 1) * 50;
+ float humidity = (humidity_map[i] + 1) * 50;
+ biomeid_map[i] = getBiome(heat, humidity, height_map[i])->id;
}
}
}
for (size_t i = 1; i < m_elements.size(); i++) {
b = (Biome *)m_elements[i];
- if (!b || y > b->height_max || y < b->height_min) {
- printf("not good - %p %d %d %d\n", b, y, b->height_max, b->height_min);
+ if (!b || y > b->height_max || y < b->height_min)
continue;
- }
float d_heat = heat - b->heat_point;
float d_humidity = humidity - b->humidity_point;
#include "mapgen.h"
#include "noise.h"
-//#include <string>
-//#include "nodedef.h"
-//#include "gamedef.h"
-//#include "mapnode.h"
-
-enum BiomeTerrainType
+enum BiomeType
{
- BIOME_TERRAIN_NORMAL,
- BIOME_TERRAIN_LIQUID,
- BIOME_TERRAIN_NETHER,
- BIOME_TERRAIN_AETHER,
- BIOME_TERRAIN_FLAT
+ BIOME_TYPE_NORMAL,
+ BIOME_TYPE_LIQUID,
+ BIOME_TYPE_NETHER,
+ BIOME_TYPE_AETHER,
+ BIOME_TYPE_FLAT
};
extern NoiseParams nparams_biome_def_heat;
extern NoiseParams nparams_biome_def_humidity;
-struct BiomeNoiseInput {
- v2s16 mapsize;
- float *heat_map;
- float *humidity_map;
- s16 *height_map;
-};
-
class Biome : public GenElement {
public:
u32 flags;
return new Biome;
}
- void calcBiomes(BiomeNoiseInput *input, u8 *biomeid_map);
+ void calcBiomes(s16 sx, s16 sy, float *heat_map, float *humidity_map,
+ s16 *height_map, u8 *biomeid_map);
Biome *getBiome(float heat, float humidity, s16 y);
};
}
-std::string Ore::getName()
-{
- return name;
-}
-
-
size_t Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
{
int in_range = 0;
size_t placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
virtual void generate(ManualMapVoxelManipulator *vm, int seed,
u32 blockseed, v3s16 nmin, v3s16 nmax) = 0;
- virtual std::string getName();
};
class OreScatter : public Ore {
struct EnumString ModApiMapgen::es_BiomeTerrainType[] =
{
- {BIOME_TERRAIN_NORMAL, "normal"},
- {BIOME_TERRAIN_LIQUID, "liquid"},
- {BIOME_TERRAIN_NETHER, "nether"},
- {BIOME_TERRAIN_AETHER, "aether"},
- {BIOME_TERRAIN_FLAT, "flat"},
+ {BIOME_TYPE_NORMAL, "normal"},
+ {BIOME_TYPE_LIQUID, "liquid"},
+ {BIOME_TYPE_NETHER, "nether"},
+ {BIOME_TYPE_AETHER, "aether"},
+ {BIOME_TYPE_FLAT, "flat"},
{0, NULL},
};
NodeResolver *resolver = getServer(L)->getNodeDefManager()->getResolver();
BiomeManager *bmgr = getServer(L)->getEmergeManager()->biomemgr;
- enum BiomeTerrainType terrain = (BiomeTerrainType)getenumfield(L, index,
- "terrain_type", es_BiomeTerrainType, BIOME_TERRAIN_NORMAL);
- Biome *b = bmgr->create(terrain);
+ enum BiomeType biometype = (BiomeType)getenumfield(L, index, "type",
+ es_BiomeTerrainType, BIOME_TYPE_NORMAL);
+ Biome *b = bmgr->create(biometype);
b->name = getstringfield_default(L, index, "name", "");
b->depth_top = getintfield_default(L, index, "depth_top", 1);