From bc466f07a454271d4845a7e8c7f0822541c5afbd Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Thu, 20 Sep 2012 13:25:54 +0000 Subject: Refactored windows. As described on the forum: http://forum.mc-server.org/showthread.php?tid=561 For now, only basic clicking works; shift-click not implemented yet. git-svn-id: http://mc-server.googlecode.com/svn/trunk@867 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Protocol125.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'source/Protocol125.cpp') diff --git a/source/Protocol125.cpp b/source/Protocol125.cpp index adea37824..f9a13668b 100644 --- a/source/Protocol125.cpp +++ b/source/Protocol125.cpp @@ -2,6 +2,12 @@ // Protocol125.cpp // Implements the cProtocol125 class representing the release 1.2.5 protocol (#29) +/* +Documentation: + - protocol: http://wiki.vg/wiki/index.php?title=Protocol&oldid=2513 + - session handling: http://wiki.vg/wiki/index.php?title=Session&oldid=2262 + - slot format: http://wiki.vg/wiki/index.php?title=Slot_Data&oldid=2152 +*/ #include "Globals.h" @@ -14,7 +20,7 @@ #include "cPickup.h" #include "cPlayer.h" #include "cChatColor.h" -#include "cWindow.h" +#include "UI/cWindow.h" #include "cRoot.h" #include "cServer.h" @@ -713,7 +719,7 @@ void cProtocol125::SendWeather(eWeather a_Weather) void cProtocol125::SendWholeInventory(const cInventory & a_Inventory) { cCSLock Lock(m_CSPacket); - SendWholeInventory(0, a_Inventory.c_NumSlots, a_Inventory.GetSlots()); + SendWindowSlots(0, a_Inventory.c_NumSlots, a_Inventory.GetSlots()); } @@ -723,11 +729,9 @@ void cProtocol125::SendWholeInventory(const cInventory & a_Inventory) void cProtocol125::SendWholeInventory(const cWindow & a_Window) { cCSLock Lock(m_CSPacket); - SendWholeInventory( - (char)a_Window.GetWindowID(), - a_Window.GetNumSlots(), - a_Window.GetSlots() - ); + cItems Slots; + a_Window.GetSlots(*(m_Client->GetPlayer()), Slots); + SendWindowSlots(a_Window.GetWindowID(), Slots.size(), &(Slots[0])); } @@ -748,6 +752,10 @@ void cProtocol125::SendWindowClose(char a_WindowID) void cProtocol125::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) { + LOGD("Sending a WindowOpen packet: ID = %d, Type = %d, Title = \"%s\", NumSlots = %d", + a_WindowID, a_WindowType, a_WindowTitle.c_str(), a_NumSlots + ); + if (a_WindowType < 0) { // Do not send for inventory windows @@ -1246,8 +1254,11 @@ void cProtocol125::SendPreChunk(int a_ChunkX, int a_ChunkZ, bool a_ShouldLoad) -void cProtocol125::SendWholeInventory(char a_WindowID, int a_NumItems, const cItem * a_Items) +void cProtocol125::SendWindowSlots(char a_WindowID, int a_NumItems, const cItem * a_Items) { + LOGD("Sending a InventoryWhole packet: WindowID = %d, NumItems = %d", + a_WindowID, a_NumItems + ); WriteByte (PACKET_INVENTORY_WHOLE); WriteByte (a_WindowID); WriteShort((short)a_NumItems); -- cgit v1.2.3