From: Elias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com> Date: Thu, 5 Nov 2020 13:08:25 +0000 (+0100) Subject: Merge pull request #10 from corarona/master X-Git-Tag: 05-11-2020~1 X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=91ad0d049706ed2892ba728cb8cad48480908027;hp=1bab49049bfc4bf89b4ee69fe734e2a79de0eb9f;p=dragonfireclient.git Merge pull request #10 from corarona/master lua api: set_pitch and make_screenshot --- diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index 03fc20c60..6f3046f3c 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -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"] = { diff --git a/builtin/client/cheats/render.lua b/builtin/client/cheats/render.lua index 092c7fefc..6402246f3 100644 --- a/builtin/client/cheats/render.lua +++ b/builtin/client/cheats/render.lua @@ -1 +1,2 @@ core.register_list_command("xray", "Configure X-Ray", "xray_nodes") +core.register_list_command("search", "Configure NodeESP", "node_esp_nodes") diff --git a/builtin/common/chatcommands.lua b/builtin/common/chatcommands.lua index 709c3d00a..bf989db7d 100644 --- a/builtin/common/chatcommands.lua +++ b/builtin/common/chatcommands.lua @@ -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 diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 74fb5dc92..ce7d301dd 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -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 diff --git a/src/client/game.cpp b/src/client/game.cpp index 479484ae9..2e8a50294 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -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 diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index fbd7e2ab7..f65864599 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -818,9 +818,9 @@ static void getTileInfo( u16 *lights, u8 &waving, TileSpec &tile, + // lol more Input bool xray, - std::set xraySet - ) + std::set 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 xraySet; + std::set 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 */ diff --git a/src/client/mapblock_mesh.h b/src/client/mapblock_mesh.h index 6af23a656..95fda83e5 100644 --- a/src/client/mapblock_mesh.h +++ b/src/client/mapblock_mesh.h @@ -134,6 +134,8 @@ class MapBlockMesh void updateCameraOffset(v3s16 camera_offset); + std::set esp_nodes; + private: scene::IMesh *m_mesh[MAX_TILE_LAYERS]; MinimapMapblock *m_minimap_mapblock; diff --git a/src/client/minimap.cpp b/src/client/minimap.cpp index 68770ec19..8ea1a0283 100644 --- a/src/client/minimap.cpp +++ b/src/client/minimap.cpp @@ -474,8 +474,8 @@ void Minimap::drawMinimap() core::matrix4 oldViewMat = driver->getTransform(video::ETS_VIEW); driver->setViewPort(core::rect( - 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 img_rect(0, 0, imgsize.Width, imgsize.Height); static const video::SColor col(255, 255, 255, 255); diff --git a/src/client/render/core.cpp b/src/client/render/core.cpp index 223af5142..cb4f1deb7 100644 --- a/src/client/render/core.cpp +++ b/src/client/render/core.cpp @@ -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(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(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 *sectors = map.getSectorsPtr(); + + for (auto §or_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 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(); diff --git a/src/client/render/core.h b/src/client/render/core.h index 90b81b060..2040155a6 100644 --- a/src/client/render/core.h +++ b/src/client/render/core.h @@ -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; } }; diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp index 1534289d4..e6d25d4ee 100644 --- a/src/client/renderingengine.cpp +++ b/src/client/renderingengine.cpp @@ -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) diff --git a/src/client/renderingengine.h b/src/client/renderingengine.h index c5fa8918b..99aa3c678 100644 --- a/src/client/renderingengine.h +++ b/src/client/renderingengine.h @@ -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); diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index a00d39c30..4c3d311db 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -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 diff --git a/src/gui/cheatMenu.cpp b/src/gui/cheatMenu.cpp index e66fbc250..d441e8dfc 100644 --- a/src/gui/cheatMenu.cpp +++ b/src/gui/cheatMenu.cpp @@ -23,8 +23,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "cheatMenu.h" #include -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 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 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 screensize = driver->getScreenSize(); - + u32 y = 5; - + int i = 0; for (std::string cheat : enabled_cheats) { - core::dimension2d dim = m_font->getDimension(utf8_to_wide(cheat).c_str()); + core::dimension2d dim = + m_font->getDimension(utf8_to_wide(cheat).c_str()); u32 x = screensize.Width - 5 - dim.Width; - + core::rect fontbounds(x, y, x + dim.Width, y + dim.Height); m_font->draw(cheat.c_str(), fontbounds, colors[i], false, false); - + y += dim.Height; i++; } diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index 8be73c483..b15858a48 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -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; }; diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 7d4c1e748..210363417 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -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); } diff --git a/src/script/lua_api/CMakeLists.txt b/src/script/lua_api/CMakeLists.txt index f6963f707..3f1b89085 100644 --- a/src/script/lua_api/CMakeLists.txt +++ b/src/script/lua_api/CMakeLists.txt @@ -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 diff --git a/src/script/lua_api/l_clientobject.cpp b/src/script/lua_api/l_clientobject.cpp index d88b538a1..05b3e2850 100644 --- a/src/script/lua_api/l_clientobject.cpp +++ b/src/script/lua_api/l_clientobject.cpp @@ -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}}; diff --git a/src/script/lua_api/l_clientobject.h b/src/script/lua_api/l_clientobject.h index 521591444..a4516e047 100644 --- a/src/script/lua_api/l_clientobject.h +++ b/src/script/lua_api/l_clientobject.h @@ -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); diff --git a/src/script/lua_api/l_inventoryaction.cpp b/src/script/lua_api/l_inventoryaction.cpp index f3037ba83..f65137465 100644 --- a/src/script/lua_api/l_inventoryaction.cpp +++ b/src/script/lua_api/l_inventoryaction.cpp @@ -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(L, 2); - + try { loc.deSerialize(locStr); dynamic_cast(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(L, 2)); std::string l = readParam(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(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}}; diff --git a/src/script/lua_api/l_inventoryaction.h b/src/script/lua_api/l_inventoryaction.h index c1a96d010..a4cc6cbe5 100644 --- a/src/script/lua_api/l_inventoryaction.h +++ b/src/script/lua_api/l_inventoryaction.h @@ -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(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 LuaInventoryAction* checkobject(lua_State *L, int narg); + static LuaInventoryAction *checkobject(lua_State *L, int narg); static void Register(lua_State *L); }; diff --git a/util/ci/lint_autocorrect.sh b/util/ci/lint_autocorrect.sh index a2ea40e6a..6a8881231 100644 --- a/util/ci/lint_autocorrect.sh +++ b/util/ci/lint_autocorrect.sh @@ -28,7 +28,7 @@ function perform_lint() { printf ":\n%s\n" "$d" fi - ${CLANG_FORMAT} "-i $f" + ${CLANG_FORMAT} -i "$f" fail=1 fi