mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
C++11 cleanup on constructors (#6000)
* C++11 cleanup on constructors dir script
This commit is contained in:
parent
4a78949083
commit
4a5e8ad343
40 changed files with 117 additions and 180 deletions
|
@ -33,13 +33,6 @@ extern "C" {
|
|||
#include "porting.h"
|
||||
#include "common/c_internal.h"
|
||||
|
||||
/******************************************************************************/
|
||||
AsyncEngine::AsyncEngine() :
|
||||
initDone(false),
|
||||
jobIdCounter(0)
|
||||
{
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
AsyncEngine::~AsyncEngine()
|
||||
{
|
||||
|
|
|
@ -39,24 +39,18 @@ class AsyncEngine;
|
|||
// Data required to queue a job
|
||||
struct LuaJobInfo
|
||||
{
|
||||
LuaJobInfo() :
|
||||
serializedFunction(""),
|
||||
serializedParams(""),
|
||||
serializedResult(""),
|
||||
id(0),
|
||||
valid(false)
|
||||
{}
|
||||
LuaJobInfo() {};
|
||||
|
||||
// Function to be called in async environment
|
||||
std::string serializedFunction;
|
||||
std::string serializedFunction = "";
|
||||
// Parameter to be passed to function
|
||||
std::string serializedParams;
|
||||
std::string serializedParams = "";
|
||||
// Result of function call
|
||||
std::string serializedResult;
|
||||
std::string serializedResult = "";
|
||||
// JobID used to identify a job and match it to callback
|
||||
unsigned int id;
|
||||
unsigned int id = 0;
|
||||
|
||||
bool valid;
|
||||
bool valid = false;
|
||||
};
|
||||
|
||||
// Asynchronous working environment
|
||||
|
@ -68,7 +62,7 @@ public:
|
|||
void *run();
|
||||
|
||||
private:
|
||||
AsyncEngine *jobDispatcher;
|
||||
AsyncEngine *jobDispatcher = nullptr;
|
||||
};
|
||||
|
||||
// Asynchornous thread and job management
|
||||
|
@ -76,7 +70,7 @@ class AsyncEngine {
|
|||
friend class AsyncWorkerThread;
|
||||
typedef void (*StateInitializer)(lua_State *L, int top);
|
||||
public:
|
||||
AsyncEngine();
|
||||
AsyncEngine() {};
|
||||
~AsyncEngine();
|
||||
|
||||
/**
|
||||
|
@ -137,13 +131,13 @@ protected:
|
|||
|
||||
private:
|
||||
// Variable locking the engine against further modification
|
||||
bool initDone;
|
||||
bool initDone = false;
|
||||
|
||||
// Internal store for registred state initializers
|
||||
std::vector<StateInitializer> stateInitializers;
|
||||
|
||||
// Internal counter to create job IDs
|
||||
unsigned int jobIdCounter;
|
||||
unsigned int jobIdCounter = 0;
|
||||
|
||||
// Mutex to protect job queue
|
||||
std::mutex jobQueueMutex;
|
||||
|
|
|
@ -71,9 +71,7 @@ public:
|
|||
ScriptApiBase
|
||||
*/
|
||||
|
||||
ScriptApiBase::ScriptApiBase() :
|
||||
m_luastackmutex(),
|
||||
m_gamedef(NULL)
|
||||
ScriptApiBase::ScriptApiBase()
|
||||
{
|
||||
#ifdef SCRIPTAPI_LOCK_DEBUG
|
||||
m_lock_recursion_count = 0;
|
||||
|
@ -111,14 +109,6 @@ ScriptApiBase::ScriptApiBase() :
|
|||
|
||||
lua_pushstring(m_luastack, porting::getPlatformName());
|
||||
lua_setglobal(m_luastack, "PLATFORM");
|
||||
|
||||
// m_secure gets set to true inside
|
||||
// ScriptApiSecurity::initializeSecurity(), if neccessary.
|
||||
// Default to false otherwise
|
||||
m_secure = false;
|
||||
|
||||
m_environment = NULL;
|
||||
m_guiengine = NULL;
|
||||
}
|
||||
|
||||
ScriptApiBase::~ScriptApiBase()
|
||||
|
|
|
@ -119,7 +119,7 @@ protected:
|
|||
|
||||
std::recursive_mutex m_luastackmutex;
|
||||
std::string m_last_run_mod;
|
||||
bool m_secure;
|
||||
bool m_secure = false;
|
||||
#ifdef SCRIPTAPI_LOCK_DEBUG
|
||||
int m_lock_recursion_count;
|
||||
std::thread::id m_owning_thread;
|
||||
|
@ -128,11 +128,11 @@ protected:
|
|||
private:
|
||||
static int luaPanic(lua_State *L);
|
||||
|
||||
lua_State* m_luastack;
|
||||
lua_State *m_luastack = nullptr;
|
||||
|
||||
IGameDef* m_gamedef;
|
||||
Environment* m_environment;
|
||||
GUIEngine* m_guiengine;
|
||||
IGameDef *m_gamedef = nullptr;
|
||||
Environment *m_environment = nullptr;
|
||||
GUIEngine *m_guiengine = nullptr;
|
||||
};
|
||||
|
||||
#endif /* S_BASE_H_ */
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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[];
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -67,7 +67,7 @@ private:
|
|||
|
||||
static int l_get_movement(lua_State *L);
|
||||
|
||||
LocalPlayer *m_localplayer;
|
||||
LocalPlayer *m_localplayer = nullptr;
|
||||
|
||||
public:
|
||||
LuaLocalPlayer(LocalPlayer *m);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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[];
|
||||
|
|
|
@ -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[];
|
||||
|
|
|
@ -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_ */
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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[];
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue