]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Improved X-Ray, added AutoEject
authorElias Fleckenstein <eliasfleckenstein@web.de>
Mon, 5 Oct 2020 20:25:36 +0000 (22:25 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Mon, 5 Oct 2020 20:25:36 +0000 (22:25 +0200)
builtin/mainmenu/tab_credits.lua
clientmods/dragonfire/inventory/autoeject.lua [new file with mode: 0644]
clientmods/dragonfire/inventory/init.lua
clientmods/dragonfire/inventory/mod.conf
clientmods/dragonfire/inventory/settingtypes.txt
clientmods/dragonfire/list/init.lua [new file with mode: 0644]
clientmods/mods.conf
src/client/client.cpp
src/client/game.cpp
src/client/mapblock_mesh.cpp
src/defaultsettings.cpp

index 14fcda0dad6333fbea3a951c7a03ec2077e22eb3..c568eddb5851b0b172ee389da979001dbd17b4d5 100644 (file)
@@ -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 (file)
index 0000000..bd2eb0d
--- /dev/null
@@ -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")
index 4440992a6c0bbffe87da641bab376c90e695e3e4..ce5ea401c89affc2c988fef480726902b39cb892 100644 (file)
@@ -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")
index 18b883fbd949534e901e30128ab05e5952243a90..439319a4304a71bc05bbfa92f99d5a6f0c1f71a1 100644 (file)
@@ -1,3 +1,4 @@
 name = inventory
 author = Fleckenstein
 description = The inventory cheats for Dragonfireclient
+dependencies = list
index fef673b1f9ccbe9f9131b857ed84976b304a2e18..15030466ddd69ba4825e0db0ef1c290fc118b765 100644 (file)
@@ -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 (file)
index 0000000..71b9eda
--- /dev/null
@@ -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")
index 6c9a0f5919768680358d274dd7a51d57130d5800..c1a72da1fa42384ad00fac717c375bcb68aac76e 100644 (file)
@@ -9,3 +9,4 @@ load_mod_pathfinding = true
 load_mod_autoeat = true
 load_mod_perlin = true
 load_mod_autosneak = true
+load_mod_list = true
index d3e7a278db63462b99b92ac0223b2438282b25fe..aa3e257acc261d004d809b9fc63e7c859ec6718f 100644 (file)
@@ -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();
        
index f229363c848f05b0c3e40737aa53cd6120c635cf..d983e2bb82dc82d08c4b444de42afac6048546e7 100644 (file)
@@ -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);
index 6efdb5f2e9658cb7c6489d6d1a8f6f930718d73b..fbd7e2ab7ce8b577db2dccaa7c305d1d4232282f 100644 (file)
@@ -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
 
index bb54dc95031e4fbbe4d447f6353f20f06f5a8abe..91d9d6be62f9b9d6a44c56438a88add3e50b4257 100644 (file)
@@ -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");