summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Pioch <lukas@zgow.de>2017-08-01 18:54:31 +0200
committerLukas Pioch <lukas@zgow.de>2017-08-27 14:54:42 +0200
commit2126a1719d60a232d8e57b9a0dfec1b5ef556ca4 (patch)
tree687b2732a676b43095f061fcff9e8c5da1203998
parentAdded end check for stack, use ForEachArrayElement to read table (diff)
downloadcuberite-2126a1719d60a232d8e57b9a0dfec1b5ef556ca4.tar
cuberite-2126a1719d60a232d8e57b9a0dfec1b5ef556ca4.tar.gz
cuberite-2126a1719d60a232d8e57b9a0dfec1b5ef556ca4.tar.bz2
cuberite-2126a1719d60a232d8e57b9a0dfec1b5ef556ca4.tar.lz
cuberite-2126a1719d60a232d8e57b9a0dfec1b5ef556ca4.tar.xz
cuberite-2126a1719d60a232d8e57b9a0dfec1b5ef556ca4.tar.zst
cuberite-2126a1719d60a232d8e57b9a0dfec1b5ef556ca4.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/ManualBindings.cpp9
-rw-r--r--src/Protocol/Protocol_1_9.cpp5
2 files changed, 8 insertions, 6 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 45fc11ccb..c298170a8 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -3979,7 +3979,9 @@ static int tolua_cBookContent_GetPages(lua_State * tolua_S)
{
return 0;
}
- cBookContent * BookContent = reinterpret_cast<cBookContent *>(tolua_tousertype(tolua_S, 1, nullptr));
+
+ cBookContent * BookContent = nullptr;
+ L.GetStackValue(1, BookContent);
L.Push(BookContent->GetPages());
return 1;
}
@@ -4001,9 +4003,10 @@ static int tolua_cBookContent_SetPages(lua_State * tolua_S)
{
return 0;
}
- cBookContent * BookContent = reinterpret_cast<cBookContent *>(tolua_tousertype(tolua_S, 1, nullptr));
+
+ cBookContent * BookContent = nullptr;
cLuaState::cStackTablePtr Pages;
- L.GetStackValue(2, Pages);
+ L.GetStackValues(1, BookContent, Pages);
Pages->ForEachArrayElement([=](cLuaState & a_LuaState, int a_Index) -> bool
{
AString Page;
diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp
index 9879140d4..aba0a9d01 100644
--- a/src/Protocol/Protocol_1_9.cpp
+++ b/src/Protocol/Protocol_1_9.cpp
@@ -2953,6 +2953,7 @@ void cProtocol_1_9_0::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, con
cParsedNBT NBT(BookData.c_str(), BookData.size());
cItem BookItem;
+ bool IsSigned = true;
if (a_Channel == "MC|BSign")
{
BookItem = cItem(E_ITEM_WRITTEN_BOOK);
@@ -2961,13 +2962,11 @@ void cProtocol_1_9_0::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, con
}
else
{
+ IsSigned = false;
BookItem = cItem(E_ITEM_BOOK_AND_QUILL);
cBookContent::ParseFromNBT(0, BookItem.m_BookContent, NBT);
}
- // If true, player has clicked on the sign button
- bool IsSigned = (BookItem.m_ItemType == E_ITEM_WRITTEN_BOOK) ? true : false;
-
if (cRoot::Get()->GetPluginManager()->CallHookPlayerEditingBook(Player, BookItem.m_BookContent, IsSigned))
{
// Plugin denied the editing of the book