mirror of
https://github.com/moparisthebest/minetest
synced 2024-12-23 16:08:51 -05: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 EmergeThread;
|
||||||
class INodeDefManager;
|
class INodeDefManager;
|
||||||
class Settings;
|
class Settings;
|
||||||
//class ManualMapVoxelManipulator;
|
|
||||||
|
|
||||||
class BiomeManager;
|
class BiomeManager;
|
||||||
class OreManager;
|
class OreManager;
|
||||||
|
@ -348,7 +348,7 @@ GenElement *GenElementManager::getByName(std::string &name)
|
|||||||
GenElement *GenElementManager::update(u32 id, GenElement *elem)
|
GenElement *GenElementManager::update(u32 id, GenElement *elem)
|
||||||
{
|
{
|
||||||
if (id >= m_elements.size())
|
if (id >= m_elements.size())
|
||||||
return false;
|
return NULL;
|
||||||
|
|
||||||
GenElement *old_elem = m_elements[id];
|
GenElement *old_elem = m_elements[id];
|
||||||
m_elements[id] = elem;
|
m_elements[id] = elem;
|
||||||
|
@ -230,12 +230,8 @@ void MapgenV5::makeChunk(BlockMakeData *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate biomes
|
// Calculate biomes
|
||||||
BiomeNoiseInput binput;
|
bmgr->calcBiomes(csize.X, csize.Z, noise_heat->result,
|
||||||
binput.mapsize = v2s16(csize.X, csize.Z);
|
noise_humidity->result, heightmap, biomemap);
|
||||||
binput.heat_map = noise_heat->result;
|
|
||||||
binput.humidity_map = noise_humidity->result;
|
|
||||||
binput.height_map = heightmap;
|
|
||||||
bmgr->calcBiomes(&binput, biomemap);
|
|
||||||
|
|
||||||
// Actually place the biome-specific nodes
|
// Actually place the biome-specific nodes
|
||||||
generateBiomes();
|
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);
|
int index = (p.Y - node_min.Z) * ystride + (p.X - node_min.X);
|
||||||
return getBiome(index, p);
|
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
|
// Just do something very simple as for now
|
||||||
/*double d = noise2d_perlin(
|
/*double d = noise2d_perlin(
|
||||||
@ -608,7 +608,7 @@ int MapgenV6::generateGround() {
|
|||||||
if (surface_y > stone_surface_max_y)
|
if (surface_y > stone_surface_max_y)
|
||||||
stone_surface_max_y = surface_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
|
// Fill ground with stone
|
||||||
v3s16 em = vm->m_area.getExtent();
|
v3s16 em = vm->m_area.getExtent();
|
||||||
@ -652,7 +652,7 @@ void MapgenV6::addMud() {
|
|||||||
if (surface_y == vm->m_area.MinEdge.Y - 1)
|
if (surface_y == vm->m_area.MinEdge.Y - 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BiomeType bt = getBiome(index, v2s16(x, z));
|
BiomeV6Type bt = getBiome(index, v2s16(x, z));
|
||||||
addnode = (bt == BT_DESERT) ? n_desert_sand : n_dirt;
|
addnode = (bt == BT_DESERT) ? n_desert_sand : n_dirt;
|
||||||
|
|
||||||
if (bt == BT_DESERT && surface_y + mud_add_amount <= water_level + 1) {
|
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[];
|
extern FlagDesc flagdesc_mapgen_v6[];
|
||||||
|
|
||||||
|
|
||||||
enum BiomeType
|
enum BiomeV6Type
|
||||||
{
|
{
|
||||||
BT_NORMAL,
|
BT_NORMAL,
|
||||||
BT_DESERT
|
BT_DESERT
|
||||||
@ -132,8 +132,8 @@ public:
|
|||||||
virtual float getMudAmount(int index);
|
virtual float getMudAmount(int index);
|
||||||
bool getHaveBeach(v2s16 p);
|
bool getHaveBeach(v2s16 p);
|
||||||
bool getHaveBeach(int index);
|
bool getHaveBeach(int index);
|
||||||
BiomeType getBiome(v2s16 p);
|
BiomeV6Type getBiome(v2s16 p);
|
||||||
BiomeType getBiome(int index, v2s16 p);
|
BiomeV6Type getBiome(int index, v2s16 p);
|
||||||
|
|
||||||
u32 get_blockseed(u64 seed, v3s16 p);
|
u32 get_blockseed(u64 seed, v3s16 p);
|
||||||
|
|
||||||
|
@ -233,12 +233,8 @@ void MapgenV7::makeChunk(BlockMakeData *data) {
|
|||||||
updateHeightmap(node_min, node_max);
|
updateHeightmap(node_min, node_max);
|
||||||
|
|
||||||
// Calculate biomes
|
// Calculate biomes
|
||||||
BiomeNoiseInput binput;
|
bmgr->calcBiomes(csize.X, csize.Z, noise_heat->result,
|
||||||
binput.mapsize = v2s16(csize.X, csize.Z);
|
noise_humidity->result, heightmap, biomemap);
|
||||||
binput.heat_map = noise_heat->result;
|
|
||||||
binput.humidity_map = noise_humidity->result;
|
|
||||||
binput.height_map = heightmap;
|
|
||||||
bmgr->calcBiomes(&binput, biomemap);
|
|
||||||
|
|
||||||
// Actually place the biome-specific nodes and what not
|
// Actually place the biome-specific nodes and what not
|
||||||
generateBiomes();
|
generateBiomes();
|
||||||
|
@ -76,14 +76,15 @@ BiomeManager::~BiomeManager()
|
|||||||
|
|
||||||
|
|
||||||
// just a PoC, obviously needs optimization later on (precalculate this)
|
// 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;
|
int i = 0;
|
||||||
for (int y = 0; y != input->mapsize.Y; y++) {
|
for (int y = 0; y != sy; y++) {
|
||||||
for (int x = 0; x != input->mapsize.X; x++, i++) {
|
for (int x = 0; x != sx; x++, i++) {
|
||||||
float heat = (input->heat_map[i] + 1) * 50;
|
float heat = (heat_map[i] + 1) * 50;
|
||||||
float humidity = (input->humidity_map[i] + 1) * 50;
|
float humidity = (humidity_map[i] + 1) * 50;
|
||||||
biomeid_map[i] = getBiome(heat, humidity, input->height_map[i])->id;
|
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++) {
|
for (size_t i = 1; i < m_elements.size(); i++) {
|
||||||
b = (Biome *)m_elements[i];
|
b = (Biome *)m_elements[i];
|
||||||
if (!b || y > b->height_max || y < b->height_min) {
|
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);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
float d_heat = heat - b->heat_point;
|
float d_heat = heat - b->heat_point;
|
||||||
float d_humidity = humidity - b->humidity_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 "mapgen.h"
|
||||||
#include "noise.h"
|
#include "noise.h"
|
||||||
|
|
||||||
//#include <string>
|
enum BiomeType
|
||||||
//#include "nodedef.h"
|
|
||||||
//#include "gamedef.h"
|
|
||||||
//#include "mapnode.h"
|
|
||||||
|
|
||||||
enum BiomeTerrainType
|
|
||||||
{
|
{
|
||||||
BIOME_TERRAIN_NORMAL,
|
BIOME_TYPE_NORMAL,
|
||||||
BIOME_TERRAIN_LIQUID,
|
BIOME_TYPE_LIQUID,
|
||||||
BIOME_TERRAIN_NETHER,
|
BIOME_TYPE_NETHER,
|
||||||
BIOME_TERRAIN_AETHER,
|
BIOME_TYPE_AETHER,
|
||||||
BIOME_TERRAIN_FLAT
|
BIOME_TYPE_FLAT
|
||||||
};
|
};
|
||||||
|
|
||||||
extern NoiseParams nparams_biome_def_heat;
|
extern NoiseParams nparams_biome_def_heat;
|
||||||
extern NoiseParams nparams_biome_def_humidity;
|
extern NoiseParams nparams_biome_def_humidity;
|
||||||
|
|
||||||
|
|
||||||
struct BiomeNoiseInput {
|
|
||||||
v2s16 mapsize;
|
|
||||||
float *heat_map;
|
|
||||||
float *humidity_map;
|
|
||||||
s16 *height_map;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Biome : public GenElement {
|
class Biome : public GenElement {
|
||||||
public:
|
public:
|
||||||
u32 flags;
|
u32 flags;
|
||||||
@ -83,7 +71,8 @@ public:
|
|||||||
return new Biome;
|
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);
|
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)
|
size_t Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
|
||||||
{
|
{
|
||||||
int in_range = 0;
|
int in_range = 0;
|
||||||
|
@ -73,7 +73,6 @@ public:
|
|||||||
size_t placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
|
size_t placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
|
||||||
virtual void generate(ManualMapVoxelManipulator *vm, int seed,
|
virtual void generate(ManualMapVoxelManipulator *vm, int seed,
|
||||||
u32 blockseed, v3s16 nmin, v3s16 nmax) = 0;
|
u32 blockseed, v3s16 nmin, v3s16 nmax) = 0;
|
||||||
virtual std::string getName();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class OreScatter : public Ore {
|
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[] =
|
struct EnumString ModApiMapgen::es_BiomeTerrainType[] =
|
||||||
{
|
{
|
||||||
{BIOME_TERRAIN_NORMAL, "normal"},
|
{BIOME_TYPE_NORMAL, "normal"},
|
||||||
{BIOME_TERRAIN_LIQUID, "liquid"},
|
{BIOME_TYPE_LIQUID, "liquid"},
|
||||||
{BIOME_TERRAIN_NETHER, "nether"},
|
{BIOME_TYPE_NETHER, "nether"},
|
||||||
{BIOME_TERRAIN_AETHER, "aether"},
|
{BIOME_TYPE_AETHER, "aether"},
|
||||||
{BIOME_TERRAIN_FLAT, "flat"},
|
{BIOME_TYPE_FLAT, "flat"},
|
||||||
{0, NULL},
|
{0, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -312,9 +312,9 @@ int ModApiMapgen::l_register_biome(lua_State *L)
|
|||||||
NodeResolver *resolver = getServer(L)->getNodeDefManager()->getResolver();
|
NodeResolver *resolver = getServer(L)->getNodeDefManager()->getResolver();
|
||||||
BiomeManager *bmgr = getServer(L)->getEmergeManager()->biomemgr;
|
BiomeManager *bmgr = getServer(L)->getEmergeManager()->biomemgr;
|
||||||
|
|
||||||
enum BiomeTerrainType terrain = (BiomeTerrainType)getenumfield(L, index,
|
enum BiomeType biometype = (BiomeType)getenumfield(L, index, "type",
|
||||||
"terrain_type", es_BiomeTerrainType, BIOME_TERRAIN_NORMAL);
|
es_BiomeTerrainType, BIOME_TYPE_NORMAL);
|
||||||
Biome *b = bmgr->create(terrain);
|
Biome *b = bmgr->create(biometype);
|
||||||
|
|
||||||
b->name = getstringfield_default(L, index, "name", "");
|
b->name = getstringfield_default(L, index, "name", "");
|
||||||
b->depth_top = getintfield_default(L, index, "depth_top", 1);
|
b->depth_top = getintfield_default(L, index, "depth_top", 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user