]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Remove some unused variable from Lua class wrappers
authorsfan5 <sfan5@live.de>
Fri, 8 Apr 2022 13:52:22 +0000 (15:52 +0200)
committersfan5 <sfan5@live.de>
Mon, 2 May 2022 18:54:55 +0000 (20:54 +0200)
src/script/lua_api/l_noise.cpp
src/script/lua_api/l_noise.h
src/script/lua_api/l_vmanip.cpp
src/script/lua_api/l_vmanip.h

index f43ba837a3d6b2bc17cd5d3ce1bd22f46d2721be..0eee49b7d7682d8daec95f20ef5d6f1b4f3d3332 100644 (file)
@@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
   LuaPerlinNoise
 */
 
-LuaPerlinNoise::LuaPerlinNoise(NoiseParams *params) :
+LuaPerlinNoise::LuaPerlinNoise(const NoiseParams *params) :
        np(*params)
 {
 }
@@ -141,12 +141,10 @@ luaL_Reg LuaPerlinNoise::methods[] = {
   LuaPerlinNoiseMap
 */
 
-LuaPerlinNoiseMap::LuaPerlinNoiseMap(NoiseParams *params, s32 seed, v3s16 size)
+LuaPerlinNoiseMap::LuaPerlinNoiseMap(const NoiseParams *np, s32 seed, v3s16 size)
 {
-       m_is3d = size.Z > 1;
-       np = *params;
        try {
-               noise = new Noise(&np, seed, size.X, size.Y, size.Z);
+               noise = new Noise(np, seed, size.X, size.Y, size.Z);
        } catch (InvalidNoiseParamsException &e) {
                throw LuaError(e.what());
        }
@@ -217,7 +215,7 @@ int LuaPerlinNoiseMap::l_get_3d_map(lua_State *L)
        LuaPerlinNoiseMap *o = checkobject(L, 1);
        v3f p = check_v3f(L, 2);
 
-       if (!o->m_is3d)
+       if (!o->is3D())
                return 0;
 
        Noise *n = o->noise;
@@ -248,7 +246,7 @@ int LuaPerlinNoiseMap::l_get_3d_map_flat(lua_State *L)
        v3f p                = check_v3f(L, 2);
        bool use_buffer      = lua_istable(L, 3);
 
-       if (!o->m_is3d)
+       if (!o->is3D())
                return 0;
 
        Noise *n = o->noise;
@@ -289,7 +287,7 @@ int LuaPerlinNoiseMap::l_calc_3d_map(lua_State *L)
        LuaPerlinNoiseMap *o = checkobject(L, 1);
        v3f p                = check_v3f(L, 2);
 
-       if (!o->m_is3d)
+       if (!o->is3D())
                return 0;
 
        Noise *n = o->noise;
index 9f50dfd3fee7d8b3559c563a9606a1aacd7de76b..29ab41a31f538cd54cbf8e4f6bf6c3b81b2683ef 100644 (file)
@@ -30,6 +30,7 @@ class LuaPerlinNoise : public ModApiBase
 {
 private:
        NoiseParams np;
+
        static const char className[];
        static luaL_Reg methods[];
 
@@ -42,7 +43,7 @@ class LuaPerlinNoise : public ModApiBase
        static int l_get_3d(lua_State *L);
 
 public:
-       LuaPerlinNoise(NoiseParams *params);
+       LuaPerlinNoise(const NoiseParams *params);
        ~LuaPerlinNoise() = default;
 
        // LuaPerlinNoise(seed, octaves, persistence, scale)
@@ -59,9 +60,8 @@ class LuaPerlinNoise : public ModApiBase
 */
 class LuaPerlinNoiseMap : public ModApiBase
 {
-       NoiseParams np;
        Noise *noise;
-       bool m_is3d;
+
        static const char className[];
        static luaL_Reg methods[];
 
@@ -80,10 +80,11 @@ class LuaPerlinNoiseMap : public ModApiBase
        static int l_get_map_slice(lua_State *L);
 
 public:
-       LuaPerlinNoiseMap(NoiseParams *np, s32 seed, v3s16 size);
-
+       LuaPerlinNoiseMap(const NoiseParams *np, s32 seed, v3s16 size);
        ~LuaPerlinNoiseMap();
 
+       inline bool is3D() const { return noise->sz > 1; }
+
        // LuaPerlinNoiseMap(np, size)
        // Creates an LuaPerlinNoiseMap and leaves it on top of stack
        static int create_object(lua_State *L);
index 1fa0802104593ab56f262198d4da7b303ab2f84b..a3ece627c7322589e474865a22bfb735f5b13758 100644 (file)
@@ -17,7 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-
+#include <map>
 #include "lua_api/l_vmanip.h"
 #include "lua_api/l_internal.h"
 #include "common/c_content.h"
@@ -112,23 +112,23 @@ int LuaVoxelManip::l_write_to_map(lua_State *L)
 
        LuaVoxelManip *o = checkobject(L, 1);
        bool update_light = !lua_isboolean(L, 2) || readParam<bool>(L, 2);
+
        GET_ENV_PTR;
        ServerMap *map = &(env->getServerMap());
+
+       std::map<v3s16, MapBlock*> modified_blocks;
        if (o->is_mapgen_vm || !update_light) {
-               o->vm->blitBackAll(&(o->modified_blocks));
+               o->vm->blitBackAll(&modified_blocks);
        } else {
-               voxalgo::blit_back_with_light(map, o->vm,
-                       &(o->modified_blocks));
+               voxalgo::blit_back_with_light(map, o->vm, &modified_blocks);
        }
 
        MapEditEvent event;
        event.type = MEET_OTHER;
-       for (const auto &modified_block : o->modified_blocks)
-               event.modified_blocks.insert(modified_block.first);
-
+       for (const auto &it : modified_blocks)
+               event.modified_blocks.insert(it.first);
        map->dispatchEvent(event);
 
-       o->modified_blocks.clear();
        return 0;
 }
 
index 15ab9eef8c2fc8717604c038b3fa0bdefb8ae789..5113070dc573d0092398ad857e8f1570dd5dc1e1 100644 (file)
@@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #pragma once
 
-#include <map>
 #include "irr_v3d.h"
 #include "lua_api/l_base.h"
 
@@ -33,7 +32,6 @@ class MMVManip;
 class LuaVoxelManip : public ModApiBase
 {
 private:
-       std::map<v3s16, MapBlock *> modified_blocks;
        bool is_mapgen_vm = false;
 
        static const char className[];