summaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_areastore.cpp7
-rw-r--r--src/script/lua_api/l_areastore.h2
-rw-r--r--src/script/lua_api/l_camera.cpp3
-rw-r--r--src/script/lua_api/l_camera.h2
-rw-r--r--src/script/lua_api/l_itemstackmeta.h2
-rw-r--r--src/script/lua_api/l_localplayer.cpp3
-rw-r--r--src/script/lua_api/l_localplayer.h2
-rw-r--r--src/script/lua_api/l_minimap.cpp3
-rw-r--r--src/script/lua_api/l_minimap.h2
-rw-r--r--src/script/lua_api/l_nodemeta.cpp6
-rw-r--r--src/script/lua_api/l_nodemeta.h6
-rw-r--r--src/script/lua_api/l_nodetimer.h2
-rw-r--r--src/script/lua_api/l_object.h35
-rw-r--r--src/script/lua_api/l_settings.cpp4
-rw-r--r--src/script/lua_api/l_settings.h6
-rw-r--r--src/script/lua_api/l_storage.h2
-rw-r--r--src/script/lua_api/l_vmanip.cpp11
-rw-r--r--src/script/lua_api/l_vmanip.h4
18 files changed, 45 insertions, 57 deletions
diff --git a/src/script/lua_api/l_areastore.cpp b/src/script/lua_api/l_areastore.cpp
index b81985a7f..1e30e704e 100644
--- a/src/script/lua_api/l_areastore.cpp
+++ b/src/script/lua_api/l_areastore.cpp
@@ -300,20 +300,19 @@ int LuaAreaStore::l_from_file(lua_State *L)
return deserialization_helper(L, o->as, is);
}
-LuaAreaStore::LuaAreaStore()
+LuaAreaStore::LuaAreaStore() : as(AreaStore::getOptimalImplementation())
{
- this->as = AreaStore::getOptimalImplementation();
}
LuaAreaStore::LuaAreaStore(const std::string &type)
{
#if USE_SPATIAL
if (type == "LibSpatial") {
- this->as = new SpatialAreaStore();
+ as = new SpatialAreaStore();
} else
#endif
{
- this->as = new VectorAreaStore();
+ as = new VectorAreaStore();
}
}
diff --git a/src/script/lua_api/l_areastore.h b/src/script/lua_api/l_areastore.h
index 8292e7712..9cb6249d0 100644
--- a/src/script/lua_api/l_areastore.h
+++ b/src/script/lua_api/l_areastore.h
@@ -49,7 +49,7 @@ private:
static int l_from_file(lua_State *L);
public:
- AreaStore *as;
+ AreaStore *as = nullptr;
LuaAreaStore();
LuaAreaStore(const std::string &type);
diff --git a/src/script/lua_api/l_camera.cpp b/src/script/lua_api/l_camera.cpp
index 862384198..ef842a222 100644
--- a/src/script/lua_api/l_camera.cpp
+++ b/src/script/lua_api/l_camera.cpp
@@ -4,9 +4,8 @@
#include "content_cao.h"
#include "camera.h"
-LuaCamera::LuaCamera(Camera *m)
+LuaCamera::LuaCamera(Camera *m) : m_camera(m)
{
- m_camera = m;
}
void LuaCamera::create(lua_State *L, Camera *m)
diff --git a/src/script/lua_api/l_camera.h b/src/script/lua_api/l_camera.h
index 04921ad03..c4a0f877c 100644
--- a/src/script/lua_api/l_camera.h
+++ b/src/script/lua_api/l_camera.h
@@ -26,7 +26,7 @@ private:
static int l_get_look_horizontal(lua_State *L);
static int l_get_aspect_ratio(lua_State *L);
- Camera *m_camera;
+ Camera *m_camera = nullptr;
public:
LuaCamera(Camera *m);
diff --git a/src/script/lua_api/l_itemstackmeta.h b/src/script/lua_api/l_itemstackmeta.h
index 4ef64a91e..6e841d2dc 100644
--- a/src/script/lua_api/l_itemstackmeta.h
+++ b/src/script/lua_api/l_itemstackmeta.h
@@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class ItemStackMetaRef : public MetaDataRef
{
private:
- ItemStack *istack;
+ ItemStack *istack = nullptr;
static const char className[];
static const luaL_Reg methods[];
diff --git a/src/script/lua_api/l_localplayer.cpp b/src/script/lua_api/l_localplayer.cpp
index 7ec4eaa62..7f932cbca 100644
--- a/src/script/lua_api/l_localplayer.cpp
+++ b/src/script/lua_api/l_localplayer.cpp
@@ -21,9 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "l_internal.h"
#include "script/common/c_converter.h"
-LuaLocalPlayer::LuaLocalPlayer(LocalPlayer *m)
+LuaLocalPlayer::LuaLocalPlayer(LocalPlayer *m) : m_localplayer(m)
{
- m_localplayer = m;
}
void LuaLocalPlayer::create(lua_State *L, LocalPlayer *m)
diff --git a/src/script/lua_api/l_localplayer.h b/src/script/lua_api/l_localplayer.h
index e56ec808f..e618e6be5 100644
--- a/src/script/lua_api/l_localplayer.h
+++ b/src/script/lua_api/l_localplayer.h
@@ -67,7 +67,7 @@ private:
static int l_get_movement(lua_State *L);
- LocalPlayer *m_localplayer;
+ LocalPlayer *m_localplayer = nullptr;
public:
LuaLocalPlayer(LocalPlayer *m);
diff --git a/src/script/lua_api/l_minimap.cpp b/src/script/lua_api/l_minimap.cpp
index afb3766fb..be981c884 100644
--- a/src/script/lua_api/l_minimap.cpp
+++ b/src/script/lua_api/l_minimap.cpp
@@ -24,9 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "minimap.h"
#include "settings.h"
-LuaMinimap::LuaMinimap(Minimap *m)
+LuaMinimap::LuaMinimap(Minimap *m) : m_minimap(m)
{
- m_minimap = m;
}
void LuaMinimap::create(lua_State *L, Minimap *m)
diff --git a/src/script/lua_api/l_minimap.h b/src/script/lua_api/l_minimap.h
index ba702b0b1..d4fbf6330 100644
--- a/src/script/lua_api/l_minimap.h
+++ b/src/script/lua_api/l_minimap.h
@@ -48,7 +48,7 @@ private:
static int l_set_shape(lua_State *L);
static int l_get_shape(lua_State *L);
- Minimap *m_minimap;
+ Minimap *m_minimap = nullptr;
public:
LuaMinimap(Minimap *m);
diff --git a/src/script/lua_api/l_nodemeta.cpp b/src/script/lua_api/l_nodemeta.cpp
index 5dfa6d52e..aa8d1c453 100644
--- a/src/script/lua_api/l_nodemeta.cpp
+++ b/src/script/lua_api/l_nodemeta.cpp
@@ -171,14 +171,12 @@ bool NodeMetaRef::handleFromTable(lua_State *L, int table, Metadata *_meta)
NodeMetaRef::NodeMetaRef(v3s16 p, ServerEnvironment *env):
m_p(p),
- m_env(env),
- m_is_local(false)
+ m_env(env)
{
}
NodeMetaRef::NodeMetaRef(Metadata *meta):
- m_meta(meta),
- m_is_local(true)
+ m_meta(meta)
{
}
diff --git a/src/script/lua_api/l_nodemeta.h b/src/script/lua_api/l_nodemeta.h
index dd4260ff9..72d26ef36 100644
--- a/src/script/lua_api/l_nodemeta.h
+++ b/src/script/lua_api/l_nodemeta.h
@@ -34,9 +34,9 @@ class NodeMetadata;
class NodeMetaRef : public MetaDataRef {
private:
v3s16 m_p;
- ServerEnvironment *m_env;
- Metadata *m_meta;
- bool m_is_local;
+ ServerEnvironment *m_env = nullptr;
+ Metadata *m_meta = nullptr;
+ bool m_is_local = false;
static const char className[];
static const luaL_Reg methodsServer[];
diff --git a/src/script/lua_api/l_nodetimer.h b/src/script/lua_api/l_nodetimer.h
index ae362d8b3..df77ed98f 100644
--- a/src/script/lua_api/l_nodetimer.h
+++ b/src/script/lua_api/l_nodetimer.h
@@ -29,7 +29,7 @@ class NodeTimerRef : public ModApiBase
{
private:
v3s16 m_p;
- ServerEnvironment *m_env;
+ ServerEnvironment *m_env = nullptr;
static const char className[];
static const luaL_Reg methods[];
diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h
index 9801ce02b..77874f00c 100644
--- a/src/script/lua_api/l_object.h
+++ b/src/script/lua_api/l_object.h
@@ -33,16 +33,29 @@ class RemotePlayer;
*/
class ObjectRef : public ModApiBase {
-private:
- ServerActiveObject *m_object;
-
- static const char className[];
- static const luaL_Reg methods[];
public:
+ ObjectRef(ServerActiveObject *object);
+
+ ~ObjectRef();
+
+ // Creates an ObjectRef and leaves it on top of stack
+ // Not callable from Lua; all references are created on the C side.
+ static void create(lua_State *L, ServerActiveObject *object);
+
+ static void set_null(lua_State *L);
+
+ static void Register(lua_State *L);
+
static ObjectRef *checkobject(lua_State *L, int narg);
static ServerActiveObject* getobject(ObjectRef *ref);
private:
+ ServerActiveObject *m_object = nullptr;
+
+ static const char className[];
+ static const luaL_Reg methods[];
+
+
static LuaEntitySAO* getluaobject(ObjectRef *ref);
static PlayerSAO* getplayersao(ObjectRef *ref);
@@ -319,18 +332,6 @@ private:
// get_nametag_attributes(self)
static int l_get_nametag_attributes(lua_State *L);
-public:
- ObjectRef(ServerActiveObject *object);
-
- ~ObjectRef();
-
- // Creates an ObjectRef and leaves it on top of stack
- // Not callable from Lua; all references are created on the C side.
- static void create(lua_State *L, ServerActiveObject *object);
-
- static void set_null(lua_State *L);
-
- static void Register(lua_State *L);
};
#endif /* L_OBJECT_H_ */
diff --git a/src/script/lua_api/l_settings.cpp b/src/script/lua_api/l_settings.cpp
index 70807f3d2..3dc5c9574 100644
--- a/src/script/lua_api/l_settings.cpp
+++ b/src/script/lua_api/l_settings.cpp
@@ -32,9 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
LuaSettings::LuaSettings(Settings *settings, const std::string &filename) :
m_settings(settings),
- m_filename(filename),
- m_is_own_settings(false),
- m_write_allowed(true)
+ m_filename(filename)
{
}
diff --git a/src/script/lua_api/l_settings.h b/src/script/lua_api/l_settings.h
index 54b003ab3..a664b4494 100644
--- a/src/script/lua_api/l_settings.h
+++ b/src/script/lua_api/l_settings.h
@@ -57,10 +57,10 @@ private:
// to_table(self) -> {[key1]=value1,...}
static int l_to_table(lua_State *L);
- Settings *m_settings;
+ Settings *m_settings = nullptr;
std::string m_filename;
- bool m_is_own_settings;
- bool m_write_allowed;
+ bool m_is_own_settings = false;
+ bool m_write_allowed = true;
public:
LuaSettings(Settings *settings, const std::string &filename);
diff --git a/src/script/lua_api/l_storage.h b/src/script/lua_api/l_storage.h
index ec6f8d941..eaf7ec9f6 100644
--- a/src/script/lua_api/l_storage.h
+++ b/src/script/lua_api/l_storage.h
@@ -38,7 +38,7 @@ public:
class StorageRef : public MetaDataRef
{
private:
- ModMetadata *m_object;
+ ModMetadata *m_object = nullptr;
static const char className[];
static const luaL_Reg methods[];
diff --git a/src/script/lua_api/l_vmanip.cpp b/src/script/lua_api/l_vmanip.cpp
index 254a7e5a6..ed5042bcf 100644
--- a/src/script/lua_api/l_vmanip.cpp
+++ b/src/script/lua_api/l_vmanip.cpp
@@ -365,22 +365,17 @@ int LuaVoxelManip::l_get_emerged_area(lua_State *L)
return 2;
}
-LuaVoxelManip::LuaVoxelManip(MMVManip *mmvm, bool is_mg_vm)
+LuaVoxelManip::LuaVoxelManip(MMVManip *mmvm, bool is_mg_vm) : vm(mmvm), is_mapgen_vm(is_mg_vm)
{
- this->vm = mmvm;
- this->is_mapgen_vm = is_mg_vm;
}
-LuaVoxelManip::LuaVoxelManip(Map *map)
+LuaVoxelManip::LuaVoxelManip(Map *map) : vm(new MMVManip(map))
{
- this->vm = new MMVManip(map);
- this->is_mapgen_vm = false;
}
LuaVoxelManip::LuaVoxelManip(Map *map, v3s16 p1, v3s16 p2)
{
- this->vm = new MMVManip(map);
- this->is_mapgen_vm = false;
+ vm = new MMVManip(map);
v3s16 bp1 = getNodeBlockPos(p1);
v3s16 bp2 = getNodeBlockPos(p2);
diff --git a/src/script/lua_api/l_vmanip.h b/src/script/lua_api/l_vmanip.h
index b6a69f36a..e706f3727 100644
--- a/src/script/lua_api/l_vmanip.h
+++ b/src/script/lua_api/l_vmanip.h
@@ -35,7 +35,7 @@ class LuaVoxelManip : public ModApiBase
{
private:
std::map<v3s16, MapBlock *> modified_blocks;
- bool is_mapgen_vm;
+ bool is_mapgen_vm = false;
static const char className[];
static const luaL_Reg methods[];
@@ -65,7 +65,7 @@ private:
static int l_get_emerged_area(lua_State *L);
public:
- MMVManip *vm;
+ MMVManip *vm = nullptr;
LuaVoxelManip(MMVManip *mmvm, bool is_mapgen_vm);
LuaVoxelManip(Map *map, v3s16 p1, v3s16 p2);