C++11 cleanup on constructors (#6000)
* C++11 cleanup on constructors dir script
This commit is contained in:
parent
4a78949083
commit
4a5e8ad343
@ -33,13 +33,6 @@ extern "C" {
|
|||||||
#include "porting.h"
|
#include "porting.h"
|
||||||
#include "common/c_internal.h"
|
#include "common/c_internal.h"
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
AsyncEngine::AsyncEngine() :
|
|
||||||
initDone(false),
|
|
||||||
jobIdCounter(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
AsyncEngine::~AsyncEngine()
|
AsyncEngine::~AsyncEngine()
|
||||||
{
|
{
|
||||||
|
@ -39,24 +39,18 @@ class AsyncEngine;
|
|||||||
// Data required to queue a job
|
// Data required to queue a job
|
||||||
struct LuaJobInfo
|
struct LuaJobInfo
|
||||||
{
|
{
|
||||||
LuaJobInfo() :
|
LuaJobInfo() {};
|
||||||
serializedFunction(""),
|
|
||||||
serializedParams(""),
|
|
||||||
serializedResult(""),
|
|
||||||
id(0),
|
|
||||||
valid(false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
// Function to be called in async environment
|
// Function to be called in async environment
|
||||||
std::string serializedFunction;
|
std::string serializedFunction = "";
|
||||||
// Parameter to be passed to function
|
// Parameter to be passed to function
|
||||||
std::string serializedParams;
|
std::string serializedParams = "";
|
||||||
// Result of function call
|
// Result of function call
|
||||||
std::string serializedResult;
|
std::string serializedResult = "";
|
||||||
// JobID used to identify a job and match it to callback
|
// 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
|
// Asynchronous working environment
|
||||||
@ -68,7 +62,7 @@ public:
|
|||||||
void *run();
|
void *run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AsyncEngine *jobDispatcher;
|
AsyncEngine *jobDispatcher = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Asynchornous thread and job management
|
// Asynchornous thread and job management
|
||||||
@ -76,7 +70,7 @@ class AsyncEngine {
|
|||||||
friend class AsyncWorkerThread;
|
friend class AsyncWorkerThread;
|
||||||
typedef void (*StateInitializer)(lua_State *L, int top);
|
typedef void (*StateInitializer)(lua_State *L, int top);
|
||||||
public:
|
public:
|
||||||
AsyncEngine();
|
AsyncEngine() {};
|
||||||
~AsyncEngine();
|
~AsyncEngine();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,13 +131,13 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Variable locking the engine against further modification
|
// Variable locking the engine against further modification
|
||||||
bool initDone;
|
bool initDone = false;
|
||||||
|
|
||||||
// Internal store for registred state initializers
|
// Internal store for registred state initializers
|
||||||
std::vector<StateInitializer> stateInitializers;
|
std::vector<StateInitializer> stateInitializers;
|
||||||
|
|
||||||
// Internal counter to create job IDs
|
// Internal counter to create job IDs
|
||||||
unsigned int jobIdCounter;
|
unsigned int jobIdCounter = 0;
|
||||||
|
|
||||||
// Mutex to protect job queue
|
// Mutex to protect job queue
|
||||||
std::mutex jobQueueMutex;
|
std::mutex jobQueueMutex;
|
||||||
|
@ -71,9 +71,7 @@ public:
|
|||||||
ScriptApiBase
|
ScriptApiBase
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ScriptApiBase::ScriptApiBase() :
|
ScriptApiBase::ScriptApiBase()
|
||||||
m_luastackmutex(),
|
|
||||||
m_gamedef(NULL)
|
|
||||||
{
|
{
|
||||||
#ifdef SCRIPTAPI_LOCK_DEBUG
|
#ifdef SCRIPTAPI_LOCK_DEBUG
|
||||||
m_lock_recursion_count = 0;
|
m_lock_recursion_count = 0;
|
||||||
@ -111,14 +109,6 @@ ScriptApiBase::ScriptApiBase() :
|
|||||||
|
|
||||||
lua_pushstring(m_luastack, porting::getPlatformName());
|
lua_pushstring(m_luastack, porting::getPlatformName());
|
||||||
lua_setglobal(m_luastack, "PLATFORM");
|
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()
|
ScriptApiBase::~ScriptApiBase()
|
||||||
|
@ -119,7 +119,7 @@ protected:
|
|||||||
|
|
||||||
std::recursive_mutex m_luastackmutex;
|
std::recursive_mutex m_luastackmutex;
|
||||||
std::string m_last_run_mod;
|
std::string m_last_run_mod;
|
||||||
bool m_secure;
|
bool m_secure = false;
|
||||||
#ifdef SCRIPTAPI_LOCK_DEBUG
|
#ifdef SCRIPTAPI_LOCK_DEBUG
|
||||||
int m_lock_recursion_count;
|
int m_lock_recursion_count;
|
||||||
std::thread::id m_owning_thread;
|
std::thread::id m_owning_thread;
|
||||||
@ -128,11 +128,11 @@ protected:
|
|||||||
private:
|
private:
|
||||||
static int luaPanic(lua_State *L);
|
static int luaPanic(lua_State *L);
|
||||||
|
|
||||||
lua_State* m_luastack;
|
lua_State *m_luastack = nullptr;
|
||||||
|
|
||||||
IGameDef* m_gamedef;
|
IGameDef *m_gamedef = nullptr;
|
||||||
Environment* m_environment;
|
Environment *m_environment = nullptr;
|
||||||
GUIEngine* m_guiengine;
|
GUIEngine *m_guiengine = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* S_BASE_H_ */
|
#endif /* S_BASE_H_ */
|
||||||
|
@ -300,20 +300,19 @@ int LuaAreaStore::l_from_file(lua_State *L)
|
|||||||
return deserialization_helper(L, o->as, is);
|
return deserialization_helper(L, o->as, is);
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaAreaStore::LuaAreaStore()
|
LuaAreaStore::LuaAreaStore() : as(AreaStore::getOptimalImplementation())
|
||||||
{
|
{
|
||||||
this->as = AreaStore::getOptimalImplementation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaAreaStore::LuaAreaStore(const std::string &type)
|
LuaAreaStore::LuaAreaStore(const std::string &type)
|
||||||
{
|
{
|
||||||
#if USE_SPATIAL
|
#if USE_SPATIAL
|
||||||
if (type == "LibSpatial") {
|
if (type == "LibSpatial") {
|
||||||
this->as = new SpatialAreaStore();
|
as = new SpatialAreaStore();
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
this->as = new VectorAreaStore();
|
as = new VectorAreaStore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ private:
|
|||||||
static int l_from_file(lua_State *L);
|
static int l_from_file(lua_State *L);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AreaStore *as;
|
AreaStore *as = nullptr;
|
||||||
|
|
||||||
LuaAreaStore();
|
LuaAreaStore();
|
||||||
LuaAreaStore(const std::string &type);
|
LuaAreaStore(const std::string &type);
|
||||||
|
@ -4,9 +4,8 @@
|
|||||||
#include "content_cao.h"
|
#include "content_cao.h"
|
||||||
#include "camera.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)
|
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_look_horizontal(lua_State *L);
|
||||||
static int l_get_aspect_ratio(lua_State *L);
|
static int l_get_aspect_ratio(lua_State *L);
|
||||||
|
|
||||||
Camera *m_camera;
|
Camera *m_camera = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LuaCamera(Camera *m);
|
LuaCamera(Camera *m);
|
||||||
|
@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
class ItemStackMetaRef : public MetaDataRef
|
class ItemStackMetaRef : public MetaDataRef
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
ItemStack *istack;
|
ItemStack *istack = nullptr;
|
||||||
|
|
||||||
static const char className[];
|
static const char className[];
|
||||||
static const luaL_Reg methods[];
|
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 "l_internal.h"
|
||||||
#include "script/common/c_converter.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)
|
void LuaLocalPlayer::create(lua_State *L, LocalPlayer *m)
|
||||||
|
@ -67,7 +67,7 @@ private:
|
|||||||
|
|
||||||
static int l_get_movement(lua_State *L);
|
static int l_get_movement(lua_State *L);
|
||||||
|
|
||||||
LocalPlayer *m_localplayer;
|
LocalPlayer *m_localplayer = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LuaLocalPlayer(LocalPlayer *m);
|
LuaLocalPlayer(LocalPlayer *m);
|
||||||
|
@ -24,9 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "minimap.h"
|
#include "minimap.h"
|
||||||
#include "settings.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)
|
void LuaMinimap::create(lua_State *L, Minimap *m)
|
||||||
|
@ -48,7 +48,7 @@ private:
|
|||||||
static int l_set_shape(lua_State *L);
|
static int l_set_shape(lua_State *L);
|
||||||
static int l_get_shape(lua_State *L);
|
static int l_get_shape(lua_State *L);
|
||||||
|
|
||||||
Minimap *m_minimap;
|
Minimap *m_minimap = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LuaMinimap(Minimap *m);
|
LuaMinimap(Minimap *m);
|
||||||
|
@ -171,14 +171,12 @@ bool NodeMetaRef::handleFromTable(lua_State *L, int table, Metadata *_meta)
|
|||||||
|
|
||||||
NodeMetaRef::NodeMetaRef(v3s16 p, ServerEnvironment *env):
|
NodeMetaRef::NodeMetaRef(v3s16 p, ServerEnvironment *env):
|
||||||
m_p(p),
|
m_p(p),
|
||||||
m_env(env),
|
m_env(env)
|
||||||
m_is_local(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeMetaRef::NodeMetaRef(Metadata *meta):
|
NodeMetaRef::NodeMetaRef(Metadata *meta):
|
||||||
m_meta(meta),
|
m_meta(meta)
|
||||||
m_is_local(true)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,9 +34,9 @@ class NodeMetadata;
|
|||||||
class NodeMetaRef : public MetaDataRef {
|
class NodeMetaRef : public MetaDataRef {
|
||||||
private:
|
private:
|
||||||
v3s16 m_p;
|
v3s16 m_p;
|
||||||
ServerEnvironment *m_env;
|
ServerEnvironment *m_env = nullptr;
|
||||||
Metadata *m_meta;
|
Metadata *m_meta = nullptr;
|
||||||
bool m_is_local;
|
bool m_is_local = false;
|
||||||
|
|
||||||
static const char className[];
|
static const char className[];
|
||||||
static const luaL_Reg methodsServer[];
|
static const luaL_Reg methodsServer[];
|
||||||
|
@ -29,7 +29,7 @@ class NodeTimerRef : public ModApiBase
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
v3s16 m_p;
|
v3s16 m_p;
|
||||||
ServerEnvironment *m_env;
|
ServerEnvironment *m_env = nullptr;
|
||||||
|
|
||||||
static const char className[];
|
static const char className[];
|
||||||
static const luaL_Reg methods[];
|
static const luaL_Reg methods[];
|
||||||
|
@ -33,16 +33,29 @@ class RemotePlayer;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class ObjectRef : public ModApiBase {
|
class ObjectRef : public ModApiBase {
|
||||||
private:
|
|
||||||
ServerActiveObject *m_object;
|
|
||||||
|
|
||||||
static const char className[];
|
|
||||||
static const luaL_Reg methods[];
|
|
||||||
public:
|
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 ObjectRef *checkobject(lua_State *L, int narg);
|
||||||
|
|
||||||
static ServerActiveObject* getobject(ObjectRef *ref);
|
static ServerActiveObject* getobject(ObjectRef *ref);
|
||||||
private:
|
private:
|
||||||
|
ServerActiveObject *m_object = nullptr;
|
||||||
|
|
||||||
|
static const char className[];
|
||||||
|
static const luaL_Reg methods[];
|
||||||
|
|
||||||
|
|
||||||
static LuaEntitySAO* getluaobject(ObjectRef *ref);
|
static LuaEntitySAO* getluaobject(ObjectRef *ref);
|
||||||
|
|
||||||
static PlayerSAO* getplayersao(ObjectRef *ref);
|
static PlayerSAO* getplayersao(ObjectRef *ref);
|
||||||
@ -319,18 +332,6 @@ private:
|
|||||||
// get_nametag_attributes(self)
|
// get_nametag_attributes(self)
|
||||||
static int l_get_nametag_attributes(lua_State *L);
|
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_ */
|
#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) :
|
LuaSettings::LuaSettings(Settings *settings, const std::string &filename) :
|
||||||
m_settings(settings),
|
m_settings(settings),
|
||||||
m_filename(filename),
|
m_filename(filename)
|
||||||
m_is_own_settings(false),
|
|
||||||
m_write_allowed(true)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,10 +57,10 @@ private:
|
|||||||
// to_table(self) -> {[key1]=value1,...}
|
// to_table(self) -> {[key1]=value1,...}
|
||||||
static int l_to_table(lua_State *L);
|
static int l_to_table(lua_State *L);
|
||||||
|
|
||||||
Settings *m_settings;
|
Settings *m_settings = nullptr;
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
bool m_is_own_settings;
|
bool m_is_own_settings = false;
|
||||||
bool m_write_allowed;
|
bool m_write_allowed = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LuaSettings(Settings *settings, const std::string &filename);
|
LuaSettings(Settings *settings, const std::string &filename);
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
class StorageRef : public MetaDataRef
|
class StorageRef : public MetaDataRef
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
ModMetadata *m_object;
|
ModMetadata *m_object = nullptr;
|
||||||
|
|
||||||
static const char className[];
|
static const char className[];
|
||||||
static const luaL_Reg methods[];
|
static const luaL_Reg methods[];
|
||||||
|
@ -365,22 +365,17 @@ int LuaVoxelManip::l_get_emerged_area(lua_State *L)
|
|||||||
return 2;
|
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)
|
LuaVoxelManip::LuaVoxelManip(Map *map, v3s16 p1, v3s16 p2)
|
||||||
{
|
{
|
||||||
this->vm = new MMVManip(map);
|
vm = new MMVManip(map);
|
||||||
this->is_mapgen_vm = false;
|
|
||||||
|
|
||||||
v3s16 bp1 = getNodeBlockPos(p1);
|
v3s16 bp1 = getNodeBlockPos(p1);
|
||||||
v3s16 bp2 = getNodeBlockPos(p2);
|
v3s16 bp2 = getNodeBlockPos(p2);
|
||||||
|
@ -35,7 +35,7 @@ class LuaVoxelManip : public ModApiBase
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::map<v3s16, MapBlock *> modified_blocks;
|
std::map<v3s16, MapBlock *> modified_blocks;
|
||||||
bool is_mapgen_vm;
|
bool is_mapgen_vm = false;
|
||||||
|
|
||||||
static const char className[];
|
static const char className[];
|
||||||
static const luaL_Reg methods[];
|
static const luaL_Reg methods[];
|
||||||
@ -65,7 +65,7 @@ private:
|
|||||||
static int l_get_emerged_area(lua_State *L);
|
static int l_get_emerged_area(lua_State *L);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MMVManip *vm;
|
MMVManip *vm = nullptr;
|
||||||
|
|
||||||
LuaVoxelManip(MMVManip *mmvm, bool is_mapgen_vm);
|
LuaVoxelManip(MMVManip *mmvm, bool is_mapgen_vm);
|
||||||
LuaVoxelManip(Map *map, v3s16 p1, v3s16 p2);
|
LuaVoxelManip(Map *map, v3s16 p1, v3s16 p2);
|
||||||
|
@ -60,8 +60,6 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
Thread::Thread(const std::string &name) :
|
Thread::Thread(const std::string &name) :
|
||||||
m_name(name),
|
m_name(name),
|
||||||
m_retval(NULL),
|
|
||||||
m_joinable(false),
|
|
||||||
m_request_stop(false),
|
m_request_stop(false),
|
||||||
m_running(false)
|
m_running(false)
|
||||||
{
|
{
|
||||||
@ -130,7 +128,7 @@ bool Thread::wait()
|
|||||||
m_thread_obj->join();
|
m_thread_obj->join();
|
||||||
|
|
||||||
delete m_thread_obj;
|
delete m_thread_obj;
|
||||||
m_thread_obj = NULL;
|
m_thread_obj = nullptr;
|
||||||
|
|
||||||
assert(m_running == false);
|
assert(m_running == false);
|
||||||
m_joinable = false;
|
m_joinable = false;
|
||||||
@ -162,7 +160,7 @@ bool Thread::kill()
|
|||||||
wait();
|
wait();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_retval = NULL;
|
m_retval = nullptr;
|
||||||
m_joinable = false;
|
m_joinable = false;
|
||||||
m_request_stop = false;
|
m_request_stop = false;
|
||||||
|
|
||||||
|
@ -145,8 +145,8 @@ private:
|
|||||||
|
|
||||||
static void threadProc(Thread *thr);
|
static void threadProc(Thread *thr);
|
||||||
|
|
||||||
void *m_retval;
|
void *m_retval = nullptr;
|
||||||
bool m_joinable;
|
bool m_joinable = false;
|
||||||
std::atomic<bool> m_request_stop;
|
std::atomic<bool> m_request_stop;
|
||||||
std::atomic<bool> m_running;
|
std::atomic<bool> m_running;
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
|
@ -70,16 +70,16 @@ public:
|
|||||||
virtual void unregisterModStorage(const std::string &name) {}
|
virtual void unregisterModStorage(const std::string &name) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IItemDefManager *m_itemdef;
|
IItemDefManager *m_itemdef = nullptr;
|
||||||
INodeDefManager *m_nodedef;
|
INodeDefManager *m_nodedef = nullptr;
|
||||||
ICraftDefManager *m_craftdef;
|
ICraftDefManager *m_craftdef = nullptr;
|
||||||
ITextureSource *m_texturesrc;
|
ITextureSource *m_texturesrc = nullptr;
|
||||||
IShaderSource *m_shadersrc;
|
IShaderSource *m_shadersrc = nullptr;
|
||||||
ISoundManager *m_soundmgr;
|
ISoundManager *m_soundmgr = nullptr;
|
||||||
MtEventManager *m_eventmgr;
|
MtEventManager *m_eventmgr = nullptr;
|
||||||
scene::ISceneManager *m_scenemgr;
|
scene::ISceneManager *m_scenemgr = nullptr;
|
||||||
IRollbackManager *m_rollbackmgr;
|
IRollbackManager *m_rollbackmgr = nullptr;
|
||||||
EmergeManager *m_emergemgr;
|
EmergeManager *m_emergemgr = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,12 +53,7 @@ void TestConnection::runTests(IGameDef *gamedef)
|
|||||||
|
|
||||||
struct Handler : public con::PeerHandler
|
struct Handler : public con::PeerHandler
|
||||||
{
|
{
|
||||||
Handler(const char *a_name)
|
Handler(const char *a_name) : name(a_name) {}
|
||||||
{
|
|
||||||
count = 0;
|
|
||||||
last_id = 0;
|
|
||||||
name = a_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void peerAdded(con::Peer *peer)
|
void peerAdded(con::Peer *peer)
|
||||||
{
|
{
|
||||||
@ -76,8 +71,8 @@ struct Handler : public con::PeerHandler
|
|||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 count;
|
s32 count = 0;
|
||||||
u16 last_id;
|
u16 last_id = 0;
|
||||||
const char *name;
|
const char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ const Area *AreaStore::getArea(u32 id) const
|
|||||||
{
|
{
|
||||||
AreaMap::const_iterator it = areas_map.find(id);
|
AreaMap::const_iterator it = areas_map.find(id);
|
||||||
if (it == areas_map.end())
|
if (it == areas_map.end())
|
||||||
return NULL;
|
return nullptr;
|
||||||
return &it->second;
|
return &it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ bool SpatialAreaStore::insertArea(Area *a)
|
|||||||
if (!areas_map.insert(std::make_pair(a->id, *a)).second)
|
if (!areas_map.insert(std::make_pair(a->id, *a)).second)
|
||||||
// ID is not unique
|
// ID is not unique
|
||||||
return false;
|
return false;
|
||||||
m_tree->insertData(0, NULL, get_spatial_region(a->minedge, a->maxedge), a->id);
|
m_tree->insertData(0, nullptr, get_spatial_region(a->minedge, a->maxedge), a->id);
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -38,14 +38,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
|
|
||||||
struct Area {
|
struct Area {
|
||||||
Area() : id(U32_MAX) {}
|
Area() {}
|
||||||
Area(const v3s16 &mine, const v3s16 &maxe) :
|
Area(const v3s16 &mine, const v3s16 &maxe) :
|
||||||
id(U32_MAX), minedge(mine), maxedge(maxe)
|
minedge(mine), maxedge(maxe)
|
||||||
{
|
{
|
||||||
sortBoxVerticies(minedge, maxedge);
|
sortBoxVerticies(minedge, maxedge);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 id;
|
u32 id = U32_MAX;
|
||||||
v3s16 minedge, maxedge;
|
v3s16 minedge, maxedge;
|
||||||
std::string data;
|
std::string data;
|
||||||
};
|
};
|
||||||
@ -54,10 +54,7 @@ struct Area {
|
|||||||
class AreaStore {
|
class AreaStore {
|
||||||
public:
|
public:
|
||||||
AreaStore() :
|
AreaStore() :
|
||||||
m_cache_enabled(true),
|
m_res_cache(1000, &cacheMiss, this)
|
||||||
m_cacheblock_radius(64),
|
|
||||||
m_res_cache(1000, &cacheMiss, this),
|
|
||||||
m_next_id(0)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual ~AreaStore() {}
|
virtual ~AreaStore() {}
|
||||||
@ -123,13 +120,13 @@ private:
|
|||||||
/// Called by the cache when a value isn't found in the cache.
|
/// Called by the cache when a value isn't found in the cache.
|
||||||
static void cacheMiss(void *data, const v3s16 &mpos, std::vector<Area *> *dest);
|
static void cacheMiss(void *data, const v3s16 &mpos, std::vector<Area *> *dest);
|
||||||
|
|
||||||
bool m_cache_enabled;
|
bool m_cache_enabled = true;
|
||||||
/// Range, in nodes, of the getAreasForPos cache.
|
/// Range, in nodes, of the getAreasForPos cache.
|
||||||
/// If you modify this, call invalidateCache()
|
/// If you modify this, call invalidateCache()
|
||||||
u8 m_cacheblock_radius;
|
u8 m_cacheblock_radius = 64;
|
||||||
LRUCache<v3s16, std::vector<Area *> > m_res_cache;
|
LRUCache<v3s16, std::vector<Area *> > m_res_cache;
|
||||||
|
|
||||||
u32 m_next_id;
|
u32 m_next_id = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -165,8 +162,8 @@ protected:
|
|||||||
virtual void getAreasForPosImpl(std::vector<Area *> *result, v3s16 pos);
|
virtual void getAreasForPosImpl(std::vector<Area *> *result, v3s16 pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SpatialIndex::ISpatialIndex *m_tree;
|
SpatialIndex::ISpatialIndex *m_tree = nullptr;
|
||||||
SpatialIndex::IStorageManager *m_storagemanager;
|
SpatialIndex::IStorageManager *m_storagemanager = nullptr;
|
||||||
|
|
||||||
class VectorResultVisitor : public SpatialIndex::IVisitor {
|
class VectorResultVisitor : public SpatialIndex::IVisitor {
|
||||||
public:
|
public:
|
||||||
@ -194,8 +191,8 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SpatialAreaStore *m_store;
|
SpatialAreaStore *m_store = nullptr;
|
||||||
std::vector<Area *> *m_result;
|
std::vector<Area *> *m_result = nullptr;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ std::string generate_srp_verifier(const std::string &name,
|
|||||||
// get modified if &salt_ptr isn't NULL.
|
// get modified if &salt_ptr isn't NULL.
|
||||||
char *salt_ptr = (char *)salt.c_str();
|
char *salt_ptr = (char *)salt.c_str();
|
||||||
|
|
||||||
char *bytes_v = NULL;
|
char *bytes_v = nullptr;
|
||||||
size_t verifier_len = 0;
|
size_t verifier_len = 0;
|
||||||
gen_srp_v(name, password, &salt_ptr, &salt_len, &bytes_v, &verifier_len);
|
gen_srp_v(name, password, &salt_ptr, &salt_len, &bytes_v, &verifier_len);
|
||||||
std::string verifier = std::string(bytes_v, verifier_len);
|
std::string verifier = std::string(bytes_v, verifier_len);
|
||||||
@ -84,9 +84,9 @@ void generate_srp_verifier_and_salt(const std::string &name,
|
|||||||
const std::string &password, std::string *verifier,
|
const std::string &password, std::string *verifier,
|
||||||
std::string *salt)
|
std::string *salt)
|
||||||
{
|
{
|
||||||
char *bytes_v = NULL;
|
char *bytes_v = nullptr;
|
||||||
size_t verifier_len;
|
size_t verifier_len;
|
||||||
char *salt_ptr = NULL;
|
char *salt_ptr = nullptr;
|
||||||
size_t salt_len;
|
size_t salt_len;
|
||||||
gen_srp_v(name, password, &salt_ptr, &salt_len, &bytes_v, &verifier_len);
|
gen_srp_v(name, password, &salt_ptr, &salt_len, &bytes_v, &verifier_len);
|
||||||
*verifier = std::string(bytes_v, verifier_len);
|
*verifier = std::string(bytes_v, verifier_len);
|
||||||
|
@ -30,8 +30,7 @@ EnrichedString::EnrichedString()
|
|||||||
EnrichedString::EnrichedString(const std::wstring &string,
|
EnrichedString::EnrichedString(const std::wstring &string,
|
||||||
const std::vector<SColor> &colors):
|
const std::vector<SColor> &colors):
|
||||||
m_string(string),
|
m_string(string),
|
||||||
m_colors(colors),
|
m_colors(colors)
|
||||||
m_has_background(false)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
EnrichedString::EnrichedString(const std::wstring &s, const SColor &color)
|
EnrichedString::EnrichedString(const std::wstring &s, const SColor &color)
|
||||||
|
@ -84,7 +84,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
std::wstring m_string;
|
std::wstring m_string;
|
||||||
std::vector<irr::video::SColor> m_colors;
|
std::vector<irr::video::SColor> m_colors;
|
||||||
bool m_has_background;
|
bool m_has_background = false;
|
||||||
irr::video::SColor m_background;
|
irr::video::SColor m_background;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ inline aabb3f getNodeBox(v3s16 p, float d)
|
|||||||
class IntervalLimiter
|
class IntervalLimiter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IntervalLimiter() : m_accumulator(0) {}
|
IntervalLimiter() {}
|
||||||
/*
|
/*
|
||||||
dtime: time from last call to this method
|
dtime: time from last call to this method
|
||||||
wanted_interval: interval wanted
|
wanted_interval: interval wanted
|
||||||
@ -300,7 +300,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float m_accumulator;
|
float m_accumulator = 0.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,16 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "../exceptions.h"
|
#include "../exceptions.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
PointedThing::PointedThing():
|
|
||||||
type(POINTEDTHING_NOTHING),
|
|
||||||
node_undersurface(0,0,0),
|
|
||||||
node_abovesurface(0,0,0),
|
|
||||||
node_real_undersurface(0,0,0),
|
|
||||||
intersection_point(0,0,0),
|
|
||||||
intersection_normal(0,0,0),
|
|
||||||
object_id(-1)
|
|
||||||
{}
|
|
||||||
|
|
||||||
std::string PointedThing::dump() const
|
std::string PointedThing::dump() const
|
||||||
{
|
{
|
||||||
std::ostringstream os(std::ios::binary);
|
std::ostringstream os(std::ios::binary);
|
||||||
|
@ -36,7 +36,7 @@ enum PointedThingType
|
|||||||
struct PointedThing
|
struct PointedThing
|
||||||
{
|
{
|
||||||
//! The type of the pointed object.
|
//! The type of the pointed object.
|
||||||
PointedThingType type;
|
PointedThingType type = POINTEDTHING_NOTHING;
|
||||||
/*!
|
/*!
|
||||||
* Only valid if type is POINTEDTHING_NODE.
|
* Only valid if type is POINTEDTHING_NODE.
|
||||||
* The coordinates of the node which owns the
|
* The coordinates of the node which owns the
|
||||||
@ -74,9 +74,9 @@ struct PointedThing
|
|||||||
* Only valid if type is POINTEDTHING_OBJECT.
|
* Only valid if type is POINTEDTHING_OBJECT.
|
||||||
* The ID of the object the ray hit.
|
* The ID of the object the ray hit.
|
||||||
*/
|
*/
|
||||||
s16 object_id;
|
s16 object_id = -1;
|
||||||
|
|
||||||
PointedThing();
|
PointedThing() {};
|
||||||
std::string dump() const;
|
std::string dump() const;
|
||||||
void serialize(std::ostream &os) const;
|
void serialize(std::ostream &os) const;
|
||||||
void deSerialize(std::istream &is);
|
void deSerialize(std::istream &is);
|
||||||
|
@ -422,7 +422,7 @@ bool deSerializeStringToStruct(std::string valstr,
|
|||||||
|
|
||||||
char *fmtpos, *fmt = &format[0];
|
char *fmtpos, *fmt = &format[0];
|
||||||
while ((f = strtok_r(fmt, ",", &fmtpos)) && s) {
|
while ((f = strtok_r(fmt, ",", &fmtpos)) && s) {
|
||||||
fmt = NULL;
|
fmt = nullptr;
|
||||||
|
|
||||||
bool is_unsigned = false;
|
bool is_unsigned = false;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
@ -510,7 +510,7 @@ bool deSerializeStringToStruct(std::string valstr,
|
|||||||
bufpos += sizeof(std::string *);
|
bufpos += sizeof(std::string *);
|
||||||
strs_alloced.push_back(str);
|
strs_alloced.push_back(str);
|
||||||
|
|
||||||
s = *snext ? snext + 1 : NULL;
|
s = *snext ? snext + 1 : nullptr;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
while (*s == ' ' || *s == '\t')
|
while (*s == ' ' || *s == '\t')
|
||||||
@ -582,7 +582,7 @@ bool serializeStructToString(std::string *out,
|
|||||||
char *bufpos = (char *) value;
|
char *bufpos = (char *) value;
|
||||||
char *fmtpos, *fmt = &format[0];
|
char *fmtpos, *fmt = &format[0];
|
||||||
while ((f = strtok_r(fmt, ",", &fmtpos))) {
|
while ((f = strtok_r(fmt, ",", &fmtpos))) {
|
||||||
fmt = NULL;
|
fmt = nullptr;
|
||||||
bool is_unsigned = false;
|
bool is_unsigned = false;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
char valtype = *f;
|
char valtype = *f;
|
||||||
|
@ -454,8 +454,7 @@ class BufReader {
|
|||||||
public:
|
public:
|
||||||
BufReader(const u8 *data_, size_t size_) :
|
BufReader(const u8 *data_, size_t size_) :
|
||||||
data(data_),
|
data(data_),
|
||||||
size(size_),
|
size(size_)
|
||||||
pos(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,7 +514,7 @@ public:
|
|||||||
|
|
||||||
const u8 *data;
|
const u8 *data;
|
||||||
size_t size;
|
size_t size;
|
||||||
size_t pos;
|
size_t pos = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef MAKE_BUFREADER_GET_FXN
|
#undef MAKE_BUFREADER_GET_FXN
|
||||||
|
@ -66,15 +66,6 @@ SHA1::SHA1()
|
|||||||
{
|
{
|
||||||
// make sure that the data type is the right size
|
// make sure that the data type is the right size
|
||||||
assert( sizeof( Uint32 ) * 5 == 20 );
|
assert( sizeof( Uint32 ) * 5 == 20 );
|
||||||
|
|
||||||
// initialize
|
|
||||||
H0 = 0x67452301;
|
|
||||||
H1 = 0xefcdab89;
|
|
||||||
H2 = 0x98badcfe;
|
|
||||||
H3 = 0x10325476;
|
|
||||||
H4 = 0xc3d2e1f0;
|
|
||||||
unprocessedBytes = 0;
|
|
||||||
size = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor ********************************************************
|
// Destructor ********************************************************
|
||||||
|
@ -31,10 +31,14 @@ class SHA1
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// fields
|
// fields
|
||||||
Uint32 H0, H1, H2, H3, H4;
|
Uint32 H0 = 0x67452301;
|
||||||
|
Uint32 H1 = 0xefcdab89;
|
||||||
|
Uint32 H2 = 0x98badcfe;
|
||||||
|
Uint32 H3 = 0x10325476;
|
||||||
|
Uint32 H4 = 0xc3d2e1f0;
|
||||||
unsigned char bytes[64];
|
unsigned char bytes[64];
|
||||||
int unprocessedBytes;
|
int unprocessedBytes = 0;
|
||||||
Uint32 size;
|
Uint32 size = 0;
|
||||||
void process();
|
void process();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -27,7 +27,6 @@ TimeTaker::TimeTaker(const std::string &name, u64 *result, TimePrecision prec)
|
|||||||
{
|
{
|
||||||
m_name = name;
|
m_name = name;
|
||||||
m_result = result;
|
m_result = result;
|
||||||
m_running = true;
|
|
||||||
m_precision = prec;
|
m_precision = prec;
|
||||||
m_time1 = porting::getTime(prec);
|
m_time1 = porting::getTime(prec);
|
||||||
}
|
}
|
||||||
@ -36,7 +35,7 @@ u64 TimeTaker::stop(bool quiet)
|
|||||||
{
|
{
|
||||||
if (m_running) {
|
if (m_running) {
|
||||||
u64 dtime = porting::getTime(m_precision) - m_time1;
|
u64 dtime = porting::getTime(m_precision) - m_time1;
|
||||||
if (m_result != NULL) {
|
if (m_result != nullptr) {
|
||||||
(*m_result) += dtime;
|
(*m_result) += dtime;
|
||||||
} else {
|
} else {
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
|
@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
class TimeTaker
|
class TimeTaker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TimeTaker(const std::string &name, u64 *result=NULL,
|
TimeTaker(const std::string &name, u64 *result=nullptr,
|
||||||
TimePrecision prec=PRECISION_MILLI);
|
TimePrecision prec=PRECISION_MILLI);
|
||||||
|
|
||||||
~TimeTaker()
|
~TimeTaker()
|
||||||
@ -45,9 +45,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
u64 m_time1;
|
u64 m_time1;
|
||||||
bool m_running;
|
bool m_running = true;
|
||||||
TimePrecision m_precision;
|
TimePrecision m_precision;
|
||||||
u64 *m_result;
|
u64 *m_result = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user