1
0
Fork 0

C++11 and function rename.

This commit is contained in:
Howaner 2014-12-17 19:14:01 +01:00
parent 6ee7fd3c67
commit 8277e1ec4e
16 changed files with 71 additions and 50 deletions

View File

@ -167,6 +167,24 @@ void cLuaWindow::Destroy(void)
void cLuaWindow::DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer& a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply)
{
cSlotAreas Areas;
for (auto Area : m_SlotAreas)
{
if (Area != a_ClickedArea)
{
Areas.push_back(Area);
}
}
super::DistributeStackToAreas(a_ItemStack, a_Player, Areas, a_ShouldApply, false);
}
void cLuaWindow::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
{
if (a_ItemGrid != &m_Contents)

View File

@ -84,6 +84,7 @@ protected:
// cWindow overrides:
virtual bool ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) override;
virtual void Destroy(void) override;
virtual void DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply) override;
// cItemGrid::cListener overrides:
virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;

View File

@ -293,9 +293,8 @@ const cFurnaceRecipe::cRecipe * cFurnaceRecipe::GetRecipeFrom(const cItem & a_In
bool cFurnaceRecipe::IsFuel(const cItem & a_Item) const
{
for (FuelList::const_iterator itr = m_pState->Fuel.begin(); itr != m_pState->Fuel.end(); ++itr)
for (auto & Fuel : m_pState->Fuel)
{
const cFuel & Fuel = *itr;
if ((Fuel.In->m_ItemType == a_Item.m_ItemType) && (Fuel.In->m_ItemCount <= a_Item.m_ItemCount))
{
return true;

View File

@ -70,7 +70,7 @@ public:
// Inventory or Hotbar
AreasInOrder.push_back(m_SlotAreas[0]); /* Anvil */
}
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
protected:

View File

@ -44,7 +44,7 @@ public:
// Beacon Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
@ -63,7 +63,7 @@ public:
// Hotbar Area
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
}
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}

View File

@ -117,13 +117,13 @@ public:
// Chest Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
// Hotbar or Inventory
AreasInOrder.push_back(m_SlotAreas[0]); /* Chest */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}

View File

@ -48,19 +48,19 @@ public:
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
}
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, (a_Slot == 0));
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, (a_Slot == 0));
}
else if (a_ClickedArea == m_SlotAreas[1])
{
// Inventory Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
else
{
// Hotbar
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
};

View File

@ -40,13 +40,13 @@ public:
// DropSpenser Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
// Inventory or Hotbar
AreasInOrder.push_back(m_SlotAreas[0]); /* DropSpenser */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
};

View File

@ -79,13 +79,13 @@ public:
// Enchanting Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
// Inventory or Hotbar
AreasInOrder.push_back(m_SlotAreas[0]); /* Enchanting */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}

View File

@ -58,13 +58,13 @@ public:
// Chest Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
// Hotbar or Inventory
AreasInOrder.push_back(m_SlotAreas[0]); /* Chest */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}

View File

@ -43,14 +43,14 @@ public:
// Result Slot
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
// Furnace Input/Fuel Slot
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
else
@ -71,7 +71,7 @@ public:
// Hotbar Area
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
}
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
};

View File

@ -40,13 +40,13 @@ public:
// Hopper Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
// Inventory or Hotbar
AreasInOrder.push_back(m_SlotAreas[0]); /* Hopper */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
};

View File

@ -50,28 +50,28 @@ public:
AreasInOrder.push_back(m_SlotAreas[2]); /* Inventory */
AreasInOrder.push_back(m_SlotAreas[3]); /* Hotbar */
}
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, (a_Slot == 0));
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, (a_Slot == 0));
}
else if (a_ClickedArea == m_SlotAreas[1])
{
// Armor Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Inventory */
AreasInOrder.push_back(m_SlotAreas[3]); /* Hotbar */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
else if (a_ClickedArea == m_SlotAreas[2])
{
// Inventory Area
AreasInOrder.push_back(m_SlotAreas[1]); /* Armor */
AreasInOrder.push_back(m_SlotAreas[3]); /* Hotbar */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
else
{
// Hotbar
AreasInOrder.push_back(m_SlotAreas[1]); /* Armor */
AreasInOrder.push_back(m_SlotAreas[2]); /* Inventory */
super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}

View File

@ -33,6 +33,26 @@ public:
a_ChestCart->GetWorld()->BroadcastSoundEffect("random.chestopen", a_ChestCart->GetPosX(), a_ChestCart->GetPosY(), a_ChestCart->GetPosZ(), 1, 1);
}
virtual void DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea* a_ClickedArea, bool a_ShouldApply) override
{
cSlotAreas AreasInOrder;
if (a_ClickedArea == m_SlotAreas[0])
{
// Chest Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
// Hotbar or Inventory
AreasInOrder.push_back(m_SlotAreas[0]); /* Chest */
super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
~cMinecartWithChestWindow()
{
m_ChestCart->GetWorld()->BroadcastSoundEffect("random.chestclosed", m_ChestCart->GetPosX(), m_ChestCart->GetPosY(), m_ChestCart->GetPosZ(), 1, 1);

View File

@ -391,31 +391,13 @@ bool cWindow::ForEachClient(cItemCallback<cClientHandle> & a_Callback)
void cWindow::DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply)
{
cSlotAreas Areas;
for (auto Area : m_SlotAreas)
{
if (Area != a_ClickedArea)
{
Areas.push_back(Area);
}
}
DistributeStack(a_ItemStack, a_Player, Areas, a_ShouldApply, false);
}
void cWindow::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, cSlotAreas & a_AreasInOrder, bool a_ShouldApply, bool a_BackFill)
void cWindow::DistributeStackToAreas(cItem & a_ItemStack, cPlayer & a_Player, cSlotAreas & a_AreasInOrder, bool a_ShouldApply, bool a_BackFill)
{
for (size_t i = 0; i < 2; i++)
{
for (cSlotAreas::iterator itr = a_AreasInOrder.begin(); itr != a_AreasInOrder.end(); ++itr)
for (auto SlotArea : a_AreasInOrder)
{
(*itr)->DistributeStack(a_ItemStack, a_Player, a_ShouldApply, (i == 0), a_BackFill);
SlotArea->DistributeStack(a_ItemStack, a_Player, a_ShouldApply, (i == 0), a_BackFill);
if (a_ItemStack.IsEmpty())
{
// Distributed it all

View File

@ -153,11 +153,12 @@ public:
/** Called on shift-clicking to distribute the stack into other areas; Modifies a_ItemStack as it is distributed!
if a_ShouldApply is true, the changes are written into the slots;
if a_ShouldApply is false, only a_ItemStack is modified to reflect the number of fits (for fit-testing purposes)
*/
virtual void DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply);
if a_ShouldApply is false, only a_ItemStack is modified to reflect the number of fits (for fit-testing purposes) */
virtual void DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply) = 0;
void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, cSlotAreas & a_AreasInOrder, bool a_ShouldApply, bool a_BackFill);
/** Called from DistributeStack() to distribute the stack into a_AreasInOrder; Modifies a_ItemStack as it is distributed!
If a_BackFill is true, the areas will be filled from the back (right side). (Example: Empty Hotbar -> Item get in slot 8, not slot 0) */
void DistributeStackToAreas(cItem & a_ItemStack, cPlayer & a_Player, cSlotAreas & a_AreasInOrder, bool a_ShouldApply, bool a_BackFill);
/** Called on DblClicking to collect all stackable items from all areas into hand, starting with the specified area.
The items are accumulated in a_Dragging and removed from the SlotAreas immediately.