From e5650bb54917ead2dccac9b46dfa1a00cd737694 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 25 Nov 2011 17:00:50 +0200 Subject: [PATCH] Make liquid_alternative_* to be strings --- src/content_mapblock.cpp | 4 ++-- src/content_mapnode.cpp | 16 ++++++++-------- src/map.cpp | 12 ++++++------ src/nodedef.cpp | 21 +++++++++++---------- src/nodedef.h | 4 ++-- src/scriptapi.cpp | 8 ++++---- 6 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index 0bd2d22..8149d9f 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -237,8 +237,8 @@ void mapblock_mesh_generate_special(MeshMakeData *data, bool top_is_same_liquid = false; MapNode ntop = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x,y+1,z)); - content_t c_flowing = nodedef->get(n).liquid_alternative_flowing; - content_t c_source = nodedef->get(n).liquid_alternative_source; + content_t c_flowing = nodedef->getId(nodedef->get(n).liquid_alternative_flowing); + content_t c_source = nodedef->getId(nodedef->get(n).liquid_alternative_source); if(ntop.getContent() == c_flowing || ntop.getContent() == c_source) top_is_same_liquid = true; diff --git a/src/content_mapnode.cpp b/src/content_mapnode.cpp index eda252d..878d666 100644 --- a/src/content_mapnode.cpp +++ b/src/content_mapnode.cpp @@ -682,8 +682,8 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr) f.diggable = false; f.buildable_to = true; f.liquid_type = LIQUID_FLOWING; - f.liquid_alternative_flowing = CONTENT_WATER; - f.liquid_alternative_source = CONTENT_WATERSOURCE; + f.liquid_alternative_flowing = "water_flowing"; + f.liquid_alternative_source = "water_source"; f.liquid_viscosity = WATER_VISC; f.post_effect_color = video::SColor(64, 100, 100, 200); f.setSpecialMaterial(0, MaterialSpec("water.png", false)); @@ -705,8 +705,8 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr) f.buildable_to = true; f.liquid_type = LIQUID_SOURCE; f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; - f.liquid_alternative_flowing = CONTENT_WATER; - f.liquid_alternative_source = CONTENT_WATERSOURCE; + f.liquid_alternative_flowing = "water_flowing"; + f.liquid_alternative_source = "water_source"; f.liquid_viscosity = WATER_VISC; f.post_effect_color = video::SColor(64, 100, 100, 200); // New-style water source material (mostly unused) @@ -727,8 +727,8 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr) f.diggable = false; f.buildable_to = true; f.liquid_type = LIQUID_FLOWING; - f.liquid_alternative_flowing = CONTENT_LAVA; - f.liquid_alternative_source = CONTENT_LAVASOURCE; + f.liquid_alternative_flowing = "lava_flowing"; + f.liquid_alternative_source = "lava_source"; f.liquid_viscosity = LAVA_VISC; f.damage_per_second = 4*2; f.post_effect_color = video::SColor(192, 255, 64, 0); @@ -751,8 +751,8 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr) f.buildable_to = true; f.liquid_type = LIQUID_SOURCE; f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; - f.liquid_alternative_flowing = CONTENT_LAVA; - f.liquid_alternative_source = CONTENT_LAVASOURCE; + f.liquid_alternative_flowing = "lava_flowing"; + f.liquid_alternative_source = "lava_source"; f.liquid_viscosity = LAVA_VISC; f.damage_per_second = 4*2; f.post_effect_color = video::SColor(192, 255, 64, 0); diff --git a/src/map.cpp b/src/map.cpp index d27c6da..822b3f6 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1602,7 +1602,7 @@ void Map::transformLiquids(core::map & modified_blocks) switch (liquid_type) { case LIQUID_SOURCE: liquid_level = LIQUID_LEVEL_SOURCE; - liquid_kind = nodemgr->get(n0).liquid_alternative_flowing; + liquid_kind = nodemgr->getId(nodemgr->get(n0).liquid_alternative_flowing); break; case LIQUID_FLOWING: liquid_level = (n0.param2 & LIQUID_LEVEL_MASK); @@ -1662,8 +1662,8 @@ void Map::transformLiquids(core::map & modified_blocks) case LIQUID_SOURCE: // if this node is not (yet) of a liquid type, choose the first liquid type we encounter if (liquid_kind == CONTENT_AIR) - liquid_kind = nodemgr->get(nb.n.getContent()).liquid_alternative_flowing; - if (nodemgr->get(nb.n.getContent()).liquid_alternative_flowing !=liquid_kind) { + liquid_kind = nodemgr->getId(nodemgr->get(nb.n).liquid_alternative_flowing); + if (nodemgr->getId(nodemgr->get(nb.n).liquid_alternative_flowing) != liquid_kind) { neutrals[num_neutrals++] = nb; } else { sources[num_sources++] = nb; @@ -1672,8 +1672,8 @@ void Map::transformLiquids(core::map & modified_blocks) case LIQUID_FLOWING: // if this node is not (yet) of a liquid type, choose the first liquid type we encounter if (liquid_kind == CONTENT_AIR) - liquid_kind = nodemgr->get(nb.n.getContent()).liquid_alternative_flowing; - if (nodemgr->get(nb.n.getContent()).liquid_alternative_flowing != liquid_kind) { + liquid_kind = nodemgr->getId(nodemgr->get(nb.n).liquid_alternative_flowing); + if (nodemgr->getId(nodemgr->get(nb.n).liquid_alternative_flowing) != liquid_kind) { neutrals[num_neutrals++] = nb; } else { flows[num_flows++] = nb; @@ -1694,7 +1694,7 @@ void Map::transformLiquids(core::map & modified_blocks) // liquid_kind will be set to either the flowing alternative of the node (if it's a liquid) // or the flowing alternative of the first of the surrounding sources (if it's air), so // it's perfectly safe to use liquid_kind here to determine the new node content. - new_node_content = nodemgr->get(liquid_kind).liquid_alternative_source; + new_node_content = nodemgr->getId(nodemgr->get(liquid_kind).liquid_alternative_source); } else if (num_sources == 1 && sources[0].t != NEIGHBOR_LOWER) { // liquid_kind is set properly, see above new_node_content = liquid_kind; diff --git a/src/nodedef.cpp b/src/nodedef.cpp index 956bc1a..52d9fc8 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -144,8 +144,8 @@ void ContentFeatures::reset() extra_dug_item_rarity = 2; metadata_name = ""; liquid_type = LIQUID_NONE; - liquid_alternative_flowing = CONTENT_IGNORE; - liquid_alternative_source = CONTENT_IGNORE; + liquid_alternative_flowing = ""; + liquid_alternative_source = ""; liquid_viscosity = 0; light_source = 0; damage_per_second = 0; @@ -192,8 +192,8 @@ void ContentFeatures::serialize(std::ostream &os) writeS32(os, extra_dug_item_rarity); os<