summaryrefslogtreecommitdiffstats
path: root/src/Bindings
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Bindings/LuaState.cpp96
-rw-r--r--src/Bindings/LuaState.h10
-rw-r--r--src/Bindings/ManualBindings.cpp2
-rw-r--r--src/Bindings/PluginLua.cpp3
4 files changed, 9 insertions, 102 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index ec63d2767..ca0a258d9 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -864,28 +864,6 @@ void cLuaState::Push(const AStringVector & a_Vector)
-void cLuaState::Push(const cCraftingGrid * a_Grid)
-{
- ASSERT(IsValid());
-
- tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cCraftingGrid *>(a_Grid)), "cCraftingGrid");
-}
-
-
-
-
-
-void cLuaState::Push(const cCraftingRecipe * a_Recipe)
-{
- ASSERT(IsValid());
-
- tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cCraftingRecipe *>(a_Recipe)), "cCraftingRecipe");
-}
-
-
-
-
-
void cLuaState::Push(const char * a_Value)
{
ASSERT(IsValid());
@@ -897,17 +875,6 @@ void cLuaState::Push(const char * a_Value)
-void cLuaState::Push(const cItems & a_Items)
-{
- ASSERT(IsValid());
-
- tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cItems *>(&a_Items)), "cItems");
-}
-
-
-
-
-
void cLuaState::Push(const cNil & a_Nil)
{
ASSERT(IsValid());
@@ -919,17 +886,6 @@ void cLuaState::Push(const cNil & a_Nil)
-void cLuaState::Push(const cPlayer * a_Player)
-{
- ASSERT(IsValid());
-
- tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<cPlayer *>(a_Player)), "cPlayer");
-}
-
-
-
-
-
void cLuaState::Push(const cLuaState::cRef & a_Ref)
{
ASSERT(IsValid());
@@ -941,44 +897,11 @@ void cLuaState::Push(const cLuaState::cRef & a_Ref)
-void cLuaState::Push(const HTTPRequest * a_Request)
-{
- ASSERT(IsValid());
-
- tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<HTTPRequest *>(a_Request)), "HTTPRequest");
-}
-
-
-
-
-
-void cLuaState::Push(const HTTPTemplateRequest * a_Request)
-{
- ASSERT(IsValid());
-
- tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<HTTPTemplateRequest *>(a_Request)), "HTTPTemplateRequest");
-}
-
-
-
-
-
void cLuaState::Push(const Vector3d & a_Vector)
{
ASSERT(IsValid());
-
- tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3d *>(&a_Vector)), "Vector3<double>");
-}
-
-
-
-
-
-void cLuaState::Push(const Vector3d * a_Vector)
-{
- ASSERT(IsValid());
-
- tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3d *>(a_Vector)), "Vector3<double>");
+ auto c = new Vector3d(a_Vector);
+ tolua_pushusertype_and_takeownership(m_LuaState, c, "Vector3<double>");
}
@@ -988,19 +911,8 @@ void cLuaState::Push(const Vector3d * a_Vector)
void cLuaState::Push(const Vector3i & a_Vector)
{
ASSERT(IsValid());
-
- tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3i *>(&a_Vector)), "Vector3<int>");
-}
-
-
-
-
-
-void cLuaState::Push(const Vector3i * a_Vector)
-{
- ASSERT(IsValid());
-
- tolua_pushusertype(m_LuaState, reinterpret_cast<void *>(const_cast<Vector3i *>(a_Vector)), "Vector3<int>");
+ auto c = new Vector3i(a_Vector);
+ tolua_pushusertype_and_takeownership(m_LuaState, c, "Vector3<int>");
}
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index 1a56c18ff..ac911557d 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -573,22 +573,16 @@ public:
}
// Push a const value onto the stack (keep alpha-sorted):
+ // Note that these functions will make a copy of the actual value, because Lua doesn't have the concept
+ // of "const", and there would be lifetime management problems if they didn't.
void Push(const AString & a_String);
void Push(const AStringMap & a_Dictionary);
void Push(const AStringVector & a_Vector);
- void Push(const cCraftingGrid * a_Grid);
- void Push(const cCraftingRecipe * a_Recipe);
void Push(const char * a_Value);
- void Push(const cItems & a_Items);
void Push(const cNil & a_Nil);
- void Push(const cPlayer * a_Player);
void Push(const cRef & a_Ref);
- void Push(const HTTPRequest * a_Request);
- void Push(const HTTPTemplateRequest * a_Request);
void Push(const Vector3d & a_Vector);
- void Push(const Vector3d * a_Vector);
void Push(const Vector3i & a_Vector);
- void Push(const Vector3i * a_Vector);
// Push a simple value onto the stack (keep alpha-sorted):
void Push(bool a_Value);
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index ac349689a..c2392063a 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -1710,7 +1710,7 @@ public:
) override
{
AString content, contentType;
- return m_Callback.Call(&a_Request, a_UrlPath, cLuaState::Return, a_Content, a_ContentType);
+ return m_Callback.Call(const_cast<HTTPRequest *>(&a_Request), a_UrlPath, cLuaState::Return, a_Content, a_ContentType);
}
};
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 202477962..7de1dbb78 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -605,7 +605,8 @@ bool cPluginLua::OnPlayerFoodLevelChange(cPlayer & a_Player, int a_NewFoodLevel)
bool cPluginLua::OnPlayerFished(cPlayer & a_Player, const cItems & a_Reward)
{
- return CallSimpleHooks(cPluginManager::HOOK_PLAYER_FISHED, &a_Player, a_Reward);
+ cItems reward(a_Reward);
+ return CallSimpleHooks(cPluginManager::HOOK_PLAYER_FISHED, &a_Player, &reward);
}