diff options
-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 | 47 | ||||
-rw-r--r-- | src/version.cpp | 5 |
6 files changed, 174 insertions, 24 deletions
diff --git a/src/ap_state.cpp b/src/ap_state.cpp index ebc5fc9..d501e81 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp | |||
@@ -58,6 +58,7 @@ struct APState { | |||
58 | std::optional<std::tuple<int, int>> player_pos; | 58 | std::optional<std::tuple<int, int>> player_pos; |
59 | 59 | ||
60 | DoorShuffleMode door_shuffle_mode = kNO_DOORS; | 60 | DoorShuffleMode door_shuffle_mode = kNO_DOORS; |
61 | bool group_doors = false; | ||
61 | bool color_shuffle = false; | 62 | bool color_shuffle = false; |
62 | bool painting_shuffle = false; | 63 | bool painting_shuffle = false; |
63 | int mastery_requirement = 21; | 64 | int mastery_requirement = 21; |
@@ -137,6 +138,7 @@ struct APState { | |||
137 | player_pos = std::nullopt; | 138 | player_pos = std::nullopt; |
138 | victory_data_storage_key.clear(); | 139 | victory_data_storage_key.clear(); |
139 | door_shuffle_mode = kNO_DOORS; | 140 | door_shuffle_mode = kNO_DOORS; |
141 | group_doors = false; | ||
140 | color_shuffle = false; | 142 | color_shuffle = false; |
141 | painting_shuffle = false; | 143 | painting_shuffle = false; |
142 | painting_mapping.clear(); | 144 | painting_mapping.clear(); |
@@ -231,6 +233,17 @@ struct APState { | |||
231 | data_storage_prefix = | 233 | data_storage_prefix = |
232 | fmt::format("Lingo_{}_", apclient->get_player_number()); | 234 | fmt::format("Lingo_{}_", apclient->get_player_number()); |
233 | door_shuffle_mode = slot_data["shuffle_doors"].get<DoorShuffleMode>(); | 235 | door_shuffle_mode = slot_data["shuffle_doors"].get<DoorShuffleMode>(); |
236 | if (slot_data.contains("group_doors")) { | ||
237 | group_doors = slot_data.contains("group_doors") && | ||
238 | slot_data["group_doors"].get<int>() == 1; | ||
239 | } else { | ||
240 | // If group_doors doesn't exist yet, that means kPANELS_MODE is actually | ||
241 | // kSIMPLE_DOORS. | ||
242 | if (door_shuffle_mode == kPANELS_MODE) { | ||
243 | door_shuffle_mode = kDOORS_MODE; | ||
244 | group_doors = true; | ||
245 | } | ||
246 | } | ||
234 | color_shuffle = slot_data["shuffle_colors"].get<int>() == 1; | 247 | color_shuffle = slot_data["shuffle_colors"].get<int>() == 1; |
235 | painting_shuffle = slot_data["shuffle_paintings"].get<int>() == 1; | 248 | painting_shuffle = slot_data["shuffle_paintings"].get<int>() == 1; |
236 | mastery_requirement = slot_data["mastery_achievements"].get<int>(); | 249 | mastery_requirement = slot_data["mastery_achievements"].get<int>(); |
@@ -527,6 +540,8 @@ std::string AP_GetItemName(int item_id) { | |||
527 | 540 | ||
528 | DoorShuffleMode AP_GetDoorShuffleMode() { return GetState().door_shuffle_mode; } | 541 | DoorShuffleMode AP_GetDoorShuffleMode() { return GetState().door_shuffle_mode; } |
529 | 542 | ||
543 | bool AP_AreDoorsGrouped() { return GetState().group_doors; } | ||
544 | |||
530 | bool AP_IsColorShuffle() { return GetState().color_shuffle; } | 545 | bool AP_IsColorShuffle() { return GetState().color_shuffle; } |
531 | 546 | ||
532 | bool AP_IsPaintingShuffle() { return GetState().painting_shuffle; } | 547 | bool AP_IsPaintingShuffle() { return GetState().painting_shuffle; } |
diff --git a/src/ap_state.h b/src/ap_state.h index 7af7395..190b21f 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, |
@@ -53,6 +53,8 @@ std::string AP_GetItemName(int item_id); | |||
53 | 53 | ||
54 | DoorShuffleMode AP_GetDoorShuffleMode(); | 54 | DoorShuffleMode AP_GetDoorShuffleMode(); |
55 | 55 | ||
56 | bool AP_AreDoorsGrouped(); | ||
57 | |||
56 | bool AP_IsColorShuffle(); | 58 | bool AP_IsColorShuffle(); |
57 | 59 | ||
58 | bool AP_IsPaintingShuffle(); | 60 | bool AP_IsPaintingShuffle(); |
diff --git a/src/game_data.cpp b/src/game_data.cpp index 4c0104f..39ea360 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 | ||
@@ -425,6 +427,55 @@ struct GameData { | |||
425 | } | 427 | } |
426 | } | 428 | } |
427 | 429 | ||
430 | if (room_it.second["panel_doors"]) { | ||
431 | for (const auto &panel_door_it : room_it.second["panel_doors"]) { | ||
432 | std::string panel_door_name = panel_door_it.first.as<std::string>(); | ||
433 | int panel_door_id = | ||
434 | AddOrGetPanelDoor(rooms_[room_id].name, panel_door_name); | ||
435 | |||
436 | for (const auto &panel_node : panel_door_it.second["panels"]) { | ||
437 | int panel_id = -1; | ||
438 | |||
439 | if (panel_node.IsScalar()) { | ||
440 | panel_id = AddOrGetPanel(rooms_[room_id].name, | ||
441 | panel_node.as<std::string>()); | ||
442 | } else { | ||
443 | panel_id = AddOrGetPanel(panel_node["room"].as<std::string>(), | ||
444 | panel_node["panel"].as<std::string>()); | ||
445 | } | ||
446 | |||
447 | Panel &panel = panels_[panel_id]; | ||
448 | panel.panel_door = panel_door_id; | ||
449 | } | ||
450 | |||
451 | if (ids_config["panel_doors"] && | ||
452 | ids_config["panel_doors"][rooms_[room_id].name] && | ||
453 | ids_config["panel_doors"][rooms_[room_id].name] | ||
454 | [panel_door_name]) { | ||
455 | panel_doors_[panel_door_id].ap_item_id = | ||
456 | ids_config["panel_doors"][rooms_[room_id].name][panel_door_name] | ||
457 | .as<int>(); | ||
458 | } else { | ||
459 | wxLogError("Missing AP item ID for panel door %s - %s", | ||
460 | rooms_[room_id].name, panel_door_name); | ||
461 | } | ||
462 | |||
463 | if (panel_door_it.second["panel_group"]) { | ||
464 | std::string panel_group = | ||
465 | panel_door_it.second["panel_group"].as<std::string>(); | ||
466 | |||
467 | if (ids_config["panel_groups"] && | ||
468 | ids_config["panel_groups"][panel_group]) { | ||
469 | panel_doors_[panel_door_id].group_ap_item_id = | ||
470 | ids_config["panel_groups"][panel_group].as<int>(); | ||
471 | } else { | ||
472 | wxLogError("Missing AP item ID for panel door group %s", | ||
473 | panel_group); | ||
474 | } | ||
475 | } | ||
476 | } | ||
477 | } | ||
478 | |||
428 | if (room_it.second["paintings"]) { | 479 | if (room_it.second["paintings"]) { |
429 | for (const auto &painting : room_it.second["paintings"]) { | 480 | for (const auto &painting : room_it.second["paintings"]) { |
430 | std::string internal_id = painting["id"].as<std::string>(); | 481 | std::string internal_id = painting["id"].as<std::string>(); |
@@ -478,23 +529,47 @@ struct GameData { | |||
478 | progressive_item_name)); | 529 | progressive_item_name)); |
479 | } | 530 | } |
480 | 531 | ||
481 | int index = 1; | 532 | if (progression_it.second["doors"]) { |
482 | for (const auto &stage : progression_it.second) { | 533 | int index = 1; |
483 | int door_id = -1; | 534 | for (const auto &stage : progression_it.second["doors"]) { |
535 | int door_id = -1; | ||
484 | 536 | ||
485 | if (stage.IsScalar()) { | 537 | if (stage.IsScalar()) { |
486 | door_id = | 538 | door_id = |
487 | AddOrGetDoor(rooms_[room_id].name, stage.as<std::string>()); | 539 | AddOrGetDoor(rooms_[room_id].name, stage.as<std::string>()); |
488 | } else { | 540 | } else { |
489 | door_id = AddOrGetDoor(stage["room"].as<std::string>(), | 541 | door_id = AddOrGetDoor(stage["room"].as<std::string>(), |
490 | stage["door"].as<std::string>()); | 542 | stage["door"].as<std::string>()); |
543 | } | ||
544 | |||
545 | doors_[door_id].progressives.push_back( | ||
546 | {.item_name = progressive_item_name, | ||
547 | .ap_item_id = progressive_item_id, | ||
548 | .quantity = index}); | ||
549 | index++; | ||
491 | } | 550 | } |
551 | } | ||
492 | 552 | ||
493 | doors_[door_id].progressives.push_back( | 553 | if (progression_it.second["panel_doors"]) { |
494 | {.item_name = progressive_item_name, | 554 | int index = 1; |
495 | .ap_item_id = progressive_item_id, | 555 | for (const auto &stage : progression_it.second["panel_doors"]) { |
496 | .quantity = index}); | 556 | int panel_door_id = -1; |
497 | index++; | 557 | |
558 | if (stage.IsScalar()) { | ||
559 | panel_door_id = AddOrGetPanelDoor(rooms_[room_id].name, | ||
560 | stage.as<std::string>()); | ||
561 | } else { | ||
562 | panel_door_id = | ||
563 | AddOrGetPanelDoor(stage["room"].as<std::string>(), | ||
564 | stage["panel_door"].as<std::string>()); | ||
565 | } | ||
566 | |||
567 | panel_doors_[panel_door_id].progressives.push_back( | ||
568 | {.item_name = progressive_item_name, | ||
569 | .ap_item_id = progressive_item_id, | ||
570 | .quantity = index}); | ||
571 | index++; | ||
572 | } | ||
498 | } | 573 | } |
499 | } | 574 | } |
500 | } | 575 | } |
@@ -753,6 +828,18 @@ struct GameData { | |||
753 | return panel_by_id_[full_name]; | 828 | return panel_by_id_[full_name]; |
754 | } | 829 | } |
755 | 830 | ||
831 | int AddOrGetPanelDoor(std::string room, std::string panel) { | ||
832 | std::string full_name = room + " - " + panel; | ||
833 | |||
834 | if (!panel_doors_by_id_.count(full_name)) { | ||
835 | int panel_door_id = panel_doors_.size(); | ||
836 | panel_doors_by_id_[full_name] = panel_door_id; | ||
837 | panel_doors_.push_back({}); | ||
838 | } | ||
839 | |||
840 | return panel_doors_by_id_[full_name]; | ||
841 | } | ||
842 | |||
756 | int AddOrGetArea(std::string area) { | 843 | int AddOrGetArea(std::string area) { |
757 | if (!area_by_id_.count(area)) { | 844 | if (!area_by_id_.count(area)) { |
758 | if (loaded_area_data_) { | 845 | if (loaded_area_data_) { |
@@ -803,6 +890,10 @@ const std::vector<Door> &GD_GetDoors() { return GetState().doors_; } | |||
803 | 890 | ||
804 | const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } | 891 | const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } |
805 | 892 | ||
893 | const PanelDoor &GD_GetPanelDoor(int panel_door_id) { | ||
894 | return GetState().panel_doors_.at(panel_door_id); | ||
895 | } | ||
896 | |||
806 | int GD_GetDoorByName(const std::string &name) { | 897 | int GD_GetDoorByName(const std::string &name) { |
807 | return GetState().door_by_id_.at(name); | 898 | return GetState().door_by_id_.at(name); |
808 | } | 899 | } |
diff --git a/src/game_data.h b/src/game_data.h index 23f7b3a..197585c 100644 --- a/src/game_data.h +++ b/src/game_data.h | |||
@@ -55,6 +55,7 @@ struct Panel { | |||
55 | bool non_counting = false; | 55 | bool non_counting = false; |
56 | int ap_location_id = -1; | 56 | int ap_location_id = -1; |
57 | bool hunt = false; | 57 | bool hunt = false; |
58 | int panel_door = -1; | ||
58 | }; | 59 | }; |
59 | 60 | ||
60 | struct ProgressiveRequirement { | 61 | struct ProgressiveRequirement { |
@@ -82,6 +83,12 @@ struct Door { | |||
82 | DoorType type = DoorType::kNormal; | 83 | DoorType type = DoorType::kNormal; |
83 | }; | 84 | }; |
84 | 85 | ||
86 | struct PanelDoor { | ||
87 | int ap_item_id = -1; | ||
88 | int group_ap_item_id = -1; | ||
89 | std::vector<ProgressiveRequirement> progressives; | ||
90 | }; | ||
91 | |||
85 | struct Exit { | 92 | struct Exit { |
86 | int source_room; | 93 | int source_room; |
87 | int destination_room; | 94 | int destination_room; |
@@ -158,6 +165,7 @@ const std::vector<Door>& GD_GetDoors(); | |||
158 | const Door& GD_GetDoor(int door_id); | 165 | const Door& GD_GetDoor(int door_id); |
159 | int GD_GetDoorByName(const std::string& name); | 166 | int GD_GetDoorByName(const std::string& name); |
160 | const Panel& GD_GetPanel(int panel_id); | 167 | const Panel& GD_GetPanel(int panel_id); |
168 | const PanelDoor& GD_GetPanelDoor(int panel_door_id); | ||
161 | const PaintingExit& GD_GetPaintingExit(int painting_id); | 169 | const PaintingExit& GD_GetPaintingExit(int painting_id); |
162 | int GD_GetPaintingByName(const std::string& name); | 170 | int GD_GetPaintingByName(const std::string& name); |
163 | const std::vector<int>& GD_GetAchievementPanels(); | 171 | const std::vector<int>& GD_GetAchievementPanels(); |
diff --git a/src/tracker_state.cpp b/src/tracker_state.cpp index ba615d1..14d302b 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 | } |
@@ -375,7 +389,8 @@ class StateCalculator { | |||
375 | } | 389 | } |
376 | 390 | ||
377 | private: | 391 | private: |
378 | Decision IsNonGroupedDoorReachable(const Door& door_obj) { | 392 | template <typename T> |
393 | Decision IsNonGroupedDoorReachable(const T& door_obj) { | ||
379 | bool has_item = AP_HasItem(door_obj.ap_item_id); | 394 | bool has_item = AP_HasItem(door_obj.ap_item_id); |
380 | 395 | ||
381 | if (!has_item) { | 396 | if (!has_item) { |
@@ -411,6 +426,20 @@ class StateCalculator { | |||
411 | } | 426 | } |
412 | } | 427 | } |
413 | 428 | ||
429 | for (int panel_door_id : reqs.panel_doors) { | ||
430 | const PanelDoor& panel_door_obj = GD_GetPanelDoor(panel_door_id); | ||
431 | Decision decision = IsNonGroupedDoorReachable(panel_door_obj); | ||
432 | |||
433 | if (report) { | ||
434 | (*report)[AP_GetItemName(panel_door_obj.ap_item_id)] = | ||
435 | (decision == kYes); | ||
436 | } | ||
437 | |||
438 | if (decision != kYes) { | ||
439 | final_decision = decision; | ||
440 | } | ||
441 | } | ||
442 | |||
414 | for (int item_id : reqs.items) { | 443 | for (int item_id : reqs.items) { |
415 | bool has_item = AP_HasItem(item_id); | 444 | bool has_item = AP_HasItem(item_id); |
416 | if (report) { | 445 | 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 | } | ||