diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-11-26 15:15:50 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-11-26 15:15:50 -0500 |
commit | 1ae8293937501c3628afb7c02810aac33b832218 (patch) | |
tree | 345877810e89eb284574a40bfaba8030d0eaee7c /src/game_data.cpp | |
parent | 9bef147ae92afbb8803d98bee6b2be3385c948a2 (diff) | |
parent | 0e6be5bbe8c506882e8100ccaaf13a5f58079f97 (diff) | |
download | lingo-ap-tracker-1ae8293937501c3628afb7c02810aac33b832218.tar.gz lingo-ap-tracker-1ae8293937501c3628afb7c02810aac33b832218.tar.bz2 lingo-ap-tracker-1ae8293937501c3628afb7c02810aac33b832218.zip |
Merge branch 'panels'
Diffstat (limited to 'src/game_data.cpp')
-rw-r--r-- | src/game_data.cpp | 119 |
1 files changed, 105 insertions, 14 deletions
diff --git a/src/game_data.cpp b/src/game_data.cpp index 7b805df..828808f 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 | } |
@@ -772,6 +847,18 @@ struct GameData { | |||
772 | return panel_by_id_[full_name]; | 847 | return panel_by_id_[full_name]; |
773 | } | 848 | } |
774 | 849 | ||
850 | int AddOrGetPanelDoor(std::string room, std::string panel) { | ||
851 | std::string full_name = room + " - " + panel; | ||
852 | |||
853 | if (!panel_doors_by_id_.count(full_name)) { | ||
854 | int panel_door_id = panel_doors_.size(); | ||
855 | panel_doors_by_id_[full_name] = panel_door_id; | ||
856 | panel_doors_.push_back({}); | ||
857 | } | ||
858 | |||
859 | return panel_doors_by_id_[full_name]; | ||
860 | } | ||
861 | |||
775 | int AddOrGetArea(std::string area) { | 862 | int AddOrGetArea(std::string area) { |
776 | if (!area_by_id_.count(area)) { | 863 | if (!area_by_id_.count(area)) { |
777 | if (loaded_area_data_) { | 864 | if (loaded_area_data_) { |
@@ -827,6 +914,10 @@ const std::vector<Door> &GD_GetDoors() { return GetState().doors_; } | |||
827 | 914 | ||
828 | const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } | 915 | const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } |
829 | 916 | ||
917 | const PanelDoor &GD_GetPanelDoor(int panel_door_id) { | ||
918 | return GetState().panel_doors_.at(panel_door_id); | ||
919 | } | ||
920 | |||
830 | int GD_GetDoorByName(const std::string &name) { | 921 | int GD_GetDoorByName(const std::string &name) { |
831 | return GetState().door_by_id_.at(name); | 922 | return GetState().door_by_id_.at(name); |
832 | } | 923 | } |