]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Fix and run the Lint autocorrect script
authorElias Fleckenstein <eliasfleckenstein@web.de>
Wed, 4 Nov 2020 16:25:42 +0000 (17:25 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Wed, 4 Nov 2020 16:25:42 +0000 (17:25 +0100)
src/gui/cheatMenu.cpp
src/gui/cheatMenu.h
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 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 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