| 676 | } |
| 677 | |
| 678 | void PlayerInventory::setCustomBarSecondarySlot(CustomBarIndex customBarIndex, Maybe<InventorySlot> slot) { |
| 679 | auto& cbl = m_customBar.at(m_customBarGroup, customBarIndex); |
| 680 | // The secondary slot is not allowed to point to an empty item or a two |
| 681 | // handed item. |
| 682 | if (slot) { |
| 683 | if (!itemsAt(*slot) || itemSafeTwoHanded(itemsAt(*slot))) |
| 684 | slot = {}; |
| 685 | } |
| 686 | |
| 687 | if (cbl.first && cbl.first == slot && !itemSafeTwoHanded(itemsAt(*cbl.first))) { |
| 688 | // If we match the primary slot and the primary slot is not a two handed |
| 689 | // item, then just swap the two slots. |
| 690 | swap(cbl.first, cbl.second); |
| 691 | } else { |
| 692 | cbl.second = slot; |
| 693 | // If the primary slot was two handed, it is no longer valid so clear it. |
| 694 | if (cbl.first && itemSafeTwoHanded(itemsAt(*cbl.first))) |
| 695 | cbl.first = {}; |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | void PlayerInventory::addToCustomBar(InventorySlot slot) { |
| 700 | for (size_t j = 0; j < m_customBar.size(1); ++j) { |
no test coverage detected