summaryrefslogtreecommitdiffstats
path: root/src/Bindings/PluginLua.h
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/PluginLua.h
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 '')
-rw-r--r--src/Bindings/PluginLua.h21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index e53fbaaa8..8e40ff584 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -47,7 +47,7 @@ public:
public:
cOperation(cPluginLua & a_Plugin) :
m_Plugin(a_Plugin),
- m_Lock(a_Plugin.m_CriticalSection)
+ m_Lock(a_Plugin.m_LuaState)
{
}
@@ -56,8 +56,8 @@ public:
protected:
cPluginLua & m_Plugin;
- /** RAII lock for m_Plugin.m_CriticalSection */
- cCSLock m_Lock;
+ /** RAII lock for the Lua state. */
+ cLuaState::cLock m_Lock;
} ;
@@ -155,13 +155,6 @@ public:
/** Binds the console command to call the function specified by a Lua function reference. Simply adds to CommandMap. */
void BindConsoleCommand(const AString & a_Command, int a_FnRef);
- cLuaState & GetLuaState(void) { return m_LuaState; }
-
- cCriticalSection & GetCriticalSection(void) { return m_CriticalSection; }
-
- /** Removes a previously referenced object (luaL_unref()) */
- void Unreference(int a_LuaRef);
-
/** Calls the plugin-specified "cLuaWindow closing" callback. Returns true only if the callback returned true */
bool CallbackWindowClosing(int a_FnRef, cWindow & a_Window, cPlayer & a_Player, bool a_CanRefuse);
@@ -189,8 +182,7 @@ public:
template <typename FnT, typename... Args>
bool Call(FnT a_Fn, Args && ... a_Args)
{
- cCSLock Lock(m_CriticalSection);
- return m_LuaState.Call(a_Fn, a_Args...);
+ return cOperation(*this)().Call(a_Fn, a_Args...);
}
protected:
@@ -204,9 +196,6 @@ protected:
typedef std::map<int, cLuaCallbacks> cHookMap;
- /** The mutex protecting m_LuaState against multithreaded use. */
- cCriticalSection m_CriticalSection;
-
/** The plugin's Lua state. */
cLuaState m_LuaState;
@@ -232,7 +221,7 @@ protected:
template <typename... Args>
bool CallSimpleHooks(int a_HookType, Args && ... a_Args)
{
- cCSLock lock(m_CriticalSection);
+ cOperation op(*this);
auto & hooks = m_HookMap[a_HookType];
bool res = false;
for (auto & hook: hooks)