summaryrefslogtreecommitdiffstats
path: root/source/Protocol
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-24 09:30:39 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-24 09:30:39 +0200
commitcf87169737fdeeee7d4b160688bbed7194e46147 (patch)
tree7daaeb9af8e3187cde6068c3cff5ff0ee64f0067 /source/Protocol
parentAdded ItemCategory::IsArmor() (diff)
downloadcuberite-cf87169737fdeeee7d4b160688bbed7194e46147.tar
cuberite-cf87169737fdeeee7d4b160688bbed7194e46147.tar.gz
cuberite-cf87169737fdeeee7d4b160688bbed7194e46147.tar.bz2
cuberite-cf87169737fdeeee7d4b160688bbed7194e46147.tar.lz
cuberite-cf87169737fdeeee7d4b160688bbed7194e46147.tar.xz
cuberite-cf87169737fdeeee7d4b160688bbed7194e46147.tar.zst
cuberite-cf87169737fdeeee7d4b160688bbed7194e46147.zip
Diffstat (limited to 'source/Protocol')
-rw-r--r--source/Protocol/Protocol125.cpp3
-rw-r--r--source/Protocol/Protocol132.cpp20
2 files changed, 16 insertions, 7 deletions
diff --git a/source/Protocol/Protocol125.cpp b/source/Protocol/Protocol125.cpp
index 17def7c8a..a4b5feb82 100644
--- a/source/Protocol/Protocol125.cpp
+++ b/source/Protocol/Protocol125.cpp
@@ -874,8 +874,7 @@ void cProtocol125::SendWeather(eWeather a_Weather)
void cProtocol125::SendWholeInventory(const cInventory & a_Inventory)
{
- cCSLock Lock(m_CSPacket);
- SendWindowSlots(0, a_Inventory.c_NumSlots, a_Inventory.GetSlots());
+ SendWholeInventory(*(a_Inventory.GetOwner().GetWindow()));
}
diff --git a/source/Protocol/Protocol132.cpp b/source/Protocol/Protocol132.cpp
index c10338f54..50c335180 100644
--- a/source/Protocol/Protocol132.cpp
+++ b/source/Protocol/Protocol132.cpp
@@ -438,14 +438,24 @@ void cProtocol132::SendWholeInventory(const cWindow & a_Window)
{
// 1.3.2 requires player inventory slots to be sent as SetSlot packets,
// otherwise it sometimes fails to update the window
+
+ // Send the entire window:
super::SendWholeInventory(a_Window);
- const cItem * Slots = m_Client->GetPlayer()->GetInventory().GetSlots();
- int BaseOffset = a_Window.GetNumSlots() - cInventory::c_NumSlots + cInventory::c_MainOffset; // the number of non-inventory slots the window has; inventory follows
+
+ // Send the player inventory and hotbar:
+ const cInventory & Inventory = m_Client->GetPlayer()->GetInventory();
+ int BaseOffset = a_Window.GetNumSlots() - (cInventory::invNumSlots - cInventory::invInventoryOffset); // Number of non-inventory slots
char WindowID = a_Window.GetWindowID();
- for (int i = 0; i < cInventory::c_NumSlots - cInventory::c_MainOffset; i++)
+ for (int i = 0; i < cInventory::invInventoryCount; i++)
{
- SendInventorySlot(WindowID, BaseOffset + i, Slots[i + cInventory::c_MainOffset]);
- } // for i - Slots[]
+ SendInventorySlot(WindowID, BaseOffset + i, Inventory.GetInventorySlot(i));
+ } // for i - Inventory[]
+ BaseOffset += cInventory::invInventoryCount;
+ for (int i = 0; i < cInventory::invHotbarCount; i++)
+ {
+ SendInventorySlot(WindowID, BaseOffset + i, Inventory.GetHotbarSlot(i));
+ } // for i - Hotbar[]
+
// Send even the item being dragged:
SendInventorySlot(-1, -1, m_Client->GetPlayer()->GetDraggingItem());
}