summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-10-11 22:49:18 +0200
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-10-11 22:49:18 +0200
commit4eaafbd70f204d620d9211a672d28ec618c01d39 (patch)
treebbbee73574324a9eb1b334afe99c6ce09756eb11 /source
parentProtoProxy: Added the PACKET_COLLECT_PICKUP packet handling (diff)
downloadcuberite-4eaafbd70f204d620d9211a672d28ec618c01d39.tar
cuberite-4eaafbd70f204d620d9211a672d28ec618c01d39.tar.gz
cuberite-4eaafbd70f204d620d9211a672d28ec618c01d39.tar.bz2
cuberite-4eaafbd70f204d620d9211a672d28ec618c01d39.tar.lz
cuberite-4eaafbd70f204d620d9211a672d28ec618c01d39.tar.xz
cuberite-4eaafbd70f204d620d9211a672d28ec618c01d39.tar.zst
cuberite-4eaafbd70f204d620d9211a672d28ec618c01d39.zip
Diffstat (limited to 'source')
-rw-r--r--source/LuaCommandBinder.cpp6
-rw-r--r--source/ManualBindings.cpp2
-rw-r--r--source/Plugin_NewLua.cpp33
3 files changed, 29 insertions, 12 deletions
diff --git a/source/LuaCommandBinder.cpp b/source/LuaCommandBinder.cpp
index a495a2954..7a65cab7f 100644
--- a/source/LuaCommandBinder.cpp
+++ b/source/LuaCommandBinder.cpp
@@ -81,12 +81,6 @@ bool cLuaCommandBinder::HandleCommand( const std::string & a_Command, cPlayer* a
}
}
- // For enabling 'self' in the function, it's kind of a hack I'm not sure this is the way to go
- lua_pushvalue(func.LuaState, LUA_GLOBALSINDEX);
- lua_pushstring(func.LuaState, "self");
- tolua_pushusertype( func.LuaState, func.Plugin, "cPlugin" );
- lua_rawset(func.LuaState, -3);
- lua_pop(func.LuaState, 1);
LOGD("1. Stack size: %i", lua_gettop(func.LuaState) );
lua_rawgeti( func.LuaState, LUA_REGISTRYINDEX, func.Reference); // same as lua_getref()
diff --git a/source/ManualBindings.cpp b/source/ManualBindings.cpp
index 9ddd1360e..dca4e0083 100644
--- a/source/ManualBindings.cpp
+++ b/source/ManualBindings.cpp
@@ -808,7 +808,7 @@ static int tolua_cPlugin_Call(lua_State* tolua_S)
return 0;
}
- lua_pop(targetState, nresults+1); // I have no idea what I'm doing, but it works
+ lua_pop(targetState, nresults); // I have no idea what I'm doing, but it works
return nresults;
}
diff --git a/source/Plugin_NewLua.cpp b/source/Plugin_NewLua.cpp
index 061441735..866239b3a 100644
--- a/source/Plugin_NewLua.cpp
+++ b/source/Plugin_NewLua.cpp
@@ -184,7 +184,9 @@ bool cPlugin_NewLua::OnCollectPickup(cPlayer * a_Player, cPickup * a_Pickup)
return false;
}
- return (tolua_toboolean(m_LuaState, -1, 0) > 0);
+ bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
+ return bRetVal;
}
@@ -207,7 +209,9 @@ bool cPlugin_NewLua::OnDisconnect(cPlayer * a_Player, const AString & a_Reason)
return false;
}
- return (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
+ return bRetVal;
}
@@ -234,7 +238,9 @@ bool cPlugin_NewLua::OnBlockPlace(cPlayer * a_Player, int a_BlockX, int a_BlockY
return false;
}
- return (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
+ return bRetVal;
}
@@ -263,7 +269,9 @@ bool cPlugin_NewLua::OnBlockDig(cPlayer * a_Player, int a_BlockX, int a_BlockY,
return false;
}
- return (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
+ return bRetVal;
}
@@ -286,7 +294,9 @@ bool cPlugin_NewLua::OnChat(cPlayer * a_Player, const AString & a_Message)
return false;
}
- return (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
+ return bRetVal;
}
@@ -307,6 +317,7 @@ bool cPlugin_NewLua::OnLogin(cClientHandle * a_Client, int a_ProtocolVersion, co
return false;
bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
return bRetVal;
}
@@ -341,6 +352,7 @@ bool cPlugin_NewLua::OnPlayerJoin( cPlayer* a_Player )
return false;
bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
return bRetVal;
}
@@ -392,6 +404,7 @@ bool cPlugin_NewLua::OnKilled( cPawn* a_Killed, cEntity* a_Killer )
return false;
bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
return bRetVal;
}
@@ -433,6 +446,7 @@ bool cPlugin_NewLua::OnChunkGenerating(cWorld * a_World, int a_ChunkX, int a_Chu
return false;
bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
return bRetVal;
}
@@ -456,6 +470,7 @@ bool cPlugin_NewLua::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid
}
bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
return bRetVal;
}
@@ -479,6 +494,7 @@ bool cPlugin_NewLua::OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftin
}
bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
return bRetVal;
}
@@ -502,6 +518,7 @@ bool cPlugin_NewLua::OnPostCrafting(const cPlayer * a_Player, const cCraftingGri
}
bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
return bRetVal;
}
@@ -531,6 +548,7 @@ bool cPlugin_NewLua::OnBlockToPickup(
}
bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
return bRetVal;
}
@@ -554,6 +572,7 @@ bool cPlugin_NewLua::OnWeatherChanged(cWorld * a_World)
}
bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
return bRetVal;
}
@@ -589,6 +608,7 @@ bool cPlugin_NewLua::OnUpdatingSign(
return false;
}
+
bool bRetVal = (tolua_toboolean( m_LuaState, -5, 0) > 0);
if (lua_isstring(m_LuaState, -4))
{
@@ -606,6 +626,7 @@ bool cPlugin_NewLua::OnUpdatingSign(
{
a_Line4 = tolua_tostring(m_LuaState, -1, "");
}
+ // TODO - FIXME: This probably needs to pop 5 things from the stack before returning
return bRetVal;
}
@@ -642,6 +663,7 @@ bool cPlugin_NewLua::OnUpdatedSign(
}
bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
return bRetVal;
}
@@ -666,6 +688,7 @@ bool cPlugin_NewLua::OnHandshake(cClientHandle * a_Client, const AString & a_Use
}
bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ lua_pop(m_LuaState, 1);
return bRetVal;
}