1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-11-17 14:55:13 -05:00

merged some stuff from upstream while merging delta

This commit is contained in:
Perttu Ahola 2011-07-23 15:46:00 +03:00
commit 3882536d40
4 changed files with 101 additions and 44 deletions

View File

@ -2006,6 +2006,14 @@ void ServerMap::initBlockMake(mapgen::BlockMakeData *data, v3s16 blockpos)
/*dstream<<"initBlockMake(): ("<<blockpos.X<<","<<blockpos.Y<<"," /*dstream<<"initBlockMake(): ("<<blockpos.X<<","<<blockpos.Y<<","
<<blockpos.Z<<")"<<std::endl;*/ <<blockpos.Z<<")"<<std::endl;*/
// Do nothing if not inside limits (+-1 because of neighbors)
if(blockpos_over_limit(blockpos - v3s16(1,1,1)) ||
blockpos_over_limit(blockpos + v3s16(1,1,1)))
{
data->no_op = true;
return;
}
data->no_op = false; data->no_op = false;
data->seed = m_seed; data->seed = m_seed;
data->blockpos = blockpos; data->blockpos = blockpos;
@ -2056,6 +2064,7 @@ void ServerMap::initBlockMake(mapgen::BlockMakeData *data, v3s16 blockpos)
neighboring blocks neighboring blocks
*/ */
// The area that contains this block and it's neighbors
v3s16 bigarea_blocks_min = blockpos - v3s16(1,1,1); v3s16 bigarea_blocks_min = blockpos - v3s16(1,1,1);
v3s16 bigarea_blocks_max = blockpos + v3s16(1,1,1); v3s16 bigarea_blocks_max = blockpos + v3s16(1,1,1);
@ -2080,7 +2089,7 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data,
if(data->no_op) if(data->no_op)
{ {
dstream<<"finishBlockMake(): no-op"<<std::endl; //dstream<<"finishBlockMake(): no-op"<<std::endl;
return NULL; return NULL;
} }
@ -2332,49 +2341,54 @@ MapBlock * ServerMap::generateBlock(
Get central block Get central block
*/ */
MapBlock *block = getBlockNoCreateNoEx(p); MapBlock *block = getBlockNoCreateNoEx(p);
assert(block);
#if 0 #if 0
/* /*
Check result Check result
*/ */
bool erroneus_content = false; if(block)
for(s16 z0=0; z0<MAP_BLOCKSIZE; z0++)
for(s16 y0=0; y0<MAP_BLOCKSIZE; y0++)
for(s16 x0=0; x0<MAP_BLOCKSIZE; x0++)
{ {
v3s16 p(x0,y0,z0); bool erroneus_content = false;
MapNode n = block->getNode(p); for(s16 z0=0; z0<MAP_BLOCKSIZE; z0++)
if(n.d == CONTENT_IGNORE) for(s16 y0=0; y0<MAP_BLOCKSIZE; y0++)
for(s16 x0=0; x0<MAP_BLOCKSIZE; x0++)
{
v3s16 p(x0,y0,z0);
MapNode n = block->getNode(p);
if(n.d == CONTENT_IGNORE)
{
dstream<<"CONTENT_IGNORE at "
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl;
erroneus_content = true;
assert(0);
}
}
if(erroneus_content)
{ {
dstream<<"CONTENT_IGNORE at "
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl;
erroneus_content = true;
assert(0); assert(0);
} }
} }
if(erroneus_content)
{
assert(0);
}
#endif #endif
#if 0 #if 0
/* /*
Generate a completely empty block Generate a completely empty block
*/ */
for(s16 z0=0; z0<MAP_BLOCKSIZE; z0++) if(block)
for(s16 x0=0; x0<MAP_BLOCKSIZE; x0++)
{ {
for(s16 y0=0; y0<MAP_BLOCKSIZE; y0++) for(s16 z0=0; z0<MAP_BLOCKSIZE; z0++)
for(s16 x0=0; x0<MAP_BLOCKSIZE; x0++)
{ {
MapNode n; for(s16 y0=0; y0<MAP_BLOCKSIZE; y0++)
if(y0%2==0) {
n.d = CONTENT_AIR; MapNode n;
else if(y0%2==0)
n.d = CONTENT_STONE; n.d = CONTENT_AIR;
block->setNode(v3s16(x0,y0,z0), n); else
n.d = CONTENT_STONE;
block->setNode(v3s16(x0,y0,z0), n);
}
} }
} }
#endif #endif

View File

@ -1331,7 +1331,7 @@ void make_block(BlockMakeData *data)
{ {
if(data->no_op) if(data->no_op)
{ {
dstream<<"makeBlock: no-op"<<std::endl; //dstream<<"makeBlock: no-op"<<std::endl;
return; return;
} }

View File

@ -142,8 +142,10 @@ void init_mapnode()
Initially set every block to be shown as an unknown block. Initially set every block to be shown as an unknown block.
Don't touch CONTENT_IGNORE or CONTENT_AIR. 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]; ContentFeatures *f = &g_content_features[i];
f->setAllTextures("unknown_block.png"); f->setAllTextures("unknown_block.png");
f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
@ -265,10 +267,10 @@ void MapNode::serialize(u8 *dest, u8 version)
{ {
// In these versions, CONTENT_IGNORE and CONTENT_AIR // In these versions, CONTENT_IGNORE and CONTENT_AIR
// are 255 and 254 // are 255 and 254
if(d == CONTENT_IGNORE) if(actual_d == CONTENT_IGNORE)
d = 255; actual_d = 255;
else if(d == CONTENT_AIR) else if(actual_d == CONTENT_AIR)
d = 254; actual_d = 254;
} }
if(version == 0) if(version == 0)
@ -315,17 +317,25 @@ void MapNode::deSerialize(u8 *source, u8 version)
d = source[0]; d = source[0];
param = source[1]; param = source[1];
param2 = source[2]; param2 = source[2];
}
// Convert from old version to new // Convert from old version to new
if(version <= 18) if(version <= 18)
{ {
// In these versions, CONTENT_IGNORE and CONTENT_AIR // In these versions, CONTENT_IGNORE and CONTENT_AIR
// are 255 and 254 // are 255 and 254
if(d == 255) if(d == 255)
d = CONTENT_IGNORE; d = CONTENT_IGNORE;
else if(d == 254) else if(d == 254)
d = CONTENT_AIR; 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;
} }
} }

View File

@ -62,6 +62,38 @@ struct TestUtilities
} }
}; };
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 struct TestCompress
{ {
void Run() void Run()
@ -1033,6 +1065,7 @@ void run_tests()
DSTACK(__FUNCTION_NAME); DSTACK(__FUNCTION_NAME);
dstream<<"run_tests() started"<<std::endl; dstream<<"run_tests() started"<<std::endl;
TEST(TestUtilities); TEST(TestUtilities);
TEST(TestSettings);
TEST(TestCompress); TEST(TestCompress);
TEST(TestMapNode); TEST(TestMapNode);
TEST(TestVoxelManipulator); TEST(TestVoxelManipulator);