diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-16 22:24:07 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-16 22:24:07 +0200 |
commit | 97eda34a9437abe732cf6b60711828bbe4f0cb2e (patch) | |
tree | f06f2a5bb2ad7efd0d09d9cba0b2f8fe586a53e0 /source/UI/SlotArea.cpp | |
parent | Core: fixed a warning message when using the /item command (diff) | |
download | cuberite-97eda34a9437abe732cf6b60711828bbe4f0cb2e.tar cuberite-97eda34a9437abe732cf6b60711828bbe4f0cb2e.tar.gz cuberite-97eda34a9437abe732cf6b60711828bbe4f0cb2e.tar.bz2 cuberite-97eda34a9437abe732cf6b60711828bbe4f0cb2e.tar.lz cuberite-97eda34a9437abe732cf6b60711828bbe4f0cb2e.tar.xz cuberite-97eda34a9437abe732cf6b60711828bbe4f0cb2e.tar.zst cuberite-97eda34a9437abe732cf6b60711828bbe4f0cb2e.zip |
Diffstat (limited to 'source/UI/SlotArea.cpp')
-rw-r--r-- | source/UI/SlotArea.cpp | 61 |
1 files changed, 20 insertions, 41 deletions
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:
|