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 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
804const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } 891const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); }
805 892
893const PanelDoor &GD_GetPanelDoor(int panel_door_id) {
894 return GetState().panel_doors_.at(panel_door_id);
895}
896
806int GD_GetDoorByName(const std::string &name) { 897int GD_GetDoorByName(const std::string &name) {
807 return GetState().door_by_id_.at(name); 898 return GetState().door_by_id_.at(name);
808} 899}