Cleanup (some stuff went wrong when reverting 4-byte mapnodes); fix legacy_wallmounted

This commit is contained in:
Kahrl 2012-01-22 14:55:55 +01:00 committed by Perttu Ahola
parent 4799a8f761
commit c241902b40
4 changed files with 11 additions and 13 deletions

@ -1157,28 +1157,24 @@ void MapBlock::deSerialize_pre22(std::istream &is, u8 version, bool disk)
if(nodedef->getId("default:stone") == data[i].getContent() if(nodedef->getId("default:stone") == data[i].getContent()
&& data[i].getParam1() == 1) && data[i].getParam1() == 1)
{ {
//dstream << "legacy coal\n";
data[i].setContent(nodedef->getId("default:stone_with_coal")); data[i].setContent(nodedef->getId("default:stone_with_coal"));
data[i].setParam1(0); data[i].setParam1(0);
} }
else if(nodedef->getId("default:stone") == data[i].getContent() else if(nodedef->getId("default:stone") == data[i].getContent()
&& data[i].getParam1() == 2) && data[i].getParam1() == 2)
{ {
//dstream << "legacy iron\n";
data[i].setContent(nodedef->getId("default:stone_with_iron")); data[i].setContent(nodedef->getId("default:stone_with_iron"));
data[i].setParam1(0); data[i].setParam1(0);
} }
// facedir_simple // facedir_simple
if(f.legacy_facedir_simple) if(f.legacy_facedir_simple)
{ {
dstream << "legacy_facedir_simple\n";
data[i].setParam2(data[i].getParam1()); data[i].setParam2(data[i].getParam1());
data[i].setParam1(0); data[i].setParam1(0);
} }
// wall_mounted // wall_mounted
if(f.legacy_wallmounted) if(f.legacy_wallmounted)
{ {
dstream << "legacy_wallmounted\n";
u8 wallmounted_new_to_old[8] = {0x04, 0x08, 0x01, 0x02, 0x10, 0x20, 0, 0}; u8 wallmounted_new_to_old[8] = {0x04, 0x08, 0x01, 0x02, 0x10, 0x20, 0, 0};
u8 dir_old_format = data[i].getParam2(); u8 dir_old_format = data[i].getParam2();
u8 dir_new_format = 0; u8 dir_new_format = 0;

@ -291,31 +291,31 @@ void MapNode::serialize_pre22(u8 *dest, u8 version)
// Translate to wanted version // Translate to wanted version
MapNode n_foreign = mapnode_translate_from_internal(*this, version); MapNode n_foreign = mapnode_translate_from_internal(*this, version);
u16 actual_content = n_foreign.param0; u8 actual_param0 = n_foreign.param0;
// Convert special values from new version to old // Convert special values from new version to old
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(actual_content == CONTENT_IGNORE) if(actual_param0 == CONTENT_IGNORE)
actual_content = 255; actual_param0 = 255;
else if(actual_content == CONTENT_AIR) else if(actual_param0 == CONTENT_AIR)
actual_content = 254; actual_param0 = 254;
} }
if(version == 0) if(version == 0)
{ {
dest[0] = actual_content; dest[0] = actual_param0;
} }
else if(version <= 9) else if(version <= 9)
{ {
dest[0] = actual_content; dest[0] = actual_param0;
dest[1] = n_foreign.param1; dest[1] = n_foreign.param1;
} }
else else
{ {
dest[0] = actual_content; dest[0] = actual_param0;
dest[1] = n_foreign.param1; dest[1] = n_foreign.param1;
dest[2] = n_foreign.param2; dest[2] = n_foreign.param2;
} }

@ -112,7 +112,7 @@ struct MapNode
{ {
param1 = a_param1; param1 = a_param1;
param2 = a_param2; param2 = a_param2;
// Set content (param0 and param2&0xf0)) after other params // Set content (param0 and (param2&0xf0)) after other params
// because this needs to override part of param2 // because this needs to override part of param2
setContent(content); setContent(content);
} }

@ -394,6 +394,8 @@ public:
def.param_type_2 == CPT2_FULL def.param_type_2 == CPT2_FULL
|| ||
def.param_type_2 == CPT2_FLOWINGLIQUID def.param_type_2 == CPT2_FLOWINGLIQUID
||
def.legacy_wallmounted
); );
// Get some id // Get some id
id = getFreeId(require_full_param2); id = getFreeId(require_full_param2);