summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-08-18 01:36:51 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-08-18 01:36:51 +0200
commit7014979bffdc08187c8b91c8aefcb0a862a85187 (patch)
treefd22d73a2485bda09caac3d948f752bca7e380c3 /source
parentBugfix Update [SEE DESC} (diff)
parentFixed LuaWindow destructor causing a crash. (diff)
downloadcuberite-7014979bffdc08187c8b91c8aefcb0a862a85187.tar
cuberite-7014979bffdc08187c8b91c8aefcb0a862a85187.tar.gz
cuberite-7014979bffdc08187c8b91c8aefcb0a862a85187.tar.bz2
cuberite-7014979bffdc08187c8b91c8aefcb0a862a85187.tar.lz
cuberite-7014979bffdc08187c8b91c8aefcb0a862a85187.tar.xz
cuberite-7014979bffdc08187c8b91c8aefcb0a862a85187.tar.zst
cuberite-7014979bffdc08187c8b91c8aefcb0a862a85187.zip
Diffstat (limited to '')
-rw-r--r--source/Bindings.cpp37
-rw-r--r--source/Bindings.h2
-rw-r--r--source/LuaState.cpp31
-rw-r--r--source/LuaWindow.cpp10
-rw-r--r--source/Root.cpp12
-rw-r--r--source/Root.h3
-rw-r--r--source/Server.cpp5
-rw-r--r--source/TNTEntity.cpp4
-rw-r--r--source/TNTEntity.h8
9 files changed, 73 insertions, 39 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 955032df7..30c5e8e34 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 08/16/13 10:46:12.
+** Generated automatically by tolua++-1.0.92 on 08/17/13 23:54:30.
*/
#ifndef __cplusplus
@@ -20372,6 +20372,40 @@ static int tolua_AllToLua_cRoot_SaveAllChunks00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: BroadcastChat of class cRoot */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cRoot_BroadcastChat00
+static int tolua_AllToLua_cRoot_BroadcastChat00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cRoot",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cRoot* self = (cRoot*) tolua_tousertype(tolua_S,1,0);
+ const AString a_Message = ((const AString) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'BroadcastChat'", NULL);
+#endif
+ {
+ self->BroadcastChat(a_Message);
+ tolua_pushcppstring(tolua_S,(const char*)a_Message);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'BroadcastChat'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: GetProtocolVersionTextFromInt of class cRoot */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cRoot_GetProtocolVersionTextFromInt00
static int tolua_AllToLua_cRoot_GetProtocolVersionTextFromInt00(lua_State* tolua_S)
@@ -30174,6 +30208,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"QueueExecuteConsoleCommand",tolua_AllToLua_cRoot_QueueExecuteConsoleCommand00);
tolua_function(tolua_S,"GetTotalChunkCount",tolua_AllToLua_cRoot_GetTotalChunkCount00);
tolua_function(tolua_S,"SaveAllChunks",tolua_AllToLua_cRoot_SaveAllChunks00);
+ tolua_function(tolua_S,"BroadcastChat",tolua_AllToLua_cRoot_BroadcastChat00);
tolua_function(tolua_S,"GetProtocolVersionTextFromInt",tolua_AllToLua_cRoot_GetProtocolVersionTextFromInt00);
tolua_endmodule(tolua_S);
#ifdef __cplusplus
diff --git a/source/Bindings.h b/source/Bindings.h
index a51f3667c..fdc3f39d9 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 08/16/13 10:46:13.
+** Generated automatically by tolua++-1.0.92 on 08/17/13 23:54:30.
*/
/* Exported function */
diff --git a/source/LuaState.cpp b/source/LuaState.cpp
index d1a8613b0..4b84df1e5 100644
--- a/source/LuaState.cpp
+++ b/source/LuaState.cpp
@@ -296,7 +296,6 @@ bool cLuaState::PushFunctionFromRefTable(cRef & a_TableRef, const char * a_FnNam
void cLuaState::Push(const AString & a_String)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushcppstring(m_LuaState, a_String);
m_NumCurrentFunctionArgs += 1;
@@ -309,7 +308,6 @@ void cLuaState::Push(const AString & a_String)
void cLuaState::Push(const AStringVector & a_Vector)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
lua_createtable(m_LuaState, a_Vector.size(), 0);
int newTable = lua_gettop(m_LuaState);
@@ -329,7 +327,6 @@ void cLuaState::Push(const AStringVector & a_Vector)
void cLuaState::PushUserType(void * a_Object, const char * a_Type)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_Object, a_Type);
m_NumCurrentFunctionArgs += 1;
@@ -342,7 +339,6 @@ void cLuaState::PushUserType(void * a_Object, const char * a_Type)
void cLuaState::Push(int a_Value)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushnumber(m_LuaState, a_Value);
m_NumCurrentFunctionArgs += 1;
@@ -355,7 +351,6 @@ void cLuaState::Push(int a_Value)
void cLuaState::Push(double a_Value)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushnumber(m_LuaState, a_Value);
m_NumCurrentFunctionArgs += 1;
@@ -368,7 +363,6 @@ void cLuaState::Push(double a_Value)
void cLuaState::Push(const char * a_Value)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushstring(m_LuaState, a_Value);
m_NumCurrentFunctionArgs += 1;
@@ -381,7 +375,6 @@ void cLuaState::Push(const char * a_Value)
void cLuaState::Push(bool a_Value)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushboolean(m_LuaState, a_Value ? 1 : 0);
m_NumCurrentFunctionArgs += 1;
@@ -394,7 +387,6 @@ void cLuaState::Push(bool a_Value)
void cLuaState::Push(cWorld * a_World)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_World, "cWorld");
m_NumCurrentFunctionArgs += 1;
@@ -407,7 +399,6 @@ void cLuaState::Push(cWorld * a_World)
void cLuaState::Push(cPlayer * a_Player)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_Player, "cPlayer");
m_NumCurrentFunctionArgs += 1;
@@ -420,7 +411,6 @@ void cLuaState::Push(cPlayer * a_Player)
void cLuaState::Push(const cPlayer * a_Player)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, (void *)a_Player, "cPlayer");
m_NumCurrentFunctionArgs += 1;
@@ -433,7 +423,6 @@ void cLuaState::Push(const cPlayer * a_Player)
void cLuaState::Push(cEntity * a_Entity)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_Entity, "cEntity");
m_NumCurrentFunctionArgs += 1;
@@ -446,7 +435,6 @@ void cLuaState::Push(cEntity * a_Entity)
void cLuaState::Push(cMonster * a_Monster)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_Monster, "cMonster");
m_NumCurrentFunctionArgs += 1;
@@ -459,7 +447,6 @@ void cLuaState::Push(cMonster * a_Monster)
void cLuaState::Push(cItem * a_Item)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_Item, "cItem");
m_NumCurrentFunctionArgs += 1;
@@ -472,7 +459,6 @@ void cLuaState::Push(cItem * a_Item)
void cLuaState::Push(cItems * a_Items)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_Items, "cItems");
m_NumCurrentFunctionArgs += 1;
@@ -485,7 +471,6 @@ void cLuaState::Push(cItems * a_Items)
void cLuaState::Push(cClientHandle * a_Client)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_Client, "cClientHandle");
m_NumCurrentFunctionArgs += 1;
@@ -498,7 +483,6 @@ void cLuaState::Push(cClientHandle * a_Client)
void cLuaState::Push(cPickup * a_Pickup)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_Pickup, "cPickup");
m_NumCurrentFunctionArgs += 1;
@@ -511,7 +495,6 @@ void cLuaState::Push(cPickup * a_Pickup)
void cLuaState::Push(cChunkDesc * a_ChunkDesc)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_ChunkDesc, "cChunkDesc");
m_NumCurrentFunctionArgs += 1;
@@ -524,7 +507,6 @@ void cLuaState::Push(cChunkDesc * a_ChunkDesc)
void cLuaState::Push(const cCraftingGrid * a_Grid)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, (void *)a_Grid, "cCraftingGrid");
m_NumCurrentFunctionArgs += 1;
@@ -537,7 +519,6 @@ void cLuaState::Push(const cCraftingGrid * a_Grid)
void cLuaState::Push(const cCraftingRecipe * a_Recipe)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, (void *)a_Recipe, "cCraftingRecipe");
m_NumCurrentFunctionArgs += 1;
@@ -550,7 +531,6 @@ void cLuaState::Push(const cCraftingRecipe * a_Recipe)
void cLuaState::Push(TakeDamageInfo * a_TDI)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_TDI, "TakeDamageInfo");
m_NumCurrentFunctionArgs += 1;
@@ -563,7 +543,6 @@ void cLuaState::Push(TakeDamageInfo * a_TDI)
void cLuaState::Push(cWindow * a_Window)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_Window, "cWindow");
m_NumCurrentFunctionArgs += 1;
@@ -576,7 +555,6 @@ void cLuaState::Push(cWindow * a_Window)
void cLuaState::Push(cPlugin_NewLua * a_Plugin)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_Plugin, "cPlugin_NewLua");
m_NumCurrentFunctionArgs += 1;
@@ -589,7 +567,6 @@ void cLuaState::Push(cPlugin_NewLua * a_Plugin)
void cLuaState::Push(const HTTPRequest * a_Request)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPRequest");
m_NumCurrentFunctionArgs += 1;
@@ -602,7 +579,6 @@ void cLuaState::Push(const HTTPRequest * a_Request)
void cLuaState::Push(cWebAdmin * a_WebAdmin)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_WebAdmin, "cWebAdmin");
m_NumCurrentFunctionArgs += 1;
@@ -615,7 +591,6 @@ void cLuaState::Push(cWebAdmin * a_WebAdmin)
void cLuaState::Push(const HTTPTemplateRequest * a_Request)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, (void *)a_Request, "HTTPTemplateRequest");
m_NumCurrentFunctionArgs += 1;
@@ -628,7 +603,6 @@ void cLuaState::Push(const HTTPTemplateRequest * a_Request)
void cLuaState::Push(cTNTEntity * a_TNTEntity)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_TNTEntity, "cTNTEntity");
m_NumCurrentFunctionArgs += 1;
@@ -641,7 +615,6 @@ void cLuaState::Push(cTNTEntity * a_TNTEntity)
void cLuaState::Push(cCreeper * a_Creeper)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_Creeper, "cCreeper");
m_NumCurrentFunctionArgs += 1;
@@ -654,7 +627,6 @@ void cLuaState::Push(cCreeper * a_Creeper)
void cLuaState::Push(Vector3i * a_Vector)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_Vector, "Vector3i");
m_NumCurrentFunctionArgs += 1;
@@ -667,7 +639,6 @@ void cLuaState::Push(Vector3i * a_Vector)
void cLuaState::Push(void * a_Ptr)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
lua_pushnil(m_LuaState);
m_NumCurrentFunctionArgs += 1;
@@ -680,7 +651,6 @@ void cLuaState::Push(void * a_Ptr)
void cLuaState::Push(cHopperEntity * a_Hopper)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_Hopper, "cHopperEntity");
m_NumCurrentFunctionArgs += 1;
@@ -693,7 +663,6 @@ void cLuaState::Push(cHopperEntity * a_Hopper)
void cLuaState::Push(cBlockEntity * a_BlockEntity)
{
ASSERT(IsValid());
- ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
tolua_pushusertype(m_LuaState, a_BlockEntity, "cBlockEntity");
m_NumCurrentFunctionArgs += 1;
diff --git a/source/LuaWindow.cpp b/source/LuaWindow.cpp
index 18cc7650e..1dcfc885f 100644
--- a/source/LuaWindow.cpp
+++ b/source/LuaWindow.cpp
@@ -48,6 +48,16 @@ cLuaWindow::cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_Slo
cLuaWindow::~cLuaWindow()
{
+ m_Contents.RemoveListener(*this);
+
+ // Must delete slot areas now, because they are referencing this->m_Contents and would try to access it in cWindow's
+ // destructor, when the member is already gone.
+ for (cSlotAreas::iterator itr = m_SlotAreas.begin(), end = m_SlotAreas.end(); itr != end; ++itr)
+ {
+ delete *itr;
+ }
+ m_SlotAreas.clear();
+
ASSERT(m_OpenedBy.empty());
}
diff --git a/source/Root.cpp b/source/Root.cpp
index 07de0775c..d07cc1ee7 100644
--- a/source/Root.cpp
+++ b/source/Root.cpp
@@ -478,6 +478,18 @@ void cRoot::SaveAllChunks(void)
+void cRoot::BroadcastChat(const AString & a_Message)
+{
+ for (WorldMap::iterator itr = m_WorldsByName.begin(), end = m_WorldsByName.end(); itr != end; ++itr)
+ {
+ itr->second->BroadcastChat(a_Message);
+ } // for itr - m_WorldsByName[]
+}
+
+
+
+
+
bool cRoot::ForEachPlayer(cPlayerListCallback & a_Callback)
{
for (WorldMap::iterator itr = m_WorldsByName.begin(), itr2 = itr; itr != m_WorldsByName.end(); itr = itr2)
diff --git a/source/Root.h b/source/Root.h
index 262c9b0e5..194b1cbb5 100644
--- a/source/Root.h
+++ b/source/Root.h
@@ -95,6 +95,9 @@ public:
/// Saves all chunks in all worlds
void SaveAllChunks(void); // tolua_export
+ /// Sends a chat message to all connected clients (in all worlds)
+ void BroadcastChat(const AString & a_Message); // tolua_export
+
/// Calls the callback for each player in all worlds
bool ForEachPlayer(cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
diff --git a/source/Server.cpp b/source/Server.cpp
index fad562973..c43ee83d2 100644
--- a/source/Server.cpp
+++ b/source/Server.cpp
@@ -355,8 +355,13 @@ bool cServer::Tick(float a_Dt)
m_PlayerCount += PlayerCountDiff;
}
+ // Send the tick to the plugins, as well as let the plugin manager reload, if asked to (issue #102):
+ cPluginManager::Get()->Tick(a_Dt);
+
+ // Let the Root process all the queued commands:
cRoot::Get()->TickCommands();
+ // Tick all clients not yet assigned to a world:
TickClients(a_Dt);
if (!m_bRestarting)
diff --git a/source/TNTEntity.cpp b/source/TNTEntity.cpp
index 84b56d01a..60625667d 100644
--- a/source/TNTEntity.cpp
+++ b/source/TNTEntity.cpp
@@ -8,7 +8,7 @@
-cTNTEntity::cTNTEntity(double a_X, double a_Y, double a_Z, float a_FuseTimeInSec) :
+cTNTEntity::cTNTEntity(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec) :
super(etTNT, a_X, a_Y, a_Z, 0.98, 0.98),
m_Counter(0),
m_MaxFuseTime(a_FuseTimeInSec)
@@ -19,7 +19,7 @@ cTNTEntity::cTNTEntity(double a_X, double a_Y, double a_Z, float a_FuseTimeInSec
-cTNTEntity::cTNTEntity(const Vector3d & a_Pos, float a_FuseTimeInSec) :
+cTNTEntity::cTNTEntity(const Vector3d & a_Pos, double a_FuseTimeInSec) :
super(etTNT, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98),
m_Counter(0),
m_MaxFuseTime(a_FuseTimeInSec)
diff --git a/source/TNTEntity.h b/source/TNTEntity.h
index a8487b66f..e3eae24f2 100644
--- a/source/TNTEntity.h
+++ b/source/TNTEntity.h
@@ -16,8 +16,8 @@ class cTNTEntity :
public:
CLASS_PROTODEF(cTNTEntity);
- cTNTEntity(double a_X, double a_Y, double a_Z, float a_FuseTimeInSec);
- cTNTEntity(const Vector3d & a_Pos, float a_FuseTimeInSec);
+ cTNTEntity(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec);
+ cTNTEntity(const Vector3d & a_Pos, double a_FuseTimeInSec);
// cEntity overrides:
virtual bool Initialize(cWorld * a_World) override;
@@ -25,8 +25,8 @@ public:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
protected:
- float m_Counter; ///< How much time has elapsed since the object was created, in seconds
- float m_MaxFuseTime; ///< How long the fuse is, in seconds
+ double m_Counter; ///< How much time has elapsed since the object was created, in seconds
+ double m_MaxFuseTime; ///< How long the fuse is, in seconds
};