From 862213096645f2dc1de9278f9931948ea4ae58ca Mon Sep 17 00:00:00 2001 From: Juliano Leal Goncalves Date: Mon, 31 May 2021 01:01:35 -0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Add=20'=3D=3D'=20and=20'!?= =?UTF-8?q?=3D'=20operators=20to=20'Size'=20struct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/engine.h | 10 ++++++++++ Source/inv.cpp | 8 +++----- 2 files changed, 13 insertions(+), 5 deletions(-) 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;