summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
m---------MCServer/Plugins/Core0
-rw-r--r--MCServer/Plugins/Debuggers/Debuggers.lua7
-rw-r--r--src/Bindings/ManualBindings.cpp67
-rw-r--r--src/LightingThread.cpp4
4 files changed, 75 insertions, 3 deletions
diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core
-Subproject 4183d6cfb2049d0757d811a65bd4e75ed78b9f4
+Subproject 39d980e3a3447ac23f61c7d65426b33ee6c0718
diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua
index 74bfbf512..a047488b5 100644
--- a/MCServer/Plugins/Debuggers/Debuggers.lua
+++ b/MCServer/Plugins/Debuggers/Debuggers.lua
@@ -1689,7 +1689,12 @@ function HandleConsolePrepareChunk(a_Split)
end
end
- -- TODO: Queue the chunk for preparing, log a message when prepared
+ -- Queue the chunk for preparing, log a message when prepared:
+ world:PrepareChunk(chunkX, chunkZ,
+ function(a_CBChunkX, a_CBChunkZ)
+ LOG("Chunk [" .. chunkX .. ", " .. chunkZ .. "] has been prepared")
+ end
+ )
return true
end
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 750f7c65a..56f2e73bc 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -1874,6 +1874,72 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
+static int tolua_cWorld_PrepareChunk(lua_State * tolua_S)
+{
+ /* Function signature:
+ World:PrepareChunk(ChunkX, ChunkZ, Callback)
+ */
+
+ // Check the param types:
+ cLuaState L(tolua_S);
+ if (
+ !L.CheckParamUserType (1, "cWorld") ||
+ !L.CheckParamNumber (2, 3) ||
+ !L.CheckParamFunctionOrNil(4)
+ )
+ {
+ return 0;
+ }
+
+ // Read the params:
+ cWorld * world = nullptr;
+ int chunkX = 0, chunkZ = 0;
+ L.GetStackValues(1, world, chunkX, chunkZ);
+ if (world == nullptr)
+ {
+ LOGWARNING("World:PrepareChunk(): invalid world parameter");
+ L.LogStackTrace();
+ return 0;
+ }
+
+ // Wrap the Lua callback inside a C++ callback class:
+ class cCallback:
+ public cChunkCoordCallback
+ {
+ public:
+ cCallback(lua_State * a_LuaState):
+ m_LuaState(a_LuaState),
+ m_Callback(m_LuaState, 4)
+ {
+ }
+
+ // cChunkCoordCallback override:
+ virtual void Call(int a_CBChunkX, int a_CBChunkZ) override
+ {
+ if (m_Callback.IsValid())
+ {
+ m_LuaState.Call(m_Callback, a_CBChunkX, a_CBChunkZ);
+ }
+
+ // This is the last reference of this object, we must delete it so that it doesn't leak:
+ delete this;
+ }
+
+ protected:
+ cLuaState m_LuaState;
+ cLuaState::cRef m_Callback;
+ };
+ cCallback * callback = new cCallback(tolua_S);
+
+ // Call the chunk preparation:
+ world->PrepareChunk(chunkX, chunkZ, callback);
+ return 0;
+}
+
+
+
+
+
static int tolua_cPlayer_GetPermissions(lua_State * tolua_S)
{
// Function signature: cPlayer:GetPermissions() -> {permissions-array}
@@ -3401,6 +3467,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "GetBlockInfo", tolua_cWorld_GetBlockInfo);
tolua_function(tolua_S, "GetBlockTypeMeta", tolua_cWorld_GetBlockTypeMeta);
tolua_function(tolua_S, "GetSignLines", tolua_cWorld_GetSignLines);
+ tolua_function(tolua_S, "PrepareChunk", tolua_cWorld_PrepareChunk);
tolua_function(tolua_S, "QueueTask", tolua_cWorld_QueueTask);
tolua_function(tolua_S, "ScheduleTask", tolua_cWorld_ScheduleTask);
tolua_function(tolua_S, "SetSignLines", tolua_cWorld_SetSignLines);
diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp
index 01ba24105..ced95d4e1 100644
--- a/src/LightingThread.cpp
+++ b/src/LightingThread.cpp
@@ -226,6 +226,8 @@ void cLightingThread::Execute(void)
} // CSLock(m_CS)
LightChunk(*Item);
+ Item->Disable();
+ delete Item;
}
}
@@ -324,8 +326,6 @@ void cLightingThread::LightChunk(cLightingChunkStay & a_Item)
{
a_Item.m_CallbackAfter->Call(a_Item.m_ChunkX, a_Item.m_ChunkZ);
}
- a_Item.Disable();
- delete &a_Item;
}