cProtocol::SendWindowOpen() signature changed.

This implements #313.
master
madmaxoft 2013-11-08 21:32:14 +01:00
parent b24bdff308
commit 07fa8313b1
15 changed files with 61 additions and 50 deletions

View File

@ -2022,9 +2022,9 @@ void cClientHandle::SendWindowClose(const cWindow & a_Window)
void cClientHandle::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
void cClientHandle::SendWindowOpen(const cWindow & a_Window)
{
m_Protocol->SendWindowOpen(a_WindowID, a_WindowType, a_WindowTitle, a_NumSlots);
m_Protocol->SendWindowOpen(a_Window);
}

View File

@ -134,9 +134,9 @@ public:
void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
void SendWeather (eWeather a_Weather);
void SendWholeInventory (const cWindow & a_Window);
void SendWindowClose (const cWindow & a_Window);
void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots);
void SendWholeInventory (const cWindow & a_Window);
void SendWindowClose (const cWindow & a_Window);
void SendWindowOpen (const cWindow & a_Window);
void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value);
const AString & GetUsername(void) const; // tolua_export

View File

@ -101,7 +101,7 @@ public:
virtual void SendWeather (eWeather a_Weather) = 0;
virtual void SendWholeInventory (const cWindow & a_Window) = 0;
virtual void SendWindowClose (const cWindow & a_Window) = 0;
virtual void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) = 0;
virtual void SendWindowOpen (const cWindow & a_Window) = 0;
virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) = 0;
/// Returns the ServerID used for authentication through session.minecraft.net

View File

@ -956,19 +956,19 @@ void cProtocol125::SendWindowClose(const cWindow & a_Window)
void cProtocol125::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
void cProtocol125::SendWindowOpen(const cWindow & a_Window)
{
if (a_WindowType < 0)
if (a_Window.GetWindowType() < 0)
{
// Do not send for inventory windows
return;
}
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_WINDOW_OPEN);
WriteByte (a_WindowID);
WriteByte (a_WindowType);
WriteString(a_WindowTitle);
WriteByte (a_NumSlots);
WriteByte (a_Window.GetWindowID());
WriteByte (a_Window.GetWindowType());
WriteString(a_Window.GetWindowTitle());
WriteByte (a_Window.GetNumNonInventorySlots());
Flush();
}

View File

@ -78,7 +78,7 @@ public:
virtual void SendWeather (eWeather a_Weather) override;
virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (const cWindow & a_Window) override;
virtual void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) override;
virtual void SendWindowOpen (const cWindow & a_Window) override;
virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override;
virtual AString GetAuthServerID(void) override;

View File

@ -12,6 +12,7 @@ Implements the 1.5.x protocol classes:
#include "Protocol15x.h"
#include "../ClientHandle.h"
#include "../Item.h"
#include "../UI/Window.h"
@ -54,19 +55,19 @@ cProtocol150::cProtocol150(cClientHandle * a_Client) :
void cProtocol150::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
void cProtocol150::SendWindowOpen(const cWindow & a_Window)
{
if (a_WindowType < 0)
if (a_Window.GetWindowType() < 0)
{
// Do not send for inventory windows
return;
}
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_WINDOW_OPEN);
WriteByte (a_WindowID);
WriteByte (a_WindowType);
WriteString(a_WindowTitle);
WriteByte (a_NumSlots);
WriteByte (a_Window.GetWindowID());
WriteByte (a_Window.GetWindowType());
WriteString(a_Window.GetWindowTitle());
WriteByte (a_Window.GetNumNonInventorySlots());
WriteByte (1); // Use title
Flush();
}

View File

@ -28,7 +28,7 @@ class cProtocol150 :
public:
cProtocol150(cClientHandle * a_Client);
virtual void SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) override;
virtual void SendWindowOpen(const cWindow & a_Window) override;
virtual int ParseWindowClick(void);
} ;

View File

@ -17,6 +17,7 @@ Implements the 1.6.x protocol classes:
#include "../ClientHandle.h"
#include "../Entities/Entity.h"
#include "../Entities/Player.h"
#include "../UI/Window.h"
@ -153,23 +154,23 @@ void cProtocol161::SendRespawn(void)
void cProtocol161::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
void cProtocol161::SendWindowOpen(const cWindow & a_Window)
{
if (a_WindowType < 0)
if (a_Window.GetWindowType() < 0)
{
// Do not send for inventory windows
return;
}
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_WINDOW_OPEN);
WriteByte (a_WindowID);
WriteByte (a_WindowType);
WriteString(a_WindowTitle);
WriteByte (a_NumSlots);
WriteByte (a_Window.GetWindowID());
WriteByte (a_Window.GetWindowType());
WriteString(a_Window.GetWindowTitle());
WriteByte (a_Window.GetNumNonInventorySlots());
WriteByte (1); // Use title
if (a_WindowType == 11) // horse / donkey
if (a_Window.GetWindowType() == cWindow::wtAnimalChest)
{
WriteInt(0); // Unknown value sent only when window type is 11 (horse / donkey)
WriteInt(0); // TODO: The animal's EntityID
}
Flush();
}

View File

@ -42,7 +42,7 @@ protected:
virtual void SendHealth (void) override;
virtual void SendPlayerMaxSpeed(void) override;
virtual void SendRespawn (void) override;
virtual void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) override;
virtual void SendWindowOpen (const cWindow & a_Window) override;
virtual int ParseEntityAction (void) override;
virtual int ParsePlayerAbilities(void) override;

View File

@ -841,21 +841,24 @@ void cProtocol172::SendWindowClose(const cWindow & a_Window)
void cProtocol172::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
void cProtocol172::SendWindowOpen(const cWindow & a_Window)
{
cPacketizer Pkt(*this, 0x2d);
Pkt.WriteChar(a_WindowID);
Pkt.WriteChar(a_WindowType);
Pkt.WriteString(a_WindowTitle);
Pkt.WriteChar(a_NumSlots);
Pkt.WriteBool(true);
/*
// TODO:
if (a_WindowType == cWindow::wtHorse)
if (a_Window.GetWindowType() < 0)
{
Pkt.WriteInt(HorseID);
// Do not send this packet for player inventory windows
return;
}
cPacketizer Pkt(*this, 0x2d);
Pkt.WriteChar(a_Window.GetWindowID());
Pkt.WriteChar(a_Window.GetWindowType());
Pkt.WriteString(a_Window.GetWindowTitle());
Pkt.WriteChar(a_Window.GetNumNonInventorySlots());
Pkt.WriteBool(true);
if (a_Window.GetWindowType() == cWindow::wtAnimalChest)
{
Pkt.WriteInt(0); // TODO: The animal's EntityID
}
*/
}

View File

@ -85,9 +85,9 @@ public:
virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override;
virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) override;
virtual void SendWeather (eWeather a_Weather) override;
virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (const cWindow & a_Window) override;
virtual void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) override;
virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (const cWindow & a_Window) override;
virtual void SendWindowOpen (const cWindow & a_Window) override;
virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override;
virtual AString GetAuthServerID(void) override { return m_AuthServerID; }

View File

@ -625,10 +625,10 @@ void cProtocolRecognizer::SendWindowClose(const cWindow & a_Window)
void cProtocolRecognizer::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
void cProtocolRecognizer::SendWindowOpen(const cWindow & a_Window)
{
ASSERT(m_Protocol != NULL);
m_Protocol->SendWindowOpen(a_WindowID, a_WindowType, a_WindowTitle, a_NumSlots);
m_Protocol->SendWindowOpen(a_Window);
}

View File

@ -111,9 +111,9 @@ public:
virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override;
virtual void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) override;
virtual void SendWeather (eWeather a_Weather) override;
virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (const cWindow & a_Window) override;
virtual void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) override;
virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (const cWindow & a_Window) override;
virtual void SendWindowOpen (const cWindow & a_Window) override;
virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override;
virtual AString GetAuthServerID(void) override;

View File

@ -245,7 +245,7 @@ void cWindow::OpenedByPlayer(cPlayer & a_Player)
} // for itr - m_SlotAreas[]
}
a_Player.GetClientHandle()->SendWindowOpen(m_WindowID, m_WindowType, m_WindowTitle, GetNumSlots() - c_NumInventorySlots);
a_Player.GetClientHandle()->SendWindowOpen(*this);
}

View File

@ -60,6 +60,8 @@ public:
wtBeacon = 7,
wtAnvil = 8,
wtHopper = 9,
// Unknown: 10
wtAnimalChest = 11,
};
// tolua_end
@ -75,8 +77,12 @@ public:
cWindowOwner * GetOwner(void) { return m_Owner; }
void SetOwner( cWindowOwner * a_Owner ) { m_Owner = a_Owner; }
/// Returns the total number of slots
int GetNumSlots(void) const;
/// Returns the number of slots, excluding the player's inventory (used for network protocols)
int GetNumNonInventorySlots(void) const { return GetNumSlots() - c_NumInventorySlots; }
// tolua_begin
/// Returns the item at the specified slot for the specified player. Returns NULL if invalid SlotNum requested