From 97eda34a9437abe732cf6b60711828bbe4f0cb2e Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 16 Jun 2013 20:24:07 +0000 Subject: Rewritten furnaces Furnaces now smelt the correct number of items. Furnaces store their contents in a cItemGrid. Furnace window is updated with correct items and progressbars. Furnace recipes now use ticks instead of milliseconds. Furnaces save and load their state completely, not missing a smelt operation. Hoppers take items out of furnaces. Dropped the cSlotAreaDropSpenser class, replaced it with generic cSlotAreaItemGrid git-svn-id: http://mc-server.googlecode.com/svn/trunk@1601 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/UI/SlotArea.cpp | 61 +++++++++++++++++--------------------------------- 1 file changed, 20 insertions(+), 41 deletions(-) (limited to 'source/UI/SlotArea.cpp') diff --git a/source/UI/SlotArea.cpp b/source/UI/SlotArea.cpp index feeeb4add..fc3f248f5 100644 --- a/source/UI/SlotArea.cpp +++ b/source/UI/SlotArea.cpp @@ -475,43 +475,22 @@ cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cSlotAreaDropSpenser: - -cSlotAreaDropSpenser::cSlotAreaDropSpenser(cDropSpenserEntity * a_DropSpenser, cWindow & a_ParentWindow) : - cSlotArea(9, a_ParentWindow), - m_DropSpenser(a_DropSpenser) -{ -} - - - - - -const cItem * cSlotAreaDropSpenser::GetSlot(int a_SlotNum, cPlayer & a_Player) const -{ - return &(m_DropSpenser->GetSlot(a_SlotNum)); -} - - - - +// cSlotAreaFurnace: -void cSlotAreaDropSpenser::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) +cSlotAreaFurnace::cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_ParentWindow) : + cSlotArea(3, a_ParentWindow), + m_Furnace(a_Furnace) { - m_DropSpenser->SetSlot(a_SlotNum, a_Item); + m_Furnace->GetContents().AddListener(*this); } -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cSlotAreaFurnace: - -cSlotAreaFurnace::cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_ParentWindow) : - cSlotArea(3, a_ParentWindow), - m_Furnace(a_Furnace) +cSlotAreaFurnace::~cSlotAreaFurnace() { + m_Furnace->GetContents().RemoveListener(*this); } @@ -520,8 +499,6 @@ cSlotAreaFurnace::cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_Paren void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) { - cItem Fuel = *GetSlot(0, a_Player); - super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem); if (m_Furnace == NULL) @@ -530,16 +507,6 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a ASSERT(!"cSlotAreaFurnace::Clicked(): m_Furnace == NULL"); return; } - - if (Fuel.m_ItemType != GetSlot(0, a_Player)->m_ItemType) - { - m_Furnace->ResetCookTimer(); - } - - if (m_Furnace->StartCooking()) - { - m_ParentWindow.SendWholeWindow(*(a_Player.GetClientHandle())); - } } @@ -549,7 +516,7 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a const cItem * cSlotAreaFurnace::GetSlot(int a_SlotNum, cPlayer & a_Player) const { // a_SlotNum ranges from 0 to 2, query the items from the underlying furnace: - return m_Furnace->GetSlot(a_SlotNum); + return &(m_Furnace->GetSlot(a_SlotNum)); } @@ -565,6 +532,18 @@ void cSlotAreaFurnace::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & +void cSlotAreaFurnace::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) +{ + // Something has changed in the window, broadcast the entire window to all clients + ASSERT(a_ItemGrid == &(m_Furnace->GetContents())); + + m_ParentWindow.BroadcastWholeWindow(); +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cSlotAreaInventoryBase: -- cgit v1.2.3