From e30bec4fd6aedbe70e39640d6b1c78157aa1b38b Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 20 Oct 2012 21:53:09 +0000 Subject: Double chests are now working, and with sound. (FS #69) git-svn-id: http://mc-server.googlecode.com/svn/trunk@993 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/UI/Window.cpp | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'source/UI/Window.cpp') diff --git a/source/UI/Window.cpp b/source/UI/Window.cpp index 0c955ba57..dc5587390 100644 --- a/source/UI/Window.cpp +++ b/source/UI/Window.cpp @@ -155,8 +155,6 @@ void cWindow::OpenedByPlayer(cPlayer & a_Player) } // for itr - m_SlotAreas[] } - // TODO: Notify all areas that a new player has opened the window - a_Player.GetClientHandle()->SendWindowOpen(m_WindowID, m_WindowType, m_WindowTitle, GetNumSlots() - c_NumInventorySlots); } @@ -405,20 +403,43 @@ cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cChestWindow: -cChestWindow::cChestWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cChestEntity * a_Chest) : - cWindow(cWindow::Chest, "MCS-Chest"), +cChestWindow::cChestWindow(cChestEntity * a_Chest) : + cWindow(cWindow::Chest, "MCS-SingleChest"), m_World(a_Chest->GetWorld()), - m_BlockX(a_BlockX), - m_BlockY(a_BlockY), - m_BlockZ(a_BlockZ) + m_BlockX(a_Chest->GetPosX()), + m_BlockY(a_Chest->GetPosY()), + m_BlockZ(a_Chest->GetPosZ()) { m_SlotAreas.push_back(new cSlotAreaChest(a_Chest, *this)); + m_SlotAreas.push_back(new cSlotAreaInventory(*this)); + m_SlotAreas.push_back(new cSlotAreaHotBar(*this)); - // TODO: Double chests - + // Play the opening sound: + m_World->BroadcastSoundEffect("random.chestopen", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1); + + // Send out the chest-open packet: + m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_CHEST); +} + + + + + +cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_SecondaryChest) : + cWindow(cWindow::Chest, "MCS-DoubleChest"), + m_World(a_PrimaryChest->GetWorld()), + m_BlockX(a_PrimaryChest->GetPosX()), + m_BlockY(a_PrimaryChest->GetPosY()), + m_BlockZ(a_PrimaryChest->GetPosZ()) +{ + m_SlotAreas.push_back(new cSlotAreaChest(a_PrimaryChest, *this)); + m_SlotAreas.push_back(new cSlotAreaChest(a_SecondaryChest, *this)); m_SlotAreas.push_back(new cSlotAreaInventory(*this)); m_SlotAreas.push_back(new cSlotAreaHotBar(*this)); + // Play the opening sound: + m_World->BroadcastSoundEffect("random.chestopen", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1); + // Send out the chest-open packet: m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_CHEST); } @@ -431,6 +452,8 @@ cChestWindow::~cChestWindow() { // Send out the chest-close packet: m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_CHEST); + + m_World->BroadcastSoundEffect("random.chestclosed", m_BlockX * 8, m_BlockY * 8, m_BlockZ * 8, 1, 1); } -- cgit v1.2.3