about summary refs log tree commit diff stats
path: root/src/game_data.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game_data.cpp')
-rw-r--r--src/game_data.cpp119
1 files changed, 105 insertions, 14 deletions
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
811const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } 898const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); }
812 899
900const PanelDoor &GD_GetPanelDoor(int panel_door_id) {
901 return GetState().panel_doors_.at(panel_door_id);
902}
903
813int GD_GetDoorByName(const std::string &name) { 904int GD_GetDoorByName(const std::string &name) {
814 return GetState().door_by_id_.at(name); 905 return GetState().door_by_id_.at(name);
815} 906}