From 9b1b57a52390ecc98c27b2f923052511c387ba3d Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Wed, 2 Feb 2011 18:46:14 +0200 Subject: [PATCH] some tweaking --- src/light.cpp | 20 +++++++- src/main.cpp | 2 + src/map.cpp | 124 +++++++++++++++++++++++++++++++++++++++++++----- src/mapnode.cpp | 3 +- src/server.cpp | 8 +++- 5 files changed, 141 insertions(+), 16 deletions(-) diff --git a/src/light.cpp b/src/light.cpp index fec800874..c0255f7fb 100644 --- a/src/light.cpp +++ b/src/light.cpp @@ -29,6 +29,24 @@ with this program; if not, write to the Free Software Foundation, Inc., u8 light_decode_table[LIGHT_MAX+1] = { 0, +7, +11, +15, +21, +29, +42, +53, +69, +85, +109, +135, +167, +205, +255, +}; +/*u8 light_decode_table[LIGHT_MAX+1] = +{ +0, 6, 8, 11, @@ -43,7 +61,7 @@ u8 light_decode_table[LIGHT_MAX+1] = 143, 191, 255, -}; +};*/ /*u8 light_decode_table[LIGHT_MAX+1] = { 0, diff --git a/src/main.cpp b/src/main.cpp index ef7207894..e6b55e1bf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -348,6 +348,8 @@ Doing now: * Add some kind of erosion and other stuff that now is possible * Make client to fetch stuff asynchronously - Needs method SyncProcessData +* What is the problem with the server constantly saving one or a few + blocks? List the first saved block, maybe it explains. ====================================================================== diff --git a/src/map.cpp b/src/map.cpp index 7c0d19dbb..80210cead 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2145,7 +2145,7 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos, TimeTaker timer("generateChunkRaw()"); - // The distance how far into the neighbors the generator is allowed to go + // The distance how far into the neighbors the generator is allowed to go. s16 max_spread_amount_sectors = 2; assert(max_spread_amount_sectors <= m_chunksize); s16 max_spread_amount = max_spread_amount_sectors * MAP_BLOCKSIZE; @@ -2190,6 +2190,12 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos, *(u32)sectorpos_base_size*MAP_BLOCKSIZE *(u32)h_blocks*MAP_BLOCKSIZE; + /* + The limiting edges of the lighting update, inclusive. + */ + s16 lighting_min_d = 0-max_spread_amount; + s16 lighting_max_d = sectorpos_base_size*MAP_BLOCKSIZE+max_spread_amount-1; + /* Create the whole area of this and the neighboring chunks */ @@ -2226,6 +2232,12 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos, } } } + + /* + Clear all light emitted + */ + + core::map unlight_from; /* Now we have a big empty area. @@ -2310,7 +2322,8 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos, */ u32 stone_obstacle_amount = - myrand_range(0, myrand_range(20, myrand_range(80,150))); + myrand_range(0, myrand_range(20, 150)); + //myrand_range(0, myrand_range(20, myrand_range(80,150))); /* Loop this part, it will make stuff look older and newer nicely @@ -2346,9 +2359,19 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos, myrand_range(0, maxheight_randomized), myrand_range(5, stone_obstacle_max_size) ); - v2s16 ob_place( + /*v2s16 ob_place( myrand_range(0, sectorpos_base_size*MAP_BLOCKSIZE-1), myrand_range(0, sectorpos_base_size*MAP_BLOCKSIZE-1) + );*/ + /* + Limit by 1 to not obstruct sunlight at borders, because + it would fuck up lighting in some places because we're + leaving out removing light from the borders for optimization + and simplicity. + */ + v2s16 ob_place( + myrand_range(1, sectorpos_base_size*MAP_BLOCKSIZE-1-1), + myrand_range(1, sectorpos_base_size*MAP_BLOCKSIZE-1-1) ); // Minimum space left on top of the obstacle @@ -2450,20 +2473,20 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos, Make dungeons */ u32 dungeons_count = relative_volume / 200000; - u32 bruises_count = relative_volume * stone_surface_max_y / 15000000; + u32 bruises_count = relative_volume * stone_surface_max_y / 200000 / 50; for(u32 jj=0; jj=y_nodes_min; y--) + { + MapNode *n = &vmanip.m_data[i]; + if(n->getLight(LIGHTBANK_DAY) != 0) + { + light_sources.insert(v3s16(p2d.X, y, p2d.Y), true); + } + } + } + } +#endif + /*for(s16 x=0; xsetLight(LIGHTBANK_DAY, light); n->setLight(LIGHTBANK_NIGHT, 0); diff --git a/src/mapnode.cpp b/src/mapnode.cpp index f5ca0ca9e..c5b252d8e 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -140,7 +140,8 @@ void init_mapnode(IIrrlichtWrapper *irrlicht) i = CONTENT_WATERSOURCE; f = &g_content_features[i]; - f->setTexture(0, irrlicht->getTextureId("water.png"), WATER_ALPHA); + //f->setTexture(0, irrlicht->getTextureId("water.png"), WATER_ALPHA); + f->setAllTextures(irrlicht->getTextureId("water.png"), WATER_ALPHA); f->setInventoryTexture(irrlicht->getTextureId("water.png")); f->param_type = CPT_LIGHT; f->light_propagates = true; diff --git a/src/server.cpp b/src/server.cpp index d71a6c053..abf48df9a 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -510,9 +510,13 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime, } else { - // Limit the generating area vertically to 2/3 + /*// Limit the generating area vertically to 2/3 if(abs(p.Y - center.Y) > d_max_gen - d_max_gen / 3) - generate = false; + generate = false;*/ + + // Limit the send area vertically to 2/3 + if(abs(p.Y - center.Y) > d_max_gen - d_max_gen / 3) + continue; } #if 0