From 3e802932a6797fc0f4768ebc61cf9ac4f498c7fb Mon Sep 17 00:00:00 2001 From: changyong guo Date: Mon, 23 Jul 2018 06:23:33 +0800 Subject: recover hotbar selected slot after reconnect (#4249) 1. implement protocol message SendHeldItemChange 2. add save / load inventory equipped item slot in JSON 3. send held item slot message after player connect to server Fixes #4189 --- src/Protocol/Protocol_1_9.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/Protocol/Protocol_1_9.cpp') diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp index 64721ed04..2621f140c 100644 --- a/src/Protocol/Protocol_1_9.cpp +++ b/src/Protocol/Protocol_1_9.cpp @@ -636,6 +636,20 @@ void cProtocol_1_9_0::SendHealth(void) +void cProtocol_1_9_0::SendHeldItemChange(int a_ItemIndex) +{ + ASSERT((a_ItemIndex >= 0) && (a_ItemIndex <= 8)); // Valid check + + cPacketizer Pkt(*this, GetPacketId(sendHeldItemChange)); // Held item change + cPlayer * Player = m_Client->GetPlayer(); + Pkt.WriteBEInt8(static_cast(Player->GetInventory().GetEquippedSlotNum())); +} + + + + + + void cProtocol_1_9_0::SendHideTitle(void) { ASSERT(m_State == 3); // In game mode? -- cgit v1.2.3