summaryrefslogtreecommitdiffstats
path: root/src/Bindings
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2015-09-25 19:56:49 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2015-09-25 19:56:49 +0200
commita8bfe3a4c1993b9bbc2defc5f0b667a2348c210e (patch)
tree06352b4bce7ced41337a4f53ce9417a692a59752 /src/Bindings
parentMerge pull request #2495 from Seadragon91/clang-3.7 (diff)
downloadcuberite-a8bfe3a4c1993b9bbc2defc5f0b667a2348c210e.tar
cuberite-a8bfe3a4c1993b9bbc2defc5f0b667a2348c210e.tar.gz
cuberite-a8bfe3a4c1993b9bbc2defc5f0b667a2348c210e.tar.bz2
cuberite-a8bfe3a4c1993b9bbc2defc5f0b667a2348c210e.tar.lz
cuberite-a8bfe3a4c1993b9bbc2defc5f0b667a2348c210e.tar.xz
cuberite-a8bfe3a4c1993b9bbc2defc5f0b667a2348c210e.tar.zst
cuberite-a8bfe3a4c1993b9bbc2defc5f0b667a2348c210e.zip
Diffstat (limited to 'src/Bindings')
-rw-r--r--src/Bindings/ManualBindings_World.cpp55
1 files changed, 11 insertions, 44 deletions
diff --git a/src/Bindings/ManualBindings_World.cpp b/src/Bindings/ManualBindings_World.cpp
index 6f8499611..ba80d7130 100644
--- a/src/Bindings/ManualBindings_World.cpp
+++ b/src/Bindings/ManualBindings_World.cpp
@@ -374,7 +374,6 @@ static int tolua_cWorld_PrepareChunk(lua_State * tolua_S)
class cLuaWorldTask :
- public cWorld::cTask,
public cPluginLua::cResettable
{
public:
@@ -384,11 +383,7 @@ public:
{
}
-protected:
- int m_FnRef;
-
- // cWorld::cTask overrides:
- virtual void Run(cWorld & a_World) override
+ void Run(cWorld & a_World)
{
cCSLock Lock(m_CSPlugin);
if (m_Plugin != nullptr)
@@ -396,7 +391,10 @@ protected:
m_Plugin->Call(m_FnRef, &a_World);
}
}
-} ;
+
+protected:
+ int m_FnRef;
+};
@@ -433,9 +431,9 @@ static int tolua_cWorld_QueueTask(lua_State * tolua_S)
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Could not get function reference of parameter #1");
}
- auto task = std::make_shared<cLuaWorldTask>(*Plugin, FnRef);
- Plugin->AddResettable(task);
- self->QueueTask(task);
+ auto ResettableTask = std::make_shared<cLuaWorldTask>(*Plugin, FnRef);
+ Plugin->AddResettable(ResettableTask);
+ self->QueueTask(std::bind(&cLuaWorldTask::Run, ResettableTask, std::placeholders::_1));
return 0;
}
@@ -483,35 +481,6 @@ static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
-class cLuaScheduledWorldTask :
- public cWorld::cTask,
- public cPluginLua::cResettable
-{
-public:
- cLuaScheduledWorldTask(cPluginLua & a_Plugin, int a_FnRef) :
- cPluginLua::cResettable(a_Plugin),
- m_FnRef(a_FnRef)
- {
- }
-
-protected:
- int m_FnRef;
-
- // cWorld::cTask overrides:
- virtual void Run(cWorld & a_World) override
- {
- cCSLock Lock(m_CSPlugin);
- if (m_Plugin != nullptr)
- {
- m_Plugin->Call(m_FnRef, &a_World);
- }
- }
-};
-
-
-
-
-
static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
{
// Binding for cWorld::ScheduleTask
@@ -548,11 +517,9 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Could not get function reference of parameter #1");
}
- int DelayTicks = static_cast<int>(tolua_tonumber(tolua_S, 2, 0));
-
- auto task = std::make_shared<cLuaScheduledWorldTask>(*Plugin, FnRef);
- Plugin->AddResettable(task);
- World->ScheduleTask(DelayTicks, static_cast<cWorld::cTaskPtr>(task));
+ auto ResettableTask = std::make_shared<cLuaWorldTask>(*Plugin, FnRef);
+ Plugin->AddResettable(ResettableTask);
+ World->ScheduleTask(static_cast<int>(tolua_tonumber(tolua_S, 2, 0)), std::bind(&cLuaWorldTask::Run, ResettableTask, std::placeholders::_1));
return 0;
}