aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt88
-rw-r--r--src/client.cpp1
-rw-r--r--src/cmake_config.h.in4
-rw-r--r--src/config.h11
-rw-r--r--src/gettext.h12
-rw-r--r--src/guiPauseMenu.cpp2
-rw-r--r--src/keycode.cpp1
-rw-r--r--src/main.cpp8
-rw-r--r--src/map.cpp423
-rw-r--r--src/mapnode.h7
-rw-r--r--src/servermain.cpp2
11 files changed, 273 insertions, 286 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8ce69b2ad..fcdb3ccbc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,15 +1,19 @@
+project(minetest-delta)
cmake_minimum_required( VERSION 2.6 )
-project(minetest)
-
if(RUN_IN_PLACE)
add_definitions ( -DRUN_IN_PLACE )
endif(RUN_IN_PLACE)
-OPTION(USE_GETTEXT "Use GetText for internationalization" OFF)
+# user-visible option to enable/disable gettext usage
+OPTION(ENABLE_GETTEXT "Use GetText for internationalization" ON)
+
+# this is only set to 1 if gettext is enabled _and_ available
+set(USE_GETTEXT 0)
-if(USE_GETTEXT)
- find_package(GettextLib REQUIRED)
+find_package(GettextLib)
+
+if(GETTEXT_FOUND AND ENABLE_GETTEXT)
message(STATUS "gettext include path: ${GETTEXT_INCLUDE_DIR}")
message(STATUS "gettext msgfmt path: ${GETTEXT_MSGFMT}")
if(WIN32)
@@ -17,16 +21,13 @@ if(USE_GETTEXT)
message(STATUS "gettext dll: ${GETTEXT_DLL}")
message(STATUS "gettext iconv dll: ${GETTEXT_ICONV_DLL}")
endif()
- if (GETTEXT_FOUND)
- add_definitions( -DUSE_GETTEXT )
- message(STATUS "GetText enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}")
- else()
- message(STATUS "ERROR: GetText enabled but not found, disabling")
- set(USE_GETTEXT FALSE)
- endif(GETTEXT_FOUND)
-else(USE_GETTEXT)
+ set(USE_GETTEXT 1)
+ message(STATUS "GetText enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}")
+elseif(GETTEXT_FOUND AND NOT ENABLE_GETTEXT)
+ MESSAGE(STATUS "GetText found but disabled;")
+else(GETTEXT_FOUND AND ENABLE_GETTEXT)
message(STATUS "GetText disabled")
-endif(USE_GETTEXT)
+endif(GETTEXT_FOUND AND ENABLE_GETTEXT)
if(NOT MSVC)
set(USE_GPROF 0 CACHE BOOL "Use -pg flag for g++")
@@ -269,7 +270,7 @@ if(BUILD_CLIENT)
install(FILES ${images} DESTINATION ${DATADIR})
- if (USE_GETTEXT)
+ if(USE_GETTEXT)
foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE})
set(MO_BUILD_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo")
@@ -300,54 +301,29 @@ if(BUILD_SERVER)
endif(BUILD_SERVER)
if (USE_GETTEXT)
- add_custom_command(OUTPUT "${GETTEXT_PO_PATH}/en"
- COMMAND ${CMAKE_COMMAND} -E make_directory "${GETTEXT_PO_PATH}/en"
- COMMENT "po-update [en]: creating translation template base directory")
- set(POT_FILE "${GETTEXT_PO_PATH}/en/minetest.pot")
- file(GLOB GETTEXT_POT_DEPS *.cpp *.h)
- file(GLOB GETTEXT_POT_DEPS_REL RELATIVE ${CMAKE_SOURCE_DIR} *.cpp *.h)
- add_custom_command(OUTPUT ${POT_FILE}
- COMMAND ${GETTEXT_EXTRACT} -F -n -o ${POT_FILE} ${GETTEXT_POT_DEPS_REL}
- DEPENDS "${GETTEXT_PO_PATH}/en" ${GETTEXT_POT_DEPS}
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- COMMENT "po-update [en]: updating translation template")
-
- set(PO_FILES)
set(MO_FILES)
foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
- # skip the 'en' locale which is treated separately
- if (NOT LOCALE STREQUAL "en")
- set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/minetest.po")
- add_custom_command(OUTPUT ${PO_FILE_PATH}
- COMMAND ${GETTEXT_MSGMERGE} -F -U ${PO_FILE_PATH} ${POT_FILE}
- DEPENDS ${POT_FILE}
- WORKING_DIRECTORY "${GETTEXT_PO_PATH}/${LOCALE}"
- COMMENT "po-update [${LOCALE}]: updating strings")
-
+ set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/minetest.po")
+ set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE})
+ set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo")
+
+ add_custom_command(OUTPUT ${MO_BUILD_PATH}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${MO_BUILD_PATH}
+ COMMENT "mo-update [${LOCALE}]: Creating locale directory.")
+
+ add_custom_command(
+ OUTPUT ${MO_FILE_PATH}
+ COMMAND ${GETTEXT_MSGFMT} -o ${MO_FILE_PATH} ${PO_FILE_PATH}
+ DEPENDS ${MO_BUILD_PATH} ${PO_FILE_PATH}
+ WORKING_DIRECTORY "${GETTEXT_PO_PATH}/${LOCALE}"
+ COMMENT "mo-update [${LOCALE}]: Creating mo file."
+ )
- set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE})
- add_custom_command(OUTPUT ${MO_BUILD_PATH}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${MO_BUILD_PATH}
- COMMENT "mo-update [${LOCALE}]: Creating locale directory.")
-
- set(MO_FILE_PATH "${MO_BUILD_PATH}/minetest.mo")
-
- add_custom_command(
- OUTPUT ${MO_FILE_PATH}
- COMMAND ${GETTEXT_MSGFMT} -o ${MO_FILE_PATH} ${PO_FILE_PATH}
- DEPENDS ${MO_BUILD_PATH} ${PO_FILE_PATH}
- WORKING_DIRECTORY "${GETTEXT_PO_PATH}/${LOCALE}"
- COMMENT "mo-update [${LOCALE}]: Creating mo file."
- )
-
- set(MO_FILES ${MO_FILES} ${MO_FILE_PATH})
- set(PO_FILES ${PO_FILES} ${PO_FILE_PATH})
- endif(NOT LOCALE STREQUAL "en")
+ set(MO_FILES ${MO_FILES} ${MO_FILE_PATH})
endforeach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
add_custom_target(translations ALL COMMENT "mo update" DEPENDS ${MO_FILES})
- add_custom_target(updatepo COMMENT "po update" DEPENDS ${PO_FILES})
endif(USE_GETTEXT)
# Subdirectories
diff --git a/src/client.cpp b/src/client.cpp
index 5f299890a..c52d3ab09 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -936,7 +936,6 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
*/
//m_env.getClientMap().updateMeshes(block->getPos(), getDayNightRatio());
-
/*
Add it to mesh update queue and set it to be acknowledged after update.
*/
diff --git a/src/cmake_config.h.in b/src/cmake_config.h.in
index 5e375191f..7cbb11f6b 100644
--- a/src/cmake_config.h.in
+++ b/src/cmake_config.h.in
@@ -3,14 +3,16 @@
#ifndef CMAKE_CONFIG_H
#define CMAKE_CONFIG_H
+#define PROJECT_NAME "@PROJECT_NAME@"
#define INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
#define VERSION_STRING "@VERSION_STRING@"
+#define USE_GETTEXT @USE_GETTEXT@
#ifdef NDEBUG
#define BUILD_TYPE "Release"
#else
#define BUILD_TYPE "Debug"
#endif
-#define BUILD_INFO "VER="VERSION_STRING" RUN_IN_PLACE=@RUN_IN_PLACE@ INSTALL_PREFIX=@CMAKE_INSTALL_PREFIX@ BUILD_TYPE="BUILD_TYPE
+#define BUILD_INFO "VER="VERSION_STRING" RUN_IN_PLACE=@RUN_IN_PLACE@ USE_GETTEXT=@USE_GETTEXT@ INSTALL_PREFIX=@CMAKE_INSTALL_PREFIX@ BUILD_TYPE="BUILD_TYPE
#endif
diff --git a/src/config.h b/src/config.h
index b24cf6a69..54b89a060 100644
--- a/src/config.h
+++ b/src/config.h
@@ -9,6 +9,8 @@
#ifdef USE_CMAKE_CONFIG_H
#include "cmake_config.h"
#else
+ #define PROJECT_NAME "minetest"
+
//#define INSTALL_PREFIX ""
#define VERSION_STRING "unknown"
#ifdef NDEBUG
@@ -21,8 +23,13 @@
#else
#define RUN_IN_PLACE_BOOLSTRING "0"
#endif
- #define BUILD_INFO "NON-CMAKE RUN_IN_PLACE="RUN_IN_PLACE_BOOLSTRING" BUILD_TYPE="BUILD_TYPE
-#endif
+ #if USE_GETTEXT
+ #define USE_GETTEXT_BOOLSTRING "1"
+ #else
+ #define USE_GETTEXT_BOOLSTRING "0"
+ #endif
+ #define BUILD_INFO "NON-CMAKE RUN_IN_PLACE="RUN_IN_PLACE_BOOLSTRING" USE_GETTEXT="USE_GETTEXT_BOOLSTRING" BUILD_TYPE="BUILD_TYPE
+#endif
#endif
diff --git a/src/gettext.h b/src/gettext.h
index 73b9f8986..493f9b21b 100644
--- a/src/gettext.h
+++ b/src/gettext.h
@@ -1,4 +1,6 @@
-#ifdef USE_GETTEXT
+#include "config.h" // for USE_GETTEXT
+
+#if USE_GETTEXT
#include <libintl.h>
#else
#define gettext(String) String
@@ -8,6 +10,14 @@
#define gettext_noop(String) String
#define N_(String) gettext_noop (String)
+inline void init_gettext(const char *path) {
+#if USE_GETTEXT
+ setlocale(LC_MESSAGES, "");
+ bindtextdomain(PROJECT_NAME, path);
+ textdomain(PROJECT_NAME);
+#endif
+}
+
inline wchar_t* chartowchar_t(const char *str)
{
size_t l = strlen(str)+1;
diff --git a/src/guiPauseMenu.cpp b/src/guiPauseMenu.cpp
index 7745b8dd2..c704cd3fb 100644
--- a/src/guiPauseMenu.cpp
+++ b/src/guiPauseMenu.cpp
@@ -172,7 +172,7 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize)
);*/
std::ostringstream os;
- os<<"Minetest-c55\n";
+ os<<"Minetest-delta\n";
os<<"by Perttu Ahola and contributors\n";
os<<"celeron55@gmail.com\n";
os<<BUILD_INFO<<"\n";
diff --git a/src/keycode.cpp b/src/keycode.cpp
index d6472d2ea..f014914d0 100644
--- a/src/keycode.cpp
+++ b/src/keycode.cpp
@@ -233,4 +233,3 @@ void clearKeyCache()
{
g_key_setting_cache.clear();
}
-
diff --git a/src/main.cpp b/src/main.cpp
index 3cc748954..df0a7ff31 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1161,11 +1161,7 @@ int main(int argc, char *argv[])
// Create user data directory
fs::CreateDir(porting::path_userdata);
-#ifdef USE_GETTEXT
- setlocale(LC_MESSAGES, "");
- bindtextdomain("minetest", (porting::path_userdata+"/locale").c_str());
- textdomain("minetest");
-#endif
+ init_gettext((porting::path_data+"/../locale").c_str());
// Initialize debug streams
#ifdef RUN_IN_PLACE
@@ -1186,7 +1182,7 @@ int main(int argc, char *argv[])
BEGIN_DEBUG_EXCEPTION_HANDLER
// Print startup message
- dstream<<DTIME<<"minetest-c55"
+ dstream<<DTIME<<PROJECT_NAME
" with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST
<<", "<<BUILD_INFO
<<std::endl;
diff --git a/src/map.cpp b/src/map.cpp
index 830627066..092ce97fd 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -1540,6 +1540,17 @@ void Map::PrintInfo(std::ostream &out)
#define WATER_DROP_BOOST 4
+enum NeighborType {
+ NEIGHBOR_UPPER,
+ NEIGHBOR_SAME_LEVEL,
+ NEIGHBOR_LOWER
+};
+struct NodeNeighbor {
+ MapNode n;
+ NeighborType t;
+ v3s16 p;
+};
+
void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
{
DSTACK(__FUNCTION_NAME);
@@ -1559,240 +1570,220 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
v3s16 p0 = m_transforming_liquid.pop_front();
MapNode n0 = getNodeNoEx(p0);
-
- // Don't deal with non-liquids
- if(content_liquid(n0.getContent()) == false)
- continue;
-
- bool is_source = !content_flowing_liquid(n0.getContent());
-
- u8 liquid_level = 8;
- if(is_source == false)
- liquid_level = n0.param2 & 0x0f;
-
- // Turn possible source into non-source
- u8 nonsource_c = make_liquid_flowing(n0.getContent());
-
+
/*
- If not source, check that some node flows into this one
- and what is the level of liquid in this one
- */
- if(is_source == false)
- {
- s8 new_liquid_level_max = -1;
-
- v3s16 dirs_from[5] = {
- v3s16(0,1,0), // top
- v3s16(0,0,1), // back
- v3s16(1,0,0), // right
- v3s16(0,0,-1), // front
- v3s16(-1,0,0), // left
- };
- for(u16 i=0; i<5; i++)
- {
- bool from_top = (i==0);
-
- v3s16 p2 = p0 + dirs_from[i];
- MapNode n2 = getNodeNoEx(p2);
-
- if(content_liquid(n2.getContent()))
- {
- u8 n2_nonsource_c = make_liquid_flowing(n2.getContent());
- // Check that the liquids are the same type
- if(n2_nonsource_c != nonsource_c)
- {
- dstream<<"WARNING: Not handling: different liquids"
- " collide"<<std::endl;
- continue;
+ Collect information about current node
+ */
+ s8 liquid_level = -1;
+ u8 liquid_kind = CONTENT_IGNORE;
+ LiquidType liquid_type = content_features(n0.getContent()).liquid_type;
+ switch (liquid_type) {
+ case LIQUID_SOURCE:
+ liquid_level = 8;
+ liquid_kind = content_features(n0.getContent()).liquid_alternative_flowing;
+ break;
+ case LIQUID_FLOWING:
+ liquid_level = (n0.param2 & LIQUID_LEVEL_MASK);
+ liquid_kind = n0.getContent();
+ break;
+ case LIQUID_NONE:
+ // if this is an air node, it *could* be transformed into a liquid. otherwise,
+ // continue with the next node.
+ if (n0.getContent() != CONTENT_AIR)
+ continue;
+ liquid_kind = CONTENT_AIR;
+ break;
+ }
+
+ /*
+ Collect information about the environment
+ */
+ v3s16 dirs[6] = {
+ v3s16( 0, 1, 0), // top
+ v3s16( 0,-1, 0), // bottom
+ v3s16( 1, 0, 0), // right
+ v3s16(-1, 0, 0), // left
+ v3s16( 0, 0, 1), // back
+ v3s16( 0, 0,-1), // front
+ };
+ NodeNeighbor sources[6]; // surrounding sources
+ int num_sources = 0;
+ NodeNeighbor flows[6]; // surrounding flowing liquid nodes
+ int num_flows = 0;
+ NodeNeighbor airs[6]; // surrounding air
+ int num_airs = 0;
+ NodeNeighbor neutrals[6]; // nodes that are solid or another kind of liquid
+ int num_neutrals = 0;
+ bool flowing_down = false;
+ for (u16 i = 0; i < 6; i++) {
+ NeighborType nt = NEIGHBOR_SAME_LEVEL;
+ switch (i) {
+ case 0:
+ nt = NEIGHBOR_UPPER;
+ break;
+ case 1:
+ nt = NEIGHBOR_LOWER;
+ break;
+ }
+ v3s16 npos = p0 + dirs[i];
+ NodeNeighbor nb = {getNodeNoEx(npos), nt, npos};
+ switch (content_features(nb.n.getContent()).liquid_type) {
+ case LIQUID_NONE:
+ if (nb.n.getContent() == CONTENT_AIR) {
+ airs[num_airs++] = nb;
+ // if the current node happens to be a flowing node, it will start to flow down here.
+ if (nb.t == NEIGHBOR_LOWER)
+ flowing_down = true;
+ } else {
+ neutrals[num_neutrals++] = nb;
}
- bool n2_is_source = !content_flowing_liquid(n2.getContent());
- s8 n2_liquid_level = 8;
- if(n2_is_source == false)
- n2_liquid_level = n2.param2 & 0x07;
-
- s8 new_liquid_level = -1;
- if(from_top)
- {
- //new_liquid_level = 7;
- if(n2_liquid_level >= 7 - WATER_DROP_BOOST)
- new_liquid_level = 7;
- else
- new_liquid_level = n2_liquid_level + WATER_DROP_BOOST;
+ break;
+ 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 = content_features(nb.n.getContent()).liquid_alternative_flowing;
+ if (content_features(nb.n.getContent()).liquid_alternative_flowing !=liquid_kind) {
+ neutrals[num_neutrals++] = nb;
+ } else {
+ sources[num_sources++] = nb;
}
- else if(n2_liquid_level > 0)
- {
- new_liquid_level = n2_liquid_level - 1;
+ break;
+ 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 = content_features(nb.n.getContent()).liquid_alternative_flowing;
+ if (content_features(nb.n.getContent()).liquid_alternative_flowing != liquid_kind) {
+ neutrals[num_neutrals++] = nb;
+ } else {
+ flows[num_flows++] = nb;
+ if (nb.t == NEIGHBOR_LOWER)
+ flowing_down = true;
}
-
- if(new_liquid_level > new_liquid_level_max)
- new_liquid_level_max = new_liquid_level;
- }
- } //for
-
- /*
- If liquid level should be something else, update it and
- add all the neighboring water nodes to the transform queue.
- */
- if(new_liquid_level_max != liquid_level)
- {
- if(new_liquid_level_max == -1)
- {
- // Remove water alltoghether
- n0.setContent(CONTENT_AIR);
- n0.param2 = 0;
- setNode(p0, n0);
- }
- else
- {
- n0.param2 = new_liquid_level_max;
- setNode(p0, n0);
- }
-
- // Block has been modified
- {
- v3s16 blockpos = getNodeBlockPos(p0);
- MapBlock *block = getBlockNoCreateNoEx(blockpos);
- if(block != NULL)
- modified_blocks.insert(blockpos, block);
+ break;
+ }
+ }
+
+ /*
+ decide on the type (and possibly level) of the current node
+ */
+ u8 new_node_content;
+ s8 new_node_level = -1;
+ if (num_sources >= 2 || liquid_type == LIQUID_SOURCE) {
+ // 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 = content_features(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;
+ new_node_level = 7;
+ } else {
+ // no surrounding sources, so get the maximum level that can flow into this node
+ for (u16 i = 0; i < num_flows; i++) {
+ u8 nb_liquid_level = (flows[i].n.param2 & LIQUID_LEVEL_MASK);
+ switch (flows[i].t) {
+ case NEIGHBOR_UPPER:
+ if (nb_liquid_level + WATER_DROP_BOOST > new_node_level) {
+ new_node_level = 7;
+ if (nb_liquid_level + WATER_DROP_BOOST < 7)
+ new_node_level = nb_liquid_level + WATER_DROP_BOOST;
+ }
+ break;
+ case NEIGHBOR_LOWER:
+ break;
+ case NEIGHBOR_SAME_LEVEL:
+ if ((flows[i].n.param2 & LIQUID_FLOW_DOWN_MASK) != LIQUID_FLOW_DOWN_MASK &&
+ nb_liquid_level > 0 && nb_liquid_level - 1 > new_node_level) {
+ new_node_level = nb_liquid_level - 1;
+ }
+ break;
}
-
- /*
- Add neighboring non-source liquid nodes to transform queue.
- */
- v3s16 dirs[6] = {
- v3s16(0,0,1), // back
- v3s16(0,1,0), // top
- v3s16(1,0,0), // right
- v3s16(0,0,-1), // front
- v3s16(0,-1,0), // bottom
- v3s16(-1,0,0), // left
- };
- for(u16 i=0; i<6; i++)
- {
- v3s16 p2 = p0 + dirs[i];
-
- MapNode n2 = getNodeNoEx(p2);
- if(content_flowing_liquid(n2.getContent()))
- {
- m_transforming_liquid.push_back(p2);
+ }
+ // don't flow as far in open terrain - if there isn't at least one adjacent solid block,
+ // substract another unit from the resulting water level.
+ if (!flowing_down && new_node_level >= 1) {
+ bool at_wall = false;
+ for (u16 i = 0; i < num_neutrals; i++) {
+ if (neutrals[i].t == NEIGHBOR_SAME_LEVEL) {
+ at_wall = true;
+ break;
}
}
+ if (!at_wall)
+ new_node_level -= 1;
}
+
+ if (new_node_level >= 0)
+ new_node_content = liquid_kind;
+ else
+ new_node_content = CONTENT_AIR;
}
-
- // Get a new one from queue if the node has turned into non-water
- if(content_liquid(n0.getContent()) == false)
+
+ /*
+ check if anything has changed. if not, just continue with the next node.
+ */
+ if (new_node_content == n0.getContent() && (content_features(n0.getContent()).liquid_type != LIQUID_FLOWING ||
+ ((n0.param2 & LIQUID_LEVEL_MASK) == (u8)new_node_level &&
+ ((n0.param2 & LIQUID_FLOW_DOWN_MASK) == LIQUID_FLOW_DOWN_MASK)
+ == flowing_down)))
continue;
-
+
+
/*
- Flow water from this node
- */
- v3s16 dirs_to[5] = {
- v3s16(0,-1,0), // bottom
- v3s16(0,0,1), // back
- v3s16(1,0,0), // right
- v3s16(0,0,-1), // front
- v3s16(-1,0,0), // left
- };
- for(u16 i=0; i<5; i++)
- {
- bool to_bottom = (i == 0);
-
- // If liquid is at lowest possible height, it's not going
- // anywhere except down
- if(liquid_level == 0 && to_bottom == false)
- continue;
-
- u8 liquid_next_level = 0;
- // If going to bottom
- if(to_bottom)
- {
- //liquid_next_level = 7;
- if(liquid_level >= 7 - WATER_DROP_BOOST)
- liquid_next_level = 7;
- else
- liquid_next_level = liquid_level + WATER_DROP_BOOST;
- }
- else
- liquid_next_level = liquid_level - 1;
-
- bool n2_changed = false;
- bool flowed = false;
-
- v3s16 p2 = p0 + dirs_to[i];
-
- MapNode n2 = getNodeNoEx(p2);
- //dstream<<"[1] n2.param="<<(int)n2.param<<std::endl;
-
- if(content_liquid(n2.getContent()))
- {
- u8 n2_nonsource_c = make_liquid_flowing(n2.getContent());
- // Check that the liquids are the same type
- if(n2_nonsource_c != nonsource_c)
- {
- dstream<<"WARNING: Not handling: different liquids"
- " collide"<<std::endl;
- continue;
- }
- bool n2_is_source = !content_flowing_liquid(n2.getContent());
- u8 n2_liquid_level = 8;
- if(n2_is_source == false)
- n2_liquid_level = n2.param2 & 0x07;
-
- if(to_bottom)
- {
- flowed = true;
- }
-
- if(n2_is_source)
- {
- // Just flow into the source, nothing changes.
- // n2_changed is not set because destination didn't change
- flowed = true;
+ update the current node
+ */
+ bool flow_down_enabled = (flowing_down && ((n0.param2 & LIQUID_FLOW_DOWN_MASK) != LIQUID_FLOW_DOWN_MASK));
+ n0.setContent(new_node_content);
+ if (content_features(n0.getContent()).liquid_type == LIQUID_FLOWING) {
+ // set level to last 3 bits, flowing down bit to 4th bit
+ n0.param2 = (flowing_down ? LIQUID_FLOW_DOWN_MASK : 0x00) | (new_node_level & LIQUID_LEVEL_MASK);
+ } else {
+ n0.param2 = 0;
+ }
+ setNode(p0, n0);
+ v3s16 blockpos = getNodeBlockPos(p0);
+ MapBlock *block = getBlockNoCreateNoEx(blockpos);
+ if(block != NULL)
+ modified_blocks.insert(blockpos, block);
+
+ /*
+ enqueue neighbors for update if neccessary
+ */
+ switch (content_features(n0.getContent()).liquid_type) {
+ case LIQUID_SOURCE:
+ // make sure source flows into all neighboring nodes
+ for (u16 i = 0; i < num_flows; i++)
+ if (flows[i].t != NEIGHBOR_UPPER)
+ m_transforming_liquid.push_back(flows[i].p);
+ for (u16 i = 0; i < num_airs; i++)
+ if (airs[i].t != NEIGHBOR_UPPER)
+ m_transforming_liquid.push_back(airs[i].p);
+ break;
+ case LIQUID_NONE:
+ // this flow has turned to air; neighboring flows might need to do the same
+ for (u16 i = 0; i < num_flows; i++)
+ m_transforming_liquid.push_back(flows[i].p);
+ break;
+ case LIQUID_FLOWING:
+ for (u16 i = 0; i < num_flows; i++) {
+ u8 flow_level = (flows[i].n.param2 & LIQUID_LEVEL_MASK);
+ // liquid_level is still the ORIGINAL level of this node.
+ if (flows[i].t != NEIGHBOR_UPPER && ((flow_level < liquid_level || flow_level < new_node_level) ||
+ flow_down_enabled))
+ m_transforming_liquid.push_back(flows[i].p);
}
- else
- {
- if(liquid_next_level > liquid_level)
- {
- n2.param2 = liquid_next_level;
- setNode(p2, n2);
-
- n2_changed = true;
- flowed = true;
- }
+ for (u16 i = 0; i < num_airs; i++) {
+ if (airs[i].t != NEIGHBOR_UPPER && (airs[i].t == NEIGHBOR_LOWER || new_node_level > 0))
+ m_transforming_liquid.push_back(airs[i].p);
}
- }
- else if(n2.getContent() == CONTENT_AIR)
- {
- n2.setContent(nonsource_c);
- n2.param2 = liquid_next_level;
- setNode(p2, n2);
-
- n2_changed = true;
- flowed = true;
- }
-
- //dstream<<"[2] n2.param="<<(int)n2.param<<std::endl;
-
- if(n2_changed)
- {
- m_transforming_liquid.push_back(p2);
-
- v3s16 blockpos = getNodeBlockPos(p2);
- MapBlock *block = getBlockNoCreateNoEx(blockpos);
- if(block != NULL)
- modified_blocks.insert(blockpos, block);
- }
-
- // If n2_changed to bottom, don't flow anywhere else
- if(to_bottom && flowed && !is_source)
break;
}
-
+
loopcount++;
//if(loopcount >= 100000)
- if(loopcount >= initial_size * 1)
+ if(loopcount >= initial_size * 10) {
break;
+ }
}
//dstream<<"Map::transformLiquids(): loopcount="<<loopcount<<std::endl;
}
diff --git a/src/mapnode.h b/src/mapnode.h
index 956de6852..3cca985bc 100644
--- a/src/mapnode.h
+++ b/src/mapnode.h
@@ -401,9 +401,16 @@ enum LightBank
};
/*
+ Masks for MapNode.param2 of flowing liquids
+ */
+#define LIQUID_LEVEL_MASK 0x07
+#define LIQUID_FLOW_DOWN_MASK 0x08
+
+/*
This is the stuff what the whole world consists of.
*/
+
struct MapNode
{
/*
diff --git a/src/servermain.cpp b/src/servermain.cpp
index 91fd1d3a5..dc41720fb 100644
--- a/src/servermain.cpp
+++ b/src/servermain.cpp
@@ -162,7 +162,7 @@ int main(int argc, char *argv[])
BEGIN_DEBUG_EXCEPTION_HANDLER
// Print startup message
- dstream<<DTIME<<"minetest-c55"
+ dstream<<DTIME<<PROJECT_NAME <<
" with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST
<<", "<<BUILD_INFO
<<std::endl;