From 2bf1b2abf0e90da14080573d7270cca62b2815f0 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 16 Jul 2024 01:19:02 -0400 Subject: Display correct sunwarp doors when shuffled --- src/subway_map.cpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/subway_map.cpp b/src/subway_map.cpp index e3b844d..044e6fa 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp @@ -16,6 +16,29 @@ constexpr int OWL_ACTUAL_SIZE = 32; enum class ItemDrawType { kNone, kBox, kOwl }; +namespace { + +std::optional GetRealSubwayDoor(const SubwayItem subway_item) { + std::optional subway_door = subway_item.door; + if (AP_IsSunwarpShuffle() && subway_item.sunwarp && + subway_item.sunwarp->type != SubwaySunwarpType::kFinal) { + int sunwarp_index = subway_item.sunwarp->dots - 1; + if (subway_item.sunwarp->type == SubwaySunwarpType::kExit) { + sunwarp_index += 6; + } + + for (const auto &[start_index, mapping] : AP_GetSunwarpMapping()) { + if (start_index == sunwarp_index || mapping.exit_index == sunwarp_index) { + subway_door = GD_GetSunwarpDoors().at(mapping.dots - 1); + } + } + + return subway_door; + } +} + +} // namespace + SubwayMap::SubwayMap(wxWindow *parent) : wxPanel(parent, wxID_ANY) { SetBackgroundStyle(wxBG_STYLE_PAINT); @@ -267,9 +290,11 @@ void SubwayMap::OnPaint(wxPaintEvent &event) { // Note that these requirements are duplicated on OnMouseClick so that it // knows when an item has a hover effect. const SubwayItem &subway_item = GD_GetSubwayItem(*hovered_item_); - if (subway_item.door && !GetDoorRequirements(*subway_item.door).empty()) { + std::optional subway_door = GetRealSubwayDoor(subway_item); + + if (subway_door && !GetDoorRequirements(*subway_door).empty()) { const std::map &report = - GetDoorRequirements(*subway_item.door); + GetDoorRequirements(*subway_door); int acc_height = 10; int col_width = 0; @@ -450,7 +475,9 @@ void SubwayMap::OnMouseClick(wxMouseEvent &event) { if (actual_hover_) { const SubwayItem &subway_item = GD_GetSubwayItem(*actual_hover_); - if ((subway_item.door && !GetDoorRequirements(*subway_item.door).empty()) || + std::optional subway_door = GetRealSubwayDoor(subway_item); + + if ((subway_door && !GetDoorRequirements(*subway_door).empty()) || networks_.IsItemInNetwork(*hovered_item_)) { if (actual_hover_ != hovered_item_) { hovered_item_ = actual_hover_; -- cgit 1.4.1