diff --git a/Source/engine.h b/Source/engine.h index 4aab6d8fd..246a56ec2 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -195,6 +195,16 @@ struct Point { struct Size { int Width; int Height; + + bool operator==(const Size &other) const + { + return Width == other.Width && Height == other.Height; + } + + bool operator!=(const Size &other) const + { + return !(*this == other); + } }; struct ActorPosition { diff --git a/Source/inv.cpp b/Source/inv.cpp index b210c5081..6a9b5a6e8 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -377,9 +377,7 @@ Size GetInventorySize(const ItemStruct &item) */ bool FitsInBeltSlot(const ItemStruct &item) { - Size size = GetInventorySize(item); - - return size.Width == 1 && size.Height == 1; + return GetInventorySize(item) == Size { 1, 1 }; } /** @@ -659,7 +657,7 @@ bool AutoPlaceItemInInventory(PlayerStruct &player, const ItemStruct &item, bool return false; } - if (itemSize.Width == 1 && itemSize.Height == 3) { + if (itemSize == Size { 1, 3 }) { for (int i = 0; i < 20; i++) { if (AutoPlaceItemInInventorySlot(player, i, item, persistItem)) return true; @@ -667,7 +665,7 @@ bool AutoPlaceItemInInventory(PlayerStruct &player, const ItemStruct &item, bool return false; } - if (itemSize.Width == 2 && itemSize.Height == 3) { + if (itemSize == Size { 2, 3 }) { for (int i = 0; i < 9; i++) { if (AutoPlaceItemInInventorySlot(player, i, item, persistItem)) return true;