From b2908b641f87797beadfd2a580da68914c3cbae6 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Tue, 10 Nov 2026 16:52:24 +0000 Subject: [PATCH] Decompile fn_04182 (UILapineBox_IngredientListWnd::CanUseIngredient) Batch #16316 by youko: 0 byte-identical, 1 confirmed by peer review. - fn_04182 UILapineBox_IngredientListWnd::CanUseIngredient: logic confirmed by peer review Peer-reviewed-by: Yommy, Toshiro, bgamez23 Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/UILapineBoxWnd.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/Source/UI/UILapineBoxWnd.cpp b/Source/UI/UILapineBoxWnd.cpp index 36574cfef..1b34264b5 100644 --- a/Source/UI/UILapineBoxWnd.cpp +++ b/Source/UI/UILapineBoxWnd.cpp @@ -226,25 +226,18 @@ __declspec(noinline) ITEM_INFO UILapineBoxWnd::ReadMaterial(int x, int y) { // OFFSET: 0x00602620 // FUNCTION: fn_04182 bool UILapineBox_IngredientListWnd::CanUseIngredient(std::uint32_t identity) { - std::vector::iterator entryIt; - for (entryIt = this->items.begin(); entryIt != this->items.end(); ++entryIt) { - if ((*entryIt)->item.identity[1] == identity) { - break; - } - } + const auto entryIt = std::find_if(this->items.begin(), this->items.end(), [identity](UIIngredientInfoWnd* entry) { + return identity == entry->item.identity[1]; + }); if (entryIt == this->items.end()) { return false; } const ITEM_INFO& item = (*entryIt)->item; - std::vector::iterator material; - const std::vector::iterator end = this->materials.end(); - for (material = this->materials.begin(); material != end; ++material) { - ITEM_INFO copy(*material); - if (std::atoi(item.itemId.c_str()) == std::atoi(copy.itemId.c_str())) { - break; - } - } + const auto material = std::find_if(this->materials.begin(), this->materials.end(), [&item](ITEM_INFO candidate) { + const int itemId = std::atoi(item.itemId.c_str()); + return itemId == std::atoi(candidate.itemId.c_str()); + }); if (material == this->materials.end()) { return false; } @@ -266,7 +259,7 @@ bool UILapineBox_IngredientListWnd::CanUseIngredient(std::uint32_t identity) { this->parent->SendMsg(this, UM_RECEIVE_MSG, reinterpret_cast(LookupMessage(MSI_ITEMSHOP_CURRENCY)), 0, 0, 0); } - if (Equipment(item) && !item.IsApprenticeItem() && !item.HasSpecialCard()) { + if (Equipment(item) == true && !item.IsApprenticeItem() && !item.HasSpecialCard()) { const int* cards = reinterpret_cast(item.cards); for (int index = 0; index < ItemSlotsCount(item); ++index) { if (index < 4 && cards[index] > 0) {