1
0

Fixed personal crafting grid not being tossed on inventory close.

FS #355, http://www.mc-server.org/support/index.php?do=details&task_id=355

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1358 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2013-04-04 11:47:31 +00:00
parent fbacc1e1c4
commit 4aed49a70f
10 changed files with 22 additions and 36 deletions

View File

@ -1359,18 +1359,18 @@ void cClientHandle::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNu
void cClientHandle::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
void cClientHandle::SendWindowClose(const cWindow & a_Window)
{
m_Protocol->SendWindowOpen(a_WindowID, a_WindowType, a_WindowTitle, a_NumSlots);
m_Protocol->SendWindowClose(a_Window);
}
void cClientHandle::SendWindowClose(char a_WindowID)
void cClientHandle::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots)
{
m_Protocol->SendWindowClose(a_WindowID);
m_Protocol->SendWindowOpen(a_WindowID, a_WindowType, a_WindowTitle, a_NumSlots);
}

View File

@ -125,7 +125,7 @@ public:
void SendWeather (eWeather a_Weather);
void SendWholeInventory (const cInventory & a_Inventory);
void SendWholeInventory (const cWindow & a_Window);
void SendWindowClose (char a_WindowID);
void SendWindowClose (const cWindow & a_Window);
void SendWindowOpen (char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots);
void SendUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );

View File

@ -455,27 +455,8 @@ void cPlayer::OpenWindow( cWindow* a_Window )
void cPlayer::CloseWindow(char a_WindowType)
{
if (m_CurrentWindow == m_InventoryWindow)
{
// The inventory window must not be closed and must not be even sent a close packet
if (IsDraggingItem()) // But we need to check if player is holding anything
{
LOGD("Player holds item in inventory window! Dropping it...");
TossItem(true, GetDraggingItem().m_ItemCount);
}
return;
}
if (m_CurrentWindow != NULL)
{
// TODO: This code should be in cChestWindow instead
if ((a_WindowType == 1) && (m_CurrentWindow->GetWindowType() == cWindow::Chest))
{
int x, y, z;
m_CurrentWindow->GetOwner()->GetBlockPos(x, y, z);
m_World->BroadcastBlockAction(x, y, z, 1, 0, E_BLOCK_CHEST);
}
m_CurrentWindow->ClosedByPlayer(*this);
}
m_CurrentWindow = m_InventoryWindow;

View File

@ -96,7 +96,7 @@ public:
virtual void SendWeather (eWeather a_Weather) = 0;
virtual void SendWholeInventory (const cInventory & a_Inventory) = 0;
virtual void SendWholeInventory (const cWindow & a_Window) = 0;
virtual void SendWindowClose (char a_WindowID) = 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;
/// Returns the ServerID used for authentication through session.minecraft.net

View File

@ -863,11 +863,17 @@ void cProtocol125::SendWholeInventory(const cWindow & a_Window)
void cProtocol125::SendWindowClose(char a_WindowID)
void cProtocol125::SendWindowClose(const cWindow & a_Window)
{
if (a_Window.GetWindowType() == cWindow::Inventory)
{
// Do not send inventory-window-close
return;
}
cCSLock Lock(m_CSPacket);
WriteByte(PACKET_WINDOW_CLOSE);
WriteByte(a_WindowID);
WriteByte(a_Window.GetWindowID());
Flush();
}

View File

@ -73,7 +73,7 @@ public:
virtual void SendWeather (eWeather a_Weather) override;
virtual void SendWholeInventory (const cInventory & a_Inventory) override;
virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (char a_WindowID) 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 AString GetAuthServerID(void) override;

View File

@ -556,10 +556,10 @@ void cProtocolRecognizer::SendWholeInventory(const cWindow & a_Window)
void cProtocolRecognizer::SendWindowClose(char a_WindowID)
void cProtocolRecognizer::SendWindowClose(const cWindow & a_Window)
{
ASSERT(m_Protocol != NULL);
m_Protocol->SendWindowClose(a_WindowID);
m_Protocol->SendWindowClose(a_Window);
}

View File

@ -100,7 +100,7 @@ public:
virtual void SendWeather (eWeather a_Weather) override;
virtual void SendWholeInventory (const cInventory & a_Inventory) override;
virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (char a_WindowID) 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 AString GetAuthServerID(void) override;

View File

@ -165,8 +165,6 @@ void cWindow::OpenedByPlayer(cPlayer & a_Player)
void cWindow::ClosedByPlayer(cPlayer & a_Player)
{
ASSERT(m_WindowType != Inventory); // Inventory windows must not be closed (the client would repeat the close packet, looping forever)
// Checks whether the player is still holding an item
if (a_Player.IsDraggingItem())
{
@ -177,7 +175,7 @@ void cWindow::ClosedByPlayer(cPlayer & a_Player)
cClientHandle * ClientHandle = a_Player.GetClientHandle();
if (ClientHandle != NULL)
{
ClientHandle->SendWindowClose(m_WindowID);
ClientHandle->SendWindowClose(*this);
}
{
@ -189,7 +187,8 @@ void cWindow::ClosedByPlayer(cPlayer & a_Player)
} // for itr - m_SlotAreas[]
m_OpenedBy.remove(&a_Player);
if (m_OpenedBy.empty())
if ((m_WindowType != Inventory) && m_OpenedBy.empty())
{
Destroy();
}

View File

@ -62,7 +62,7 @@ public:
char GetWindowID(void) const { return m_WindowID; }
int GetWindowType(void) const { return m_WindowType; }
cWindowOwner * GetOwner() { return m_Owner; }
cWindowOwner * GetOwner(void) { return m_Owner; }
void SetOwner( cWindowOwner * a_Owner ) { m_Owner = a_Owner; }
int GetNumSlots(void) const;