diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ap_state.cpp | 15 | ||||
-rw-r--r-- | src/ap_state.h | 4 | ||||
-rw-r--r-- | src/game_data.cpp | 119 | ||||
-rw-r--r-- | src/game_data.h | 8 | ||||
-rw-r--r-- | src/tracker_state.cpp | 49 | ||||
-rw-r--r-- | src/version.cpp | 5 |
6 files changed, 175 insertions, 25 deletions
diff --git a/src/ap_state.cpp b/src/ap_state.cpp index f8d4ee0..fbd8d12 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp | |||
@@ -60,6 +60,7 @@ struct APState { | |||
60 | std::optional<std::tuple<int, int>> player_pos; | 60 | std::optional<std::tuple<int, int>> player_pos; |
61 | 61 | ||
62 | DoorShuffleMode door_shuffle_mode = kNO_DOORS; | 62 | DoorShuffleMode door_shuffle_mode = kNO_DOORS; |
63 | bool group_doors = false; | ||
63 | bool color_shuffle = false; | 64 | bool color_shuffle = false; |
64 | bool painting_shuffle = false; | 65 | bool painting_shuffle = false; |
65 | int mastery_requirement = 21; | 66 | int mastery_requirement = 21; |
@@ -140,6 +141,7 @@ struct APState { | |||
140 | player_pos = std::nullopt; | 141 | player_pos = std::nullopt; |
141 | victory_data_storage_key.clear(); | 142 | victory_data_storage_key.clear(); |
142 | door_shuffle_mode = kNO_DOORS; | 143 | door_shuffle_mode = kNO_DOORS; |
144 | group_doors = false; | ||
143 | color_shuffle = false; | 145 | color_shuffle = false; |
144 | painting_shuffle = false; | 146 | painting_shuffle = false; |
145 | painting_mapping.clear(); | 147 | painting_mapping.clear(); |
@@ -236,6 +238,17 @@ struct APState { | |||
236 | data_storage_prefix = | 238 | data_storage_prefix = |
237 | fmt::format("Lingo_{}_", apclient->get_player_number()); | 239 | fmt::format("Lingo_{}_", apclient->get_player_number()); |
238 | door_shuffle_mode = slot_data["shuffle_doors"].get<DoorShuffleMode>(); | 240 | door_shuffle_mode = slot_data["shuffle_doors"].get<DoorShuffleMode>(); |
241 | if (slot_data.contains("group_doors")) { | ||
242 | group_doors = slot_data.contains("group_doors") && | ||
243 | slot_data["group_doors"].get<int>() == 1; | ||
244 | } else { | ||
245 | // If group_doors doesn't exist yet, that means kPANELS_MODE is actually | ||
246 | // kSIMPLE_DOORS. | ||
247 | if (door_shuffle_mode == kPANELS_MODE) { | ||
248 | door_shuffle_mode = kDOORS_MODE; | ||
249 | group_doors = true; | ||
250 | } | ||
251 | } | ||
239 | color_shuffle = slot_data["shuffle_colors"].get<int>() == 1; | 252 | color_shuffle = slot_data["shuffle_colors"].get<int>() == 1; |
240 | painting_shuffle = slot_data["shuffle_paintings"].get<int>() == 1; | 253 | painting_shuffle = slot_data["shuffle_paintings"].get<int>() == 1; |
241 | mastery_requirement = slot_data["mastery_achievements"].get<int>(); | 254 | mastery_requirement = slot_data["mastery_achievements"].get<int>(); |
@@ -534,6 +547,8 @@ std::string AP_GetItemName(int item_id) { | |||
534 | 547 | ||
535 | DoorShuffleMode AP_GetDoorShuffleMode() { return GetState().door_shuffle_mode; } | 548 | DoorShuffleMode AP_GetDoorShuffleMode() { return GetState().door_shuffle_mode; } |
536 | 549 | ||
550 | bool AP_AreDoorsGrouped() { return GetState().group_doors; } | ||
551 | |||
537 | bool AP_IsColorShuffle() { return GetState().color_shuffle; } | 552 | bool AP_IsColorShuffle() { return GetState().color_shuffle; } |
538 | 553 | ||
539 | bool AP_IsPaintingShuffle() { return GetState().painting_shuffle; } | 554 | bool AP_IsPaintingShuffle() { return GetState().painting_shuffle; } |
diff --git a/src/ap_state.h b/src/ap_state.h index f8936e5..e06d4ff 100644 --- a/src/ap_state.h +++ b/src/ap_state.h | |||
@@ -11,7 +11,7 @@ | |||
11 | 11 | ||
12 | class TrackerFrame; | 12 | class TrackerFrame; |
13 | 13 | ||
14 | enum DoorShuffleMode { kNO_DOORS = 0, kSIMPLE_DOORS = 1, kCOMPLEX_DOORS = 2 }; | 14 | enum DoorShuffleMode { kNO_DOORS = 0, kPANELS_MODE = 1, kDOORS_MODE = 2 }; |
15 | 15 | ||
16 | enum VictoryCondition { | 16 | enum VictoryCondition { |
17 | kTHE_END = 0, | 17 | kTHE_END = 0, |
@@ -55,6 +55,8 @@ std::string AP_GetItemName(int item_id); | |||
55 | 55 | ||
56 | DoorShuffleMode AP_GetDoorShuffleMode(); | 56 | DoorShuffleMode AP_GetDoorShuffleMode(); |
57 | 57 | ||
58 | bool AP_AreDoorsGrouped(); | ||
59 | |||
58 | bool AP_IsColorShuffle(); | 60 | bool AP_IsColorShuffle(); |
59 | 61 | ||
60 | bool AP_IsPaintingShuffle(); | 62 | bool AP_IsPaintingShuffle(); |
diff --git a/src/game_data.cpp b/src/game_data.cpp index c39e239..4d448d3 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp | |||
@@ -42,6 +42,7 @@ struct GameData { | |||
42 | std::vector<Room> rooms_; | 42 | std::vector<Room> rooms_; |
43 | std::vector<Door> doors_; | 43 | std::vector<Door> doors_; |
44 | std::vector<Panel> panels_; | 44 | std::vector<Panel> panels_; |
45 | std::vector<PanelDoor> panel_doors_; | ||
45 | std::vector<MapArea> map_areas_; | 46 | std::vector<MapArea> map_areas_; |
46 | std::vector<SubwayItem> subway_items_; | 47 | std::vector<SubwayItem> subway_items_; |
47 | std::vector<PaintingExit> paintings_; | 48 | std::vector<PaintingExit> paintings_; |
@@ -49,6 +50,7 @@ struct GameData { | |||
49 | std::map<std::string, int> room_by_id_; | 50 | std::map<std::string, int> room_by_id_; |
50 | std::map<std::string, int> door_by_id_; | 51 | std::map<std::string, int> door_by_id_; |
51 | std::map<std::string, int> panel_by_id_; | 52 | std::map<std::string, int> panel_by_id_; |
53 | std::map<std::string, int> panel_doors_by_id_; | ||
52 | std::map<std::string, int> area_by_id_; | 54 | std::map<std::string, int> area_by_id_; |
53 | std::map<std::string, int> painting_by_id_; | 55 | std::map<std::string, int> painting_by_id_; |
54 | 56 | ||
@@ -430,6 +432,55 @@ struct GameData { | |||
430 | } | 432 | } |
431 | } | 433 | } |
432 | 434 | ||
435 | if (room_it.second["panel_doors"]) { | ||
436 | for (const auto &panel_door_it : room_it.second["panel_doors"]) { | ||
437 | std::string panel_door_name = panel_door_it.first.as<std::string>(); | ||
438 | int panel_door_id = | ||
439 | AddOrGetPanelDoor(rooms_[room_id].name, panel_door_name); | ||
440 | |||
441 | for (const auto &panel_node : panel_door_it.second["panels"]) { | ||
442 | int panel_id = -1; | ||
443 | |||
444 | if (panel_node.IsScalar()) { | ||
445 | panel_id = AddOrGetPanel(rooms_[room_id].name, | ||
446 | panel_node.as<std::string>()); | ||
447 | } else { | ||
448 | panel_id = AddOrGetPanel(panel_node["room"].as<std::string>(), | ||
449 | panel_node["panel"].as<std::string>()); | ||
450 | } | ||
451 | |||
452 | Panel &panel = panels_[panel_id]; | ||
453 | panel.panel_door = panel_door_id; | ||
454 | } | ||
455 | |||
456 | if (ids_config["panel_doors"] && | ||
457 | ids_config["panel_doors"][rooms_[room_id].name] && | ||
458 | ids_config["panel_doors"][rooms_[room_id].name] | ||
459 | [panel_door_name]) { | ||
460 | panel_doors_[panel_door_id].ap_item_id = | ||
461 | ids_config["panel_doors"][rooms_[room_id].name][panel_door_name] | ||
462 | .as<int>(); | ||
463 | } else { | ||
464 | TrackerLog(fmt::format("Missing AP item ID for panel door {} - {}", | ||
465 | rooms_[room_id].name, panel_door_name)); | ||
466 | } | ||
467 | |||
468 | if (panel_door_it.second["panel_group"]) { | ||
469 | std::string panel_group = | ||
470 | panel_door_it.second["panel_group"].as<std::string>(); | ||
471 | |||
472 | if (ids_config["panel_groups"] && | ||
473 | ids_config["panel_groups"][panel_group]) { | ||
474 | panel_doors_[panel_door_id].group_ap_item_id = | ||
475 | ids_config["panel_groups"][panel_group].as<int>(); | ||
476 | } else { | ||
477 | TrackerLog(fmt::format( | ||
478 | "Missing AP item ID for panel door group {}", panel_group)); | ||
479 | } | ||
480 | } | ||
481 | } | ||
482 | } | ||
483 | |||
433 | if (room_it.second["paintings"]) { | 484 | if (room_it.second["paintings"]) { |
434 | for (const auto &painting : room_it.second["paintings"]) { | 485 | for (const auto &painting : room_it.second["paintings"]) { |
435 | std::string internal_id = painting["id"].as<std::string>(); | 486 | std::string internal_id = painting["id"].as<std::string>(); |
@@ -483,23 +534,47 @@ struct GameData { | |||
483 | progressive_item_name)); | 534 | progressive_item_name)); |
484 | } | 535 | } |
485 | 536 | ||
486 | int index = 1; | 537 | if (progression_it.second["doors"]) { |
487 | for (const auto &stage : progression_it.second) { | 538 | int index = 1; |
488 | int door_id = -1; | 539 | for (const auto &stage : progression_it.second["doors"]) { |
540 | int door_id = -1; | ||
489 | 541 | ||
490 | if (stage.IsScalar()) { | 542 | if (stage.IsScalar()) { |
491 | door_id = | 543 | door_id = |
492 | AddOrGetDoor(rooms_[room_id].name, stage.as<std::string>()); | 544 | AddOrGetDoor(rooms_[room_id].name, stage.as<std::string>()); |
493 | } else { | 545 | } else { |
494 | door_id = AddOrGetDoor(stage["room"].as<std::string>(), | 546 | door_id = AddOrGetDoor(stage["room"].as<std::string>(), |
495 | stage["door"].as<std::string>()); | 547 | stage["door"].as<std::string>()); |
548 | } | ||
549 | |||
550 | doors_[door_id].progressives.push_back( | ||
551 | {.item_name = progressive_item_name, | ||
552 | .ap_item_id = progressive_item_id, | ||
553 | .quantity = index}); | ||
554 | index++; | ||
496 | } | 555 | } |
556 | } | ||
497 | 557 | ||
498 | doors_[door_id].progressives.push_back( | 558 | if (progression_it.second["panel_doors"]) { |
499 | {.item_name = progressive_item_name, | 559 | int index = 1; |
500 | .ap_item_id = progressive_item_id, | 560 | for (const auto &stage : progression_it.second["panel_doors"]) { |
501 | .quantity = index}); | 561 | int panel_door_id = -1; |
502 | index++; | 562 | |
563 | if (stage.IsScalar()) { | ||
564 | panel_door_id = AddOrGetPanelDoor(rooms_[room_id].name, | ||
565 | stage.as<std::string>()); | ||
566 | } else { | ||
567 | panel_door_id = | ||
568 | AddOrGetPanelDoor(stage["room"].as<std::string>(), | ||
569 | stage["panel_door"].as<std::string>()); | ||
570 | } | ||
571 | |||
572 | panel_doors_[panel_door_id].progressives.push_back( | ||
573 | {.item_name = progressive_item_name, | ||
574 | .ap_item_id = progressive_item_id, | ||
575 | .quantity = index}); | ||
576 | index++; | ||
577 | } | ||
503 | } | 578 | } |
504 | } | 579 | } |
505 | } | 580 | } |
@@ -760,6 +835,18 @@ struct GameData { | |||
760 | return panel_by_id_[full_name]; | 835 | return panel_by_id_[full_name]; |
761 | } | 836 | } |
762 | 837 | ||
838 | int AddOrGetPanelDoor(std::string room, std::string panel) { | ||
839 | std::string full_name = room + " - " + panel; | ||
840 | |||
841 | if (!panel_doors_by_id_.count(full_name)) { | ||
842 | int panel_door_id = panel_doors_.size(); | ||
843 | panel_doors_by_id_[full_name] = panel_door_id; | ||
844 | panel_doors_.push_back({}); | ||
845 | } | ||
846 | |||
847 | return panel_doors_by_id_[full_name]; | ||
848 | } | ||
849 | |||
763 | int AddOrGetArea(std::string area) { | 850 | int AddOrGetArea(std::string area) { |
764 | if (!area_by_id_.count(area)) { | 851 | if (!area_by_id_.count(area)) { |
765 | if (loaded_area_data_) { | 852 | if (loaded_area_data_) { |
@@ -810,6 +897,10 @@ const std::vector<Door> &GD_GetDoors() { return GetState().doors_; } | |||
810 | 897 | ||
811 | const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } | 898 | const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } |
812 | 899 | ||
900 | const PanelDoor &GD_GetPanelDoor(int panel_door_id) { | ||
901 | return GetState().panel_doors_.at(panel_door_id); | ||
902 | } | ||
903 | |||
813 | int GD_GetDoorByName(const std::string &name) { | 904 | int GD_GetDoorByName(const std::string &name) { |
814 | return GetState().door_by_id_.at(name); | 905 | return GetState().door_by_id_.at(name); |
815 | } | 906 | } |
diff --git a/src/game_data.h b/src/game_data.h index 3179365..9b6f3b2 100644 --- a/src/game_data.h +++ b/src/game_data.h | |||
@@ -56,6 +56,7 @@ struct Panel { | |||
56 | bool non_counting = false; | 56 | bool non_counting = false; |
57 | int ap_location_id = -1; | 57 | int ap_location_id = -1; |
58 | bool hunt = false; | 58 | bool hunt = false; |
59 | int panel_door = -1; | ||
59 | }; | 60 | }; |
60 | 61 | ||
61 | struct ProgressiveRequirement { | 62 | struct ProgressiveRequirement { |
@@ -83,6 +84,12 @@ struct Door { | |||
83 | DoorType type = DoorType::kNormal; | 84 | DoorType type = DoorType::kNormal; |
84 | }; | 85 | }; |
85 | 86 | ||
87 | struct PanelDoor { | ||
88 | int ap_item_id = -1; | ||
89 | int group_ap_item_id = -1; | ||
90 | std::vector<ProgressiveRequirement> progressives; | ||
91 | }; | ||
92 | |||
86 | struct Exit { | 93 | struct Exit { |
87 | int source_room; | 94 | int source_room; |
88 | int destination_room; | 95 | int destination_room; |
@@ -161,6 +168,7 @@ const std::vector<Door>& GD_GetDoors(); | |||
161 | const Door& GD_GetDoor(int door_id); | 168 | const Door& GD_GetDoor(int door_id); |
162 | int GD_GetDoorByName(const std::string& name); | 169 | int GD_GetDoorByName(const std::string& name); |
163 | const Panel& GD_GetPanel(int panel_id); | 170 | const Panel& GD_GetPanel(int panel_id); |
171 | const PanelDoor& GD_GetPanelDoor(int panel_door_id); | ||
164 | const PaintingExit& GD_GetPaintingExit(int painting_id); | 172 | const PaintingExit& GD_GetPaintingExit(int painting_id); |
165 | int GD_GetPaintingByName(const std::string& name); | 173 | int GD_GetPaintingByName(const std::string& name); |
166 | const std::vector<int>& GD_GetAchievementPanels(); | 174 | const std::vector<int>& GD_GetAchievementPanels(); |
diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index 2ee705c..4a49fac 100644 --- a/src/tracker_state.cpp +++ b/src/tracker_state.cpp | |||
@@ -19,11 +19,12 @@ namespace { | |||
19 | struct Requirements { | 19 | struct Requirements { |
20 | bool disabled = false; | 20 | bool disabled = false; |
21 | 21 | ||
22 | std::set<int> doors; // non-grouped, handles progressive | 22 | std::set<int> doors; // non-grouped, handles progressive |
23 | std::set<int> items; // all other items | 23 | std::set<int> panel_doors; // non-grouped, handles progressive |
24 | std::set<int> rooms; // maybe | 24 | std::set<int> items; // all other items |
25 | bool mastery = false; // maybe | 25 | std::set<int> rooms; // maybe |
26 | bool panel_hunt = false; // maybe | 26 | bool mastery = false; // maybe |
27 | bool panel_hunt = false; // maybe | ||
27 | 28 | ||
28 | void Merge(const Requirements& rhs) { | 29 | void Merge(const Requirements& rhs) { |
29 | if (rhs.disabled) { | 30 | if (rhs.disabled) { |
@@ -33,6 +34,9 @@ struct Requirements { | |||
33 | for (int id : rhs.doors) { | 34 | for (int id : rhs.doors) { |
34 | doors.insert(id); | 35 | doors.insert(id); |
35 | } | 36 | } |
37 | for (int id : rhs.panel_doors) { | ||
38 | panel_doors.insert(id); | ||
39 | } | ||
36 | for (int id : rhs.items) { | 40 | for (int id : rhs.items) { |
37 | items.insert(id); | 41 | items.insert(id); |
38 | } | 42 | } |
@@ -78,15 +82,14 @@ class RequirementCalculator { | |||
78 | requirements.doors.insert(door_obj.id); | 82 | requirements.doors.insert(door_obj.id); |
79 | break; | 83 | break; |
80 | } | 84 | } |
81 | } else if (AP_GetDoorShuffleMode() == kNO_DOORS || door_obj.skip_item) { | 85 | } else if (AP_GetDoorShuffleMode() != kDOORS_MODE || door_obj.skip_item) { |
82 | requirements.rooms.insert(door_obj.room); | 86 | requirements.rooms.insert(door_obj.room); |
83 | 87 | ||
84 | for (int panel_id : door_obj.panels) { | 88 | for (int panel_id : door_obj.panels) { |
85 | const Requirements& panel_reqs = GetPanel(panel_id); | 89 | const Requirements& panel_reqs = GetPanel(panel_id); |
86 | requirements.Merge(panel_reqs); | 90 | requirements.Merge(panel_reqs); |
87 | } | 91 | } |
88 | } else if (AP_GetDoorShuffleMode() == kSIMPLE_DOORS && | 92 | } else if (AP_AreDoorsGrouped() && !door_obj.group_name.empty()) { |
89 | !door_obj.group_name.empty()) { | ||
90 | requirements.items.insert(door_obj.group_ap_item_id); | 93 | requirements.items.insert(door_obj.group_ap_item_id); |
91 | } else { | 94 | } else { |
92 | requirements.doors.insert(door_obj.id); | 95 | requirements.doors.insert(door_obj.id); |
@@ -133,6 +136,17 @@ class RequirementCalculator { | |||
133 | requirements.items.insert(GD_GetItemIdForColor(color)); | 136 | requirements.items.insert(GD_GetItemIdForColor(color)); |
134 | } | 137 | } |
135 | } | 138 | } |
139 | |||
140 | if (panel_obj.panel_door != -1 && | ||
141 | AP_GetDoorShuffleMode() == kPANELS_MODE) { | ||
142 | const PanelDoor& panel_door_obj = GD_GetPanelDoor(panel_obj.panel_door); | ||
143 | |||
144 | if (panel_door_obj.group_ap_item_id != -1 && AP_AreDoorsGrouped()) { | ||
145 | requirements.items.insert(panel_door_obj.group_ap_item_id); | ||
146 | } else { | ||
147 | requirements.panel_doors.insert(panel_obj.panel_door); | ||
148 | } | ||
149 | } | ||
136 | 150 | ||
137 | panels_[panel_id] = requirements; | 151 | panels_[panel_id] = requirements; |
138 | } | 152 | } |
@@ -296,7 +310,7 @@ class StateCalculator { | |||
296 | if (AP_HasEarlyColorHallways() && room_obj.name == "Starting Room") { | 310 | if (AP_HasEarlyColorHallways() && room_obj.name == "Starting Room") { |
297 | new_boundary.push_back( | 311 | new_boundary.push_back( |
298 | {.source_room = room_exit.destination_room, | 312 | {.source_room = room_exit.destination_room, |
299 | .destination_room = GD_GetRoomByName("Outside The Undeterred"), | 313 | .destination_room = GD_GetRoomByName("Color Hallways"), |
300 | .type = EntranceType::kPainting}); | 314 | .type = EntranceType::kPainting}); |
301 | } | 315 | } |
302 | 316 | ||
@@ -378,7 +392,8 @@ class StateCalculator { | |||
378 | } | 392 | } |
379 | 393 | ||
380 | private: | 394 | private: |
381 | Decision IsNonGroupedDoorReachable(const Door& door_obj) { | 395 | template <typename T> |
396 | Decision IsNonGroupedDoorReachable(const T& door_obj) { | ||
382 | bool has_item = AP_HasItem(door_obj.ap_item_id); | 397 | bool has_item = AP_HasItem(door_obj.ap_item_id); |
383 | 398 | ||
384 | if (!has_item) { | 399 | if (!has_item) { |
@@ -414,6 +429,20 @@ class StateCalculator { | |||
414 | } | 429 | } |
415 | } | 430 | } |
416 | 431 | ||
432 | for (int panel_door_id : reqs.panel_doors) { | ||
433 | const PanelDoor& panel_door_obj = GD_GetPanelDoor(panel_door_id); | ||
434 | Decision decision = IsNonGroupedDoorReachable(panel_door_obj); | ||
435 | |||
436 | if (report) { | ||
437 | (*report)[AP_GetItemName(panel_door_obj.ap_item_id)] = | ||
438 | (decision == kYes); | ||
439 | } | ||
440 | |||
441 | if (decision != kYes) { | ||
442 | final_decision = decision; | ||
443 | } | ||
444 | } | ||
445 | |||
417 | for (int item_id : reqs.items) { | 446 | for (int item_id : reqs.items) { |
418 | bool has_item = AP_HasItem(item_id); | 447 | bool has_item = AP_HasItem(item_id); |
419 | if (report) { | 448 | if (report) { |
diff --git a/src/version.cpp b/src/version.cpp new file mode 100644 index 0000000..3b4d5f3 --- /dev/null +++ b/src/version.cpp | |||
@@ -0,0 +1,5 @@ | |||
1 | #include "version.h" | ||
2 | |||
3 | std::ostream& operator<<(std::ostream& out, const Version& ver) { | ||
4 | return out << "v" << ver.major << "." << ver.minor << "." << ver.revision; | ||
5 | } | ||