mirror of
https://github.com/moparisthebest/minetest
synced 2024-11-17 23:05:07 -05:00
fixed invalid block loading (the action is to generate a new one)
This commit is contained in:
parent
92432a28c0
commit
741776313a
44
src/map.cpp
44
src/map.cpp
@ -2004,34 +2004,13 @@ double tree_amount_2d(u64 seed, v2s16 p)
|
||||
return 0.04 * (noise-zeroval) / (1.0-zeroval);
|
||||
}
|
||||
|
||||
/*double base_rock_level_2d(u64 seed, v2s16 p)
|
||||
{
|
||||
return WATER_LEVEL - 6.0 + 25. * noise2d_perlin(
|
||||
0.5+(float)p.X/500., 0.5+(float)p.Y/500.,
|
||||
seed, 6, 0.6);
|
||||
}*/
|
||||
|
||||
/*double highlands_level_2d(u64 seed, v2s16 p)
|
||||
{
|
||||
double a = noise2d_perlin(
|
||||
0.5+(float)p.X/1000., 0.5+(float)p.Y/1000.,
|
||||
seed-359, 6, 0.65);
|
||||
if(a > 0.0)
|
||||
//if(1)
|
||||
{
|
||||
return WATER_LEVEL + 25;
|
||||
return WATER_LEVEL + 55. * noise2d_perlin(
|
||||
0.5+(float)p.X/500., 0.5+(float)p.Y/500.,
|
||||
seed+85039, 6, 0.69);
|
||||
}
|
||||
else
|
||||
return -100000;
|
||||
}*/
|
||||
#define AVERAGE_MUD_AMOUNT 4
|
||||
|
||||
double base_rock_level_2d(u64 seed, v2s16 p)
|
||||
{
|
||||
// The base ground level
|
||||
double base = (double)WATER_LEVEL - 4.0 + 25. * noise2d_perlin(
|
||||
double base = (double)WATER_LEVEL - (double)AVERAGE_MUD_AMOUNT
|
||||
+ 25. * noise2d_perlin(
|
||||
0.5+(float)p.X/500., 0.5+(float)p.Y/500.,
|
||||
(seed>>32)+654879876, 6, 0.6);
|
||||
|
||||
@ -3837,6 +3816,7 @@ MapBlock * ServerMap::generateBlock(
|
||||
|
||||
v2s16 p2d(p.X, p.Z);
|
||||
s16 block_y = p.Y;
|
||||
v2s16 p2d_nodes = p2d * MAP_BLOCKSIZE;
|
||||
|
||||
/*
|
||||
Do not generate over-limit
|
||||
@ -3875,14 +3855,17 @@ MapBlock * ServerMap::generateBlock(
|
||||
{
|
||||
//dstream<<"generateBlock: x0="<<x0<<", z0="<<z0<<std::endl;
|
||||
|
||||
s16 surface_y = 0;
|
||||
//s16 surface_y = 0;
|
||||
|
||||
s16 surface_y = base_rock_level_2d(m_seed, p2d_nodes+v2s16(x0,z0))
|
||||
+ AVERAGE_MUD_AMOUNT;
|
||||
|
||||
if(surface_y < lowest_ground_y)
|
||||
lowest_ground_y = surface_y;
|
||||
if(surface_y > highest_ground_y)
|
||||
highest_ground_y = surface_y;
|
||||
|
||||
s32 surface_depth = 2;
|
||||
s32 surface_depth = AVERAGE_MUD_AMOUNT;
|
||||
|
||||
for(s16 y0=0; y0<MAP_BLOCKSIZE; y0++)
|
||||
{
|
||||
@ -4500,7 +4483,7 @@ MapBlock * ServerMap::emergeBlock(
|
||||
|| p.Y > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
|
||||
|| p.Z < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
|
||||
|| p.Z > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE)
|
||||
throw InvalidPositionException("generateBlock(): pos. over limit");
|
||||
throw InvalidPositionException("emergeBlock(): pos. over limit");
|
||||
|
||||
v2s16 p2d(p.X, p.Z);
|
||||
s16 block_y = p.Y;
|
||||
@ -5169,6 +5152,10 @@ void ServerMap::loadBlock(std::string sectordir, std::string blockfile, MapSecto
|
||||
u8 version = SER_FMT_VER_INVALID;
|
||||
is.read((char*)&version, 1);
|
||||
|
||||
if(is.fail())
|
||||
throw SerializationError("ServerMap::loadBlock(): Failed"
|
||||
" to read MapBlock version");
|
||||
|
||||
/*u32 block_size = MapBlock::serializedLength(version);
|
||||
SharedBuffer<u8> data(block_size);
|
||||
is.read((char*)*data, block_size);*/
|
||||
@ -5218,7 +5205,8 @@ void ServerMap::loadBlock(std::string sectordir, std::string blockfile, MapSecto
|
||||
catch(SerializationError &e)
|
||||
{
|
||||
dstream<<"WARNING: Invalid block data on disk "
|
||||
"(SerializationError). Ignoring."
|
||||
"(SerializationError). Ignoring. "
|
||||
"A new one will be generated."
|
||||
<<std::endl;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user