diff --git a/src/app/zelda3/overworld/overworld_item.h b/src/app/zelda3/overworld/overworld_item.h index 9562fcdc..a1b53041 100644 --- a/src/app/zelda3/overworld/overworld_item.h +++ b/src/app/zelda3/overworld/overworld_item.h @@ -1,6 +1,7 @@ #ifndef YAZE_APP_ZELDA3_OVERWORLD_ITEM_H_ #define YAZE_APP_ZELDA3_OVERWORLD_ITEM_H_ +#include #include #include #include @@ -65,6 +66,25 @@ class OverworldItem : public GameEntity { bool deleted = false; }; +inline bool CompareOverworldItems(const std::vector& items1, + const std::vector& items2) { + if (items1.size() != items2.size()) { + return false; + } + + const auto is_same_item = [](const OverworldItem& a, const OverworldItem& b) { + return a.x_ == b.x_ && a.y_ == b.y_ && a.id_ == b.id_; + }; + + return std::all_of(items1.begin(), items1.end(), + [&](const OverworldItem& it) { + return std::any_of(items2.begin(), items2.end(), + [&](const OverworldItem& other) { + return is_same_item(it, other); + }); + }); +} + const std::vector kSecretItemNames = { "Nothing", // 0 "Green Rupee", // 1