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/mapnode.cpp | 92 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 42 deletions(-) (limited to 'src/mapnode.cpp') diff --git a/src/mapnode.cpp b/src/mapnode.cpp index 1e9b64989..c9f85c303 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -30,8 +30,6 @@ with this program; if not, write to the Free Software Foundation, Inc., ContentFeatures::~ContentFeatures() { - /*if(translate_to) - delete translate_to;*/ if(initial_metadata) delete initial_metadata; } @@ -83,12 +81,16 @@ void ContentFeatures::setInventoryTextureCube(std::string top, inventory_texture = g_texturesource->getTextureRaw(imgname_full); } -struct ContentFeatures g_content_features[256]; +struct ContentFeatures g_content_features[MAX_CONTENT+1]; -ContentFeatures & content_features(u8 i) +ContentFeatures & content_features(content_t i) { return g_content_features[i]; } +ContentFeatures & content_features(MapNode &n) +{ + return content_features(n.getContent()); +} /* See mapnode.h for description. @@ -128,7 +130,7 @@ void init_mapnode() initial_material_type = MATERIAL_ALPHA_SIMPLE; else initial_material_type = MATERIAL_ALPHA_NONE;*/ - for(u16 i=0; i<256; i++) + for(u16 i=0; i 0) - param = 0; + param1 = 0; else - param = source[1]; + param1 = source[1]; } else if(version <= 9) { - d = source[0]; - param = source[1]; + param0 = source[0]; + param1 = source[1]; } else { - d = source[0]; - param = source[1]; + param0 = source[0]; + param1 = source[1]; param2 = source[2]; } - // Convert from old version to new + // Convert special values 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; + if(param0 == 255) + param0 = CONTENT_IGNORE; + else if(param0 == 254) + param0 = 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; + 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); } /* -- cgit v1.2.3