mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
Fix warnings and other misc. minor changes
This commit is contained in:
parent
5b8855e83c
commit
8d3a68f343
@ -42,7 +42,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
class EmergeThread;
|
||||
class INodeDefManager;
|
||||
class Settings;
|
||||
//class ManualMapVoxelManipulator;
|
||||
|
||||
class BiomeManager;
|
||||
class OreManager;
|
||||
|
@ -348,7 +348,7 @@ GenElement *GenElementManager::getByName(std::string &name)
|
||||
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;
|
||||
|
@ -230,12 +230,8 @@ void MapgenV5::makeChunk(BlockMakeData *data) {
|
||||
}
|
||||
|
||||
// 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();
|
||||
|
@ -312,7 +312,7 @@ bool MapgenV6::getHaveBeach(v2s16 p) {
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
@ -387,7 +387,7 @@ bool MapgenV6::getHaveBeach(int index)
|
||||
}
|
||||
|
||||
|
||||
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(
|
||||
@ -608,7 +608,7 @@ int MapgenV6::generateGround() {
|
||||
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();
|
||||
@ -652,7 +652,7 @@ void MapgenV6::addMud() {
|
||||
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) {
|
||||
|
@ -34,7 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
extern FlagDesc flagdesc_mapgen_v6[];
|
||||
|
||||
|
||||
enum BiomeType
|
||||
enum BiomeV6Type
|
||||
{
|
||||
BT_NORMAL,
|
||||
BT_DESERT
|
||||
@ -132,8 +132,8 @@ public:
|
||||
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);
|
||||
|
||||
|
@ -233,12 +233,8 @@ void MapgenV7::makeChunk(BlockMakeData *data) {
|
||||
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();
|
||||
|
@ -76,14 +76,15 @@ BiomeManager::~BiomeManager()
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -96,10 +97,8 @@ Biome *BiomeManager::getBiome(float heat, float humidity, s16 y)
|
||||
|
||||
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;
|
||||
|
@ -23,31 +23,19 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#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;
|
||||
@ -83,7 +71,8 @@ public:
|
||||
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);
|
||||
};
|
||||
|
||||
|
@ -70,12 +70,6 @@ Ore::~Ore()
|
||||
}
|
||||
|
||||
|
||||
std::string Ore::getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
size_t Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
|
||||
{
|
||||
int in_range = 0;
|
||||
|
@ -73,7 +73,6 @@ public:
|
||||
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 {
|
||||
|
@ -38,11 +38,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
|
||||
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},
|
||||
};
|
||||
|
||||
@ -312,9 +312,9 @@ int ModApiMapgen::l_register_biome(lua_State *L)
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user