From fe855e004f424fec1f7f3f2e7e06be2f70f4952e Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 22 Jul 2011 01:37:05 +0300 Subject: Fixed new map generator causing a crash when generating at map limit --- src/map.cpp | 68 +++++++++++++++++++++++++++++++++++----------------------- src/mapgen.cpp | 2 +- 2 files changed, 42 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/map.cpp b/src/map.cpp index 9ff0fa6d3..2a3e9f760 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2012,7 +2012,15 @@ void ServerMap::initBlockMake(mapgen::BlockMakeData *data, v3s16 blockpos) { /*dstream<<"initBlockMake(): ("<no_op = true; + return; + } + data->no_op = false; data->seed = m_seed; data->blockpos = blockpos; @@ -2063,6 +2071,7 @@ void ServerMap::initBlockMake(mapgen::BlockMakeData *data, v3s16 blockpos) neighboring blocks */ + // The area that contains this block and it's neighbors v3s16 bigarea_blocks_min = blockpos - v3s16(1,1,1); v3s16 bigarea_blocks_max = blockpos + v3s16(1,1,1); @@ -2087,7 +2096,7 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data, if(data->no_op) { - dstream<<"finishBlockMake(): no-op"<getNode(p); - if(n.d == CONTENT_IGNORE) + bool erroneus_content = false; + for(s16 z0=0; z0getNode(p); + if(n.d == CONTENT_IGNORE) + { + dstream<<"CONTENT_IGNORE at " + <<"("<setNode(v3s16(x0,y0,z0), n); + for(s16 y0=0; y0setNode(v3s16(x0,y0,z0), n); + } } } #endif diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 4a2a39aec..acff3b963 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -1303,7 +1303,7 @@ void make_block(BlockMakeData *data) { if(data->no_op) { - dstream<<"makeBlock: no-op"< Date: Fri, 22 Jul 2011 01:37:21 +0300 Subject: Fixed small error in mapnode.cpp (didn't cause any harm though) --- src/mapnode.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mapnode.cpp b/src/mapnode.cpp index 391e593f9..b9dfd35b0 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -142,8 +142,10 @@ void init_mapnode() Initially set every block to be shown as an unknown block. Don't touch CONTENT_IGNORE or CONTENT_AIR. */ - for(u16 i=0; i<=253; i++) + for(u16 i=0; i<256; i++) { + if(i == CONTENT_IGNORE || i == CONTENT_AIR) + continue; ContentFeatures *f = &g_content_features[i]; f->setAllTextures("unknown_block.png"); f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; -- cgit v1.2.3 From 2b39be44e45cbd0b00eb954d06d55d8164f311a4 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 22 Jul 2011 13:10:58 +0300 Subject: added an unit test for the Settings thingy (the python ConfigParser -like thing) --- src/test.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src') diff --git a/src/test.cpp b/src/test.cpp index 7d71552a8..0487f1436 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -61,6 +61,38 @@ struct TestUtilities assert(is_yes("FAlse") == false); } }; + +struct TestSettings +{ + void Run() + { + Settings s; + // Test reading of settings + s.parseConfigLine("leet = 1337"); + s.parseConfigLine("leetleet = 13371337"); + s.parseConfigLine("leetleet_neg = -13371337"); + s.parseConfigLine("floaty_thing = 1.1"); + s.parseConfigLine("stringy_thing = asd /( ¤%&(/\" BLÖÄRP"); + s.parseConfigLine("coord = (1, 2, 4.5)"); + assert(s.getS32("leet") == 1337); + assert(s.getS16("leetleet") == 32767); + assert(s.getS16("leetleet_neg") == -32768); + // Not sure if 1.1 is an exact value as a float, but doesn't matter + assert(fabs(s.getFloat("floaty_thing") - 1.1) < 0.001); + assert(s.get("stringy_thing") == "asd /( ¤%&(/\" BLÖÄRP"); + assert(fabs(s.getV3F("coord").X - 1.0) < 0.001); + assert(fabs(s.getV3F("coord").Y - 2.0) < 0.001); + assert(fabs(s.getV3F("coord").Z - 4.5) < 0.001); + // Test the setting of settings too + s.setFloat("floaty_thing_2", 1.2); + s.setV3F("coord2", v3f(1, 2, 3.3)); + assert(s.get("floaty_thing_2").substr(0,3) == "1.2"); + assert(fabs(s.getFloat("floaty_thing_2") - 1.2) < 0.001); + assert(fabs(s.getV3F("coord2").X - 1.0) < 0.001); + assert(fabs(s.getV3F("coord2").Y - 2.0) < 0.001); + assert(fabs(s.getV3F("coord2").Z - 3.3) < 0.001); + } +}; struct TestCompress { @@ -1033,6 +1065,7 @@ void run_tests() DSTACK(__FUNCTION_NAME); dstream<<"run_tests() started"< Date: Fri, 22 Jul 2011 18:51:49 +0300 Subject: Fixed the problem of <=r548 clients fucking up maps on >=r549 servers. Also, already fucked up maps are now loaded correctly. --- src/mapnode.cpp | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/mapnode.cpp b/src/mapnode.cpp index b9dfd35b0..1e9b64989 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -267,10 +267,10 @@ void MapNode::serialize(u8 *dest, u8 version) { // In these versions, CONTENT_IGNORE and CONTENT_AIR // are 255 and 254 - if(d == CONTENT_IGNORE) - d = 255; - else if(d == CONTENT_AIR) - d = 254; + if(actual_d == CONTENT_IGNORE) + actual_d = 255; + else if(actual_d == CONTENT_AIR) + actual_d = 254; } if(version == 0) @@ -317,17 +317,25 @@ void MapNode::deSerialize(u8 *source, u8 version) d = source[0]; param = source[1]; param2 = source[2]; - - // Convert from old version to new - if(version <= 18) - { - // In these versions, CONTENT_IGNORE and CONTENT_AIR - // are 255 and 254 - if(d == 255) - d = CONTENT_IGNORE; - else if(d == 254) - d = CONTENT_AIR; - } + } + + // Convert from old version to new + if(version <= 18) + { + // In these versions, CONTENT_IGNORE and CONTENT_AIR + // are 255 and 254 + if(d == 255) + d = CONTENT_IGNORE; + else if(d == 254) + d = CONTENT_AIR; + } + // version 19 is fucked up with sometimes the old values and sometimes not + if(version == 19) + { + if(d == 255) + d = CONTENT_IGNORE; + else if(d == 254) + d = CONTENT_AIR; } } -- cgit v1.2.3