1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

C++11 cleanup on constructors (#6000)

* C++11 cleanup on constructors dir script
This commit is contained in:
Vincent Glize 2017-06-19 23:54:58 +02:00 committed by Loïc Blot
parent 4a78949083
commit 4a5e8ad343
40 changed files with 117 additions and 180 deletions

View file

@ -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();
}
}

View file

@ -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);

View file

@ -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)

View file

@ -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);

View file

@ -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[];

View file

@ -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)

View file

@ -67,7 +67,7 @@ private:
static int l_get_movement(lua_State *L);
LocalPlayer *m_localplayer;
LocalPlayer *m_localplayer = nullptr;
public:
LuaLocalPlayer(LocalPlayer *m);

View file

@ -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)

View file

@ -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);

View file

@ -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)
{
}

View file

@ -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[];

View file

@ -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[];

View file

@ -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_ */

View file

@ -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)
{
}

View file

@ -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);

View file

@ -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[];

View file

@ -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);

View file

@ -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);