summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2018-01-15 12:35:27 +0100
committerGitHub <noreply@github.com>2018-01-15 12:35:27 +0100
commita72891fbb091440711cbbf95db7a433d641fcc6c (patch)
tree79fb7a31350ff1f8a491be2b4adcc5d7231996dd
parentRename cEntity swim states (#3996) (diff)
downloadcuberite-a72891fbb091440711cbbf95db7a433d641fcc6c.tar
cuberite-a72891fbb091440711cbbf95db7a433d641fcc6c.tar.gz
cuberite-a72891fbb091440711cbbf95db7a433d641fcc6c.tar.bz2
cuberite-a72891fbb091440711cbbf95db7a433d641fcc6c.tar.lz
cuberite-a72891fbb091440711cbbf95db7a433d641fcc6c.tar.xz
cuberite-a72891fbb091440711cbbf95db7a433d641fcc6c.tar.zst
cuberite-a72891fbb091440711cbbf95db7a433d641fcc6c.zip
-rw-r--r--src/UI/Window.cpp38
-rw-r--r--src/UI/Window.h2
2 files changed, 6 insertions, 34 deletions
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index 55df04798..629db12c2 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -421,43 +421,15 @@ void cWindow::DistributeStackToAreas(cItem & a_ItemStack, cPlayer & a_Player, cS
bool cWindow::CollectItemsToHand(cItem & a_Dragging, cSlotArea & a_Area, cPlayer & a_Player, bool a_CollectFullStacks)
{
- // First ask the slot areas from a_Area till the end of list:
- bool ShouldCollect = false;
- for (cSlotAreas::iterator itr = m_SlotAreas.begin(), end = m_SlotAreas.end(); itr != end; ++itr)
+ // Ask to collect items from each slot area in order:
+ for (auto Area : m_SlotAreas)
{
- if (&a_Area == *itr)
- {
- ShouldCollect = true;
- }
- if (!ShouldCollect)
- {
- continue;
- }
- if ((*itr)->CollectItemsToHand(a_Dragging, a_Player, a_CollectFullStacks))
- {
- // a_Dragging is full
- return true;
- }
- }
-
- // a_Dragging still not full, ask slot areas before a_Area in the list:
- for (cSlotAreas::iterator itr = m_SlotAreas.begin(), end = m_SlotAreas.end(); itr != end; ++itr)
- {
- if (*itr == &a_Area)
- {
- // All areas processed
- return false;
- }
- if ((*itr)->CollectItemsToHand(a_Dragging, a_Player, a_CollectFullStacks))
+ if (Area->CollectItemsToHand(a_Dragging, a_Player, a_CollectFullStacks))
{
- // a_Dragging is full
- return true;
+ return true; // a_Dragging is full
}
}
- // Shouldn't reach here
- // a_Area is expected to be part of m_SlotAreas[], so the "return false" in the loop above should have returned already
- ASSERT(!"This branch should not be reached");
- return false;
+ return false; // All areas processed
}
diff --git a/src/UI/Window.h b/src/UI/Window.h
index bdd489d32..65fbc3756 100644
--- a/src/UI/Window.h
+++ b/src/UI/Window.h
@@ -169,7 +169,7 @@ public:
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.
+ /** Called on DblClicking to collect all stackable items from all areas into hand.
The items are accumulated in a_Dragging and removed from the SlotAreas immediately.
If a_CollectFullStacks is false, slots with full stacks in the area are skipped while collecting.
Returns true if full stack has been collected, false if there's space remaining to fill. */