From 1cb943a4a68ea5d0fee65672321405c4697f5136 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 8 Dec 2024 16:13:27 -0500 Subject: Add workaround for 0.5.1 number hunt logic bug --- src/game_data.cpp | 29 ++++++++++++++++++++++++++++- src/game_data.h | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/game_data.cpp b/src/game_data.cpp index 828808f..0ac77af 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -55,6 +55,7 @@ struct GameData { std::map painting_by_id_; std::vector door_definition_order_; + std::vector room_definition_order_; std::map room_by_painting_; std::map room_by_sunwarp_; @@ -104,6 +105,7 @@ struct GameData { for (const auto &room_it : lingo_config) { int room_id = AddOrGetRoom(room_it.first.as()); + room_definition_order_.push_back(room_id); for (const auto &entrance_it : room_it.second["entrances"]) { int from_room_id = AddOrGetRoom(entrance_it.first.as()); @@ -722,6 +724,31 @@ struct GameData { } } + // As a workaround for a generator bug in 0.5.1, we are going to remove the + // panel door requirement on panels that are defined earlier in the file than + // the panel door is. This results in logic that matches the generator, even + // if it is not true to how the game should work. This will be reverted once + // the logic bug is fixed and released. + // See: https://github.com/ArchipelagoMW/Archipelago/pull/4342 + for (Panel& panel : panels_) { + if (panel.panel_door == -1) { + continue; + } + const PanelDoor &panel_door = panel_doors_[panel.panel_door]; + for (int room_id : room_definition_order_) { + if (room_id == panel_door.room) { + // The panel door was defined first (or at the same time as the panel), + // so we're good. + break; + } else if (room_id == panel.room) { + // The panel was defined first, so we have to pretend the panel door is + // not required for this panel. + panel.panel_door = -1; + break; + } + } + } + // Report errors. for (const std::string &area : malconfigured_areas_) { TrackerLog(fmt::format("Area data not found for: {}", area)); @@ -853,7 +880,7 @@ struct GameData { if (!panel_doors_by_id_.count(full_name)) { int panel_door_id = panel_doors_.size(); panel_doors_by_id_[full_name] = panel_door_id; - panel_doors_.push_back({}); + panel_doors_.push_back({.room = AddOrGetRoom(room)}); } return panel_doors_by_id_[full_name]; diff --git a/src/game_data.h b/src/game_data.h index b00bac9..31a1e78 100644 --- a/src/game_data.h +++ b/src/game_data.h @@ -85,6 +85,7 @@ struct Door { }; struct PanelDoor { + int room; int ap_item_id = -1; int group_ap_item_id = -1; std::vector progressives; -- cgit 1.4.1