Make liquid_alternative_* to be strings
authorPerttu Ahola <celeron55@gmail.com>
Fri, 25 Nov 2011 15:00:50 +0000 (17:00 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Tue, 29 Nov 2011 17:13:51 +0000 (19:13 +0200)
src/content_mapblock.cpp
src/content_mapnode.cpp
src/map.cpp
src/nodedef.cpp
src/nodedef.h
src/scriptapi.cpp

index 0bd2d22638cafeec980f43229afe0fadbd3393ec..8149d9f3492e64b30ee387b4407fa3128f95db1f 100644 (file)
@@ -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;
                        
index eda252dc178a25e6f4d06e3f98492682dab50ebf..878d66654bece6619f1c36a1169a948a840ccfff 100644 (file)
@@ -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);
index d27c6da120f963862be7107e7c1cce7b0bdebbfa..822b3f659bf06aa6a10e7afdc3d34a096ec2cf2a 100644 (file)
@@ -1602,7 +1602,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & 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<v3s16, MapBlock*> & 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<v3s16, MapBlock*> & 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<v3s16, MapBlock*> & 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;
index 956bc1a5fa9b57aa23257ae77f2bfce095aaf937..52d9fc8bf497d5b80ec75dcb5e00684084d5ecd2 100644 (file)
@@ -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<<serializeString(metadata_name);
        writeU8(os, liquid_type);
-       writeU16(os, liquid_alternative_flowing);
-       writeU16(os, liquid_alternative_source);
+       os<<serializeString(liquid_alternative_flowing);
+       os<<serializeString(liquid_alternative_source);
        writeU8(os, liquid_viscosity);
        writeU8(os, light_source);
        writeU32(os, damage_per_second);
@@ -244,8 +244,8 @@ void ContentFeatures::deSerialize(std::istream &is, IGameDef *gamedef)
        extra_dug_item_rarity = readS32(is);
        metadata_name = deSerializeString(is);
        liquid_type = (enum LiquidType)readU8(is);
-       liquid_alternative_flowing = readU16(is);
-       liquid_alternative_source = readU16(is);
+       liquid_alternative_flowing = deSerializeString(is);
+       liquid_alternative_source = deSerializeString(is);
        liquid_viscosity = readU8(is);
        light_source = readU8(is);
        damage_per_second = readU32(is);
@@ -337,13 +337,14 @@ public:
                        ContentFeatures f;
                        f.name = "ignore";
                        f.drawtype = NDT_AIRLIKE;
-                       /*f.param_type = CPT_LIGHT;
-                       f.light_propagates = true;
-                       f.sunlight_propagates = true;*/
+                       f.param_type = CPT_NONE;
+                       f.light_propagates = false;
+                       f.sunlight_propagates = false;
                        f.walkable = false;
                        f.pointable = false;
                        f.diggable = false;
-                       f.buildable_to = false;
+                       // A way to remove accidental CONTENT_IGNOREs
+                       f.buildable_to = true;
                        f.air_equivalent = true;
                        set(CONTENT_IGNORE, f);
                }
index 87f5fce83686836ad54c75e6aa1c2f2aebaa2fa3..645e75e3e4a2b6ce1933eeaeb5f2b6b4c298287f 100644 (file)
@@ -193,9 +193,9 @@ struct ContentFeatures
        // Whether the node is non-liquid, source liquid or flowing liquid
        enum LiquidType liquid_type;
        // If the content is liquid, this is the flowing version of the liquid.
-       content_t liquid_alternative_flowing;
+       std::string liquid_alternative_flowing;
        // If the content is liquid, this is the source version of the liquid.
-       content_t liquid_alternative_source;
+       std::string liquid_alternative_source;
        // Viscosity for fluid flow, ranging from 1 to 7, with
        // 1 giving almost instantaneous propagation and 7 being
        // the slowest possible
index f19e98893b5a87b8de0f8cca93f12a4805a9d69a..6f16c72e7aeea54e20b35fedf1704fef0bedfe47 100644 (file)
@@ -609,11 +609,11 @@ static int l_register_node(lua_State *L)
        f.liquid_type = (LiquidType)getenumfield(L, table0, "liquidtype",
                        es_LiquidType, LIQUID_NONE);
        // If the content is liquid, this is the flowing version of the liquid.
-       // TODO: as name
-       // content_t liquid_alternative_flowing;
+       getstringfield(L, table0, "liquid_alternative_flowing",
+                       f.liquid_alternative_flowing);
        // If the content is liquid, this is the source version of the liquid.
-       // TODO: as name
-       // content_t liquid_alternative_source;
+       getstringfield(L, table0, "liquid_alternative_source",
+                       f.liquid_alternative_source);
        // Viscosity for fluid flow, ranging from 1 to 7, with
        // 1 giving almost instantaneous propagation and 7 being
        // the slowest possible