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
This commit is contained in:
@@ -474,37 +474,6 @@ 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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cSlotAreaDropSpenser::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
|
||||
{
|
||||
m_DropSpenser->SetSlot(a_SlotNum, a_Item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// cSlotAreaFurnace:
|
||||
|
||||
@@ -512,6 +481,16 @@ cSlotAreaFurnace::cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_Paren
|
||||
cSlotArea(3, a_ParentWindow),
|
||||
m_Furnace(a_Furnace)
|
||||
{
|
||||
m_Furnace->GetContents().AddListener(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user