Remove some unused variable from Lua class wrappers

This commit is contained in:
sfan5 2022-04-08 15:52:22 +02:00
parent 41e79d902d
commit 5362f472ff
4 changed files with 20 additions and 23 deletions

@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
LuaPerlinNoise LuaPerlinNoise
*/ */
LuaPerlinNoise::LuaPerlinNoise(NoiseParams *params) : LuaPerlinNoise::LuaPerlinNoise(const NoiseParams *params) :
np(*params) np(*params)
{ {
} }
@ -141,12 +141,10 @@ luaL_Reg LuaPerlinNoise::methods[] = {
LuaPerlinNoiseMap 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 { 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) { } catch (InvalidNoiseParamsException &e) {
throw LuaError(e.what()); throw LuaError(e.what());
} }
@ -217,7 +215,7 @@ int LuaPerlinNoiseMap::l_get_3d_map(lua_State *L)
LuaPerlinNoiseMap *o = checkobject(L, 1); LuaPerlinNoiseMap *o = checkobject(L, 1);
v3f p = check_v3f(L, 2); v3f p = check_v3f(L, 2);
if (!o->m_is3d) if (!o->is3D())
return 0; return 0;
Noise *n = o->noise; Noise *n = o->noise;
@ -248,7 +246,7 @@ int LuaPerlinNoiseMap::l_get_3d_map_flat(lua_State *L)
v3f p = check_v3f(L, 2); v3f p = check_v3f(L, 2);
bool use_buffer = lua_istable(L, 3); bool use_buffer = lua_istable(L, 3);
if (!o->m_is3d) if (!o->is3D())
return 0; return 0;
Noise *n = o->noise; Noise *n = o->noise;
@ -289,7 +287,7 @@ int LuaPerlinNoiseMap::l_calc_3d_map(lua_State *L)
LuaPerlinNoiseMap *o = checkobject(L, 1); LuaPerlinNoiseMap *o = checkobject(L, 1);
v3f p = check_v3f(L, 2); v3f p = check_v3f(L, 2);
if (!o->m_is3d) if (!o->is3D())
return 0; return 0;
Noise *n = o->noise; Noise *n = o->noise;

@ -30,6 +30,7 @@ class LuaPerlinNoise : public ModApiBase
{ {
private: private:
NoiseParams np; NoiseParams np;
static const char className[]; static const char className[];
static luaL_Reg methods[]; static luaL_Reg methods[];
@ -42,7 +43,7 @@ private:
static int l_get_3d(lua_State *L); static int l_get_3d(lua_State *L);
public: public:
LuaPerlinNoise(NoiseParams *params); LuaPerlinNoise(const NoiseParams *params);
~LuaPerlinNoise() = default; ~LuaPerlinNoise() = default;
// LuaPerlinNoise(seed, octaves, persistence, scale) // LuaPerlinNoise(seed, octaves, persistence, scale)
@ -59,9 +60,8 @@ public:
*/ */
class LuaPerlinNoiseMap : public ModApiBase class LuaPerlinNoiseMap : public ModApiBase
{ {
NoiseParams np;
Noise *noise; Noise *noise;
bool m_is3d;
static const char className[]; static const char className[];
static luaL_Reg methods[]; static luaL_Reg methods[];
@ -80,10 +80,11 @@ class LuaPerlinNoiseMap : public ModApiBase
static int l_get_map_slice(lua_State *L); static int l_get_map_slice(lua_State *L);
public: public:
LuaPerlinNoiseMap(NoiseParams *np, s32 seed, v3s16 size); LuaPerlinNoiseMap(const NoiseParams *np, s32 seed, v3s16 size);
~LuaPerlinNoiseMap(); ~LuaPerlinNoiseMap();
inline bool is3D() const { return noise->sz > 1; }
// LuaPerlinNoiseMap(np, size) // LuaPerlinNoiseMap(np, size)
// Creates an LuaPerlinNoiseMap and leaves it on top of stack // Creates an LuaPerlinNoiseMap and leaves it on top of stack
static int create_object(lua_State *L); static int create_object(lua_State *L);

@ -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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include <map>
#include "lua_api/l_vmanip.h" #include "lua_api/l_vmanip.h"
#include "lua_api/l_internal.h" #include "lua_api/l_internal.h"
#include "common/c_content.h" #include "common/c_content.h"
@ -112,23 +112,23 @@ int LuaVoxelManip::l_write_to_map(lua_State *L)
LuaVoxelManip *o = checkobject(L, 1); LuaVoxelManip *o = checkobject(L, 1);
bool update_light = !lua_isboolean(L, 2) || readParam<bool>(L, 2); bool update_light = !lua_isboolean(L, 2) || readParam<bool>(L, 2);
GET_ENV_PTR; GET_ENV_PTR;
ServerMap *map = &(env->getServerMap()); ServerMap *map = &(env->getServerMap());
std::map<v3s16, MapBlock*> modified_blocks;
if (o->is_mapgen_vm || !update_light) { if (o->is_mapgen_vm || !update_light) {
o->vm->blitBackAll(&(o->modified_blocks)); o->vm->blitBackAll(&modified_blocks);
} else { } else {
voxalgo::blit_back_with_light(map, o->vm, voxalgo::blit_back_with_light(map, o->vm, &modified_blocks);
&(o->modified_blocks));
} }
MapEditEvent event; MapEditEvent event;
event.type = MEET_OTHER; event.type = MEET_OTHER;
for (const auto &modified_block : o->modified_blocks) for (const auto &it : modified_blocks)
event.modified_blocks.insert(modified_block.first); event.modified_blocks.insert(it.first);
map->dispatchEvent(event); map->dispatchEvent(event);
o->modified_blocks.clear();
return 0; return 0;
} }

@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma once #pragma once
#include <map>
#include "irr_v3d.h" #include "irr_v3d.h"
#include "lua_api/l_base.h" #include "lua_api/l_base.h"
@ -33,7 +32,6 @@ class MMVManip;
class LuaVoxelManip : public ModApiBase class LuaVoxelManip : public ModApiBase
{ {
private: private:
std::map<v3s16, MapBlock *> modified_blocks;
bool is_mapgen_vm = false; bool is_mapgen_vm = false;
static const char className[]; static const char className[];