mirror of
https://github.com/minetest/minetest.git
synced 2024-11-30 03:23:45 +01:00
Math mapgen fix, ip show on connect, pathfinder segfault fix
This commit is contained in:
parent
75b8c13b00
commit
f764297be2
@ -145,7 +145,7 @@ double sphere(double x, double y, double z, double d, int ITR = 1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////// Mapgen Singlenode parameter read/write
|
//////////////////////// Mapgen Math parameter read/write
|
||||||
|
|
||||||
bool MapgenMathParams::readParams(Settings *settings) {
|
bool MapgenMathParams::readParams(Settings *settings) {
|
||||||
//params = settings->getJson("mg_math");
|
//params = settings->getJson("mg_math");
|
||||||
@ -171,6 +171,8 @@ void MapgenMathParams::writeParams(Settings *settings) {
|
|||||||
|
|
||||||
MapgenMath::MapgenMath(int mapgenid, MapgenMathParams *params_, EmergeManager *emerge) : MapgenV7(mapgenid, params_, emerge) {
|
MapgenMath::MapgenMath(int mapgenid, MapgenMathParams *params_, EmergeManager *emerge) : MapgenV7(mapgenid, params_, emerge) {
|
||||||
mg_params = params_;
|
mg_params = params_;
|
||||||
|
this->lighting = 0;
|
||||||
|
this->ridges = 0;
|
||||||
|
|
||||||
Json::Value & params = mg_params->params;
|
Json::Value & params = mg_params->params;
|
||||||
invert = params["invert"].empty() ? 1 : params["invert"].asBool(); //params["invert"].empty()?1:params["invert"].asBool();
|
invert = params["invert"].empty() ? 1 : params["invert"].asBool(); //params["invert"].empty()?1:params["invert"].asBool();
|
||||||
@ -238,7 +240,7 @@ MapgenMath::~MapgenMath() {
|
|||||||
|
|
||||||
void MapgenMath::generateTerrain() {
|
void MapgenMath::generateTerrain() {
|
||||||
|
|
||||||
MapNode n_air(CONTENT_AIR), n_water_source(c_water_source, LIGHT_SUN);
|
MapNode n_air(CONTENT_AIR, LIGHT_SUN), n_water_source(c_water_source, LIGHT_SUN);
|
||||||
MapNode n_stone(c_stone, LIGHT_SUN);
|
MapNode n_stone(c_stone, LIGHT_SUN);
|
||||||
u32 index = 0;
|
u32 index = 0;
|
||||||
v3s16 em = vm->m_area.getExtent();
|
v3s16 em = vm->m_area.getExtent();
|
||||||
@ -263,6 +265,7 @@ void MapgenMath::generateTerrain() {
|
|||||||
if (vm->m_data[i].getContent() == CONTENT_IGNORE)
|
if (vm->m_data[i].getContent() == CONTENT_IGNORE)
|
||||||
vm->m_data[i] = (y > water_level + biome->filler_height) ?
|
vm->m_data[i] = (y > water_level + biome->filler_height) ?
|
||||||
MapNode(biome->c_filler) : n_stone;
|
MapNode(biome->c_filler) : n_stone;
|
||||||
|
// vm->m_data[i] = n_stone;
|
||||||
} else if (y <= water_level) {
|
} else if (y <= water_level) {
|
||||||
vm->m_data[i] = n_water_source;
|
vm->m_data[i] = n_water_source;
|
||||||
} else {
|
} else {
|
||||||
|
@ -42,8 +42,6 @@ class MapgenMath : public MapgenV7 {
|
|||||||
MapgenMath(int mapgenid, MapgenMathParams *mg_params, EmergeManager *emerge);
|
MapgenMath(int mapgenid, MapgenMathParams *mg_params, EmergeManager *emerge);
|
||||||
~MapgenMath();
|
~MapgenMath();
|
||||||
|
|
||||||
|
|
||||||
//void makeChunk(BlockMakeData *data);
|
|
||||||
void generateTerrain();
|
void generateTerrain();
|
||||||
int getGroundLevelAtPoint(v2s16 p);
|
int getGroundLevelAtPoint(v2s16 p);
|
||||||
|
|
||||||
|
@ -76,7 +76,10 @@ MapgenV7::MapgenV7(int mapgenid, MapgenV7Params *params, EmergeManager *emerge)
|
|||||||
|
|
||||||
this->seed = (int)params->seed;
|
this->seed = (int)params->seed;
|
||||||
this->water_level = params->water_level;
|
this->water_level = params->water_level;
|
||||||
this->flags = params->flags;
|
this->flags = params->flags;
|
||||||
|
this->lighting = 1;
|
||||||
|
this->ridges = 1;
|
||||||
|
|
||||||
this->csize = v3s16(1, 1, 1) * params->chunksize * MAP_BLOCKSIZE;
|
this->csize = v3s16(1, 1, 1) * params->chunksize * MAP_BLOCKSIZE;
|
||||||
this->ystride = csize.X; //////fix this
|
this->ystride = csize.X; //////fix this
|
||||||
|
|
||||||
@ -183,7 +186,8 @@ void MapgenV7::makeChunk(BlockMakeData *data) {
|
|||||||
c_lava_source = ndef->getId("mapgen_lava_source");
|
c_lava_source = ndef->getId("mapgen_lava_source");
|
||||||
|
|
||||||
generateTerrain();
|
generateTerrain();
|
||||||
carveRidges();
|
if (this->ridges)
|
||||||
|
carveRidges();
|
||||||
|
|
||||||
if (flags & MG_CAVES)
|
if (flags & MG_CAVES)
|
||||||
generateCaves(stone_surface_max_y);
|
generateCaves(stone_surface_max_y);
|
||||||
@ -211,7 +215,8 @@ void MapgenV7::makeChunk(BlockMakeData *data) {
|
|||||||
|
|
||||||
updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);
|
updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);
|
||||||
|
|
||||||
calcLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
|
if (this->lighting)
|
||||||
|
calcLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
|
||||||
node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE);
|
node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE);
|
||||||
//setLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
|
//setLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
|
||||||
// node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE, 0xFF);
|
// node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE, 0xFF);
|
||||||
|
@ -60,6 +60,8 @@ public:
|
|||||||
int ystride;
|
int ystride;
|
||||||
v3s16 csize;
|
v3s16 csize;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
|
bool lighting;
|
||||||
|
bool ridges;
|
||||||
|
|
||||||
u32 blockseed;
|
u32 blockseed;
|
||||||
v3s16 node_min;
|
v3s16 node_min;
|
||||||
|
@ -880,7 +880,7 @@ bool pathfinder::update_cost_heuristic( v3s16 ipos,
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
void pathfinder::build_path(std::vector<v3s16>& path,v3s16 pos, int level) {
|
void pathfinder::build_path(std::vector<v3s16>& path,v3s16 pos, int level) {
|
||||||
level ++;
|
level ++;
|
||||||
if (level > 1000) {
|
if (level > 700) {
|
||||||
ERROR_TARGET
|
ERROR_TARGET
|
||||||
<< LVL "Pathfinder: path is too long aborting" << std::endl;
|
<< LVL "Pathfinder: path is too long aborting" << std::endl;
|
||||||
return;
|
return;
|
||||||
|
@ -2154,7 +2154,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
os<<player->getName()<<" ";
|
os<<player->getName()<<" ";
|
||||||
}
|
}
|
||||||
|
|
||||||
actionstream<<player->getName()<<" joins game. List of players: "
|
actionstream<<player->getName()<<" ["<<addr_s<<"] "<<" joins game. List of players: "
|
||||||
<<os.str()<<std::endl;
|
<<os.str()<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,32 +185,11 @@ void Address::Resolve(const char *name)
|
|||||||
// IP address -> textual representation
|
// IP address -> textual representation
|
||||||
std::string Address::serializeString() const
|
std::string Address::serializeString() const
|
||||||
{
|
{
|
||||||
if(m_addr_family == AF_INET)
|
char str[INET6_ADDRSTRLEN];
|
||||||
{
|
if (inet_ntop(m_addr_family, (m_addr_family == AF_INET) ? (void*)&(m_address.ipv4.sin_addr) : (void*)&(m_address.ipv6.sin6_addr), str, INET6_ADDRSTRLEN) == NULL) {
|
||||||
u8 a, b, c, d, addr;
|
return std::string("");
|
||||||
addr = ntohl(m_address.ipv4.sin_addr.s_addr);
|
|
||||||
a = (addr & 0xFF000000) >> 24;
|
|
||||||
b = (addr & 0x00FF0000) >> 16;
|
|
||||||
c = (addr & 0x0000FF00) >> 8;
|
|
||||||
d = (addr & 0x000000FF);
|
|
||||||
return itos(a) + "." + itos(b) + "." + itos(c) + "." + itos(d);
|
|
||||||
}
|
}
|
||||||
else if(m_addr_family == AF_INET6)
|
return std::string(str);
|
||||||
{
|
|
||||||
std::ostringstream os;
|
|
||||||
for(int i = 0; i < 16; i += 2)
|
|
||||||
{
|
|
||||||
u16 section =
|
|
||||||
(m_address.ipv6.sin6_addr.s6_addr[i] << 8) |
|
|
||||||
(m_address.ipv6.sin6_addr.s6_addr[i + 1]);
|
|
||||||
os << std::hex << section;
|
|
||||||
if(i < 14)
|
|
||||||
os << ":";
|
|
||||||
}
|
|
||||||
return os.str();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return std::string("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sockaddr_in Address::getAddress() const
|
struct sockaddr_in Address::getAddress() const
|
||||||
|
Loading…
Reference in New Issue
Block a user