From e8366993ce3f1cc0c2c6cde1d133773d1f23c474 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Mon, 6 Aug 2012 20:10:16 +0000 Subject: A bit of cleanup and documentation around the UI window handling git-svn-id: http://mc-server.googlecode.com/svn/trunk@716 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cPlayer.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'source/cPlayer.cpp') diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp index b7b7919fd..c260330f6 100644 --- a/source/cPlayer.cpp +++ b/source/cPlayer.cpp @@ -460,7 +460,7 @@ void cPlayer::CloseWindow(char a_WindowType) (m_Inventory->GetWindow()->GetDraggingItem()->m_ItemCount > 0) ) { - LOG("Player holds item! Dropping it..."); + LOGD("Player holds item! Dropping it..."); TossItem( true, m_Inventory->GetWindow()->GetDraggingItem()->m_ItemCount ); } @@ -481,17 +481,18 @@ void cPlayer::CloseWindow(char a_WindowType) m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY() + 1.6f, GetPosZ(), vX * 2, vY * 2, vZ * 2); } - if (m_CurrentWindow) + if (m_CurrentWindow != NULL) { // FIXME: If the player entity is destroyed while having a chest window open, the chest will not close - if (a_WindowType == 1 && strcmp(m_CurrentWindow->GetWindowTitle().c_str(), "UberChest") == 0) { // Chest - cBlockEntity *block = m_CurrentWindow->GetOwner()->GetEntity(); + if ((a_WindowType == 1) && (m_CurrentWindow->GetWindowType() == cWindow::Chest)) + { + // Chest cPacket_BlockAction ChestClose; - ChestClose.m_PosX = block->GetPosX(); - ChestClose.m_PosY = (short)block->GetPosY(); - ChestClose.m_PosZ = block->GetPosZ(); - ChestClose.m_Byte1 = 1; - ChestClose.m_Byte2 = 0; + int y = 0; + m_CurrentWindow->GetOwner()->GetBlockPos(ChestClose.m_PosX, y, ChestClose.m_PosZ); + ChestClose.m_PosY = (short)y; + ChestClose.m_Byte1 = 1; // Unused, always 1 + ChestClose.m_Byte2 = 0; // 0 = closed m_World->Broadcast(ChestClose); } -- cgit v1.2.3