Skip to content

Commit

Permalink
Inventory: skip redundant stack movement
Browse files Browse the repository at this point in the history
The list of dragged stacks includes the source stack, which
however does not need to be moved onto itself.
This is an optimization.
  • Loading branch information
SmallJoker authored and sfan5 committed Aug 27, 2023
1 parent 0ba899e commit bf9f831
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/gui/guiFormSpecMenu.cpp
Expand Up @@ -4447,6 +4447,12 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
if (m_left_drag_stacks.size() > 1) {
// Finalize the left-dragging
for (auto &ds : m_left_drag_stacks) {
if (ds.first == *m_selected_item) {
// This entry is needed to properly calculate the stack sizes.
// The stack already exists, hence no further action needed here.
continue;
}

// Check how many items we should move to this slot,
// it may be less than the full split
Inventory *inv_to = m_invmgr->getInventory(ds.first.inventoryloc);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/guiInventoryList.h
Expand Up @@ -43,7 +43,7 @@ class GUIInventoryList : public gui::IGUIElement
{
}

bool operator==(const ItemSpec& other)
bool operator==(const ItemSpec& other) const
{
return inventoryloc == other.inventoryloc &&
listname == other.listname && i == other.i;
Expand Down

0 comments on commit bf9f831

Please sign in to comment.