summaryrefslogtreecommitdiffstats
path: root/source/cClientHandle.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-20 15:25:54 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-20 15:25:54 +0200
commitbc466f07a454271d4845a7e8c7f0822541c5afbd (patch)
treec8455a2af322bbd847b6b4ea74256b78aa834c4c /source/cClientHandle.cpp
parentProtoProxy: moar packets! (can now sustain parsing while connected to vanilla server, most of the times) (diff)
downloadcuberite-bc466f07a454271d4845a7e8c7f0822541c5afbd.tar
cuberite-bc466f07a454271d4845a7e8c7f0822541c5afbd.tar.gz
cuberite-bc466f07a454271d4845a7e8c7f0822541c5afbd.tar.bz2
cuberite-bc466f07a454271d4845a7e8c7f0822541c5afbd.tar.lz
cuberite-bc466f07a454271d4845a7e8c7f0822541c5afbd.tar.xz
cuberite-bc466f07a454271d4845a7e8c7f0822541c5afbd.tar.zst
cuberite-bc466f07a454271d4845a7e8c7f0822541c5afbd.zip
Diffstat (limited to 'source/cClientHandle.cpp')
-rw-r--r--source/cClientHandle.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index 35e5a0ee4..7108c7711 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -10,8 +10,7 @@
#include "cInventory.h"
#include "cChestEntity.h"
#include "cSignEntity.h"
-#include "cWindow.h"
-#include "cCraftingWindow.h"
+#include "UI/cWindow.h"
#include "cItem.h"
#include "cTorch.h"
#include "cDoors.h"
@@ -256,7 +255,7 @@ void cClientHandle::Authenticate(void)
m_Protocol->SendTimeUpdate(World->GetWorldTime());
// Send inventory
- m_Player->GetInventory().SendWholeInventory(this);
+ m_Player->GetInventory().SendWholeInventory(*this);
// Send health
m_Player->SendHealth();
@@ -451,14 +450,18 @@ bool cClientHandle::HandleLogin(int a_ProtocolVersion, const AString & a_Usernam
void cClientHandle::HandleCreativeInventory(short a_SlotNum, const cItem & a_HeldItem)
{
// This is for creative Inventory changes
- if (m_Player->GetGameMode() == 1)
+ if (m_Player->GetGameMode() != eGameMode_Creative)
{
- m_Player->GetInventory().Clicked(a_SlotNum, false, false, a_HeldItem);
+ LOGWARNING("Got a CreativeInventoryAction packet from user \"%s\" while not in creative mode. Ignoring.", m_Username.c_str());
+ return;
}
- else
+ if (m_Player->GetWindow()->GetWindowType() != cWindow::Inventory)
{
- LOGWARNING("Got a CreativeInventoryAction packet from user \"%s\" while not in creative mode. Ignoring.", m_Username.c_str());
+ LOGWARNING("Got a CreativeInventoryAction packet from user \"%s\" while not in the inventory window. Ignoring.", m_Username.c_str());
+ return;
}
+
+ m_Player->GetWindow()->Clicked(*m_Player, 0, a_SlotNum, false, false, a_HeldItem);
}
@@ -821,11 +824,10 @@ void cClientHandle::HandleWindowClose(char a_WindowID)
void cClientHandle::HandleWindowClick(char a_WindowID, short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, const cItem & a_HeldItem)
{
- if (a_WindowID == 0)
- {
- m_Player->GetInventory().Clicked(a_SlotNum, a_IsRightClick, a_IsShiftPressed, a_HeldItem);
- return;
- }
+ LOGD("WindowClick: WinID %d, SlotNum %d, IsRclk %d, IsShift %d, Item %s x %d",
+ a_WindowID, a_SlotNum, a_IsRightClick, a_IsShiftPressed,
+ ItemToString(a_HeldItem).c_str(), a_HeldItem.m_ItemCount
+ );
cWindow * Window = m_Player->GetWindow();
if (Window == NULL)