Skip to content

Commit

Permalink
Inventory: Fix assertion caused by a no-op stack movement
Browse files Browse the repository at this point in the history
  • Loading branch information
SmallJoker committed Aug 5, 2023
1 parent 128d22e commit 28ee491
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/gui/guiFormSpecMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4452,6 +4452,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
Original file line number Diff line number Diff line change
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
3 changes: 3 additions & 0 deletions src/inventorymanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
return;
}

if (list_from.get() == list_to.get() && from_i == to_i)
return; // Same slot

/*
Do not handle rollback if both inventories are that of the same player
*/
Expand Down

0 comments on commit 28ee491

Please sign in to comment.