diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 88 | ||||
-rw-r--r-- | src/client.cpp | 1 | ||||
-rw-r--r-- | src/cmake_config.h.in | 4 | ||||
-rw-r--r-- | src/config.h | 11 | ||||
-rw-r--r-- | src/content_craft.cpp | 16 | ||||
-rw-r--r-- | src/content_mapblock.cpp | 47 | ||||
-rw-r--r-- | src/content_mapnode.cpp | 14 | ||||
-rw-r--r-- | src/content_mapnode.h | 2 | ||||
-rw-r--r-- | src/environment.cpp | 4 | ||||
-rw-r--r-- | src/game.cpp | 50 | ||||
-rw-r--r-- | src/gettext.h | 34 | ||||
-rw-r--r-- | src/guiKeyChangeMenu.cpp | 177 | ||||
-rw-r--r-- | src/guiKeyChangeMenu.h | 35 | ||||
-rw-r--r-- | src/guiMainMenu.cpp | 26 | ||||
-rw-r--r-- | src/guiMessageMenu.cpp | 4 | ||||
-rw-r--r-- | src/guiPasswordChange.cpp | 18 | ||||
-rw-r--r-- | src/guiPauseMenu.cpp | 12 | ||||
-rw-r--r-- | src/guiTextInputMenu.cpp | 4 | ||||
-rw-r--r-- | src/keycode.cpp | 1 | ||||
-rw-r--r-- | src/main.cpp | 8 | ||||
-rw-r--r-- | src/map.cpp | 428 | ||||
-rw-r--r-- | src/mapnode.h | 12 | ||||
-rw-r--r-- | src/player.cpp | 31 | ||||
-rw-r--r-- | src/player.h | 1 | ||||
-rw-r--r-- | src/servermain.cpp | 2 |
25 files changed, 615 insertions, 415 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4d51f7104..ce53651b0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,15 +1,19 @@ -cmake_minimum_required( VERSION 2.6 ) - project(minetest) +cmake_minimum_required( VERSION 2.6 ) 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) + +find_package(GettextLib) -if(USE_GETTEXT) - find_package(GettextLib REQUIRED) +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++") @@ -274,7 +275,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") @@ -305,54 +306,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 55f0af6dc..02f78e233 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/content_craft.cpp b/src/content_craft.cpp index b5a1dc776..481ea1a63 100644 --- a/src/content_craft.cpp +++ b/src/content_craft.cpp @@ -413,6 +413,22 @@ InventoryItem *craft_get_result(InventoryItem **items) } } + // Ladder + { + ItemSpec specs[9]; + specs[0] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[2] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[3] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[4] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[5] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[6] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[8] = ItemSpec(ITEM_CRAFT, "Stick"); + if(checkItemCombination(items, specs)) + { + return new MaterialItem(CONTENT_LADDER, 1); + } + } + return NULL; } diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index 3044c8b35..ed2cd766a 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -1134,6 +1134,53 @@ void mapblock_mesh_generate_special(MeshMakeData *data, u16 indices[] = {0,1,2,2,3,0}; collector.append(material_rail, vertices, 4, indices, 6); } + else if (n.getContent() == CONTENT_LADDER) { + u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio)); + video::SColor c(255,l,l,l); + + float d = (float)BS/16; + + // Assume wall is at X+ + video::S3DVertex vertices[4] = + { + video::S3DVertex(BS/2-d,-BS/2,-BS/2, 0,0,0, c, 0,1), + video::S3DVertex(BS/2-d,-BS/2,BS/2, 0,0,0, c, 1,1), + video::S3DVertex(BS/2-d,BS/2,BS/2, 0,0,0, c, 1,0), + video::S3DVertex(BS/2-d,BS/2,-BS/2, 0,0,0, c, 0,0), + }; + + v3s16 dir = unpackDir(n.param2); + + for(s32 i=0; i<4; i++) + { + if(dir == v3s16(1,0,0)) + vertices[i].Pos.rotateXZBy(0); + if(dir == v3s16(-1,0,0)) + vertices[i].Pos.rotateXZBy(180); + if(dir == v3s16(0,0,1)) + vertices[i].Pos.rotateXZBy(90); + if(dir == v3s16(0,0,-1)) + vertices[i].Pos.rotateXZBy(-90); + if(dir == v3s16(0,-1,0)) + vertices[i].Pos.rotateXYBy(-90); + if(dir == v3s16(0,1,0)) + vertices[i].Pos.rotateXYBy(90); + + vertices[i].Pos += intToFloat(p + blockpos_nodes, BS); + } + + video::SMaterial material_ladder; + material_ladder.setFlag(video::EMF_LIGHTING, false); + material_ladder.setFlag(video::EMF_BACK_FACE_CULLING, false); + material_ladder.setFlag(video::EMF_BILINEAR_FILTER, false); + material_ladder.setFlag(video::EMF_FOG_ENABLE, true); + material_ladder.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + material_ladder.setTexture(0, g_texturesource->getTextureRaw("ladder.png")); + + u16 indices[] = {0,1,2,2,3,0}; + // Add to mesh collector + collector.append(material_ladder, vertices, 4, indices, 6); + } } } #endif diff --git a/src/content_mapnode.cpp b/src/content_mapnode.cpp index 7589f06ed..b164033db 100644 --- a/src/content_mapnode.cpp +++ b/src/content_mapnode.cpp @@ -303,6 +303,20 @@ void content_mapnode_init() f->walkable = false; setDirtLikeDiggingProperties(f->digging_properties, 0.75); + i = CONTENT_LADDER; + f = &content_features(i); + f->setInventoryTexture("ladder.png"); + f->light_propagates = true; + f->param_type = CPT_LIGHT; + f->is_ground_content = true; + f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; + f->wall_mounted = true; + f->solidness = 0; + f->air_equivalent = true; + f->walkable = false; + f->climbable = true; + setWoodLikeDiggingProperties(f->digging_properties, 0.5); + // Deprecated i = CONTENT_COALSTONE; f = &content_features(i); diff --git a/src/content_mapnode.h b/src/content_mapnode.h index 609df0a95..9643db746 100644 --- a/src/content_mapnode.h +++ b/src/content_mapnode.h @@ -46,6 +46,7 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version); #define CONTENT_FURNACE 16 #define CONTENT_FENCE 21 #define CONTENT_RAIL 30 +#define CONTENT_LADDER 31 // 0x800...0xfff (2048...4095): higher 4 bytes of param2 are not usable #define CONTENT_GRASS 0x800 //1 @@ -75,6 +76,5 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version); #define CONTENT_NC 0x817 #define CONTENT_NC_RB 0x818 - #endif diff --git a/src/environment.cpp b/src/environment.cpp index e9b94f3fa..680d209fc 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -1511,6 +1511,8 @@ void ClientEnvironment::step(float dtime) /* Get the speed the player is going */ + bool is_climbing = lplayer->is_climbing; + f32 player_speed = 0.001; // just some small value player_speed = lplayer->getSpeed().getLength(); @@ -1568,7 +1570,7 @@ void ClientEnvironment::step(float dtime) v3f lplayerpos = lplayer->getPosition(); // Apply physics - if(free_move == false) + if(free_move == false && is_climbing == false) { // Gravity v3f speed = lplayer->getSpeed(); diff --git a/src/game.cpp b/src/game.cpp index a42bf2b2c..c4a9aba00 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -538,6 +538,56 @@ void getPointedNode(Client *client, v3f player_position, } } } + + else if(n.getContent() == CONTENT_LADDER) + { + v3s16 dir = unpackDir(n.param2); + v3f dir_f = v3f(dir.X, dir.Y, dir.Z); + dir_f *= BS/2 - BS/6 - BS/20; + v3f cpf = npf + dir_f; + f32 distance = (cpf - camera_position).getLength(); + + v3f vertices[4] = + { + v3f(BS*0.42,-BS/2,-BS/2), + v3f(BS*0.49, BS/2, BS/2), + }; + + for(s32 i=0; i<2; i++) + { + if(dir == v3s16(1,0,0)) + vertices[i].rotateXZBy(0); + if(dir == v3s16(-1,0,0)) + vertices[i].rotateXZBy(180); + if(dir == v3s16(0,0,1)) + vertices[i].rotateXZBy(90); + if(dir == v3s16(0,0,-1)) + vertices[i].rotateXZBy(-90); + if(dir == v3s16(0,-1,0)) + vertices[i].rotateXYBy(-90); + if(dir == v3s16(0,1,0)) + vertices[i].rotateXYBy(90); + + vertices[i] += npf; + } + + core::aabbox3d<f32> box; + + box = core::aabbox3d<f32>(vertices[0]); + box.addInternalPoint(vertices[1]); + + if(distance < mindistance) + { + if(box.intersectsWithLine(shootline)) + { + nodefound = true; + nodepos = np; + neighbourpos = np; + mindistance = distance; + nodehilightbox = box; + } + } + } else if(n.getContent() == CONTENT_RAIL) { v3s16 dir = unpackDir(n.param0); diff --git a/src/gettext.h b/src/gettext.h index 73b9f8986..0e6ee0fd5 100644 --- a/src/gettext.h +++ b/src/gettext.h @@ -1,4 +1,8 @@ -#ifdef USE_GETTEXT +#ifndef GETTEXT_HEADER +#include "config.h" // for USE_GETTEXT +#include <iostream> + +#if USE_GETTEXT #include <libintl.h> #else #define gettext(String) String @@ -8,6 +12,17 @@ #define gettext_noop(String) String #define N_(String) gettext_noop (String) +inline void init_gettext(const char *path) { +#if USE_GETTEXT + // don't do this if MSVC compiler is used, it gives an assertion fail + #ifndef _MSC_VER + setlocale(LC_MESSAGES, ""); + #endif + bindtextdomain(PROJECT_NAME, path); + textdomain(PROJECT_NAME); +#endif +} + inline wchar_t* chartowchar_t(const char *str) { size_t l = strlen(str)+1; @@ -15,3 +30,20 @@ inline wchar_t* chartowchar_t(const char *str) mbstowcs(nstr, str, l); return nstr; } + +inline wchar_t* wgettext(const char *str) +{ + return chartowchar_t(gettext(str)); +} + +inline void changeCtype(const char *l) +{ + char *ret = NULL; + ret = setlocale(LC_CTYPE, l); + if(ret == NULL) + std::cout<<"locale could not be set"<<std::endl; + else + std::cout<<"locale has been set to:"<<ret<<std::endl; +} +#define GETTEXT_HEADER +#endif diff --git a/src/guiKeyChangeMenu.cpp b/src/guiKeyChangeMenu.cpp index 98d6f8086..20a3d361e 100644 --- a/src/guiKeyChangeMenu.cpp +++ b/src/guiKeyChangeMenu.cpp @@ -76,13 +76,13 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) recalculateAbsolutePosition(false); v2s32 topleft(0, 0); - + changeCtype(""); { core::rect < s32 > rect(0, 0, 125, 20); rect += topleft + v2s32(25, 3); - const wchar_t *text = L"KEYBINDINGS"; //gui::IGUIStaticText *t = - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(wgettext("KEYBINDINGS"), + rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } v2s32 offset(25, 40); @@ -91,8 +91,8 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); - const wchar_t *text = L"Forward"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(wgettext("Forward"), + rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } @@ -101,15 +101,15 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->forward = Environment->addButton(rect, this, GUI_ID_KEY_FORWARD_BUTTON, - narrow_to_wide(KeyNames[key_forward]).c_str()); + wgettext(KeyNames[key_forward])); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); - const wchar_t *text = L"Backward"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(wgettext("Backward"), + rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } @@ -118,14 +118,14 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->backward = Environment->addButton(rect, this, GUI_ID_KEY_BACKWARD_BUTTON, - narrow_to_wide(KeyNames[key_backward]).c_str()); + wgettext(KeyNames[key_backward])); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); - const wchar_t *text = L"Left"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(wgettext("Left"), + rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } @@ -133,14 +133,14 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->left = Environment->addButton(rect, this, GUI_ID_KEY_LEFT_BUTTON, - narrow_to_wide(KeyNames[key_left]).c_str()); + wgettext(KeyNames[key_left])); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); - const wchar_t *text = L"Right"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(wgettext("Right"), + rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } @@ -149,14 +149,14 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->right = Environment->addButton(rect, this, GUI_ID_KEY_RIGHT_BUTTON, - narrow_to_wide(KeyNames[key_right]).c_str()); + wgettext(KeyNames[key_right])); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); - const wchar_t *text = L"Use"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(wgettext("Use"), + rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } @@ -164,14 +164,14 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->use = Environment->addButton(rect, this, GUI_ID_KEY_USE_BUTTON, - narrow_to_wide(KeyNames[key_use]).c_str()); + wgettext(KeyNames[key_use])); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); - const wchar_t *text = L"Sneak"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(wgettext("Sneak"), + rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } @@ -180,14 +180,13 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->sneak = Environment->addButton(rect, this, GUI_ID_KEY_SNEAK_BUTTON, - narrow_to_wide(KeyNames[key_sneak]).c_str()); + wgettext(KeyNames[key_sneak])); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); - const wchar_t *text = L"Jump"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(wgettext("Jump"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } @@ -195,15 +194,15 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->jump = Environment->addButton(rect, this, GUI_ID_KEY_JUMP_BUTTON, - narrow_to_wide(KeyNames[key_jump]).c_str()); + wgettext(KeyNames[key_jump])); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); - const wchar_t *text = L"Inventory"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(wgettext("Inventory"), + rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } @@ -212,14 +211,13 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->inventory = Environment->addButton(rect, this, GUI_ID_KEY_INVENTORY_BUTTON, - narrow_to_wide(KeyNames[key_inventory]).c_str()); + wgettext(KeyNames[key_inventory])); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); - const wchar_t *text = L"Chat"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(wgettext("Chat"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } @@ -227,7 +225,7 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->chat = Environment->addButton(rect, this, GUI_ID_KEY_CHAT_BUTTON, - narrow_to_wide(KeyNames[key_chat]).c_str()); + wgettext(KeyNames[key_chat])); } //next col @@ -235,8 +233,8 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); - const wchar_t *text = L"Toggle fly"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(wgettext("Toggle fly"), + rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } @@ -244,14 +242,14 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->fly = Environment->addButton(rect, this, GUI_ID_KEY_FLY_BUTTON, - narrow_to_wide(KeyNames[key_fly]).c_str()); + wgettext(KeyNames[key_fly])); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); - const wchar_t *text = L"Toggle fast"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(wgettext("Toggle fast"), + rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } @@ -259,14 +257,14 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->fast = Environment->addButton(rect, this, GUI_ID_KEY_FAST_BUTTON, - narrow_to_wide(KeyNames[key_fast]).c_str()); + wgettext(KeyNames[key_fast])); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); - const wchar_t *text = L"Range select"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(wgettext("Range select"), + rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } @@ -275,15 +273,15 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->range = Environment->addButton(rect, this, GUI_ID_KEY_RANGE_BUTTON, - narrow_to_wide(KeyNames[key_range]).c_str()); + wgettext(KeyNames[key_range])); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); - const wchar_t *text = L"Print stacks"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(wgettext("Print stacks"), + rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } @@ -291,18 +289,21 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->dump = Environment->addButton(rect, this, GUI_ID_KEY_DUMP_BUTTON, - narrow_to_wide(KeyNames[key_dump]).c_str()); + wgettext(KeyNames[key_dump])); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(size.X - 100 - 20, size.Y - 40); - Environment->addButton(rect, this, GUI_ID_BACK_BUTTON, L"Save"); + Environment->addButton(rect, this, GUI_ID_BACK_BUTTON, + wgettext("Save")); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(size.X - 100 - 20 - 100 - 20, size.Y - 40); - Environment->addButton(rect, this, GUI_ID_ABORT_BUTTON, L"Cancel"); + Environment->addButton(rect, this, GUI_ID_ABORT_BUTTON, + wgettext("Cancel")); } + changeCtype("C"); } void GUIKeyChangeMenu::drawMenu() @@ -366,45 +367,45 @@ bool GUIKeyChangeMenu::resetMenu() { case GUI_ID_KEY_FORWARD_BUTTON: this->forward->setText( - narrow_to_wide(KeyNames[key_forward]).c_str()); + wgettext(KeyNames[key_forward])); break; case GUI_ID_KEY_BACKWARD_BUTTON: this->backward->setText( - narrow_to_wide(KeyNames[key_backward]).c_str()); + wgettext(KeyNames[key_backward])); break; case GUI_ID_KEY_LEFT_BUTTON: - this->left->setText(narrow_to_wide(KeyNames[key_left]).c_str()); + this->left->setText(wgettext(KeyNames[key_left])); break; case GUI_ID_KEY_RIGHT_BUTTON: - this->right->setText(narrow_to_wide(KeyNames[key_right]).c_str()); + this->right->setText(wgettext(KeyNames[key_right])); break; case GUI_ID_KEY_JUMP_BUTTON: - this->jump->setText(narrow_to_wide(KeyNames[key_jump]).c_str()); + this->jump->setText(wgettext(KeyNames[key_jump])); break; case GUI_ID_KEY_SNEAK_BUTTON: - this->sneak->setText(narrow_to_wide(KeyNames[key_sneak]).c_str()); + this->sneak->setText(wgettext(KeyNames[key_sneak])); break; case GUI_ID_KEY_INVENTORY_BUTTON: this->inventory->setText( - narrow_to_wide(KeyNames[key_inventory]).c_str()); + wgettext(KeyNames[key_inventory])); break; case GUI_ID_KEY_CHAT_BUTTON: - this->chat->setText(narrow_to_wide(KeyNames[key_chat]).c_str()); + this->chat->setText(wgettext(KeyNames[key_chat])); break; case GUI_ID_KEY_RANGE_BUTTON: - this->range->setText(narrow_to_wide(KeyNames[key_range]).c_str()); + this->range->setText(wgettext(KeyNames[key_range])); break; case GUI_ID_KEY_FLY_BUTTON: - this->fly->setText(narrow_to_wide(KeyNames[key_fly]).c_str()); + this->fly->setText(wgettext(KeyNames[key_fly])); break; case GUI_ID_KEY_FAST_BUTTON: - this->fast->setText(narrow_to_wide(KeyNames[key_fast]).c_str()); + this->fast->setText(wgettext(KeyNames[key_fast])); break; case GUI_ID_KEY_USE_BUTTON: - this->use->setText(narrow_to_wide(KeyNames[key_use]).c_str()); + this->use->setText(wgettext(KeyNames[key_use])); break; case GUI_ID_KEY_DUMP_BUTTON: - this->dump->setText(narrow_to_wide(KeyNames[key_dump]).c_str()); + this->dump->setText(wgettext(KeyNames[key_dump])); break; } activeKey = -1; @@ -417,85 +418,86 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event) if (event.EventType == EET_KEY_INPUT_EVENT && activeKey >= 0 && event.KeyInput.PressedDown) { + changeCtype(""); if (activeKey == GUI_ID_KEY_FORWARD_BUTTON) { this->forward->setText( - narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + wgettext(KeyNames[event.KeyInput.Key])); this->key_forward = event.KeyInput.Key; } else if (activeKey == GUI_ID_KEY_BACKWARD_BUTTON) { this->backward->setText( - narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + wgettext(KeyNames[event.KeyInput.Key])); this->key_backward = event.KeyInput.Key; } else if (activeKey == GUI_ID_KEY_LEFT_BUTTON) { this->left->setText( - narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + wgettext(KeyNames[event.KeyInput.Key])); this->key_left = event.KeyInput.Key; } else if (activeKey == GUI_ID_KEY_RIGHT_BUTTON) { this->right->setText( - narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + wgettext(KeyNames[event.KeyInput.Key])); this->key_right = event.KeyInput.Key; } else if (activeKey == GUI_ID_KEY_JUMP_BUTTON) { this->jump->setText( - narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + wgettext(KeyNames[event.KeyInput.Key])); this->key_jump = event.KeyInput.Key; } else if (activeKey == GUI_ID_KEY_SNEAK_BUTTON) { this->sneak->setText( - narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + wgettext(KeyNames[event.KeyInput.Key])); this->key_sneak = event.KeyInput.Key; } else if (activeKey == GUI_ID_KEY_INVENTORY_BUTTON) { this->inventory->setText( - narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + wgettext(KeyNames[event.KeyInput.Key])); this->key_inventory = event.KeyInput.Key; } else if (activeKey == GUI_ID_KEY_CHAT_BUTTON) { this->chat->setText( - narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + wgettext(KeyNames[event.KeyInput.Key])); this->key_chat = event.KeyInput.Key; } else if (activeKey == GUI_ID_KEY_RANGE_BUTTON) { this->range->setText( - narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + wgettext(KeyNames[event.KeyInput.Key])); this->key_range = event.KeyInput.Key; } else if (activeKey == GUI_ID_KEY_FLY_BUTTON) { this->fly->setText( - narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + wgettext(KeyNames[event.KeyInput.Key])); this->key_fly = event.KeyInput.Key; } else if (activeKey == GUI_ID_KEY_FAST_BUTTON) { this->fast->setText( - narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + wgettext(KeyNames[event.KeyInput.Key])); this->key_fast = event.KeyInput.Key; } else if (activeKey == GUI_ID_KEY_USE_BUTTON) { this->use->setText( - narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + wgettext(KeyNames[event.KeyInput.Key])); this->key_use = event.KeyInput.Key; } else if (activeKey == GUI_ID_KEY_DUMP_BUTTON) { this->dump->setText( - narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + wgettext(KeyNames[event.KeyInput.Key])); this->key_dump = event.KeyInput.Key; } - + changeCtype("C"); activeKey = -1; return true; } @@ -514,6 +516,12 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event) } if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED) { + if(event.GUIEvent.Caller->getID() != GUI_ID_BACK_BUTTON && + event.GUIEvent.Caller->getID() != GUI_ID_ABORT_BUTTON) + { + changeCtype(""); + } + switch (event.GUIEvent.Caller->getID()) { case GUI_ID_BACK_BUTTON: //back @@ -526,70 +534,71 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event) case GUI_ID_KEY_FORWARD_BUTTON: resetMenu(); activeKey = event.GUIEvent.Caller->getID(); - this->forward->setText(L"press Key"); + this->forward->setText(wgettext("press Key")); break; case GUI_ID_KEY_BACKWARD_BUTTON: resetMenu(); activeKey = event.GUIEvent.Caller->getID(); - this->backward->setText(L"press Key"); + this->backward->setText(wgettext("press Key")); break; case GUI_ID_KEY_LEFT_BUTTON: resetMenu(); activeKey = event.GUIEvent.Caller->getID(); - this->left->setText(L"press Key"); + this->left->setText(wgettext("press Key")); break; case GUI_ID_KEY_RIGHT_BUTTON: resetMenu(); activeKey = event.GUIEvent.Caller->getID(); - this->right->setText(L"press Key"); + this->right->setText(wgettext("press Key")); break; case GUI_ID_KEY_USE_BUTTON: resetMenu(); activeKey = event.GUIEvent.Caller->getID(); - this->use->setText(L"press Key"); + this->use->setText(wgettext("press Key")); break; case GUI_ID_KEY_FLY_BUTTON: resetMenu(); activeKey = event.GUIEvent.Caller->getID(); - this->fly->setText(L"press Key"); + this->fly->setText(wgettext("press Key")); break; case GUI_ID_KEY_FAST_BUTTON: resetMenu(); activeKey = event.GUIEvent.Caller->getID(); - this->fast->setText(L"press Key"); + this->fast->setText(wgettext("press Key")); break; case GUI_ID_KEY_JUMP_BUTTON: resetMenu(); activeKey = event.GUIEvent.Caller->getID(); - this->jump->setText(L"press Key"); + this->jump->setText(wgettext("press Key")); break; case GUI_ID_KEY_CHAT_BUTTON: resetMenu(); activeKey = event.GUIEvent.Caller->getID(); - this->chat->setText(L"press Key"); + this->chat->setText(wgettext("press Key")); break; case GUI_ID_KEY_SNEAK_BUTTON: resetMenu(); activeKey = event.GUIEvent.Caller->getID(); - this->sneak->setText(L"press Key"); + this->sneak->setText(wgettext("press Key")); break; case GUI_ID_KEY_INVENTORY_BUTTON: resetMenu(); activeKey = event.GUIEvent.Caller->getID(); - this->inventory->setText(L"press Key"); + this->inventory->setText(wgettext("press Key")); break; case GUI_ID_KEY_DUMP_BUTTON: resetMenu(); activeKey = event.GUIEvent.Caller->getID(); - this->dump->setText(L"press Key"); + this->dump->setText(wgettext("press Key")); break; case GUI_ID_KEY_RANGE_BUTTON: resetMenu(); activeKey = event.GUIEvent.Caller->getID(); - this->range->setText(L"press Key"); + this->range->setText(wgettext("press Key")); break; } //Buttons + changeCtype("C"); } } diff --git a/src/guiKeyChangeMenu.h b/src/guiKeyChangeMenu.h index e9e359c3c..db86ab2d1 100644 --- a/src/guiKeyChangeMenu.h +++ b/src/guiKeyChangeMenu.h @@ -26,35 +26,36 @@ #include "utility.h" #include "modalMenu.h" #include "client.h" +#include "gettext.h" #include <string> static const char *KeyNames[] = - { "-", "Left Button", "Right Button", "Cancel", "Middle Button", "X Button 1", - "X Button 2", "-", "Back", "Tab", "-", "-", "Clear", "Return", "-", - "-", "Shift", "Control", "Menu", "Pause", "Capital", "Kana", "-", - "Junja", "Final", "Kanji", "-", "Escape", "Convert", "Nonconvert", - "Accept", "Mode Change", "Space", "Priot", "Next", "End", "Home", - "Left", "Up", "Right", "Down", "Select", "Print", "Execute", - "Snapshot", "Insert", "Delete", "Help", "0", "1", "2", "3", "4", "5", + { "-", N_("Left Button"), N_("Right Button"), N_("Cancel"), N_("Middle Button"), N_("X Button 1"), + N_("X Button 2"), "-", N_("Back"), N_("Tab"), "-", "-", N_("Clear"), N_("Return"), "-", + "-", N_("Shift"), N_("Control"), N_("Menu"), N_("Pause"), N_("Capital"), N_("Kana"), "-", + N_("Junja"), N_("Final"), N_("Kanji"), "-", N_("Escape"), N_("Convert"), N_("Nonconvert"), + N_("Accept"), N_("Mode Change"), N_("Space"), N_("Priot"), N_("Next"), N_("End"), N_("Home"), + N_("Left"), N_("Up"), N_("Right"), N_("Down"), N_("Select"), N_("Print"), N_("Execute"), + N_("Snapshot"), N_("Insert"), N_("Delete"), N_("Help"), "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "-", "-", "-", "-", "-", "-", "-", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", - "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Left Windows", - "Right Windows", "Apps", "-", "Sleep", "Numpad 0", "Numpad 1", - "Numpad 2", "Numpad 3", "Numpad 4", "Numpad 5", "Numpad 6", "Numpad 7", - "Numpad 8", "Numpad 9", "Numpad *", "Numpad +", "Numpad /", "Numpad -", + "R", "S", "T", "U", "V", "W", "X", "Y", "Z", N_("Left Windows"), + N_("Right Windows"), N_("Apps"), "-", N_("Sleep"), N_("Numpad 0"), N_("Numpad 1"), + N_("Numpad 2"), N_("Numpad 3"), N_("Numpad 4"), N_("Numpad 5"), N_("Numpad 6"), N_("Numpad 7"), + N_("Numpad 8"), N_("Numpad 9"), N_("Numpad *"), N_("Numpad +"), N_("Numpad /"), N_("Numpad -"), "Numpad .", "Numpad /", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24", "-", "-", "-", "-", "-", "-", - "-", "-", "Num Lock", "Scroll Lock", "-", "-", "-", "-", "-", "-", "-", - "-", "-", "-", "-", "-", "-", "-", "Left Shift", "Right Shight", - "Left Control", "Right Control", "Left Menu", "Right Menu", "-", "-", + "-", "-", N_("Num Lock"), N_("Scroll Lock"), "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", N_("Left Shift"), N_("Right Shight"), + N_("Left Control"), N_("Right Control"), N_("Left Menu"), N_("Right Menu"), "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", - "-", "-", "-", "-", "-", "Plus", "Comma", "Minus", "Period", "-", "-", + "-", "-", "-", "-", "-", N_("Plus"), N_("Comma"), N_("Minus"), N_("Period"), "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", - "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "Attn", "CrSel", - "ExSel", "Erase OEF", "Play", "Zoom", "PA1", "OEM Clear", "-" }; + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", N_("Attn"), N_("CrSel"), + N_("ExSel"), N_("Erase OEF"), N_("Play"), N_("Zoom"), N_("PA1"), N_("OEM Clear"), "-" }; enum { GUI_ID_BACK_BUTTON = 101, GUI_ID_ABORT_BUTTON, GUI_ID_SCROLL_BAR, diff --git a/src/guiMainMenu.cpp b/src/guiMainMenu.cpp index 1d7f224f6..2d5bd151a 100644 --- a/src/guiMainMenu.cpp +++ b/src/guiMainMenu.cpp @@ -164,6 +164,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) v2s32 topleft_client(40, 0); v2s32 size_client = size - v2s32(40, 0); + changeCtype(""); { core::rect<s32> rect(0, 0, 20, 125); rect += topleft_client + v2s32(-15, 60); @@ -177,9 +178,10 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) { core::rect<s32> rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, 50+6); - Environment->addStaticText(chartowchar_t(gettext("Name/Password")), + Environment->addStaticText(wgettext("Name/Password"), rect, false, true, this, -1); } + changeCtype("C"); { core::rect<s32> rect(0, 0, 230, 30); rect += topleft_client + v2s32(160, 50); @@ -196,13 +198,15 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) e->setPasswordBox(true); } + changeCtype(""); // Address + port { core::rect<s32> rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, 100+6); - Environment->addStaticText(chartowchar_t(gettext("Address/Port")), + Environment->addStaticText(wgettext("Address/Port"), rect, false, true, this, -1); } + changeCtype("C"); { core::rect<s32> rect(0, 0, 230, 30); rect += topleft_client + v2s32(160, 100); @@ -217,23 +221,24 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) rect += topleft_client + v2s32(size_client.X-60-100, 100); Environment->addEditBox(text_port.c_str(), rect, true, this, GUI_ID_PORT_INPUT); } + changeCtype(""); { core::rect<s32> rect(0, 0, 400, 20); rect += topleft_client + v2s32(160, 100+35); - Environment->addStaticText(chartowchar_t(gettext("Leave address blank to start a local server.")), + Environment->addStaticText(wgettext("Leave address blank to start a local server."), rect, false, true, this, -1); } { core::rect<s32> rect(0, 0, 250, 30); rect += topleft_client + v2s32(35, 150); Environment->addCheckBox(fancy_trees, rect, this, GUI_ID_FANCYTREE_CB, - chartowchar_t(gettext("Fancy trees"))); + wgettext("Fancy trees")); } { core::rect<s32> rect(0, 0, 250, 30); rect += topleft_client + v2s32(35, 150+30); Environment->addCheckBox(smooth_lighting, rect, this, GUI_ID_SMOOTH_LIGHTING_CB, - chartowchar_t(gettext("Smooth Lighting"))); + wgettext("Smooth Lighting")); } // Start game button { @@ -241,7 +246,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) //rect += topleft_client + v2s32(size_client.X/2-180/2, 225-30/2); rect += topleft_client + v2s32(size_client.X-180-40, 150+25); Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, - chartowchar_t(gettext("Start Game / Connect"))); + wgettext("Start Game / Connect")); } // Key change button @@ -250,7 +255,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) //rect += topleft_client + v2s32(size_client.X/2-180/2, 225-30/2); rect += topleft_client + v2s32(size_client.X-180-40-100-20, 150+25); Environment->addButton(rect, this, GUI_ID_CHANGE_KEYS_BUTTON, - chartowchar_t(gettext("Change keys"))); + wgettext("Change keys")); } /* Server section @@ -273,13 +278,13 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) core::rect<s32> rect(0, 0, 250, 30); rect += topleft_server + v2s32(35, 30); Environment->addCheckBox(creative_mode, rect, this, GUI_ID_CREATIVE_CB, - chartowchar_t(gettext("Creative Mode"))); + wgettext("Creative Mode")); } { core::rect<s32> rect(0, 0, 250, 30); rect += topleft_server + v2s32(35, 60); Environment->addCheckBox(enable_damage, rect, this, GUI_ID_DAMAGE_CB, - chartowchar_t(gettext("Enable Damage"))); + wgettext("Enable Damage")); } // Map delete button { @@ -287,8 +292,9 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) //rect += topleft_server + v2s32(size_server.X-40-130, 100+25); rect += topleft_server + v2s32(40, 100+25); Environment->addButton(rect, this, GUI_ID_DELETE_MAP_BUTTON, - chartowchar_t(gettext("Delete map"))); + wgettext("Delete map")); } + changeCtype("C"); } void GUIMainMenu::drawMenu() diff --git a/src/guiMessageMenu.cpp b/src/guiMessageMenu.cpp index 155be6029..14b360708 100644 --- a/src/guiMessageMenu.cpp +++ b/src/guiMessageMenu.cpp @@ -85,14 +85,16 @@ void GUIMessageMenu::regenerateGui(v2u32 screensize) Environment->addStaticText(m_message_text.c_str(), rect, false, true, this, 256); } + changeCtype(""); { core::rect<s32> rect(0, 0, 140, 30); rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+25); gui::IGUIElement *e = Environment->addButton(rect, this, 257, - chartowchar_t(gettext("Proceed"))); + wgettext("Proceed")); Environment->setFocus(e); } + changeCtype("C"); } void GUIMessageMenu::drawMenu() diff --git a/src/guiPasswordChange.cpp b/src/guiPasswordChange.cpp index fabe75110..273326fd5 100644 --- a/src/guiPasswordChange.cpp +++ b/src/guiPasswordChange.cpp @@ -96,12 +96,14 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) Add stuff */ s32 ypos = 50; + changeCtype(""); { core::rect<s32> rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, ypos+6); - Environment->addStaticText(chartowchar_t(gettext("Old Password")), + Environment->addStaticText(wgettext("Old Password"), rect, false, true, this, -1); } + changeCtype("C"); { core::rect<s32> rect(0, 0, 230, 30); rect += topleft_client + v2s32(160, ypos); @@ -111,12 +113,14 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) e->setPasswordBox(true); } ypos += 50; + changeCtype(""); { core::rect<s32> rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, ypos+6); - Environment->addStaticText(chartowchar_t(gettext("New Password")), + Environment->addStaticText(wgettext("New Password"), rect, false, true, this, -1); } + changeCtype("C"); { core::rect<s32> rect(0, 0, 230, 30); rect += topleft_client + v2s32(160, ypos); @@ -125,12 +129,14 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) e->setPasswordBox(true); } ypos += 50; + changeCtype(""); { core::rect<s32> rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, ypos+6); - Environment->addStaticText(chartowchar_t(gettext("Confirm Password")), + Environment->addStaticText(wgettext("Confirm Password"), rect, false, true, this, -1); } + changeCtype("C"); { core::rect<s32> rect(0, 0, 230, 30); rect += topleft_client + v2s32(160, ypos); @@ -140,10 +146,11 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) } ypos += 50; + changeCtype(""); { core::rect<s32> rect(0, 0, 140, 30); rect = rect + v2s32(size.X/2-140/2, ypos); - Environment->addButton(rect, this, ID_change, chartowchar_t(gettext("Change"))); + Environment->addButton(rect, this, ID_change, wgettext("Change")); } ypos += 50; @@ -152,10 +159,11 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) rect += topleft_client + v2s32(35, ypos); IGUIElement *e = Environment->addStaticText( - chartowchar_t(gettext("Passwords do not match!")), + wgettext("Passwords do not match!"), rect, false, true, this, ID_message); e->setVisible(false); } + changeCtype("C"); } diff --git a/src/guiPauseMenu.cpp b/src/guiPauseMenu.cpp index 7745b8dd2..eae887a4c 100644 --- a/src/guiPauseMenu.cpp +++ b/src/guiPauseMenu.cpp @@ -103,32 +103,33 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize) const s32 btn_gap = 20;
const s32 btn_num = 4;
s32 btn_y = size.Y/2-((btn_num*btn_height+(btn_num-1)*btn_gap))/2;
+ changeCtype("");
{
core::rect<s32> rect(0, 0, 140, btn_height);
rect = rect + v2s32(size.X/2-140/2, btn_y);
Environment->addButton(rect, this, 256,
- chartowchar_t(gettext("Continue")));
+ wgettext("Continue"));
}
btn_y += btn_height + btn_gap;
{
core::rect<s32> rect(0, 0, 140, btn_height);
rect = rect + v2s32(size.X/2-140/2, btn_y);
Environment->addButton(rect, this, 261,
- chartowchar_t(gettext("Change Password")));
+ wgettext("Change Password"));
}
btn_y += btn_height + btn_gap;
{
core::rect<s32> rect(0, 0, 140, btn_height);
rect = rect + v2s32(size.X/2-140/2, btn_y);
Environment->addButton(rect, this, 260,
- chartowchar_t(gettext("Disconnect")));
+ wgettext("Disconnect"));
}
btn_y += btn_height + btn_gap;
{
core::rect<s32> rect(0, 0, 140, btn_height);
rect = rect + v2s32(size.X/2-140/2, btn_y);
Environment->addButton(rect, this, 257,
- chartowchar_t(gettext("Exit to OS")));
+ wgettext("Exit to OS"));
}
{
@@ -172,7 +173,7 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize) );*/
std::ostringstream os;
- os<<"Minetest-c55\n";
+ os<<"Minetest\n";
os<<"by Perttu Ahola and contributors\n";
os<<"celeron55@gmail.com\n";
os<<BUILD_INFO<<"\n";
@@ -180,6 +181,7 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize) Environment->addStaticText(narrow_to_wide(os.str()).c_str(), rect, false, true, this, 259);
}
+ changeCtype("C");
}
void GUIPauseMenu::drawMenu()
diff --git a/src/guiTextInputMenu.cpp b/src/guiTextInputMenu.cpp index 252e452f5..bfe0ea5de 100644 --- a/src/guiTextInputMenu.cpp +++ b/src/guiTextInputMenu.cpp @@ -104,12 +104,14 @@ void GUITextInputMenu::regenerateGui(v2u32 screensize) Environment->addEditBox(text.c_str(), rect, true, this, 256); Environment->setFocus(e); } + changeCtype(""); { core::rect<s32> rect(0, 0, 140, 30); rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+25); Environment->addButton(rect, this, 257, - chartowchar_t(gettext("Proceed"))); + wgettext("Proceed")); } + changeCtype("C"); } void GUITextInputMenu::drawMenu() 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 3193194af..4f57fc078 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1164,11 +1164,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 @@ -1189,7 +1185,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..dc4459263 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1086,7 +1086,7 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n, v3s16 p2 = p + dirs[i]; MapNode n2 = getNode(p2); - if(content_liquid(n2.getContent())) + if(content_liquid(n2.getContent()) || n2.getContent() == CONTENT_AIR) { m_transforming_liquid.push_back(p2); } @@ -1260,7 +1260,7 @@ void Map::removeNodeAndUpdate(v3s16 p, v3s16 p2 = p + dirs[i]; MapNode n2 = getNode(p2); - if(content_liquid(n2.getContent())) + if(content_liquid(n2.getContent()) || n2.getContent() == CONTENT_AIR) { m_transforming_liquid.push_back(p2); } @@ -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,221 @@ 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 + */ + content_t 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 { + // set the liquid level and flow bit to 0 + n0.param2 &= ~(LIQUID_LEVEL_MASK | LIQUID_FLOW_DOWN_MASK); + } + 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 aeb72c97a..389fa1c9c 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -96,7 +96,7 @@ enum LiquidType LIQUID_SOURCE }; -class MapNode; +struct MapNode; class NodeMetadata; struct ContentFeatures @@ -128,6 +128,8 @@ struct ContentFeatures bool pointable; // Player can dig these bool diggable; + // Player can climb these + bool climbable; // Player can build on these bool buildable_to; // Whether the node has no liquid, source liquid or flowing liquid @@ -171,6 +173,7 @@ struct ContentFeatures walkable = true; pointable = true; diggable = true; + climbable = false; buildable_to = false; liquid_type = LIQUID_NONE; wall_mounted = false; @@ -404,9 +407,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/player.cpp b/src/player.cpp index c43276ef1..be478e869 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -376,6 +376,21 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d, } /* + Check if player is climbing + */ + + try { + v3s16 pp = floatToInt(position + v3f(0,0.5*BS,0), BS); + v3s16 pp2 = floatToInt(position + v3f(0,-0.2*BS,0), BS); + is_climbing = ((content_features(map.getNode(pp).getContent()).climbable || + content_features(map.getNode(pp2).getContent()).climbable) && !free_move); + } + catch(InvalidPositionException &e) + { + is_climbing = false; + } + + /* Collision uncertainty radius Make it a bit larger than the maximum distance of movement */ @@ -461,7 +476,7 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d, Player is allowed to jump when this is true. */ touching_ground = false; - + /*std::cout<<"Checking collisions for (" <<oldpos_i.X<<","<<oldpos_i.Y<<","<<oldpos_i.Z <<") -> (" @@ -723,7 +738,7 @@ void LocalPlayer::applyControl(float dtime) bool fast_move = g_settings.getBool("fast_move"); bool continuous_forward = g_settings.getBool("continuous_forward"); - if(free_move) + if(free_move || is_climbing) { v3f speed = getSpeed(); speed.Y = 0; @@ -750,6 +765,12 @@ void LocalPlayer::applyControl(float dtime) speed.Y = -walkspeed_max; setSpeed(speed); } + else if(is_climbing) + { + v3f speed = getSpeed(); + speed.Y = -3*BS; + setSpeed(speed); + } else { // If not free movement but fast is allowed, aux1 is @@ -812,6 +833,12 @@ void LocalPlayer::applyControl(float dtime) setSpeed(speed); swimming_up = true; } + else if(is_climbing) + { + v3f speed = getSpeed(); + speed.Y = 3*BS; + setSpeed(speed); + } } // The speed of the player (Y is ignored) diff --git a/src/player.h b/src/player.h index 29460e1e1..78ca14948 100644 --- a/src/player.h +++ b/src/player.h @@ -118,6 +118,7 @@ public: bool in_water; // This is more stable and defines the maximum speed of the player bool in_water_stable; + bool is_climbing; bool swimming_up; Inventory inventory; 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; |