some generation-time mud flow tweaking

This commit is contained in:
Perttu Ahola 2011-02-03 13:48:17 +02:00
parent 9b1b57a523
commit 71dbee43d0
5 changed files with 123 additions and 73 deletions

@ -27,7 +27,7 @@ void set_default_settings()
g_settings.setDefault("wanted_fps", "30"); g_settings.setDefault("wanted_fps", "30");
g_settings.setDefault("fps_max", "60"); g_settings.setDefault("fps_max", "60");
g_settings.setDefault("viewing_range_nodes_max", "300"); g_settings.setDefault("viewing_range_nodes_max", "300");
g_settings.setDefault("viewing_range_nodes_min", "28"); g_settings.setDefault("viewing_range_nodes_min", "35");
g_settings.setDefault("screenW", "800"); g_settings.setDefault("screenW", "800");
g_settings.setDefault("screenH", "600"); g_settings.setDefault("screenH", "600");
g_settings.setDefault("port", ""); g_settings.setDefault("port", "");

@ -350,6 +350,8 @@ Doing now:
- Needs method SyncProcessData - Needs method SyncProcessData
* What is the problem with the server constantly saving one or a few * What is the problem with the server constantly saving one or a few
blocks? List the first saved block, maybe it explains. blocks? List the first saved block, maybe it explains.
* Water doesn't start flowing after map generation like it should
* Better water generation
====================================================================== ======================================================================
@ -2775,7 +2777,8 @@ int main(int argc, char *argv[])
if(g_settings.getBool("enable_fog") == true) if(g_settings.getBool("enable_fog") == true)
{ {
f32 range = draw_control.wanted_range * BS; //f32 range = draw_control.wanted_range * BS + MAP_BLOCKSIZE/2*BS;
f32 range = draw_control.wanted_range * BS + MAP_BLOCKSIZE/3*BS;
if(draw_control.range_all) if(draw_control.range_all)
range = 100000*BS; range = 100000*BS;

@ -1455,7 +1455,8 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
u32 loopcount = 0; u32 loopcount = 0;
u32 initial_size = m_transforming_liquid.size(); u32 initial_size = m_transforming_liquid.size();
//dstream<<"transformLiquids(): initial_size="<<initial_size<<std::endl; if(initial_size != 0)
dstream<<"transformLiquids(): initial_size="<<initial_size<<std::endl;
while(m_transforming_liquid.size() != 0) while(m_transforming_liquid.size() != 0)
{ {
@ -2321,9 +2322,13 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
Randomize some parameters Randomize some parameters
*/ */
u32 stone_obstacle_amount = u32 stone_obstacle_amount = 0;
myrand_range(0, myrand_range(20, 150)); if(myrand() % 2 == 0)
//myrand_range(0, myrand_range(20, myrand_range(80,150))); stone_obstacle_amount = myrand_range(0, myrand_range(20, 150));
else
stone_obstacle_amount = myrand_range(0, myrand_range(20, 50));
//u32 stone_obstacle_amount =
// myrand_range(0, myrand_range(20, myrand_range(80,150)));
/* /*
Loop this part, it will make stuff look older and newer nicely Loop this part, it will make stuff look older and newer nicely
@ -2375,7 +2380,7 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
); );
// Minimum space left on top of the obstacle // Minimum space left on top of the obstacle
s16 min_head_space = 10; s16 min_head_space = 12;
for(s16 x=-ob_size.X/2; x<ob_size.X/2; x++) for(s16 x=-ob_size.X/2; x<ob_size.X/2; x++)
for(s16 z=-ob_size.Z/2; z<ob_size.Z/2; z++) for(s16 z=-ob_size.Z/2; z<ob_size.Z/2; z++)
@ -2449,7 +2454,7 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
} }
// Add mud // Add mud
count = 0; count = 0;
for(; y<=y_nodes_max; y++) for(; y<=y_nodes_max - min_head_space; y++)
{ {
MapNode &n = vmanip.m_data[i]; MapNode &n = vmanip.m_data[i];
n.d = CONTENT_MUD; n.d = CONTENT_MUD;
@ -2587,11 +2592,11 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
s16 d1 = d0 + rs - 1; s16 d1 = d0 + rs - 1;
for(s16 z0=d0; z0<=d1; z0++) for(s16 z0=d0; z0<=d1; z0++)
{ {
s16 si = rs - abs(z0); s16 si = rs - MYMAX(0, abs(z0)-rs/4);
for(s16 x0=-si; x0<=si-1; x0++) for(s16 x0=-si; x0<=si-1; x0++)
{ {
s16 maxabsxz = abs(x0)>abs(z0)?abs(x0):abs(z0); s16 maxabsxz = MYMAX(abs(x0), abs(z0));
s16 si2 = rs - maxabsxz; s16 si2 = rs - MYMAX(0, maxabsxz-rs/4);
//s16 si2 = rs - abs(x0); //s16 si2 = rs - abs(x0);
for(s16 y0=-si2+1; y0<=si2-1; y0++) for(s16 y0=-si2+1; y0<=si2-1; y0++)
{ {
@ -2638,7 +2643,7 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
/* /*
Make ore veins Make ore veins
*/ */
for(u32 jj=0; jj<relative_volume/524; jj++) for(u32 jj=0; jj<relative_volume/2000; jj++)
{ {
s16 max_vein_diameter = 3; s16 max_vein_diameter = 3;
@ -2768,6 +2773,8 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
Add mud to the central chunk Add mud to the central chunk
*/ */
s16 mud_add_amount = myrand_range(1, 5);
for(s16 x=0; x<sectorpos_base_size*MAP_BLOCKSIZE; x++) for(s16 x=0; x<sectorpos_base_size*MAP_BLOCKSIZE; x++)
for(s16 z=0; z<sectorpos_base_size*MAP_BLOCKSIZE; z++) for(s16 z=0; z<sectorpos_base_size*MAP_BLOCKSIZE; z++)
{ {
@ -2802,7 +2809,7 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
MapNode &n = vmanip.m_data[i]; MapNode &n = vmanip.m_data[i];
n.d = CONTENT_MUD; n.d = CONTENT_MUD;
mudcount++; mudcount++;
if(mudcount >= 3) if(mudcount >= mud_add_amount)
break; break;
vmanip.m_area.add_y(em, i, 1); vmanip.m_area.add_y(em, i, 1);
@ -2838,11 +2845,17 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
leaving out removing light from the borders for optimization leaving out removing light from the borders for optimization
and simplicity. and simplicity.
*/ */
for(s16 x=0-max_spread_amount+2; /*for(s16 x=0-max_spread_amount+2;
x<sectorpos_base_size*MAP_BLOCKSIZE+max_spread_amount-2; x<sectorpos_base_size*MAP_BLOCKSIZE+max_spread_amount-2;
x++) x++)
for(s16 z=0-max_spread_amount+2; for(s16 z=0-max_spread_amount+2;
z<sectorpos_base_size*MAP_BLOCKSIZE+max_spread_amount-2; z<sectorpos_base_size*MAP_BLOCKSIZE+max_spread_amount-2;
z++)*/
for(s16 x=0-max_spread_amount+1;
x<sectorpos_base_size*MAP_BLOCKSIZE+max_spread_amount-1;
x++)
for(s16 z=0-max_spread_amount+1;
z<sectorpos_base_size*MAP_BLOCKSIZE+max_spread_amount-1;
z++) z++)
{ {
// Node position in 2d // Node position in 2d
@ -2850,26 +2863,39 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
v3s16 em = vmanip.m_area.getExtent(); v3s16 em = vmanip.m_area.getExtent();
u32 i = vmanip.m_area.index(v3s16(p2d.X, y_nodes_max, p2d.Y)); u32 i = vmanip.m_area.index(v3s16(p2d.X, y_nodes_max, p2d.Y));
s16 y; s16 y=y_nodes_max;
// Go to ground level
for(y=y_nodes_max; y>=y_nodes_min; y--) for(;;)
{ {
MapNode &n = vmanip.m_data[i]; MapNode *n = NULL;
//if(n.d != CONTENT_AIR) // Find mud
if(content_walkable(n.d)) for(; y>=y_nodes_min; y--)
{
n = &vmanip.m_data[i];
//if(content_walkable(n->d))
// break;
if(n->d == CONTENT_MUD || n->d == CONTENT_GRASS)
break; break;
vmanip.m_area.add_y(em, i, -1); vmanip.m_area.add_y(em, i, -1);
} }
// If not mud, do nothing to it // Stop if out of area
//if(vmanip.m_area.contains(i) == false)
if(y < y_nodes_min)
break;
/*// If not mud, do nothing to it
MapNode *n = &vmanip.m_data[i]; MapNode *n = &vmanip.m_data[i];
if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS) if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS)
continue; continue;*/
// Make it exactly mud // Make it exactly mud
n->d = CONTENT_MUD; n->d = CONTENT_MUD;
/*s16 recurse_count = 0;
mudflow_recurse:*/
v3s16 dirs4[4] = { v3s16 dirs4[4] = {
v3s16(0,0,1), // back v3s16(0,0,1), // back
v3s16(1,0,0), // right v3s16(1,0,0), // right
@ -2883,19 +2909,29 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
{ {
v3s16 dirp = dirs4[di]; v3s16 dirp = dirs4[di];
u32 i2 = i; u32 i2 = i;
// Check that side is air // Move to side
vmanip.m_area.add_p(em, i2, dirp); vmanip.m_area.add_p(em, i2, dirp);
// Fail if out of area
if(vmanip.m_area.contains(i2) == false)
continue;
// Check that side is air
MapNode *n2 = &vmanip.m_data[i2]; MapNode *n2 = &vmanip.m_data[i2];
if(content_walkable(n2->d)) if(content_walkable(n2->d))
continue; continue;
// Check that under side is air // Check that under side is air
vmanip.m_area.add_y(em, i2, -1); vmanip.m_area.add_y(em, i2, -1);
// Fail if out of area
if(vmanip.m_area.contains(i2) == false)
continue;
n2 = &vmanip.m_data[i2]; n2 = &vmanip.m_data[i2];
if(content_walkable(n2->d)) if(content_walkable(n2->d))
continue; continue;
// Loop further down until not air // Loop further down until not air
do{ do{
vmanip.m_area.add_y(em, i2, -1); vmanip.m_area.add_y(em, i2, -1);
// Fail if out of area
if(vmanip.m_area.contains(i2) == false)
continue;
n2 = &vmanip.m_data[i2]; n2 = &vmanip.m_data[i2];
}while(content_walkable(n2->d) == false); }while(content_walkable(n2->d) == false);
// Loop one up so that we're in air // Loop one up so that we're in air
@ -2907,18 +2943,13 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
// Set old place to be air // Set old place to be air
*n = MapNode(CONTENT_AIR); *n = MapNode(CONTENT_AIR);
#if 0
// Switch mud and other and change mud source to air
//MapNode tempnode = *n2;
*n2 = *n;
//*n = tempnode;
// Force old mud position to be air
n->d = CONTENT_AIR;
#endif
// Done // Done
break; break;
} }
// Continue from next y
y--;
}
} }
} }
@ -4683,6 +4714,12 @@ void ServerMap::save(bool only_changed)
{ {
saveBlock(block); saveBlock(block);
block_count++; block_count++;
/*dstream<<"ServerMap: Written block ("
<<block->getPos().X<<","
<<block->getPos().Y<<","
<<block->getPos().Z<<")"
<<std::endl;*/
} }
} }
} }

@ -1829,5 +1829,11 @@ inline bool string_allowed(const std::string &s, const std::string &allowed_char
return true; return true;
} }
/*
Some helper stuff
*/
#define MYMIN(a,b) ((a)<(b)?(a):(b))
#define MYMAX(a,b) ((a)>(b)?(a):(b))
#endif #endif

@ -152,6 +152,10 @@ public:
p.Z >= MinEdge.Z && p.Z <= MaxEdge.Z p.Z >= MinEdge.Z && p.Z <= MaxEdge.Z
); );
} }
bool contains(s32 i) const
{
return (i >= 0 && i < getVolume());
}
bool operator==(const VoxelArea &other) const bool operator==(const VoxelArea &other) const
{ {
return (MinEdge == other.MinEdge return (MinEdge == other.MinEdge