From 004fb711a86d91985d8e94e1b87089db2ac2cadc Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 16 Apr 2024 11:34:49 -0400 Subject: Support panels mode door shuffle --- src/game_data.cpp | 123 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 109 insertions(+), 14 deletions(-) (limited to 'src/game_data.cpp') diff --git a/src/game_data.cpp b/src/game_data.cpp index ee818c4..eece8d7 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -43,11 +43,13 @@ struct GameData { std::vector rooms_; std::vector doors_; std::vector panels_; + std::vector panel_doors_; std::vector map_areas_; std::map room_by_id_; std::map door_by_id_; std::map panel_by_id_; + std::map panel_doors_by_id_; std::map area_by_id_; std::vector door_definition_order_; @@ -408,6 +410,59 @@ struct GameData { } } + if (room_it.second["panel_doors"]) { + for (const auto &panel_door_it : room_it.second["panel_doors"]) { + std::string panel_door_name = panel_door_it.first.as(); + int panel_door_id = + AddOrGetPanelDoor(rooms_[room_id].name, panel_door_name); + + for (const auto &panel_node : panel_door_it.second["panels"]) { + int panel_id = -1; + + if (panel_node.IsScalar()) { + panel_id = AddOrGetPanel(rooms_[room_id].name, + panel_node.as()); + } else { + panel_id = AddOrGetPanel(panel_node["room"].as(), + panel_node["panel"].as()); + } + + Panel &panel = panels_[panel_id]; + panel.panel_door = panel_door_id; + } + + if (ids_config["panel_doors"] && + ids_config["panel_doors"][rooms_[room_id].name] && + ids_config["panel_doors"][rooms_[room_id].name] + [panel_door_name]) { + panel_doors_[panel_door_id].ap_item_id = + ids_config["panel_doors"][rooms_[room_id].name][panel_door_name] + .as(); + } else { + std::ostringstream errmsg; + errmsg << "Missing AP item ID for panel door " + << rooms_[room_id].name << " - " << panel_door_name; + TrackerLog(errmsg.str()); + } + + if (panel_door_it.second["panel_group"]) { + std::string panel_group = + panel_door_it.second["panel_group"].as(); + + if (ids_config["panel_groups"] && + ids_config["panel_groups"][panel_group]) { + panel_doors_[panel_door_id].group_ap_item_id = + ids_config["panel_groups"][panel_group].as(); + } else { + std::ostringstream errmsg; + errmsg << "Missing AP item ID for panel door group " + << panel_group; + TrackerLog(errmsg.str()); + } + } + } + } + if (room_it.second["paintings"]) { for (const auto &painting : room_it.second["paintings"]) { std::string painting_id = painting["id"].as(); @@ -449,23 +504,47 @@ struct GameData { TrackerLog(errmsg.str()); } - int index = 1; - for (const auto &stage : progression_it.second) { - int door_id = -1; + if (progression_it.second["doors"]) { + int index = 1; + for (const auto &stage : progression_it.second["doors"]) { + int door_id = -1; + + if (stage.IsScalar()) { + door_id = + AddOrGetDoor(rooms_[room_id].name, stage.as()); + } else { + door_id = AddOrGetDoor(stage["room"].as(), + stage["door"].as()); + } - if (stage.IsScalar()) { - door_id = - AddOrGetDoor(rooms_[room_id].name, stage.as()); - } else { - door_id = AddOrGetDoor(stage["room"].as(), - stage["door"].as()); + doors_[door_id].progressives.push_back( + {.item_name = progressive_item_name, + .ap_item_id = progressive_item_id, + .quantity = index}); + index++; } + } + + if (progression_it.second["panel_doors"]) { + int index = 1; + for (const auto &stage : progression_it.second["panel_doors"]) { + int panel_door_id = -1; + + if (stage.IsScalar()) { + panel_door_id = AddOrGetPanelDoor(rooms_[room_id].name, + stage.as()); + } else { + panel_door_id = + AddOrGetPanelDoor(stage["room"].as(), + stage["panel_door"].as()); + } - doors_[door_id].progressives.push_back( - {.item_name = progressive_item_name, - .ap_item_id = progressive_item_id, - .quantity = index}); - index++; + panel_doors_[panel_door_id].progressives.push_back( + {.item_name = progressive_item_name, + .ap_item_id = progressive_item_id, + .quantity = index}); + index++; + } } } } @@ -643,6 +722,18 @@ struct GameData { return panel_by_id_[full_name]; } + int AddOrGetPanelDoor(std::string room, std::string panel) { + std::string full_name = room + " - " + panel; + + 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({}); + } + + return panel_doors_by_id_[full_name]; + } + int AddOrGetArea(std::string area) { if (!area_by_id_.count(area)) { if (loaded_area_data_) { @@ -679,6 +770,10 @@ const std::vector &GD_GetDoors() { return GetState().doors_; } const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } +const PanelDoor &GD_GetPanelDoor(int panel_door_id) { + return GetState().panel_doors_.at(panel_door_id); +} + const Panel &GD_GetPanel(int panel_id) { return GetState().panels_.at(panel_id); } -- cgit 1.4.1 From 6676e8fda6c58a93ae9d5cea0c4ad622a77305be Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 9 Jun 2024 23:50:54 -0400 Subject: Fix panels game data error reporting --- src/game_data.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/game_data.cpp') diff --git a/src/game_data.cpp b/src/game_data.cpp index 1ccf511..759eb0c 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -455,10 +455,8 @@ struct GameData { ids_config["panel_doors"][rooms_[room_id].name][panel_door_name] .as(); } else { - std::ostringstream errmsg; - errmsg << "Missing AP item ID for panel door " - << rooms_[room_id].name << " - " << panel_door_name; - TrackerLog(errmsg.str()); + wxLogError("Missing AP item ID for panel door %s - %s", + rooms_[room_id].name, panel_door_name); } if (panel_door_it.second["panel_group"]) { @@ -470,10 +468,8 @@ struct GameData { panel_doors_[panel_door_id].group_ap_item_id = ids_config["panel_groups"][panel_group].as(); } else { - std::ostringstream errmsg; - errmsg << "Missing AP item ID for panel door group " - << panel_group; - TrackerLog(errmsg.str()); + wxLogError("Missing AP item ID for panel door group %s", + panel_group); } } } -- cgit 1.4.1 From 378766bcee3cad04256ada937f96b232aba85cf3 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 24 Jul 2024 09:40:06 -0400 Subject: TrackerLog usage --- src/game_data.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/game_data.cpp') diff --git a/src/game_data.cpp b/src/game_data.cpp index 39ea360..ec8d8f5 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -456,8 +456,8 @@ struct GameData { ids_config["panel_doors"][rooms_[room_id].name][panel_door_name] .as(); } else { - wxLogError("Missing AP item ID for panel door %s - %s", - rooms_[room_id].name, panel_door_name); + TrackerLog(fmt::format("Missing AP item ID for panel door {} - {}", + rooms_[room_id].name, panel_door_name)); } if (panel_door_it.second["panel_group"]) { @@ -469,8 +469,8 @@ struct GameData { panel_doors_[panel_door_id].group_ap_item_id = ids_config["panel_groups"][panel_group].as(); } else { - wxLogError("Missing AP item ID for panel door group %s", - panel_group); + TrackerLog(fmt::format( + "Missing AP item ID for panel door group {}", panel_group)); } } } -- cgit 1.4.1