]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Merge pull request #10 from corarona/master
authorElias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com>
Thu, 5 Nov 2020 13:08:25 +0000 (14:08 +0100)
committerGitHub <noreply@github.com>
Thu, 5 Nov 2020 13:08:25 +0000 (14:08 +0100)
lua api: set_pitch and make_screenshot

22 files changed:
builtin/client/cheats/init.lua
builtin/client/cheats/render.lua
builtin/common/chatcommands.lua
builtin/settingtypes.txt
src/client/game.cpp
src/client/mapblock_mesh.cpp
src/client/mapblock_mesh.h
src/client/minimap.cpp
src/client/render/core.cpp
src/client/render/core.h
src/client/renderingengine.cpp
src/client/renderingengine.h
src/defaultsettings.cpp
src/gui/cheatMenu.cpp
src/gui/cheatMenu.h
src/script/common/c_content.cpp
src/script/lua_api/CMakeLists.txt
src/script/lua_api/l_clientobject.cpp
src/script/lua_api/l_clientobject.h
src/script/lua_api/l_inventoryaction.cpp
src/script/lua_api/l_inventoryaction.h
util/ci/lint_autocorrect.sh

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 709c3d00a7738b6323e4110702b46c6a5df70313..bf989db7d1f8fd53349a18f20a421a974fea2758 100644 (file)
@@ -68,7 +68,7 @@ if INIT == "client" then
                                        end
                                end
                        end
-                       return false, "Invalid usage. (See /help " .. command .. ")"
+                       return false, "Invalid usage. (See .help " .. command .. ")"
                end
                core.register_chatcommand(command, def)
        end
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..2e8a50294d96e36571320ae01c20670aa4b5f7c2 100644 (file)
@@ -116,6 +116,8 @@ Game::Game() :
                &updateAllMapBlocksCallback, this);
        g_settings->registerChangedCallback("fullbright",
                &updateAllMapBlocksCallback, this);
+       g_settings->registerChangedCallback("node_esp_nodes",
+               &updateAllMapBlocksCallback, this);
                
        readSettings();
 
@@ -182,6 +184,8 @@ Game::~Game()
                &updateAllMapBlocksCallback, this);
        g_settings->deregisterChangedCallback("fullbright",
                &updateAllMapBlocksCallback, this);
+       g_settings->deregisterChangedCallback("node_esp_nodes",
+               &updateAllMapBlocksCallback, this);
 }
 
 bool Game::startup(bool *kill,
@@ -3194,7 +3198,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..f65864599605c3d78d07191c386b08d144c42130 100644 (file)
@@ -818,9 +818,9 @@ static void getTileInfo(
                u16 *lights,
                u8 &waving,
                TileSpec &tile,
+               // lol more Input
                bool xray,
-               std::set<content_t> xraySet
-       )
+               std::set<content_t> xraySet)
 {
        VoxelManipulator &vmanip = data->m_vmanip;
        const NodeDefManager *ndef = data->m_client->ndef();
@@ -831,7 +831,6 @@ static void getTileInfo(
        content_t c0 = n0.getContent();
        if (xray && xraySet.find(c0) != xraySet.end())
                c0 = CONTENT_AIR;
-
        // Don't even try to get n1 if n0 is already CONTENT_IGNORE
        if (c0 == CONTENT_IGNORE) {
                makes_face = false;
@@ -946,7 +945,7 @@ 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,
@@ -954,7 +953,7 @@ static void updateFastFaceRow(
                                        next_tile,
                                        xray,
                                        xraySet);
-
+                       
                        if (next_makes_face == makes_face
                                        && next_p_corrected == p_corrected + translate_dir
                                        && next_face_dir_corrected == face_dir_corrected
@@ -1096,10 +1095,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
@@ -1114,6 +1115,23 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
        }
        // End of slow part
 
+       /*
+               NodeESP
+       */
+       {
+               v3s16 blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE;
+               for (s16 x = 0; x < MAP_BLOCKSIZE; x++) {
+                       for (s16 y = 0; y < MAP_BLOCKSIZE; y++) {
+                               for (s16 z = 0; z < MAP_BLOCKSIZE; z++) {
+                                       v3s16 pos = v3s16(x, y, z) + blockpos_nodes;
+                                       const MapNode &node = data->m_vmanip.getNodeRefUnsafeCheckFlags(pos);
+                                       if (nodeESPSet.find(node.getContent()) != nodeESPSet.end())
+                                               esp_nodes.insert(pos);
+                               }
+                       }
+               }
+       }
+
        /*
                Convert FastFaces to MeshCollector
        */
index 6af23a656fdd3e004abf3884ba4c4f6b193b7c25..95fda83e5b6766d176cb1ae2a2c58e537c36dcf0 100644 (file)
@@ -134,6 +134,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 68770ec198bc0f17ce2fd0522606d69b977a5158..8ea1a0283d61bb17ed78ef091372c4aa5d40547a 100644 (file)
@@ -474,8 +474,8 @@ void Minimap::drawMinimap()
        core::matrix4 oldViewMat = driver->getTransform(video::ETS_VIEW);
 
        driver->setViewPort(core::rect<s32>(
-               screensize.X - size - 10, 10,
-               screensize.X - 10, size + 10));
+               screensize.X - size * 2 - 10, 10,
+               screensize.X - size - 10, size + 10));
        driver->setTransform(video::ETS_PROJECTION, core::matrix4());
        driver->setTransform(video::ETS_VIEW, core::matrix4());
 
@@ -529,7 +529,7 @@ void Minimap::drawMinimap()
        driver->setViewPort(oldViewPort);
 
        // Draw player markers
-       v2s32 s_pos(screensize.X - size - 10, 10);
+       v2s32 s_pos(screensize.X - size * 2 - 10, 10);
        core::dimension2di imgsize(data->object_marker_red->getOriginalSize());
        core::rect<s32> img_rect(0, 0, imgsize.Width, imgsize.Height);
        static const video::SColor col(255, 255, 255, 255);
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..4c3d311db9f8ddffc6206eeac2ff95456571c3ee 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");
@@ -317,7 +320,7 @@ void set_default_settings(Settings *settings)
        settings->setDefault("arm_inertia", "true");
 
        settings->setDefault("enable_minimap", "true");
-       settings->setDefault("minimap_shape_round", "true");
+       settings->setDefault("minimap_shape_round", "false");
        settings->setDefault("minimap_double_scan_height", "true");
 
        // Effects
index e66fbc250366b1c7062dcb513d14001b96f76e18..d441e8dfcecd8c1ba2da9f810e2d1946f8ea8b29 100644 (file)
@@ -23,8 +23,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "cheatMenu.h"
 #include <cstddef>
 
-FontMode CheatMenu::fontStringToEnum(std::string str) {
-       if (str == "FM_Standard") 
+FontMode CheatMenu::fontStringToEnum(std::string str)
+{
+       if (str == "FM_Standard")
                return FM_Standard;
        else if (str == "FM_Mono")
                return FM_Mono;
@@ -52,18 +53,21 @@ CheatMenu::CheatMenu(Client *client) : m_client(client)
        font_color = g_settings->getV3F("cheat_menu_font_color");
        selected_font_color = g_settings->getV3F("cheat_menu_selected_font_color");
 
-       m_bg_color = video::SColor(g_settings->getU32("cheat_menu_bg_color_alpha"), 
-                                                          bg_color.X, bg_color.Y, bg_color.Z);
-       
-       m_active_bg_color = video::SColor(g_settings->getU32("cheat_menu_active_bg_color_alpha"), 
-                                                                 active_bg_color.X, active_bg_color.Y, active_bg_color.Z);
+       m_bg_color = video::SColor(g_settings->getU32("cheat_menu_bg_color_alpha"),
+                       bg_color.X, bg_color.Y, bg_color.Z);
+
+       m_active_bg_color = video::SColor(
+                       g_settings->getU32("cheat_menu_active_bg_color_alpha"),
+                       active_bg_color.X, active_bg_color.Y, active_bg_color.Z);
 
        m_font_color = video::SColor(g_settings->getU32("cheat_menu_font_color_alpha"),
-                                                                font_color.X, font_color.Y, font_color.Z);
+                       font_color.X, font_color.Y, font_color.Z);
+
+       m_selected_font_color = video::SColor(
+                       g_settings->getU32("cheat_menu_selected_font_color_alpha"),
+                       selected_font_color.X, selected_font_color.Y,
+                       selected_font_color.Z);
 
-       m_selected_font_color = video::SColor(g_settings->getU32("cheat_menu_selected_font_color_alpha"),
-                                                                                 selected_font_color.X, selected_font_color.Y, selected_font_color.Z);
-       
        m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, fontMode);
 
        if (!m_font) {
@@ -137,64 +141,73 @@ void CheatMenu::draw(video::IVideoDriver *driver, bool show_debug)
 void CheatMenu::drawHUD(video::IVideoDriver *driver, double dtime)
 {
        CHEAT_MENU_GET_SCRIPTPTR
-       
+
        m_rainbow_offset += dtime;
 
        m_rainbow_offset = fmod(m_rainbow_offset, 6.0f);
-       
+
        std::vector<std::string> enabled_cheats;
-       
+
        int cheat_count = 0;
-       
-       for (auto category = script->m_cheat_categories.begin(); category != script->m_cheat_categories.end(); category++) {
-               for (auto cheat = (*category)->m_cheats.begin(); cheat != (*category)->m_cheats.end(); cheat++) {
+
+       for (auto category = script->m_cheat_categories.begin();
+                       category != script->m_cheat_categories.end(); category++) {
+               for (auto cheat = (*category)->m_cheats.begin();
+                               cheat != (*category)->m_cheats.end(); cheat++) {
                        if ((*cheat)->is_enabled()) {
                                enabled_cheats.push_back((*cheat)->m_name);
                                cheat_count++;
                        }
                }
        }
-       
+
        if (enabled_cheats.empty())
                return;
-       
+
        std::vector<video::SColor> colors;
-       
+
        for (int i = 0; i < cheat_count; i++) {
                video::SColor color;
                f32 h = (f32)i * 2.0f / (f32)cheat_count - m_rainbow_offset;
                if (h < 0)
                        h = 6.0f + h;
                f32 x = (1 - fabs(fmod(h, 2.0f) - 1.0f)) * 255.0f;
-               switch((int)h) {
+               switch ((int)h) {
                case 0:
-                       color = video::SColor(255, 255, x, 0); break;
+                       color = video::SColor(255, 255, x, 0);
+                       break;
                case 1:
-                       color = video::SColor(255, x, 255, 0); break;
+                       color = video::SColor(255, x, 255, 0);
+                       break;
                case 2:
-                       color = video::SColor(255, 0, 255, x); break;
+                       color = video::SColor(255, 0, 255, x);
+                       break;
                case 3:
-                       color = video::SColor(255, 0, x, 255); break;
+                       color = video::SColor(255, 0, x, 255);
+                       break;
                case 4:
-                       color = video::SColor(255, x, 0, 255); break;
+                       color = video::SColor(255, x, 0, 255);
+                       break;
                case 5:
-                       color = video::SColor(255, 255, 0, x); break;
+                       color = video::SColor(255, 255, 0, x);
+                       break;
                }
                colors.push_back(color);
        }
-       
+
        core::dimension2d<u32> screensize = driver->getScreenSize();
-       
+
        u32 y = 5;
-       
+
        int i = 0;
        for (std::string cheat : enabled_cheats) {
-               core::dimension2d<u32> dim = m_font->getDimension(utf8_to_wide(cheat).c_str());
+               core::dimension2d<u32> dim =
+                               m_font->getDimension(utf8_to_wide(cheat).c_str());
                u32 x = screensize.Width - 5 - dim.Width;
-               
+
                core::rect<s32> fontbounds(x, y, x + dim.Width, y + dim.Height);
                m_font->draw(cheat.c_str(), fontbounds, colors[i], false, false);
-               
+
                y += dim.Height;
                i++;
        }
index 8be73c4831a3829ceb78ce575f5d0d1b547837fb..b15858a48999012f8f743647fbff88fbe3845f96 100644 (file)
@@ -42,18 +42,15 @@ class CheatMenu
 public:
        CheatMenu(Client *client);
 
-       ClientScripting *getScript()
-       {
-               return m_client->getScript();
-       }
+       ClientScripting *getScript() { return m_client->getScript(); }
 
        void draw(video::IVideoDriver *driver, bool show_debug);
-       
+
        void drawHUD(video::IVideoDriver *driver, double dtime);
 
        void drawEntry(video::IVideoDriver *driver, std::string name, int number,
-               bool selected, bool active,
-               CheatMenuEntryType entry_type = CHEAT_MENU_ENTRY_TYPE_ENTRY);
+                       bool selected, bool active,
+                       CheatMenuEntryType entry_type = CHEAT_MENU_ENTRY_TYPE_ENTRY);
 
        void selectUp();
        void selectDown();
@@ -82,6 +79,6 @@ class CheatMenu
 
        gui::IGUIFont *m_font = nullptr;
        v2u32 m_fontsize;
-       
+
        float m_rainbow_offset = 0.0;
 };
index 7d4c1e748e0f5fac18b150d14ff71c4fee76db28..2103634177f79c3ed638a4dc8cd08a0dbf0baaa2 100644 (file)
@@ -1837,9 +1837,10 @@ void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm,
        } else if (pointed.type == POINTEDTHING_OBJECT) {
                lua_pushstring(L, "object");
                lua_setfield(L, -2, "type");
-
                if (csm) {
+#ifndef SERVER
                        ClientObjectRef::create(L, pointed.object_id);
+#endif
                } else {
                        push_objectRef(L, pointed.object_id);
                }
index f6963f707cad037b17bd4df630a72463a63952a5..3f1b890859a459d7f4b76708d3ff014e57af83eb 100644 (file)
@@ -6,7 +6,6 @@ set(common_SCRIPT_LUA_API_SRCS
        ${CMAKE_CURRENT_SOURCE_DIR}/l_env.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/l_http.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/l_inventory.cpp
-       ${CMAKE_CURRENT_SOURCE_DIR}/l_inventoryaction.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/l_item.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/l_itemstackmeta.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/l_mapgen.cpp
@@ -30,6 +29,7 @@ set(client_SCRIPT_LUA_API_SRCS
        ${CMAKE_CURRENT_SOURCE_DIR}/l_camera.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/l_client.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/l_clientobject.cpp
+       ${CMAKE_CURRENT_SOURCE_DIR}/l_inventoryaction.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/l_localplayer.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/l_mainmenu.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/l_minimap.cpp
index d88b538a181aed84a05a191e1497f5b78c9d0fb5..05b3e28503001f736b4cc3814d7959ba4f1e2ebf 100644 (file)
@@ -146,7 +146,7 @@ int ClientObjectRef::l_punch(lua_State *L)
 {
        ClientObjectRef *ref = checkobject(L, 1);
        GenericCAO *gcao = get_generic_cao(ref, L);
-       PointedThing pointed(gcao->getId(), v3f(0,0,0), v3s16(0,0,0), 0);
+       PointedThing pointed(gcao->getId(), v3f(0, 0, 0), v3s16(0, 0, 0), 0);
        getClient(L)->interact(INTERACT_START_DIGGING, pointed);
        return 0;
 }
@@ -155,7 +155,7 @@ int ClientObjectRef::l_rightclick(lua_State *L)
 {
        ClientObjectRef *ref = checkobject(L, 1);
        GenericCAO *gcao = get_generic_cao(ref, L);
-       PointedThing pointed(gcao->getId(), v3f(0,0,0), v3s16(0,0,0), 0);
+       PointedThing pointed(gcao->getId(), v3f(0, 0, 0), v3s16(0, 0, 0), 0);
        getClient(L)->interact(INTERACT_PLACE, pointed);
        return 0;
 }
@@ -223,6 +223,5 @@ luaL_Reg ClientObjectRef::methods[] = {luamethod(ClientObjectRef, get_pos),
                luamethod(ClientObjectRef, get_attach),
                luamethod(ClientObjectRef, get_nametag),
                luamethod(ClientObjectRef, get_item_textures),
-               luamethod(ClientObjectRef, get_max_hp),
-               luamethod(ClientObjectRef, punch),
+               luamethod(ClientObjectRef, get_max_hp), luamethod(ClientObjectRef, punch),
                luamethod(ClientObjectRef, rightclick), {0, 0}};
index 5215914446c178e2f5b00d07d2e6e7d42c11a63a..a4516e04749b9700a7cd739bb6b541cec2d7505e 100644 (file)
@@ -60,7 +60,7 @@ class ClientObjectRef : public ModApiBase
 
        // is_player(self)
        static int l_is_player(lua_State *L);
-       
+
        // is_local_player(self)
        static int l_is_local_player(lua_State *L);
 
index f3037ba83dfdcacd08d18269e5f79acaadd1854c..f65137465e332b2d9e6b774c97c0244ce104d6c8 100644 (file)
@@ -43,9 +43,9 @@ int LuaInventoryAction::l_apply(lua_State *L)
 
        std::ostringstream os(std::ios::binary);
        o->m_action->serialize(os);
-       
+
        std::istringstream is(os.str(), std::ios_base::binary);
-       
+
        InventoryAction *a = InventoryAction::deSerialize(is);
 
        getClient(L)->inventoryAction(a);
@@ -69,29 +69,30 @@ int LuaInventoryAction::l_to(lua_State *L)
 int LuaInventoryAction::l_craft(lua_State *L)
 {
        LuaInventoryAction *o = checkobject(L, 1);
-       
+
        if (o->m_action->getType() != IAction::Craft)
                return 0;
-               
+
        std::string locStr;
        InventoryLocation loc;
-       
+
        locStr = readParam<std::string>(L, 2);
-       
+
        try {
                loc.deSerialize(locStr);
                dynamic_cast<ICraftAction *>(o->m_action)->craft_inv = loc;
-       } catch (SerializationError &) {}
-       
+       } catch (SerializationError &) {
+       }
+
        return 0;
 }
 
 int LuaInventoryAction::l_set_count(lua_State *L)
 {
        LuaInventoryAction *o = checkobject(L, 1);
-       
+
        s16 count = luaL_checkinteger(L, 2);
-       
+
        switch (o->m_action->getType()) {
        case IAction::Move:
                ((IMoveAction *)o->m_action)->count = count;
@@ -103,7 +104,7 @@ int LuaInventoryAction::l_set_count(lua_State *L)
                ((ICraftAction *)o->m_action)->count = count;
                break;
        }
-       
+
        return 0;
 }
 
@@ -127,23 +128,25 @@ LuaInventoryAction::~LuaInventoryAction()
        delete m_action;
 }
 
-void LuaInventoryAction::readFullInventoryLocationInto(lua_State *L, InventoryLocation *loc, std::string *list, s16 *index)
+void LuaInventoryAction::readFullInventoryLocationInto(
+               lua_State *L, InventoryLocation *loc, std::string *list, s16 *index)
 {
        try {
                loc->deSerialize(readParam<std::string>(L, 2));
                std::string l = readParam<std::string>(L, 3);
                *list = l;
                *index = luaL_checkinteger(L, 4) - 1;
-       } catch (SerializationError &) {}
+       } catch (SerializationError &) {
+       }
 }
 
 int LuaInventoryAction::create_object(lua_State *L)
 {
        IAction type;
        std::string typeStr;
-       
+
        typeStr = readParam<std::string>(L, 1);
-       
+
        if (typeStr == "move")
                type = IAction::Move;
        else if (typeStr == "drop")
@@ -206,11 +209,7 @@ void LuaInventoryAction::Register(lua_State *L)
 }
 
 const char LuaInventoryAction::className[] = "InventoryAction";
-const luaL_Reg LuaInventoryAction::methods[] = {
-       luamethod(LuaInventoryAction, apply),
-       luamethod(LuaInventoryAction, from),
-       luamethod(LuaInventoryAction, to),
-       luamethod(LuaInventoryAction, craft),
-       luamethod(LuaInventoryAction, set_count),
-       {0,0}
-};
+const luaL_Reg LuaInventoryAction::methods[] = {luamethod(LuaInventoryAction, apply),
+               luamethod(LuaInventoryAction, from), luamethod(LuaInventoryAction, to),
+               luamethod(LuaInventoryAction, craft),
+               luamethod(LuaInventoryAction, set_count), {0, 0}};
index c1a96d010122c2b1b1feb601a2bc2b2000b56426..a4cc6cbe5fd63c46b3cec5e5455f460625d8a04f 100644 (file)
@@ -20,44 +20,46 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "inventorymanager.h"
 #include "lua_api/l_base.h"
 
-#define GET_MOVE_ACTION \
-       LuaInventoryAction *o = checkobject(L, 1); \
-       if (o->m_action->getType() == IAction::Craft) \
-               return 0; \
+#define GET_MOVE_ACTION                                                                  \
+       LuaInventoryAction *o = checkobject(L, 1);                                       \
+       if (o->m_action->getType() == IAction::Craft)                                    \
+               return 0;                                                                \
        MoveAction *act = dynamic_cast<MoveAction *>(o->m_action);
 
-class LuaInventoryAction : public ModApiBase {
+class LuaInventoryAction : public ModApiBase
+{
 private:
        InventoryAction *m_action;
-       
-       static void readFullInventoryLocationInto(lua_State *L, InventoryLocation *loc, std::string *list, s16 *index);
-       
+
+       static void readFullInventoryLocationInto(lua_State *L, InventoryLocation *loc,
+                       std::string *list, s16 *index);
+
        static const char className[];
        static const luaL_Reg methods[];
-       
+
        // Exported functions
-       
+
        // garbage collector
        static int gc_object(lua_State *L);
 
        // __tostring metamethod
        static int mt_tostring(lua_State *L);
-       
+
        // apply(self)
        static int l_apply(lua_State *L);
-       
+
        // from(self, location, list, index)
        static int l_from(lua_State *L);
-       
+
        // to(self, location, list, index)
        static int l_to(lua_State *L);
-       
+
        // craft(self, location)
        static int l_craft(lua_State *L);
 
        // set_count(self, count)
        static int l_set_count(lua_State *L);
-               
+
 public:
        LuaInventoryAction(const IAction &type);
        ~LuaInventoryAction();
@@ -67,6 +69,6 @@ class LuaInventoryAction : public ModApiBase {
        static int create_object(lua_State *L);
        // Not callable from Lua
        static int create(lua_State *L, const IAction &type);
-       static LuaInventoryActioncheckobject(lua_State *L, int narg);
+       static LuaInventoryAction *checkobject(lua_State *L, int narg);
        static void Register(lua_State *L);
 };
index a2ea40e6a7b0985f4057f92fbf237f411100488c..6a8881231170858e54c0292eb05cd21fadbc6cf9 100644 (file)
@@ -28,7 +28,7 @@ function perform_lint() {
                                        printf ":\n%s\n" "$d"
                                fi
                                
-                               ${CLANG_FORMAT} "-i $f"
+                               ${CLANG_FORMAT} -i "$f"
 
                                fail=1
                        fi