From 3891bc43e084b9bd1c345638dfbbffa9d71658c9 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Mon, 17 Jan 2011 02:40:53 +0200 Subject: fine-tuning of map generator and server and stuff. --- src/map.cpp | 241 +++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 150 insertions(+), 91 deletions(-) (limited to 'src/map.cpp') diff --git a/src/map.cpp b/src/map.cpp index c290f69e9..d15ac0a7b 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1317,17 +1317,26 @@ ServerMap::ServerMap(std::string savedir, HMParams hmp, MapParams mp): */ { + dstream<<"Generating map point attribute lists"<addPoint(p, Attribute(plants_amount)); + } + + for(u32 i=0; i<1000; i++) + { + /*u32 lim = MAP_GENERATION_LIMIT; + if(i < 400) + lim = 2000;*/ + + u32 lim = 500 + MAP_GENERATION_LIMIT * i / 1000; + + v3s16 p( + -lim + myrand()%(lim*2), + 0, + -lim + myrand()%(lim*2) + ); + float caves_amount = 0; if(myrand()%5 == 0) { @@ -1370,20 +1397,21 @@ ServerMap::ServerMap(std::string savedir, HMParams hmp, MapParams mp): caves_amount = 0.05; } - list_plants_amount->addPoint(p, Attribute(plants_amount)); list_caves_amount->addPoint(p, Attribute(caves_amount)); } -#if 1 - for(u32 i=0; i<3000; i++) + + for(u32 i=0; i<5000; i++) { - u32 lim = MAP_GENERATION_LIMIT; - if(i < 100) - lim = 1000; + /*u32 lim = MAP_GENERATION_LIMIT; + if(i < 400) + lim = 2000;*/ + + u32 lim = 1000 + MAP_GENERATION_LIMIT * i / 5000; v3s16 p( - -lim + myrand()%(lim*2), + -lim + (myrand()%(lim*2)), 0, - -lim + myrand()%(lim*2) + -lim + (myrand()%(lim*2)) ); /*s32 bh_i = (myrand()%200) - 50; @@ -1404,13 +1432,13 @@ ServerMap::ServerMap(std::string savedir, HMParams hmp, MapParams mp): if(myrand()%4 == 0) { baseheight = 100; - randmax = 100; + randmax = 50; randfactor = 0.63; } - else if(myrand()%5 == 0) + else if(myrand()%6 == 0) { baseheight = 200; - randmax = 200; + randmax = 100; randfactor = 0.66; } else if(myrand()%4 == 0) @@ -1423,7 +1451,7 @@ ServerMap::ServerMap(std::string savedir, HMParams hmp, MapParams mp): { baseheight = 0; randmax = 30; - randfactor = 0.60; + randfactor = 0.63; } else { @@ -1436,68 +1464,16 @@ ServerMap::ServerMap(std::string savedir, HMParams hmp, MapParams mp): list_randmax->addPoint(p, Attribute(randmax)); list_randfactor->addPoint(p, Attribute(randfactor)); } -#endif /*list_baseheight->addPoint(v3s16(0,0,0), Attribute(5)); list_randmax->addPoint(v3s16(0,0,0), Attribute(20)); list_randfactor->addPoint(v3s16(0,0,0), Attribute(0.6));*/ - } - -#if 0 - { - PointAttributeList *palist = m_padb.getList("hm_baseheight"); - - { - v3s16 p(0,0,0); - Attribute attr; - attr.set("5"); - palist->addPoint(p, attr); - } - /*{ - v3s16 p(-50,-50,0); - Attribute attr; - attr.set("-10"); - palist->addPoint(p, attr); - } - - { - v3s16 p(50,0,50); - Attribute attr; - attr.set("200"); - palist->addPoint(p, attr); - }*/ + // Easy spawn point + /*list_baseheight->addPoint(v3s16(0,0,0), Attribute(0)); + list_randmax->addPoint(v3s16(0,0,0), Attribute(10)); + list_randfactor->addPoint(v3s16(0,0,0), Attribute(0.65));*/ } -#endif -#if 0 - { - PointAttributeList *palist = m_padb.getList("plants_amount"); - - // Back - { - v3s16 p(0,0,-100); - Attribute attr; - attr.set("0"); - palist->addPoint(p, attr); - } - - // Front right - { - v3s16 p(100,0,100); - Attribute attr; - attr.set("2.0"); - palist->addPoint(p, attr); - } - - // Front left - { - v3s16 p(-100,0,100); - Attribute attr; - attr.set("0.2"); - palist->addPoint(p, attr); - } - } -#endif /* Try to load map; if not found, create a new one. @@ -1704,6 +1680,8 @@ MapSector * ServerMap::emergeSector(v2s16 p2d) Get local attributes */ + //dstream<<"emergeSector(): Reading point attribute lists"<getInterpolatedFloat(nodepos2d); + //dstream<<"emergeSector(): done."< 0.001) { if(myrand()%(s32)(200.0 / m_params.ravines_amount) == 0) { @@ -2061,13 +2041,32 @@ MapBlock * ServerMap::emergeBlock( bool some_part_underground = block_y * MAP_BLOCKSIZE <= highest_ground_y; + bool mostly_underwater_surface = false; + if(highest_ground_y < WATER_LEVEL + && some_part_underground && !completely_underground) + mostly_underwater_surface = true; + /* Get local attributes */ + + //dstream<<"emergeBlock(): Getting local attributes"<getInterpolatedFloat(nodepos2d); + { + /* + NOTE: BEWARE: Too big amount of attribute points slows verything + down by a lot. + 1 interpolation from 5000 points takes 2-3ms. + */ + //TimeTaker timer("emergeBlock() local attribute retrieval"); + v2s16 nodepos2d = p2d * MAP_BLOCKSIZE; + PointAttributeList *list_caves_amount = m_padb.getList("caves_amount"); + caves_amount = list_caves_amount->getInterpolatedFloat(nodepos2d); + } + + //dstream<<"emergeBlock(): Done"<getPos()] = block; @@ -2336,9 +2350,9 @@ continue_generating: /* Add meseblocks */ - for(s16 i=0; i< underground_level/4 + 1; i++) + for(s16 i=0; igetPos(), block); } - + + /* + Debug information + */ + if(0) + { + dstream + <<"lighting_invalidated_blocks.size()" + <<", has_dungeons" + <<", completely_ug" + <<", some_part_ug" + <<" "<getPos(), camera_position, + camera_direction, range) == false) + { + continue; + } + +#if 0 v3s16 blockpos_nodes = block->getPosRelative(); // Block center position @@ -3434,8 +3479,6 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass) { // If block is far away, don't draw it if(d > m_control.wanted_range * BS) - // This is nicer when fog is used - //if((dforward+d)/2 > m_control.wanted_range * BS) continue; } @@ -3460,7 +3503,23 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass) if(cosangle < cos(FOV_ANGLE/2. * 4./3.)) continue; } +#endif + + v3s16 blockpos_nodes = block->getPosRelative(); + // Block center position + v3f blockpos( + ((float)blockpos_nodes.X + MAP_BLOCKSIZE/2) * BS, + ((float)blockpos_nodes.Y + MAP_BLOCKSIZE/2) * BS, + ((float)blockpos_nodes.Z + MAP_BLOCKSIZE/2) * BS + ); + + // Block position relative to camera + v3f blockpos_relative = blockpos - camera_position; + + // Total distance + f32 d = blockpos_relative.getLength(); + /* Draw the faces of the block */ -- cgit v1.2.3