From 52ad5944c080e858c49267c49703ec79b18e120f Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Thu, 21 Jul 2011 17:00:08 +0300 Subject: Attempt to fix the big bug. Now server either stops sending map or mapgen starts generating CONTENT_IGNORE. --- src/mapblock.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/mapblock.cpp') diff --git a/src/mapblock.cpp b/src/mapblock.cpp index 647a17756..cdbd54525 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -242,7 +242,12 @@ bool MapBlock::propagateSunlight(core::map & light_sources, // Check if node above block has sunlight try{ MapNode n = getNodeParent(v3s16(x, MAP_BLOCKSIZE, z)); - if(n.d == CONTENT_IGNORE || n.getLight(LIGHTBANK_DAY) != LIGHT_SUN) + if(n.d == CONTENT_IGNORE) + { + // Trust heuristics + no_sunlight = is_underground; + } + else if(n.getLight(LIGHTBANK_DAY) != LIGHT_SUN) { no_sunlight = true; } -- cgit v1.2.3 From 90d793f8f369bf1431d7a915198cd49b98bbe2d7 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 23 Jul 2011 16:55:26 +0300 Subject: extended content-type range --- src/mapblock.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/mapblock.cpp') diff --git a/src/mapblock.cpp b/src/mapblock.cpp index 647a17756..ead26dd1f 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -242,7 +242,7 @@ bool MapBlock::propagateSunlight(core::map & light_sources, // Check if node above block has sunlight try{ MapNode n = getNodeParent(v3s16(x, MAP_BLOCKSIZE, z)); - if(n.d == CONTENT_IGNORE || n.getLight(LIGHTBANK_DAY) != LIGHT_SUN) + if(n.getContent() == CONTENT_IGNORE || n.getLight(LIGHTBANK_DAY) != LIGHT_SUN) { no_sunlight = true; } @@ -260,8 +260,8 @@ bool MapBlock::propagateSunlight(core::map & light_sources, else { MapNode n = getNode(v3s16(x, MAP_BLOCKSIZE-1, z)); - //if(n.d == CONTENT_WATER || n.d == CONTENT_WATERSOURCE) - if(content_features(n.d).sunlight_propagates == false) + //if(n.getContent() == CONTENT_WATER || n.getContent() == CONTENT_WATERSOURCE) + if(content_features(n).sunlight_propagates == false) { no_sunlight = true; } @@ -322,14 +322,14 @@ bool MapBlock::propagateSunlight(core::map & light_sources, bool upper_is_air = false; try { - if(getNodeParent(pos+v3s16(0,1,0)).d == CONTENT_AIR) + if(getNodeParent(pos+v3s16(0,1,0)).getContent() == CONTENT_AIR) upper_is_air = true; } catch(InvalidPositionException &e) { } // Turn mud into grass - if(upper_is_air && n.d == CONTENT_MUD + if(upper_is_air && n.getContent() == CONTENT_MUD && current_light == LIGHT_SUN) { n.d = CONTENT_GRASS; @@ -473,7 +473,7 @@ void MapBlock::updateDayNightDiff() for(u32 i=0; i=0; y--) { - //if(is_ground_content(getNodeRef(p2d.X, y, p2d.Y).d)) - if(content_features(getNodeRef(p2d.X, y, p2d.Y).d).walkable) + MapNode n = getNodeRef(p2d.X, y, p2d.Y); + if(content_features(n).walkable) { if(y == MAP_BLOCKSIZE-1) return -2; @@ -560,7 +560,7 @@ void MapBlock::serialize(std::ostream &os, u8 version) SharedBuffer materialdata(nodecount); for(u32 i=0; i lightdata(nodecount); for(u32 i=0; i Date: Sun, 24 Jul 2011 12:09:33 +0300 Subject: Added a mapblock analyzing function for debugging use and fixed remaining mapgen bugs --- src/mapblock.cpp | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) (limited to 'src/mapblock.cpp') diff --git a/src/mapblock.cpp b/src/mapblock.cpp index 49d215bf6..b7981348c 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -867,5 +867,128 @@ void MapBlock::deSerializeDiskExtra(std::istream &is, u8 version) } } +/* + Get a quick string to describe what a block actually contains +*/ +std::string analyze_block(MapBlock *block) +{ + if(block == NULL) + { + return "NULL"; + } + + std::ostringstream desc; + + v3s16 p = block->getPos(); + char spos[20]; + snprintf(spos, 20, "(%2d,%2d,%2d), ", p.X, p.Y, p.Z); + desc<getModified()) + { + case MOD_STATE_CLEAN: + desc<<"CLEAN, "; + break; + case MOD_STATE_WRITE_AT_UNLOAD: + desc<<"WRITE_AT_UNLOAD, "; + break; + case MOD_STATE_WRITE_NEEDED: + desc<<"WRITE_NEEDED, "; + break; + default: + desc<<"unknown getModified()="+itos(block->getModified())+", "; + } + + if(block->isGenerated()) + desc<<"is_gen [X], "; + else + desc<<"is_gen [ ], "; + + if(block->getIsUnderground()) + desc<<"is_ug [X], "; + else + desc<<"is_ug [ ], "; + + if(block->getMeshExpired()) + desc<<"mesh_exp [X], "; + else + desc<<"mesh_exp [ ], "; + + if(block->getLightingExpired()) + desc<<"lighting_exp [X], "; + else + desc<<"lighting_exp [ ], "; + + if(block->isDummy()) + { + desc<<"Dummy, "; + } + else + { + // We'll just define the numbers here, don't want to include + // content_mapnode.h + const content_t content_water = 2; + const content_t content_watersource = 9; + const content_t content_tree = 0x801; + const content_t content_leaves = 0x802; + const content_t content_jungletree = 0x815; + + bool full_ignore = true; + bool some_ignore = false; + bool full_air = true; + bool some_air = false; + bool trees = false; + bool water = false; + for(s16 z0=0; z0getNode(p); + content_t c = n.getContent(); + if(c == CONTENT_IGNORE) + some_ignore = true; + else + full_ignore = false; + if(c == CONTENT_AIR) + some_air = true; + else + full_air = false; + if(c == content_tree || c == content_jungletree + || c == content_leaves) + trees = true; + if(c == content_water + || c == content_watersource) + water = true; + } + + desc<<"content {"; + + std::ostringstream ss; + + if(full_ignore) + ss<<"IGNORE (full), "; + else if(some_ignore) + ss<<"IGNORE, "; + + if(full_air) + ss<<"AIR (full), "; + else if(some_air) + ss<<"AIR, "; + + if(trees) + ss<<"trees, "; + if(water) + ss<<"water, "; + + if(ss.str().size()>=2) + desc<