void MapNode::deSerialize(u8 *source, u8 version)
{
	if(!ser_ver_supported(version))
		throw VersionMismatchException("ERROR: MapNode format not supported");

	if(version == 0)
	{
		param0 = source[0];
	}
	else if(version == 1)
	{
		param0 = source[0];
		// This version doesn't support saved lighting
		if(light_propagates() || light_source() > 0)
			param1 = 0;
		else
			param1 = source[1];
	}
	else if(version <= 9)
	{
		param0 = source[0];
		param1 = source[1];
	}
	else
	{
		param0 = source[0];
		param1 = source[1];
		param2 = source[2];
	}

	// Convert special values from old version to new
	if(version <= 18)
	{
		// In these versions, CONTENT_IGNORE and CONTENT_AIR
		// are 255 and 254
		if(param0 == 255)
			param0 = CONTENT_IGNORE;
		else if(param0 == 254)
			param0 = CONTENT_AIR;
	}
	// version 19 is f****d up with sometimes the old values and sometimes not
	if(version == 19)
	{
		if(param0 == 255)
			param0 = CONTENT_IGNORE;
		else if(param0 == 254)
			param0 = CONTENT_AIR;
	}

	// Translate to our known version
	*this = mapnode_translate_to_internal(*this, version);
}
示例#2
0
void MapNode::deSerialize(u8 *source, u8 version)
{
	if(!ser_ver_supported(version))
		throw VersionMismatchException("ERROR: MapNode format not supported");
		
	if(version == 0)
	{
		d = source[0];
	}
	else if(version == 1)
	{
		d = source[0];
		// This version doesn't support saved lighting
		if(light_propagates() || light_source() > 0)
			param = 0;
		else
			param = source[1];
	}
	else if(version <= 9)
	{
		d = source[0];
		param = source[1];
	}
	else
	{
		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;
		}
	}
}