]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Added NodeESP
authorElias Fleckenstein <eliasfleckenstein@web.de>
Thu, 5 Nov 2020 09:57:31 +0000 (10:57 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Thu, 5 Nov 2020 09:57:31 +0000 (10:57 +0100)
builtin/client/cheats/init.lua
builtin/client/cheats/render.lua
builtin/settingtypes.txt
src/client/game.cpp
src/client/mapblock_mesh.cpp
src/client/mapblock_mesh.h
src/client/render/core.cpp
src/client/render/core.h
src/client/renderingengine.cpp
src/client/renderingengine.h
src/defaultsettings.cpp

index 03fc20c60246253404e63e115cbb2a8efdb53a70..6f3046f3cf1e1559bfe608ee2eb74b93f0a1f096 100644 (file)
@@ -27,6 +27,8 @@ core.cheats = {
                ["Coords"] = "coords",
                ["Tracers"] = "enable_tracers",
                ["ESP"] = "enable_esp",
+               ["NodeTracers"] = "enable_node_tracers",
+               ["NodeESP"] = "enable_node_esp",
                ["CheatHUD"] = "cheat_hud",
        },
        ["World"] = {
index 092c7fefcde44577f37af82d8c9d77d26da7693e..6402246f3ca8a47639f45fe0f01b2aef02efbe41 100644 (file)
@@ -1 +1,2 @@
 core.register_list_command("xray", "Configure X-Ray", "xray_nodes") 
+core.register_list_command("search", "Configure NodeESP", "node_esp_nodes") 
index 74fb5dc92bda86fc4c26461a9e580388b18a35ab..ce7d301dd1728207be1848a523caacc5368e4534 100644 (file)
@@ -2345,3 +2345,9 @@ forcefield (Forcefield) bool false
 friendlist (Killaura / Forcefield Friendlist) string
 
 cheat_hud (CheatHUD) bool true
+
+enable_node_esp (NodeESP) bool false
+
+enable_node_tracers (NodeTracers) bool false
+
+node_esp_nodes (NodeESP Nodes) string
index 479484ae92a327817cd93e02d12e3b4c74c5d8e6..894f92b460d04f8041fd8b58dbd0f17234ef7ad1 100644 (file)
@@ -3194,7 +3194,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
        }
 #endif
        RenderingEngine::draw_scene(skycolor, m_game_ui->m_flags.show_hud,
-                       m_game_ui->m_flags.show_minimap, draw_wield_tool, draw_crosshair, g_settings->getBool("enable_tracers"), g_settings->getBool("enable_esp"));
+                       m_game_ui->m_flags.show_minimap, draw_wield_tool, draw_crosshair, g_settings->getBool("enable_esp"), g_settings->getBool("enable_tracers"), g_settings->getBool("enable_node_esp"), g_settings->getBool("enable_node_tracers"));
 
        /*
                Profiler graph
index fbd7e2ab7ce8b577db2dccaa7c305d1d4232282f..537ee414d800d2fd7db8e548bc02b66c11502d66 100644 (file)
@@ -818,9 +818,10 @@ static void getTileInfo(
                u16 *lights,
                u8 &waving,
                TileSpec &tile,
+               // lol more Input
                bool xray,
-               std::set<content_t> xraySet
-       )
+               std::set<content_t> xraySet,
+               std::set<content_t> nodeESPSet)
 {
        VoxelManipulator &vmanip = data->m_vmanip;
        const NodeDefManager *ndef = data->m_client->ndef();
@@ -831,7 +832,8 @@ static void getTileInfo(
        content_t c0 = n0.getContent();
        if (xray && xraySet.find(c0) != xraySet.end())
                c0 = CONTENT_AIR;
-
+       if (nodeESPSet.find(c0) != nodeESPSet.end())
+               data->m_esp_nodes.insert(blockpos_nodes + p);
        // Don't even try to get n1 if n0 is already CONTENT_IGNORE
        if (c0 == CONTENT_IGNORE) {
                makes_face = false;
@@ -909,7 +911,8 @@ static void updateFastFaceRow(
                const v3s16 &&face_dir,
                std::vector<FastFace> &dest,
                bool xray,
-               std::set<content_t> xraySet)
+               std::set<content_t> xraySet,
+               std::set<content_t> nodeESPSet)
 {
        static thread_local const bool waving_liquids =
                g_settings->getBool("enable_shaders") &&
@@ -929,7 +932,7 @@ static void updateFastFaceRow(
        // Get info of first tile
        getTileInfo(data, p, face_dir,
                        makes_face, p_corrected, face_dir_corrected,
-                       lights, waving, tile, xray, xraySet);
+                       lights, waving, tile, xray, xraySet, nodeESPSet);
 
        // Unroll this variable which has a significant build cost
        TileSpec next_tile;
@@ -946,15 +949,16 @@ static void updateFastFaceRow(
                // the face must be drawn anyway
                if (j != MAP_BLOCKSIZE - 1) {
                        p += translate_dir;
-
+                       
                        getTileInfo(data, p, face_dir,
                                        next_makes_face, next_p_corrected,
                                        next_face_dir_corrected, next_lights,
                                        waving,
                                        next_tile,
                                        xray,
-                                       xraySet);
-
+                                       xraySet,
+                                       nodeESPSet);
+                       
                        if (next_makes_face == makes_face
                                        && next_p_corrected == p_corrected + translate_dir
                                        && next_face_dir_corrected == face_dir_corrected
@@ -1003,7 +1007,7 @@ static void updateFastFaceRow(
 }
 
 static void updateAllFastFaceRows(MeshMakeData *data,
-               std::vector<FastFace> &dest, bool xray, std::set<content_t> xraySet)
+               std::vector<FastFace> &dest, bool xray, std::set<content_t> xraySet, std::set<content_t> nodeESPSet)
 {
        /*
                Go through every y,z and get top(y+) faces in rows of x+
@@ -1017,7 +1021,8 @@ static void updateAllFastFaceRows(MeshMakeData *data,
                                v3s16(0, 1, 0), //face dir
                                dest,
                                xray,
-                               xraySet);
+                               xraySet,
+                               nodeESPSet);
 
        /*
                Go through every x,y and get right(x+) faces in rows of z+
@@ -1031,7 +1036,8 @@ static void updateAllFastFaceRows(MeshMakeData *data,
                                v3s16(1, 0, 0), //face dir
                                dest,
                                xray,
-                               xraySet);
+                               xraySet,
+                               nodeESPSet);
 
        /*
                Go through every y,z and get back(z+) faces in rows of x+
@@ -1045,7 +1051,8 @@ static void updateAllFastFaceRows(MeshMakeData *data,
                                v3s16(0, 0, 1), //face dir
                                dest,
                                xray,
-                               xraySet);
+                               xraySet,
+                               nodeESPSet);
 }
 
 static void applyTileColor(PreMeshBuffer &pmb)
@@ -1096,10 +1103,12 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
                X-Ray
        */
        bool xray = g_settings->getBool("xray");
-       std::set<content_t> xraySet;
+       std::set<content_t> xraySet, nodeESPSet;
        if (xray)
                xraySet = splitToContentT(g_settings->get("xray_nodes"), data->m_client->ndef());
        
+       nodeESPSet = splitToContentT(g_settings->get("node_esp_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
@@ -1110,7 +1119,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
        {
                // 4-23ms for MAP_BLOCKSIZE=16  (NOTE: probably outdated)
                //TimeTaker timer2("updateAllFastFaceRows()");
-               updateAllFastFaceRows(data, fastfaces_new, xray, xraySet);
+               updateAllFastFaceRows(data, fastfaces_new, xray, xraySet, nodeESPSet);
        }
        // End of slow part
 
@@ -1296,6 +1305,8 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
                !m_crack_materials.empty() ||
                !m_daynight_diffs.empty() ||
                !m_animation_tiles.empty();
+       
+       esp_nodes = data->m_esp_nodes;
 }
 
 MapBlockMesh::~MapBlockMesh()
index 6af23a656fdd3e004abf3884ba4c4f6b193b7c25..67fb94976c88b727326c71f9459a98588adb786f 100644 (file)
@@ -46,6 +46,7 @@ struct MeshMakeData
        Client *m_client;
        bool m_use_shaders;
        bool m_use_tangent_vertices;
+       std::set<v3s16> m_esp_nodes;
 
        MeshMakeData(Client *client, bool use_shaders,
                        bool use_tangent_vertices = false);
@@ -134,6 +135,8 @@ class MapBlockMesh
 
        void updateCameraOffset(v3s16 camera_offset);
 
+       std::set<v3s16> esp_nodes;
+
 private:
        scene::IMesh *m_mesh[MAX_TILE_LAYERS];
        MinimapMapblock *m_minimap_mapblock;
index 223af5142df06776d947f377622ac15077134179..cb4f1deb7569822194006321d46883d6d4031758 100644 (file)
@@ -26,6 +26,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "client/hud.h"
 #include "client/minimap.h"
 #include "client/content_cao.h"
+#include "mapblock.h"
+#include "mapsector.h"
 
 RenderingCore::RenderingCore(IrrlichtDevice *_device, Client *_client, Hud *_hud)
        : device(_device), driver(device->getVideoDriver()), smgr(device->getSceneManager()),
@@ -55,7 +57,7 @@ void RenderingCore::updateScreenSize()
 }
 
 void RenderingCore::draw(video::SColor _skycolor, bool _show_hud, bool _show_minimap,
-               bool _draw_wield_tool, bool _draw_crosshair, bool _draw_tracers, bool _draw_esp)
+               bool _draw_wield_tool, bool _draw_crosshair, bool _draw_esp, bool _draw_tracers, bool _draw_node_esp, bool _draw_node_tracers)
 {
        v2u32 ss = driver->getScreenSize();
        if (screensize != ss) {
@@ -67,8 +69,10 @@ void RenderingCore::draw(video::SColor _skycolor, bool _show_hud, bool _show_min
        show_minimap = _show_minimap;
        draw_wield_tool = _draw_wield_tool;
        draw_crosshair = _draw_crosshair;
-       draw_tracers = _draw_tracers;
        draw_esp = _draw_esp;
+       draw_tracers = _draw_tracers;
+       draw_node_esp = _draw_node_esp;
+       draw_node_tracers = _draw_node_tracers;
                
        beforeDraw();
        drawAll();
@@ -91,26 +95,58 @@ void RenderingCore::drawTracersAndESP()
        material.setFlag(video::EMF_ZWRITE_ENABLE, false);
        driver->setMaterial(material);
        
-       auto allObjects = env.getAllActiveObjects();
-       for (auto &it : allObjects) {
-               ClientActiveObject *cao = it.second;
-               if (cao->isLocalPlayer() || cao->getParent())
-                       continue;
-               GenericCAO *obj = dynamic_cast<GenericCAO *>(cao);
-               if (! obj)
-                       continue;
-               aabb3f box;
-               if (! obj->getSelectionBox(&box))
-                       continue;
-               v3f pos = obj->getPosition();
-               pos -= camera_offset;
-               box.MinEdge += pos;
-               box.MaxEdge += pos;
-               pos = box.getCenter();
-               if (draw_esp)
-                       driver->draw3DBox(box, video::SColor(255, 255, 255, 255));
-               if (draw_tracers)
-                       driver->draw3DLine(eye_pos, pos, video::SColor(255, 255, 255, 255));
+       if (draw_esp || draw_tracers) {
+               auto allObjects = env.getAllActiveObjects();
+
+               for (auto &it : allObjects) {
+                       ClientActiveObject *cao = it.second;
+                       if (cao->isLocalPlayer() || cao->getParent())
+                               continue;
+                       GenericCAO *obj = dynamic_cast<GenericCAO *>(cao);
+                       if (! obj)
+                               continue;
+                       aabb3f box;
+                       if (! obj->getSelectionBox(&box))
+                               continue;
+                       v3f pos = obj->getPosition() - camera_offset;
+                       box.MinEdge += pos;
+                       box.MaxEdge += pos;
+                       if (draw_esp)
+                               driver->draw3DBox(box, video::SColor(255, 255, 255, 255));
+                       if (draw_tracers)
+                               driver->draw3DLine(eye_pos, box.getCenter(), video::SColor(255, 255, 255, 255));
+               }
+       }
+       if (draw_node_esp || draw_node_tracers) {
+               Map &map = env.getMap();
+               std::map<v2s16, MapSector*> *sectors = map.getSectorsPtr();
+               
+               for (auto &sector_it : *sectors) {
+                       MapSector *sector = sector_it.second;
+                       MapBlockVect blocks;
+                       sector->getBlocks(blocks);
+                       for (MapBlock *block : blocks) {
+                               if (! block->mesh)
+                                       continue;
+                               for (v3s16 p : block->mesh->esp_nodes) {
+                                       v3f pos = intToFloat(p, BS) - camera_offset;
+                                       MapNode node = map.getNode(p);
+                                       std::vector<aabb3f> boxes;
+                                       node.getSelectionBoxes(client->getNodeDefManager(), &boxes, node.getNeighbors(p, &map));
+                                       video::SColor color = client->getNodeDefManager()->get(node).minimap_color;
+                               
+                                       for (aabb3f box : boxes) {
+                                               box.MinEdge += pos;
+                                               box.MaxEdge += pos;
+                                               if (draw_node_esp)
+                                                       driver->draw3DBox(box, color);
+                                               if (draw_node_tracers)
+                                                       driver->draw3DLine(eye_pos, box.getCenter(), color);
+                                       }
+                               }
+                       }
+               }
+
        }
        
        driver->setMaterial(oldmaterial);
@@ -123,7 +159,7 @@ void RenderingCore::draw3D()
        if (!show_hud)
                return;
        hud->drawSelectionMesh();
-       if (draw_tracers || draw_esp)
+       if (draw_esp || draw_tracers || draw_node_esp || draw_node_tracers)
                drawTracersAndESP();
        if (draw_wield_tool)
                camera->drawWieldedTool();
index 90b81b0606d1c09808dd1461106aecc1baf55a7c..2040155a6ab2494a4ed6b15e55662edd4141188c 100644 (file)
@@ -36,8 +36,10 @@ class RenderingCore
        bool show_minimap;
        bool draw_wield_tool;
        bool draw_crosshair;
-       bool draw_tracers;
        bool draw_esp;
+       bool draw_tracers;
+       bool draw_node_esp;
+       bool draw_node_tracers;
 
        IrrlichtDevice *device;
        video::IVideoDriver *driver;
@@ -72,8 +74,8 @@ class RenderingCore
 
        void initialize();
        void draw(video::SColor _skycolor, bool _show_hud, bool _show_minimap,
-                       bool _draw_wield_tool, bool _draw_crosshair, bool _draw_tracers,
-                       bool _draw_esp);
+                       bool _draw_wield_tool, bool _draw_crosshair, bool _draw_esp,
+                       bool _draw_tracers, bool _draw_node_esp, bool _draw_node_tracers);
 
        inline v2u32 getVirtualSize() const { return virtual_size; }
 };
index 1534289d43373e1a3b9cf584c9c9abd8bb6c141c..e6d25d4ee8884d8525a78443879e59ba95700df6 100644 (file)
@@ -604,9 +604,9 @@ void RenderingEngine::_finalize()
 }
 
 void RenderingEngine::_draw_scene(video::SColor skycolor, bool show_hud,
-               bool show_minimap, bool draw_wield_tool, bool draw_crosshair, bool draw_tracers, bool draw_esp)
+               bool show_minimap, bool draw_wield_tool, bool draw_crosshair, bool draw_esp, bool draw_tracers, bool draw_node_esp, bool draw_node_tracers)
 {
-       core->draw(skycolor, show_hud, show_minimap, draw_wield_tool, draw_crosshair, draw_tracers, draw_esp);
+       core->draw(skycolor, show_hud, show_minimap, draw_wield_tool, draw_crosshair, draw_esp, draw_tracers, draw_node_esp, draw_node_tracers);
 }
 
 const char *RenderingEngine::getVideoDriverName(irr::video::E_DRIVER_TYPE type)
index c5fa8918b6e84e6fd1b5e8bd9dd067ce19be04b9..99aa3c6784d405b47879d4dc9983c469b06c036b 100644 (file)
@@ -32,7 +32,6 @@ class Client;
 class LocalPlayer;
 class Hud;
 class Minimap;
-class Tracers;
 
 class RenderingCore;
 
@@ -118,10 +117,10 @@ class RenderingEngine
        }
 
        inline static void draw_scene(video::SColor skycolor, bool show_hud,
-                       bool show_minimap, bool draw_wield_tool, bool draw_crosshair, bool draw_tracers, bool draw_esp)
+                       bool show_minimap, bool draw_wield_tool, bool draw_crosshair, bool draw_esp, bool draw_tracers, bool draw_node_esp, bool draw_node_tracers)
        {
                s_singleton->_draw_scene(skycolor, show_hud, show_minimap,
-                               draw_wield_tool, draw_crosshair, draw_tracers, draw_esp);
+                               draw_wield_tool, draw_crosshair, draw_esp, draw_tracers, draw_node_esp, draw_node_tracers);
        }
 
        inline static void initialize(Client *client, Hud *hud)
@@ -149,7 +148,7 @@ class RenderingEngine
                        bool clouds = true);
 
        void _draw_scene(video::SColor skycolor, bool show_hud, bool show_minimap,
-                       bool draw_wield_tool, bool draw_crosshair, bool draw_tracers, bool draw_esp);
+                       bool draw_wield_tool, bool draw_crosshair, bool draw_esp, bool draw_tracers, bool draw_node_esp, bool draw_node_tracers);
 
        void _initialize(Client *client, Hud *hud);
 
index a00d39c30690589731197fba683d1ccfc5bef27a..9c3cfe6657f51b2b8dac238cb122057c822dd6c3 100644 (file)
@@ -131,6 +131,9 @@ void set_default_settings(Settings *settings)
        settings->setDefault("forcefield", "false");
        settings->setDefault("friendlist", "");
        settings->setDefault("cheat_hud", "true");
+       settings->setDefault("enable_node_esp", "false");
+       settings->setDefault("enable_node_tracers", "false");
+       settings->setDefault("node_esp_nodes", "");
 
        // Keymap
        settings->setDefault("remote_port", "30000");