]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Initial Commit
authorElias Fleckenstein <eliasfleckenstein@web.de>
Mon, 6 Jul 2020 13:50:55 +0000 (15:50 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Mon, 6 Jul 2020 13:50:55 +0000 (15:50 +0200)
19 files changed:
builtin/client/cheats.lua [deleted file]
builtin/client/init.lua
builtin/client/pos.lua [new file with mode: 0644]
clientmods/preview/example.lua [deleted file]
clientmods/preview/examples/first.lua [deleted file]
clientmods/preview/init.lua [deleted file]
src/client/client.h
src/client/content_cao.cpp
src/client/game.cpp
src/client/game.h
src/client/inputhandler.cpp
src/client/keys.h
src/client/mapblock_mesh.cpp
src/client/mesh_generator_thread.h
src/gui/guiInventoryList.cpp
src/gui/guiInventoryList.h
src/network/clientpackethandler.cpp
src/nodedef.cpp
src/script/lua_api/l_localplayer.cpp

diff --git a/builtin/client/cheats.lua b/builtin/client/cheats.lua
deleted file mode 100644 (file)
index 9d7fd93..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-core.register_chatcommand("set", {
-       params = "([-n] <name> <value>) | <name>",
-       description = "Set or read client configuration setting",
-       privs = {server=true},
-       func = function(param)
-               local arg, setname, setvalue = string.match(param, "(-[n]) ([^ ]+) (.+)")
-               if arg and arg == "-n" and setname and setvalue then
-                       core.settings:set(setname, setvalue)
-                       return true, setname .. " = " .. setvalue
-               end
-
-               setname, setvalue = string.match(param, "([^ ]+) (.+)")
-               if setname and setvalue then
-                       if not core.settings:get(setname) then
-                               return false, "Failed. Use '.set -n <name> <value>' to create a new setting."
-                       end
-                       core.settings:set(setname, setvalue)
-                       return true, setname .. " = " .. setvalue
-               end
-
-               setname = string.match(param, "([^ ]+)")
-               if setname then
-                       setvalue = core.settings:get(setname)
-                       if not setvalue then
-                               setvalue = "<not set>"
-                       end
-                       return true, setname .. " = " .. setvalue
-               end
-
-               return false, "Invalid parameters (see .help set)."
-       end,
-})
-
-function core.parse_pos(param)
-       local p = {}
-       p.x, p.y, p.z = string.match(param, "^([~|%d.-]+)[, ] *([~|%d.-]+)[, ] *([~|%d.-]+)$")
-       for k, v in pairs(p) do
-               if p[k] == "~" then
-                       p[k] = core.localplayer:get_pos()[k]
-               else
-                       p[k] = tonumber(v)
-               end
-       end
-       if p.x and p.y and p.z then
-               local lm = 31000
-               if p.x < -lm or p.x > lm or p.y < -lm or p.y > lm or p.z < -lm or p.z > lm then
-                       return false, "Position out of Map bounds."
-               end
-               return true, p
-       end
-       return false, "Invalid position (" .. param .. ")"
-end
-
-core.register_chatcommand("teleport", {
-       params = "<X>,<Y>,<Z>",
-       description = "Teleport to position",
-       func = function(param)
-               local success, pos = core.parse_pos(param)
-               if success then
-                       core.localplayer:set_pos(pos)
-                       return true, "Teleporting to " .. core.pos_to_string(pos)
-               end
-               return false, pos
-       end,
-})
-
-core.register_chatcommand("place", {
-       params = "<X>,<Y>,<Z>",
-       description = "Place wielded item",
-       func = function(param)
-               local success, pos = core.parse_pos(param)
-               if success then
-                       core.place_node(pos)
-                       return true, "Node placed at " .. core.pos_to_string(pos)
-               end
-               return false, pos
-       end,
-})
-
-core.register_chatcommand("dig", {
-       params = "<X>,<Y>,<Z>",
-       description = "Dig node",
-       func = function(param)
-               local success, pos = core.parse_pos(param)
-               if success then
-                       core.dig_node(pos)
-                       return true, "Node at " .. core.pos_to_string(pos) .. " dug"
-               end
-               return false, pos
-       end,
-})
-
-core.register_chatcommand("kill", {
-       description = "Kill yourself",
-       func = function(param)
-               core.send_damage(core.localplayer:get_hp())
-       end,
-})
-
-core.register_chatcommand("scan", {
-       description = "Scan for one or multible nodes in a radius around you",
-       param = "<radius> node1[,node2...]",
-       func = function(param)
-               local radius = tonumber(param:split(" ")[1])
-               local nodes = param:split(" ")[2]:split(",")
-               local pos = core.localplayer:get_pos()
-               local fpos = core.find_node_near(pos, radius, nodes, true)
-               if fpos then
-                       return true, "Found " .. table.concat(nodes, " or ") .. " at " .. core.pos_to_string(fpos)
-               end
-               return false, "None of " .. table.concat(nodes, " or ") .. " found in a radius of " .. tostring(radius)
-       end,
-})
-
-core.register_chatcommand("digaround", {
-       description = "Scan for one or multible nodes in a radius around you",
-       param = "<radius> node1[,node2...]",
-       func = function(param)
-               local radius = tonumber(param:split(" ")[1])
-               local nodes = param:split(" ")[2]:split(",")
-               local function loop()
-                       local fpos = core.find_node_near(core.localplayer:get_pos(), radius, nodes, true)
-                       if fpos then core.dig_node(fpos) end
-                       core.after(0, loop)
-               end
-               loop()
-       end,
-})
-
-local keep_digging = false
-
-core.register_chatcommand("keepdigging", {
-       params = "<X>,<Y>,<Z>",
-       description = "Dig node again and again",
-       func = function(param)
-               local success, pos = core.parse_pos(param)
-               if success then
-                       keep_digging = true
-                       local function loop()
-                               core.dig_node(pos)
-                               if keep_digging then
-                                       core.after(0.1, loop)
-                               end
-                       end
-                       loop()
-               end
-       end,
-})
-
-core.register_chatcommand("stopdigging", {
-       description = "Stop diggin",
-       func = function()
-               keep_digging = false
-       end,
-})
-
-core.register_on_punchnode(function(pos)
-       --core.dig_node(pos)
-end)
-
index 6c024f02e3499f7534d886b75c6708c963b46684..f3c1a4c820ad4599c7eadd92562ac774d43fb1c5 100644 (file)
@@ -9,5 +9,5 @@ dofile(commonpath .. "chatcommands.lua")
 dofile(commonpath .. "vector.lua")
 dofile(clientpath .. "death_formspec.lua")
 dofile(clientpath .. "chatcommands.lua")
-dofile(clientpath .. "cheats.lua")
+dofile(clientpath .. "pos.lua")
 
diff --git a/builtin/client/pos.lua b/builtin/client/pos.lua
new file mode 100644 (file)
index 0000000..618c142
--- /dev/null
@@ -0,0 +1,19 @@
+function core.parse_pos(param)
+       local p = {}
+       p.x, p.y, p.z = string.match(param, "^([~|%d.-]+)[, ] *([~|%d.-]+)[, ] *([~|%d.-]+)$")
+       for k, v in pairs(p) do
+               if p[k] == "~" then
+                       p[k] = core.localplayer:get_pos()[k]
+               else
+                       p[k] = tonumber(v)
+               end
+       end
+       if p.x and p.y and p.z then
+               local lm = 31000
+               if p.x < -lm or p.x > lm or p.y < -lm or p.y > lm or p.z < -lm or p.z > lm then
+                       return false, "Position out of Map bounds."
+               end
+               return true, p
+       end
+       return false, "Invalid position (" .. param .. ")"
+end 
diff --git a/clientmods/preview/example.lua b/clientmods/preview/example.lua
deleted file mode 100644 (file)
index 2f42eef..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-print("Loaded example file!, loading more examples")
-dofile(core.get_modpath(core.get_current_modname()) .. "/examples/first.lua")
diff --git a/clientmods/preview/examples/first.lua b/clientmods/preview/examples/first.lua
deleted file mode 100644 (file)
index c24f461..0000000
+++ /dev/null
@@ -1 +0,0 @@
-print("loaded first.lua example file")
diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua
deleted file mode 100644 (file)
index 5777adc..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-local modname = assert(core.get_current_modname())
-local modstorage = core.get_mod_storage()
-local mod_channel
-
-dofile(core.get_modpath(modname) .. "example.lua")
-
-core.register_on_shutdown(function()
-       print("[PREVIEW] shutdown client")
-end)
-local id = nil
-
-do
-       local server_info = core.get_server_info()
-       print("Server version: " .. server_info.protocol_version)
-       print("Server ip: " .. server_info.ip)
-       print("Server address: " .. server_info.address)
-       print("Server port: " .. server_info.port)
-
-       print("CSM restrictions: " .. dump(core.get_csm_restrictions()))
-
-       local l1, l2 = core.get_language()
-       print("Configured language: " .. l1 .. " / " .. l2)
-end
-
-mod_channel = core.mod_channel_join("experimental_preview")
-
-core.after(4, function()
-       if mod_channel:is_writeable() then
-               mod_channel:send_all("preview talk to experimental")
-       end
-end)
-
-core.after(1, function()
-       id = core.localplayer:hud_add({
-                       hud_elem_type = "text",
-                       name = "example",
-                       number = 0xff0000,
-                       position = {x=0, y=1},
-                       offset = {x=8, y=-8},
-                       text = "You are using the preview mod",
-                       scale = {x=200, y=60},
-                       alignment = {x=1, y=-1},
-       })
-end)
-
-core.register_on_modchannel_message(function(channel, sender, message)
-       print("[PREVIEW][modchannels] Received message `" .. message .. "` on channel `"
-                       .. channel .. "` from sender `" .. sender .. "`")
-       core.after(1, function()
-               mod_channel:send_all("CSM preview received " .. message)
-       end)
-end)
-
-core.register_on_modchannel_signal(function(channel, signal)
-       print("[PREVIEW][modchannels] Received signal id `" .. signal .. "` on channel `"
-                       .. channel)
-end)
-
-core.register_on_inventory_open(function(inventory)
-       print("INVENTORY OPEN")
-       print(dump(inventory))
-       return false
-end)
-
-core.register_on_placenode(function(pointed_thing, node)
-       print("The local player place a node!")
-       print("pointed_thing :" .. dump(pointed_thing))
-       print("node placed :" .. dump(node))
-       return false
-end)
-
-core.register_on_item_use(function(itemstack, pointed_thing)
-       print("The local player used an item!")
-       print("pointed_thing :" .. dump(pointed_thing))
-       print("item = " .. itemstack:get_name())
-
-       if not itemstack:is_empty() then
-               return false
-       end
-
-       local pos = vector.add(core.localplayer:get_pos(), core.camera:get_offset())
-       local pos2 = vector.add(pos, vector.multiply(core.camera:get_look_dir(), 100))
-
-       local rc = core.raycast(pos, pos2)
-       local i = rc:next()
-       print("[PREVIEW] raycast next: " .. dump(i))
-       if i then
-               print("[PREVIEW] line of sight: " .. (core.line_of_sight(pos, i.above) and "yes" or "no"))
-
-               local n1 = core.find_nodes_in_area(pos, i.under, {"default:stone"})
-               local n2 = core.find_nodes_in_area_under_air(pos, i.under, {"default:stone"})
-               print(("[PREVIEW] found %s nodes, %s nodes under air"):format(
-                               n1 and #n1 or "?", n2 and #n2 or "?"))
-       end
-
-       return false
-end)
-
--- This is an example function to ensure it's working properly, should be removed before merge
-core.register_on_receiving_chat_message(function(message)
-       print("[PREVIEW] Received message " .. message)
-       return false
-end)
-
--- This is an example function to ensure it's working properly, should be removed before merge
-core.register_on_sending_chat_message(function(message)
-       print("[PREVIEW] Sending message " .. message)
-       return false
-end)
-
--- This is an example function to ensure it's working properly, should be removed before merge
-core.register_on_hp_modification(function(hp)
-       print("[PREVIEW] HP modified " .. hp)
-end)
-
--- This is an example function to ensure it's working properly, should be removed before merge
-core.register_on_damage_taken(function(hp)
-       print("[PREVIEW] Damage taken " .. hp)
-end)
-
--- This is an example function to ensure it's working properly, should be removed before merge
-core.register_chatcommand("dump", {
-       func = function(param)
-               return true, dump(_G)
-       end,
-})
-
-core.register_chatcommand("colorize_test", {
-       func = function(param)
-               return true, core.colorize("red", param)
-       end,
-})
-
-core.register_chatcommand("test_node", {
-       func = function(param)
-               core.display_chat_message(dump(core.get_node({x=0, y=0, z=0})))
-               core.display_chat_message(dump(core.get_node_or_nil({x=0, y=0, z=0})))
-       end,
-})
-
-local function preview_minimap()
-       local minimap = core.ui.minimap
-       if not minimap then
-               print("[PREVIEW] Minimap is disabled. Skipping.")
-               return
-       end
-       minimap:set_mode(4)
-       minimap:show()
-       minimap:set_pos({x=5, y=50, z=5})
-       minimap:set_shape(math.random(0, 1))
-
-       print("[PREVIEW] Minimap: mode => " .. dump(minimap:get_mode()) ..
-                       " position => " .. dump(minimap:get_pos()) ..
-                       " angle => " .. dump(minimap:get_angle()))
-end
-
-core.after(2, function()
-       print("[PREVIEW] loaded " .. modname .. " mod")
-       modstorage:set_string("current_mod", modname)
-       print(modstorage:get_string("current_mod"))
-       preview_minimap()
-end)
-
-core.after(5, function()
-       if core.ui.minimap then
-               core.ui.minimap:show()
-       end
-
-       print("[PREVIEW] Time of day " .. core.get_timeofday())
-
-       print("[PREVIEW] Node level: " .. core.get_node_level({x=0, y=20, z=0}) ..
-               " max level " .. core.get_node_max_level({x=0, y=20, z=0}))
-
-       print("[PREVIEW] Find node near: " .. dump(core.find_node_near({x=0, y=20, z=0}, 10,
-               {"group:tree", "default:dirt", "default:stone"})))
-end)
-
-core.register_on_dignode(function(pos, node)
-       print("The local player dug a node!")
-       print("pos:" .. dump(pos))
-       print("node:" .. dump(node))
-       return false
-end)
-
-core.register_on_punchnode(function(pos, node)
-       print("The local player punched a node!")
-       local itemstack = core.get_wielded_item()
-       --[[
-       -- getters
-       print(dump(itemstack:is_empty()))
-       print(dump(itemstack:get_name()))
-       print(dump(itemstack:get_count()))
-       print(dump(itemstack:get_wear()))
-       print(dump(itemstack:get_meta()))
-       print(dump(itemstack:get_metadata()
-       print(dump(itemstack:is_known()))
-       --print(dump(itemstack:get_definition()))
-       print(dump(itemstack:get_tool_capabilities()))
-       print(dump(itemstack:to_string()))
-       print(dump(itemstack:to_table()))
-       -- setters
-       print(dump(itemstack:set_name("default:dirt")))
-       print(dump(itemstack:set_count("95")))
-       print(dump(itemstack:set_wear(934)))
-       print(dump(itemstack:get_meta()))
-       print(dump(itemstack:get_metadata()))
-       --]]
-       print(dump(itemstack:to_table()))
-       print("pos:" .. dump(pos))
-       print("node:" .. dump(node))
-       return false
-end)
-
-core.register_chatcommand("privs", {
-       func = function(param)
-               return true, core.privs_to_string(minetest.get_privilege_list())
-       end,
-})
-
-core.register_chatcommand("text", {
-       func = function(param)
-               return core.localplayer:hud_change(id, "text", param)
-       end,
-})
-
-
-core.register_on_mods_loaded(function()
-       core.log("Yeah preview mod is loaded with other CSM mods.")
-end)
index 1e6ba4140dd881585c8b57f2f3b13921519f1d59..3c0c133e07dcfa603b6951a852ca2f2b45466391 100644 (file)
@@ -445,6 +445,10 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        {
                return m_env.getLocalPlayer()->formspec_prepend;
        }
+       
+       void sendPlayerPos();
+       MeshUpdateThread m_mesh_update_thread;
+       
 private:
        void loadMods();
        bool checkBuiltinIntegrity();
@@ -459,7 +463,6 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
 
        void ReceiveAll();
 
-       void sendPlayerPos();
 
        void deleteAuthData();
        // helper method shared with clientpackethandler
@@ -492,7 +495,6 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        MtEventManager *m_event;
 
 
-       MeshUpdateThread m_mesh_update_thread;
        ClientEnvironment m_env;
        ParticleManager m_particle_manager;
        std::unique_ptr<con::Connection> m_con;
index 5d719293afec12e072fd2b102da71fb6fcc2bc39..fa2ed43c9b0684b8459a1f03539dc42222d9a666 100644 (file)
@@ -793,6 +793,9 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
 
 void GenericCAO::updateLight(u8 light_at_pos)
 {
+       if (g_settings->getBool("fullbright"))
+               light_at_pos = 255;
+               
        // Don't update light of attached one
        if (getParent() != NULL) {
                return;
index 9f8eb8c94f77ab4bc809eeafd3b539d2fd9b8e2e..7c224929637421951a6faf62abdc5a0f6dca2a73 100644 (file)
@@ -1069,6 +1069,12 @@ void Game::processKeyInput()
                toggleFast();
        } else if (wasKeyDown(KeyType::NOCLIP)) {
                toggleNoClip();
+       } else if (wasKeyDown(KeyType::XRAY)) {
+               toggleXray();
+       } else if (wasKeyDown(KeyType::FULLBRIGHT)) {
+               toggleFullbright();
+       } else if (wasKeyDown(KeyType::KILLAURA)) {
+               toggleKillaura();
        } else if (wasKeyDown(KeyType::MUTE)) {
                bool new_mute_sound = !g_settings->getBool("mute_sound");
                g_settings->setBool("mute_sound", new_mute_sound);
@@ -1327,6 +1333,44 @@ void Game::toggleNoClip()
        }
 }
 
+void Game::toggleXray()
+{
+       bool xray = ! g_settings->getBool("xray");
+       g_settings->set("xray", bool_to_cstr(xray));
+
+       if (xray) {
+               m_game_ui->showTranslatedStatusText("Xray enabled");
+       } else {
+               m_game_ui->showTranslatedStatusText("Xray disabled");
+       }
+       client->m_mesh_update_thread.doUpdate();
+}
+
+void Game::toggleFullbright()
+{
+       bool fullbright = ! g_settings->getBool("fullbright");
+       g_settings->set("fullbright", bool_to_cstr(fullbright));
+
+       if (fullbright) {
+               m_game_ui->showTranslatedStatusText("Fullbright enabled");
+       } else {
+               m_game_ui->showTranslatedStatusText("Fullbright disabled");
+       }
+       client->m_mesh_update_thread.doUpdate();
+}
+
+void Game::toggleKillaura()
+{
+       bool killaura = ! g_settings->getBool("killaura");
+       g_settings->set("killaura", bool_to_cstr(killaura));
+
+       if (killaura) {
+               m_game_ui->showTranslatedStatusText("Killaura enabled");
+       } else {
+               m_game_ui->showTranslatedStatusText("Killaura disabled");
+       }
+}
+
 void Game::toggleCinematic()
 {
        bool cinematic = !g_settings->getBool("cinematic");
@@ -2181,7 +2225,7 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
        f32 d = getToolRange(selected_def, hand_item.getDefinition(itemdef_manager));
        
        if(g_settings->getBool("increase_tool_range"))
-               d = 1000;
+               d = 5;
 
        core::line3d<f32> shootline;
 
@@ -2697,7 +2741,7 @@ void Game::handlePointingAtObject(const PointedThing &pointed,
 
        m_game_ui->setInfoText(infotext);
 
-       if (input->getLeftState() || g_settings->getBool("killaura")) {
+       if (input->getLeftState() || (g_settings->getBool("killaura") && ! g_settings->getBool("killaura_fast"))) {
                bool do_punch = false;
                bool do_punch_damage = false;
 
@@ -2707,7 +2751,7 @@ void Game::handlePointingAtObject(const PointedThing &pointed,
                        runData.object_hit_delay_timer = object_hit_delay;
                }
 
-               if (input->getLeftClicked() || g_settings->getBool("killaura"))
+               if (input->getLeftClicked() || (g_settings->getBool("killaura") && ! g_settings->getBool("killaura_fast")))
                        do_punch = true;
 
                if (do_punch) {
index c1afb79fab46d5704fbc4044a87757a5522d9890..43b3660577e97c288022b015565be0ba038f3b51 100644 (file)
@@ -736,6 +736,9 @@ class Game {
        void togglePitchMove();
        void toggleFast();
        void toggleNoClip();
+       void toggleXray();
+       void toggleFullbright();
+       void toggleKillaura();
        void toggleCinematic();
        void toggleAutoforward();
 
index a79b04a9058dcf8910859c3c83d518f458ab5273..b8c236b8de72f6031b9340fb96bb829533c4c1f2 100644 (file)
@@ -71,6 +71,9 @@ void KeyCache::populate()
                        getKeySetting("keymap_decrease_viewing_range_min");
        key[KeyType::RANGESELECT] = getKeySetting("keymap_rangeselect");
        key[KeyType::ZOOM] = getKeySetting("keymap_zoom");
+       key[KeyType::XRAY] = "KEY_KEY_X";
+       key[KeyType::FULLBRIGHT] = "KEY_KEY_F";
+       key[KeyType::KILLAURA] = "KEY_KEY_C";
 
        key[KeyType::QUICKTUNE_NEXT] = getKeySetting("keymap_quicktune_next");
        key[KeyType::QUICKTUNE_PREV] = getKeySetting("keymap_quicktune_prev");
index 50d3d194b4eefe09c7988f7c6a55fa7d5a3a9d4c..08f5e36abf81c8fb86458cdd5b8c49d244b59b16 100644 (file)
@@ -68,7 +68,10 @@ class KeyType
                DECREASE_VIEWING_RANGE,
                RANGESELECT,
                ZOOM,
-
+               XRAY,
+               FULLBRIGHT,
+               KILLAURA,
+       
                QUICKTUNE_NEXT,
                QUICKTUNE_PREV,
                QUICKTUNE_INC,
index c165438a097b622a3a324f52bec823e3f1c4459f..ec896736665db992c670059714514d49c30e701e 100644 (file)
@@ -681,6 +681,7 @@ static u8 face_contents(content_t m1, content_t m2, bool *equivalent,
        u8 c1 = f1.solidness;
        u8 c2 = f2.solidness;
 
+
        if (c1 == c2)
                return 0;
 
@@ -689,6 +690,7 @@ static u8 face_contents(content_t m1, content_t m2, bool *equivalent,
        else if (c2 == 0)
                c2 = f2.visual_solidness;
 
+
        if (c1 == c2) {
                *equivalent = true;
                // If same solidness, liquid takes precense
@@ -805,25 +807,35 @@ static void getTileInfo(
        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)
+               c0 = CONTENT_AIR;
+
        // Don't even try to get n1 if n0 is already CONTENT_IGNORE
-       if (n0.getContent() == CONTENT_IGNORE) {
+       if (c0 == CONTENT_IGNORE) {
                makes_face = false;
                return;
        }
 
        const MapNode &n1 = vmanip.getNodeRefUnsafeCheckFlags(blockpos_nodes + p + face_dir);
 
-       if (n1.getContent() == CONTENT_IGNORE) {
+       content_t c1 = n1.getContent();
+       if (xray && c1 == cXray)
+               c1 = CONTENT_AIR;
+
+       if (c1 == CONTENT_IGNORE) {
                makes_face = false;
                return;
        }
 
        // This is hackish
        bool equivalent = false;
-       u8 mf = face_contents(n0.getContent(), n1.getContent(),
+       u8 mf = face_contents(c0, c1,
                        &equivalent, ndef);
 
        if (mf == 0) {
index 9a42852a31aa645053f79b40b49363b5998f7a4f..2bb74589e1a0d78eae0061d715abe5c2c0a25a96 100644 (file)
@@ -126,6 +126,6 @@ class MeshUpdateThread : public UpdateThread
        // TODO: Add callback to update these when g_settings changes
        int m_generation_interval;
 
-protected:
+public:
        virtual void doUpdate();
 };
index 53647122963eb5952048734598304548b391f5d1..58d7ae771bb4c8af8496f84e7641793e19029605 100644 (file)
@@ -1,17 +1,14 @@
 /*
 Minetest
 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
-
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
 the Free Software Foundation; either version 2.1 of the License, or
 (at your option) any later version.
-
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Lesser General Public License for more details.
-
 You should have received a copy of the GNU Lesser General Public License along
 with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
@@ -47,7 +44,8 @@ GUIInventoryList::GUIInventoryList(gui::IGUIEnvironment *env,
        m_fs_menu(fs_menu),
        m_options(options),
        m_font(font),
-       m_hovered_i(-1)
+       m_hovered_i(-1),
+       m_already_warned(false)
 {
 }
 
@@ -58,20 +56,27 @@ void GUIInventoryList::draw()
 
        Inventory *inv = m_invmgr->getInventory(m_inventoryloc);
        if (!inv) {
-               warningstream << "GUIInventoryList::draw(): "
-                               << "The inventory location "
-                               << "\"" << m_inventoryloc.dump() << "\" doesn't exist anymore"
-                               << std::endl;
+               if (!m_already_warned) {
+                       warningstream << "GUIInventoryList::draw(): "
+                                       << "The inventory location "
+                                       << "\"" << m_inventoryloc.dump() << "\" doesn't exist"
+                                       << std::endl;
+                       m_already_warned = true;
+               }
                return;
        }
        InventoryList *ilist = inv->getList(m_listname);
        if (!ilist) {
-               warningstream << "GUIInventoryList::draw(): "
-                               << "The inventory list \"" << m_listname << "\" @ \""
-                               << m_inventoryloc.dump() << "\" doesn't exist anymore"
-                               << std::endl;
+               if (!m_already_warned) {
+                       warningstream << "GUIInventoryList::draw(): "
+                                       << "The inventory list \"" << m_listname << "\" @ \""
+                                       << m_inventoryloc.dump() << "\" doesn't exist"
+                                       << std::endl;
+                       m_already_warned = true;
+               }
                return;
        }
+       m_already_warned = false;
 
        video::IVideoDriver *driver = Environment->getVideoDriver();
        Client *client = m_fs_menu->getClient();
@@ -80,9 +85,11 @@ void GUIInventoryList::draw()
        core::rect<s32> imgrect(0, 0, m_slot_size.X, m_slot_size.Y);
        v2s32 base_pos = AbsoluteRect.UpperLeftCorner;
 
+       const s32 list_size = (s32)ilist->getSize();
+
        for (s32 i = 0; i < m_geom.X * m_geom.Y; i++) {
                s32 item_i = i + m_start_item_i;
-               if (item_i >= (s32)ilist->getSize())
+               if (item_i >= list_size)
                        break;
 
                v2s32 p((i % m_geom.X) * m_slot_spacing.X,
@@ -192,10 +199,19 @@ bool GUIInventoryList::OnEvent(const SEvent &event)
 
 s32 GUIInventoryList::getItemIndexAtPos(v2s32 p) const
 {
+       // no item if no gui element at pointer
        if (!IsVisible || AbsoluteClippingRect.getArea() <= 0 ||
                        !AbsoluteClippingRect.isPointInside(p))
                return -1;
 
+       // there can not be an item if the inventory or the inventorylist does not exist
+       Inventory *inv = m_invmgr->getInventory(m_inventoryloc);
+       if (!inv)
+               return -1;
+       InventoryList *ilist = inv->getList(m_listname);
+       if (!ilist)
+               return -1;
+
        core::rect<s32> imgrect(0, 0, m_slot_size.X, m_slot_size.Y);
        v2s32 base_pos = AbsoluteRect.UpperLeftCorner;
 
@@ -210,7 +226,8 @@ s32 GUIInventoryList::getItemIndexAtPos(v2s32 p) const
 
        rect.clipAgainst(AbsoluteClippingRect);
 
-       if (rect.getArea() > 0 && rect.isPointInside(p))
+       if (rect.getArea() > 0 && rect.isPointInside(p) &&
+                       i + m_start_item_i < (s32)ilist->getSize())
                return i + m_start_item_i;
 
        return -1;
index fd2c3601bd3764a8a293a508faf79256bf2b0199..934d9ea3a98d18711b2c9f4ff6c5b745649c1375 100644 (file)
@@ -1,17 +1,14 @@
 /*
 Minetest
 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
-
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
 the Free Software Foundation; either version 2.1 of the License, or
 (at your option) any later version.
-
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Lesser General Public License for more details.
-
 You should have received a copy of the GNU Lesser General Public License along
 with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
@@ -107,7 +104,7 @@ class GUIInventoryList : public gui::IGUIElement
        const InventoryLocation m_inventoryloc;
        const std::string m_listname;
 
-       // specifies the width and height of the inventorylist in itemslots
+       // the specified width and height of the shown inventorylist in itemslots
        const v2s32 m_geom;
        // the first item's index in inventory
        const s32 m_start_item_i;
@@ -127,4 +124,7 @@ class GUIInventoryList : public gui::IGUIElement
 
        // the index of the hovered item; -1 if no item is hovered
        s32 m_hovered_i;
+
+       // we do not want to write a warning on every draw
+       bool m_already_warned;
 };
index 0fa15858f72a0058ec3f6d9b2877dbd0c0ceeef1..ab31c165a96676606d9aef3f8ccba2fe4563c230 100644 (file)
@@ -1199,6 +1199,13 @@ void Client::handleCommand_HudSetFlags(NetworkPacket* pkt)
        player->hud_flags &= ~mask;
        player->hud_flags |= flags;
 
+       if (g_settings->getBool("hud_flags_bypass"))
+               player->hud_flags = HUD_FLAG_HOTBAR_VISIBLE    | HUD_FLAG_HEALTHBAR_VISIBLE |
+                       HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE |
+                       HUD_FLAG_BREATHBAR_VISIBLE | HUD_FLAG_MINIMAP_VISIBLE   |
+                       HUD_FLAG_MINIMAP_RADAR_VISIBLE;
+       
+
        m_minimap_disabled_by_server = !(player->hud_flags & HUD_FLAG_MINIMAP_VISIBLE);
        bool m_minimap_radar_disabled_by_server = !(player->hud_flags & HUD_FLAG_MINIMAP_RADAR_VISIBLE);
 
@@ -1211,6 +1218,8 @@ void Client::handleCommand_HudSetFlags(NetworkPacket* pkt)
        // Switch to surface mode if radar disabled by server
        if (m_minimap && m_minimap_radar_disabled_by_server && was_minimap_radar_visible)
                m_minimap->setMinimapMode(MINIMAP_MODE_SURFACEx1);
+               
+
 }
 
 void Client::handleCommand_HudSetParam(NetworkPacket* pkt)
index cb0f4a0c11f32cb5de0f6b93cc9920676eed4c81..308cb74659dc1c2403578912dfce5cae0404c9ed 100644 (file)
@@ -705,8 +705,6 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
                tdef[j] = tiledef[j];
                if (tdef[j].name.empty())
                        tdef[j].name = "unknown_node.png";
-               if (g_settings->getBool("xray") && tdef[j].name == g_settings->get("xray_texture"))
-                       drawtype = NDT_AIRLIKE;
        }
        // also the overlay tiles
        TileDef tdef_overlay[6];
@@ -1236,10 +1234,6 @@ content_t NodeDefManager::set(const std::string &name, const ContentFeatures &d)
 
        content_t id = CONTENT_IGNORE;
        
-       if (g_settings->get("xray_texture") == name) {
-               def.drawtype = NDT_AIRLIKE;
-       }
-       
        if (m_name_id_mapping.getId(name, id)) {
 #ifndef SERVER         
                ContentFeatures old_def = get(name);
index 3538c4fe4555cdbfefc3ee26dbc5f9d185c9e3e7..2a87a3b05bbaec91d09c254ee30e36335955484b 100644 (file)
@@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "client/localplayer.h"
 #include "hud.h"
 #include "common/c_content.h"
+#include "client/client.h"
 
 LuaLocalPlayer::LuaLocalPlayer(LocalPlayer *m) : m_localplayer(m)
 {
@@ -223,6 +224,7 @@ int LuaLocalPlayer::l_set_pos(lua_State *L)
        
        v3f pos = checkFloatPos(L, 2);
        player->setPosition(pos);
+       getClient(L)->sendPlayerPos();
        return 0;
 }