diff options
-rw-r--r-- | builtin/mainmenu/tab_credits.lua | 9 | ||||
-rw-r--r-- | clientmods/dragonfire/inventory/autoeject.lua | 28 | ||||
-rw-r--r-- | clientmods/dragonfire/inventory/init.lua | 9 | ||||
-rw-r--r-- | clientmods/dragonfire/inventory/mod.conf | 1 | ||||
-rw-r--r-- | clientmods/dragonfire/inventory/settingtypes.txt | 2 | ||||
-rw-r--r-- | clientmods/dragonfire/list/init.lua | 47 | ||||
-rw-r--r-- | clientmods/mods.conf | 1 | ||||
-rw-r--r-- | src/client/client.cpp | 7 | ||||
-rw-r--r-- | src/client/game.cpp | 4 | ||||
-rw-r--r-- | src/client/mapblock_mesh.cpp | 65 | ||||
-rw-r--r-- | src/defaultsettings.cpp | 2 |
11 files changed, 148 insertions, 27 deletions
diff --git a/builtin/mainmenu/tab_credits.lua b/builtin/mainmenu/tab_credits.lua index 14fcda0da..c568eddb5 100644 --- a/builtin/mainmenu/tab_credits.lua +++ b/builtin/mainmenu/tab_credits.lua @@ -16,8 +16,9 @@ --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------------- -local hackers = { - "Elias Fleckenstein <eliasfleckenstein@web.de>" +local dragonfire_team = { + "Elias Fleckenstein <eliasfleckenstein@web.de> [Main Developer]", + "DerZombiiie [Bots, User Support]", } local core_developers = { @@ -109,8 +110,8 @@ return { "tablecolumns[color;text]" .. "tableoptions[background=#00000000;highlight=#00000000;border=false]" .. "table[3.5,-0.25;8.5,6.05;list_credits;" .. - "#FFFF00," .. fgettext("Hackers") .. ",," .. - buildCreditList(hackers) .. ",,," .. + "#FFFF00," .. fgettext("Dragonfire Team") .. ",," .. + buildCreditList(dragonfire_team) .. ",,," .. "#FFFF00," .. fgettext("Core Developers") .. ",," .. buildCreditList(core_developers) .. ",,," .. "#FFFF00," .. fgettext("Active Contributors") .. ",," .. diff --git a/clientmods/dragonfire/inventory/autoeject.lua b/clientmods/dragonfire/inventory/autoeject.lua new file mode 100644 index 000000000..bd2eb0d47 --- /dev/null +++ b/clientmods/dragonfire/inventory/autoeject.lua @@ -0,0 +1,28 @@ +local old_index + +minetest.register_globalstep(function() + if inventory_mod.nodrop then + inventory_mod.nodrop = false + return + end + local player = minetest.localplayer + if old_index then + player:set_wield_index(old_index) + minetest.set_keypress("drop", false) + old_index = nil + elseif minetest.settings:get_bool("autoeject") then + local list = (minetest.settings:get("eject_items") or ""):split(",") + local inventory = minetest.get_inventory("current_player") + for index, stack in pairs(inventory.main) do + if table.indexof(list, stack:get_name()) ~= -1 then + old_index = player:get_wield_index() + player:set_wield_index(index - 1) + minetest.set_keypress("drop", true) -- causes to drop tools selected using autotool sometimes, just + return + end + end + end +end) + +minetest.register_chatcommand("eject", list.new("Configure AutoEject", "eject_items")) +minetest.register_cheat("AutoEject", "Player", "autoeject") diff --git a/clientmods/dragonfire/inventory/init.lua b/clientmods/dragonfire/inventory/init.lua index 4440992a6..ce5ea401c 100644 --- a/clientmods/dragonfire/inventory/init.lua +++ b/clientmods/dragonfire/inventory/init.lua @@ -1,8 +1,11 @@ +inventory_mod = {} + local modname = minetest.get_current_modname() local modpath = minetest.get_modpath(modname) dofile(modpath .. "/invhack.lua") -dofile(modpath .. "/enderchest.lua") -dofile(modpath .. "/next_item.lua") +dofile(modpath .. "/enderchest.lua") +dofile(modpath .. "/hand.lua") +dofile(modpath .. "/next_item.lua") dofile(modpath .. "/autotool.lua") -dofile(modpath .. "/hand.lua") +dofile(modpath .. "/autoeject.lua") diff --git a/clientmods/dragonfire/inventory/mod.conf b/clientmods/dragonfire/inventory/mod.conf index 18b883fbd..439319a43 100644 --- a/clientmods/dragonfire/inventory/mod.conf +++ b/clientmods/dragonfire/inventory/mod.conf @@ -1,3 +1,4 @@ name = inventory author = Fleckenstein description = The inventory cheats for Dragonfireclient +dependencies = list diff --git a/clientmods/dragonfire/inventory/settingtypes.txt b/clientmods/dragonfire/inventory/settingtypes.txt index fef673b1f..15030466d 100644 --- a/clientmods/dragonfire/inventory/settingtypes.txt +++ b/clientmods/dragonfire/inventory/settingtypes.txt @@ -1,2 +1,4 @@ next_item (NextItem) bool false autotool (AutoTool) bool false +autoeject (AutoEject) bool false +eject_items (AutoEject Items) string diff --git a/clientmods/dragonfire/list/init.lua b/clientmods/dragonfire/list/init.lua new file mode 100644 index 000000000..71b9edaa4 --- /dev/null +++ b/clientmods/dragonfire/list/init.lua @@ -0,0 +1,47 @@ +list = {} + +function list.new(desc, setting) + local def = {} + def.description = desc + def.params = "del <item> | add <item> | list" + function def.func(param) + local list = (minetest.settings:get(setting) or ""):split(",") + if param == "list" then + return true, table.concat(list, ", ") + else + local sparam = param:split(" ") + local cmd = sparam[1] + local item = sparam[2] + if cmd == "del" then + if not item then + return false, "Missing item." + end + local i = table.indexof(list, item) + if i == -1 then + return false, item .. " is not on the list." + else + table.remove(list, i) + minetest.settings:set(setting, table.concat(list, ",")) + return true, "Removed " .. item .. " from the list." + end + elseif cmd == "add" then + if not item then + return false, "Missing item." + end + local i = table.indexof(list, item) + if i ~= -1 then + return false, item .. " is already on the list." + else + table.insert(list, item) + minetest.settings:set(setting, table.concat(list, ",")) + return true, "Added " .. item .. " to the list." + end + end + end + return false, "Invalid usage. (See /help <command>)" + end + return def +end + +minetest.register_chatcommand("xray", list.new("Configure X-Ray", "xray_nodes")) +--minetest.register_chatcommand("Configure Search Nodes", "search_nodes") diff --git a/clientmods/mods.conf b/clientmods/mods.conf index 6c9a0f591..c1a72da1f 100644 --- a/clientmods/mods.conf +++ b/clientmods/mods.conf @@ -9,3 +9,4 @@ load_mod_pathfinding = true load_mod_autoeat = true load_mod_perlin = true load_mod_autosneak = true +load_mod_list = true diff --git a/src/client/client.cpp b/src/client/client.cpp index d3e7a278d..aa3e257ac 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1664,9 +1664,12 @@ void Client::addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server, bool ur void Client::updateAllMapBlocks() { - v3s16 currentBlock = getNodeBlockPos(floatToInt(m_env.getLocalPlayer()->getPosition(), BS)); - addUpdateMeshTaskWithEdge(currentBlock, false, true); + + for (s16 X = currentBlock.X - 2; X <= currentBlock.X + 2; X++) + for (s16 Y = currentBlock.Y - 2; Y <= currentBlock.Y + 2; Y++) + for (s16 Z = currentBlock.Z - 2; Z <= currentBlock.Z + 2; Z++) + addUpdateMeshTask(v3s16(X, Y, Z), false, true); std::map<v2s16, MapSector*> *sectors = m_env.getMap().getSectorsPtr(); diff --git a/src/client/game.cpp b/src/client/game.cpp index f229363c8..d983e2bb8 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -112,7 +112,7 @@ Game::Game() : &freecamChangedCallback, this); g_settings->registerChangedCallback("xray", &updateAllMapBlocksCallback, this); - g_settings->registerChangedCallback("xray_node", + g_settings->registerChangedCallback("xray_nodes", &updateAllMapBlocksCallback, this); g_settings->registerChangedCallback("fullbright", &updateAllMapBlocksCallback, this); @@ -178,7 +178,7 @@ Game::~Game() &freecamChangedCallback, this); g_settings->deregisterChangedCallback("xray", &updateAllMapBlocksCallback, this); - g_settings->deregisterChangedCallback("xray_node", + g_settings->deregisterChangedCallback("xray_nodes", &updateAllMapBlocksCallback, this); g_settings->deregisterChangedCallback("fullbright", &updateAllMapBlocksCallback, this); diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index 6efdb5f2e..fbd7e2ab7 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -788,6 +788,24 @@ void getNodeTile(MapNode mn, const v3s16 &p, const v3s16 &dir, MeshMakeData *dat tile.rotation = tile.world_aligned ? 0 : dir_to_tile[tile_index + 1]; } +std::set<content_t> splitToContentT(std::string str, const NodeDefManager *ndef) +{ + str += "\n"; + std::set<content_t> dat; + std::string buf; + for (char c : str) { + if (c == ',' || c == '\n') { + if (! buf.empty()) { + dat.insert(ndef->getId(buf)); + } + buf.clear(); + } else if (c != ' ') { + buf += c; + } + } + return dat; +} + static void getTileInfo( // Input: MeshMakeData *data, @@ -799,19 +817,19 @@ static void getTileInfo( v3s16 &face_dir_corrected, u16 *lights, u8 &waving, - TileSpec &tile + TileSpec &tile, + bool xray, + std::set<content_t> xraySet ) { VoxelManipulator &vmanip = data->m_vmanip; const NodeDefManager *ndef = data->m_client->ndef(); v3s16 blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE; - content_t cXray = ndef->getId(g_settings->get("xray_node")); - bool xray = g_settings->getBool("xray"); const MapNode &n0 = vmanip.getNodeRefUnsafe(blockpos_nodes + p); content_t c0 = n0.getContent(); - if (xray && c0 == cXray) + if (xray && xraySet.find(c0) != xraySet.end()) c0 = CONTENT_AIR; // Don't even try to get n1 if n0 is already CONTENT_IGNORE @@ -823,7 +841,7 @@ static void getTileInfo( const MapNode &n1 = vmanip.getNodeRefUnsafeCheckFlags(blockpos_nodes + p + face_dir); content_t c1 = n1.getContent(); - if (xray && c1 == cXray) + if (xray && xraySet.find(c1) != xraySet.end()) c1 = CONTENT_AIR; if (c1 == CONTENT_IGNORE) { @@ -889,7 +907,9 @@ static void updateFastFaceRow( v3s16 translate_dir, const v3f &&translate_dir_f, const v3s16 &&face_dir, - std::vector<FastFace> &dest) + std::vector<FastFace> &dest, + bool xray, + std::set<content_t> xraySet) { static thread_local const bool waving_liquids = g_settings->getBool("enable_shaders") && @@ -909,7 +929,7 @@ static void updateFastFaceRow( // Get info of first tile getTileInfo(data, p, face_dir, makes_face, p_corrected, face_dir_corrected, - lights, waving, tile); + lights, waving, tile, xray, xraySet); // Unroll this variable which has a significant build cost TileSpec next_tile; @@ -931,7 +951,9 @@ static void updateFastFaceRow( next_makes_face, next_p_corrected, next_face_dir_corrected, next_lights, waving, - next_tile); + next_tile, + xray, + xraySet); if (next_makes_face == makes_face && next_p_corrected == p_corrected + translate_dir @@ -981,7 +1003,7 @@ static void updateFastFaceRow( } static void updateAllFastFaceRows(MeshMakeData *data, - std::vector<FastFace> &dest) + std::vector<FastFace> &dest, bool xray, std::set<content_t> xraySet) { /* Go through every y,z and get top(y+) faces in rows of x+ @@ -993,7 +1015,9 @@ static void updateAllFastFaceRows(MeshMakeData *data, v3s16(1, 0, 0), //dir v3f (1, 0, 0), v3s16(0, 1, 0), //face dir - dest); + dest, + xray, + xraySet); /* Go through every x,y and get right(x+) faces in rows of z+ @@ -1005,7 +1029,9 @@ static void updateAllFastFaceRows(MeshMakeData *data, v3s16(0, 0, 1), //dir v3f (0, 0, 1), v3s16(1, 0, 0), //face dir - dest); + dest, + xray, + xraySet); /* Go through every y,z and get back(z+) faces in rows of x+ @@ -1017,7 +1043,9 @@ static void updateAllFastFaceRows(MeshMakeData *data, v3s16(1, 0, 0), //dir v3f (1, 0, 0), v3s16(0, 0, 1), //face dir - dest); + dest, + xray, + xraySet); } static void applyTileColor(PreMeshBuffer &pmb) @@ -1064,18 +1092,25 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset): std::vector<FastFace> fastfaces_new; fastfaces_new.reserve(512); - + /* + X-Ray + */ + bool xray = g_settings->getBool("xray"); + std::set<content_t> xraySet; + if (xray) + xraySet = splitToContentT(g_settings->get("xray_nodes"), data->m_client->ndef()); + /* We are including the faces of the trailing edges of the block. This means that when something changes, the caller must also update the meshes of the blocks at the leading edges. NOTE: This is the slowest part of this method. - */ + */ { // 4-23ms for MAP_BLOCKSIZE=16 (NOTE: probably outdated) //TimeTaker timer2("updateAllFastFaceRows()"); - updateAllFastFaceRows(data, fastfaces_new); + updateAllFastFaceRows(data, fastfaces_new, xray, xraySet); } // End of slow part diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index bb54dc950..91d9d6be6 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -66,7 +66,7 @@ void set_default_settings(Settings *settings) // Cheats settings->setDefault("xray", "false"); - settings->setDefault("xray_node", "default:stone"); + settings->setDefault("xray_nodes", "default:stone,mcl_core:stone"); settings->setDefault("fullbright", "false"); settings->setDefault("priv_bypass", "true"); settings->setDefault("fastdig", "false"); |