summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaChunkStay.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2016-06-12 16:53:24 +0200
committerMattes D <github@xoft.cz>2016-06-27 20:51:51 +0200
commit24853397ef4648155d886b112e00c3e2c3d1e900 (patch)
tree8fb7a0da6418b00e9d9a29dd3fca008df12aae78 /src/Bindings/LuaChunkStay.cpp
parentChanged cLuaWindow callbacks to use cLuaState::cCallback. (diff)
downloadcuberite-24853397ef4648155d886b112e00c3e2c3d1e900.tar
cuberite-24853397ef4648155d886b112e00c3e2c3d1e900.tar.gz
cuberite-24853397ef4648155d886b112e00c3e2c3d1e900.tar.bz2
cuberite-24853397ef4648155d886b112e00c3e2c3d1e900.tar.lz
cuberite-24853397ef4648155d886b112e00c3e2c3d1e900.tar.xz
cuberite-24853397ef4648155d886b112e00c3e2c3d1e900.tar.zst
cuberite-24853397ef4648155d886b112e00c3e2c3d1e900.zip
Diffstat (limited to 'src/Bindings/LuaChunkStay.cpp')
-rw-r--r--src/Bindings/LuaChunkStay.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/Bindings/LuaChunkStay.cpp b/src/Bindings/LuaChunkStay.cpp
index d8d7da5d0..819e10f19 100644
--- a/src/Bindings/LuaChunkStay.cpp
+++ b/src/Bindings/LuaChunkStay.cpp
@@ -113,12 +113,10 @@ void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index)
-void cLuaChunkStay::Enable(cChunkMap & a_ChunkMap, int a_OnChunkAvailableStackPos, int a_OnAllChunksAvailableStackPos)
+void cLuaChunkStay::Enable(cChunkMap & a_ChunkMap, cLuaState::cCallbackPtr a_OnChunkAvailable, cLuaState::cCallbackPtr a_OnAllChunksAvailable)
{
- // Get the references to the callback functions:
- m_LuaState = &m_Plugin.GetLuaState();
- m_OnChunkAvailable.RefStack(*m_LuaState, a_OnChunkAvailableStackPos);
- m_OnAllChunksAvailable.RefStack(*m_LuaState, a_OnAllChunksAvailableStackPos);
+ m_OnChunkAvailable = a_OnChunkAvailable;
+ m_OnAllChunksAvailable = a_OnAllChunksAvailable;
// Enable the ChunkStay:
super::Enable(a_ChunkMap);
@@ -130,10 +128,9 @@ void cLuaChunkStay::Enable(cChunkMap & a_ChunkMap, int a_OnChunkAvailableStackPo
void cLuaChunkStay::OnChunkAvailable(int a_ChunkX, int a_ChunkZ)
{
- if (m_OnChunkAvailable.IsValid())
+ if (m_OnChunkAvailable != nullptr)
{
- cPluginLua::cOperation Op(m_Plugin);
- Op().Call(static_cast<int>(m_OnChunkAvailable), a_ChunkX, a_ChunkZ);
+ m_OnChunkAvailable->Call(a_ChunkX, a_ChunkZ);
}
}
@@ -143,15 +140,14 @@ void cLuaChunkStay::OnChunkAvailable(int a_ChunkX, int a_ChunkZ)
bool cLuaChunkStay::OnAllChunksAvailable(void)
{
- if (m_OnAllChunksAvailable.IsValid())
+ if (m_OnAllChunksAvailable != nullptr)
{
// Call the callback:
- cPluginLua::cOperation Op(m_Plugin);
- Op().Call(static_cast<int>(m_OnAllChunksAvailable));
+ m_OnAllChunksAvailable->Call();
// Remove the callback references - they won't be needed anymore
- m_OnChunkAvailable.UnRef();
- m_OnAllChunksAvailable.UnRef();
+ m_OnChunkAvailable.reset();
+ m_OnAllChunksAvailable.reset();
}
// Disable the ChunkStay by returning true