summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-11-08 20:09:35 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-11-08 20:09:35 +0100
commitf7ef93611cb2429ec3f1f5f77befcd1b5647be37 (patch)
tree37a4899bac07800f753c89d44c115b9f570455ed /source
parentHotfix for ThuGie's crash, with a sanity check in debug mode. (diff)
downloadcuberite-f7ef93611cb2429ec3f1f5f77befcd1b5647be37.tar
cuberite-f7ef93611cb2429ec3f1f5f77befcd1b5647be37.tar.gz
cuberite-f7ef93611cb2429ec3f1f5f77befcd1b5647be37.tar.bz2
cuberite-f7ef93611cb2429ec3f1f5f77befcd1b5647be37.tar.lz
cuberite-f7ef93611cb2429ec3f1f5f77befcd1b5647be37.tar.xz
cuberite-f7ef93611cb2429ec3f1f5f77befcd1b5647be37.tar.zst
cuberite-f7ef93611cb2429ec3f1f5f77befcd1b5647be37.zip
Diffstat (limited to 'source')
-rw-r--r--source/Globals.h4
-rw-r--r--source/PluginManager.h24
-rw-r--r--source/Plugin_Squirrel.cpp21
-rw-r--r--source/Plugin_Squirrel.h16
-rw-r--r--source/SquirrelCommandBinder.cpp20
-rw-r--r--source/SquirrelCommandBinder.h18
-rw-r--r--source/squirrelbindings/SquirrelArray.h24
-rw-r--r--source/squirrelbindings/SquirrelBaseClass.h29
-rw-r--r--source/squirrelbindings/SquirrelBindings.cpp30
-rw-r--r--source/squirrelbindings/SquirrelBindings.h23
-rw-r--r--source/squirrelbindings/SquirrelFunctions.cpp28
-rw-r--r--source/squirrelbindings/SquirrelFunctions.h24
-rw-r--r--source/squirrelbindings/SquirrelObject.h28
13 files changed, 272 insertions, 17 deletions
diff --git a/source/Globals.h b/source/Globals.h
index 40e80bd79..e536559dd 100644
--- a/source/Globals.h
+++ b/source/Globals.h
@@ -128,7 +128,9 @@ typedef unsigned short UInt16;
#endif
#if !defined(ANDROID_NDK)
- #define USE_SQUIRREL
+ // 2012_11_08 _X: Disabled SquirrelVM, because it would crash the server from time to time.
+ // For details see: http://forum.mc-server.org/showthread.php?tid=610
+ // #define USE_SQUIRREL
#endif
#if defined(ANDROID_NDK)
diff --git a/source/PluginManager.h b/source/PluginManager.h
index 8fc74c90c..ebbd0ca89 100644
--- a/source/PluginManager.h
+++ b/source/PluginManager.h
@@ -5,7 +5,11 @@
struct lua_State;
class cLuaCommandBinder;
-class cSquirrelCommandBinder;
+
+#ifdef USE_SQUIRREL
+ class cSquirrelCommandBinder;
+#endif // USE_SQUIRREL
+
class cPlugin;
// fwd: cWorld.h
@@ -124,11 +128,16 @@ public: //tolua_export
cLuaCommandBinder* GetLuaCommandBinder() const { return m_LuaCommandBinder; }
- cSquirrelCommandBinder* GetSquirrelCommandBinder() { return m_SquirrelCommandBinder; }
+ #ifdef USE_SQUIRREL
+ cSquirrelCommandBinder * GetSquirrelCommandBinder() { return m_SquirrelCommandBinder; }
+ #endif // USE_SQUIRREL
bool HasPlugin( cPlugin* a_Plugin ) const;
+
private:
+
friend class cRoot;
+
cPluginManager();
~cPluginManager();
@@ -142,8 +151,15 @@ private:
void ReloadPluginsNow();
void UnloadPluginsNow();
- cLuaCommandBinder* m_LuaCommandBinder;
- cSquirrelCommandBinder* m_SquirrelCommandBinder;
+ cLuaCommandBinder * m_LuaCommandBinder;
+
+ #ifdef USE_SQUIRREL
+ cSquirrelCommandBinder * m_SquirrelCommandBinder;
+ #endif // USE_SQUIRREL
bool m_bReloadPlugins;
}; //tolua_export
+
+
+
+
diff --git a/source/Plugin_Squirrel.cpp b/source/Plugin_Squirrel.cpp
index e11dbc07b..eac4d6a9e 100644
--- a/source/Plugin_Squirrel.cpp
+++ b/source/Plugin_Squirrel.cpp
@@ -1,4 +1,15 @@
+
#include "Globals.h"
+
+
+
+
+#ifdef USE_SUIRREL
+
+
+
+
+
#include "Plugin_Squirrel.h"
#include "squirrelbindings/SquirrelFunctions.h"
#include "squirrelbindings/SquirrelBindings.h"
@@ -386,3 +397,13 @@ bool cPlugin_Squirrel::OnUpdatedSign(
a_Player
);
}
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/Plugin_Squirrel.h b/source/Plugin_Squirrel.h
index 9d27261d0..9980d3a4d 100644
--- a/source/Plugin_Squirrel.h
+++ b/source/Plugin_Squirrel.h
@@ -1,6 +1,16 @@
#pragma once
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
+
#include "Plugin.h"
#include <sqrat.h>
#include "squirrelbindings/SquirrelObject.h"
@@ -51,3 +61,9 @@ protected:
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/SquirrelCommandBinder.cpp b/source/SquirrelCommandBinder.cpp
index 50eae9333..9ff8a43f9 100644
--- a/source/SquirrelCommandBinder.cpp
+++ b/source/SquirrelCommandBinder.cpp
@@ -1,6 +1,16 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
+
#include "SquirrelCommandBinder.h"
#include "Player.h"
#include "Plugin.h"
@@ -96,3 +106,13 @@ bool cSquirrelCommandBinder::HandleCommand( const std::string & a_Command, cPlay
}
return false;
}
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/SquirrelCommandBinder.h b/source/SquirrelCommandBinder.h
index 50e026d06..c2bc4bafe 100644
--- a/source/SquirrelCommandBinder.h
+++ b/source/SquirrelCommandBinder.h
@@ -1,5 +1,16 @@
+
#pragma once
-#include <string>
+
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
+
#include <sqrat.h>
class cPlugin;
@@ -33,3 +44,8 @@ private:
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/squirrelbindings/SquirrelArray.h b/source/squirrelbindings/SquirrelArray.h
index 0c2e34f7f..c54315aae 100644
--- a/source/squirrelbindings/SquirrelArray.h
+++ b/source/squirrelbindings/SquirrelArray.h
@@ -1,5 +1,15 @@
+
#pragma once
-#include <string>
+
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
template <typename T>
class SquirrelArray
@@ -33,4 +43,14 @@ protected:
};
-class SquirrelStringArray : public SquirrelArray<std::string> { }; \ No newline at end of file
+class SquirrelStringArray : public SquirrelArray<std::string> { };
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/squirrelbindings/SquirrelBaseClass.h b/source/squirrelbindings/SquirrelBaseClass.h
index ef03c1a55..36f532611 100644
--- a/source/squirrelbindings/SquirrelBaseClass.h
+++ b/source/squirrelbindings/SquirrelBaseClass.h
@@ -1,11 +1,26 @@
+
#pragma once
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
+
#include "SquirrelBindings.h"
#include "../Plugin_Squirrel.h"
#include "../PluginManager.h"
#include "../Root.h"
#include "../SquirrelCommandBinder.h"
-//The baseclass for squirrel plugins
+
+
+
+
+// The baseclass for squirrel plugins
class cSquirrelBaseClass
{
public:
@@ -38,4 +53,14 @@ public:
protected:
cPlugin_Squirrel *m_Instance;
-}; \ No newline at end of file
+};
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/squirrelbindings/SquirrelBindings.cpp b/source/squirrelbindings/SquirrelBindings.cpp
index 5c6b585f4..a463e55d1 100644
--- a/source/squirrelbindings/SquirrelBindings.cpp
+++ b/source/squirrelbindings/SquirrelBindings.cpp
@@ -1,4 +1,15 @@
+
#include "Globals.h"
+
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
#include "SquirrelBindings.h"
#include "SquirrelFunctions.h"
@@ -7,9 +18,16 @@
#include "../Player.h"
+
+
+
+
using namespace Sqrat;
-#ifdef USE_SQUIRREL
+
+
+
+
void BindSquirrel(HSQUIRRELVM vm)
{
RootTable()
@@ -166,4 +184,12 @@ void BindSquirrel(HSQUIRRELVM vm)
.Const("UpdatedSign", cPluginManager::HOOK_UPDATED_SIGN));
}
-#endif \ No newline at end of file
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/squirrelbindings/SquirrelBindings.h b/source/squirrelbindings/SquirrelBindings.h
index e16311d6a..fef563f4a 100644
--- a/source/squirrelbindings/SquirrelBindings.h
+++ b/source/squirrelbindings/SquirrelBindings.h
@@ -1,11 +1,32 @@
+
#pragma once
+
+
+
#ifdef USE_SQUIRREL
+
+
+
+
#include <squirrel.h>
#include <sqrat.h>
+
+
+
+
void BindSquirrel(HSQUIRRELVM vm);
-#endif
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
+
diff --git a/source/squirrelbindings/SquirrelFunctions.cpp b/source/squirrelbindings/SquirrelFunctions.cpp
index b6410ad2e..0e35f7361 100644
--- a/source/squirrelbindings/SquirrelFunctions.cpp
+++ b/source/squirrelbindings/SquirrelFunctions.cpp
@@ -1,13 +1,29 @@
#include "Globals.h"
+
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
+
#include "SquirrelFunctions.h"
#include "SquirrelBindings.h"
-#ifdef USE_SQUIRREL
+
+
static HSQUIRRELVM squirrelvm = NULL;
+
+
+
+
SQInteger runtimeErrorHandler(HSQUIRRELVM a_VM)
{
const SQChar *sErr = 0;
@@ -67,4 +83,12 @@ void sqPrint(SQChar * text)
LOGINFO("%s", text);
}
-#endif \ No newline at end of file
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/squirrelbindings/SquirrelFunctions.h b/source/squirrelbindings/SquirrelFunctions.h
index 0d08a726c..2b74fb52d 100644
--- a/source/squirrelbindings/SquirrelFunctions.h
+++ b/source/squirrelbindings/SquirrelFunctions.h
@@ -1,6 +1,28 @@
+
#pragma once
+
+#ifdef USE_SQUIRREL
+
+
+
+
#include <sqrat.h>
+
+
+
+
+
HSQUIRRELVM OpenSquirrelVM();
void CloseSquirrelVM();
-void sqPrint(SQChar * text); \ No newline at end of file
+void sqPrint(SQChar * text);
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+
diff --git a/source/squirrelbindings/SquirrelObject.h b/source/squirrelbindings/SquirrelObject.h
index 547dd4e02..a7a44d531 100644
--- a/source/squirrelbindings/SquirrelObject.h
+++ b/source/squirrelbindings/SquirrelObject.h
@@ -1,6 +1,22 @@
+
#pragma once
+
+
+
+
+
+#ifdef USE_SQUIRREL
+
+
+
+
+
#include <sqrat.h>
+
+
+
+
class SquirrelObject
{
public:
@@ -26,4 +42,14 @@ public:
protected:
Sqrat::Object m_SquirrelObject;
-}; \ No newline at end of file
+};
+
+
+
+
+
+#endif // USE_SQUIRREL
+
+
+
+