diff options
Diffstat (limited to 'src/game_data.cpp')
-rw-r--r-- | src/game_data.cpp | 122 |
1 files changed, 107 insertions, 15 deletions
diff --git a/src/game_data.cpp b/src/game_data.cpp index e75170e..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 | ||
@@ -109,6 +111,7 @@ struct GameData { | |||
109 | auto process_single_entrance = | 111 | auto process_single_entrance = |
110 | [this, room_id, from_room_id](const YAML::Node &option) { | 112 | [this, room_id, from_room_id](const YAML::Node &option) { |
111 | Exit exit_obj; | 113 | Exit exit_obj; |
114 | exit_obj.source_room = from_room_id; | ||
112 | exit_obj.destination_room = room_id; | 115 | exit_obj.destination_room = room_id; |
113 | 116 | ||
114 | if (option["door"]) { | 117 | if (option["door"]) { |
@@ -143,7 +146,7 @@ struct GameData { | |||
143 | switch (entrance_it.second.Type()) { | 146 | switch (entrance_it.second.Type()) { |
144 | case YAML::NodeType::Scalar: { | 147 | case YAML::NodeType::Scalar: { |
145 | // This is just "true". | 148 | // This is just "true". |
146 | rooms_[from_room_id].exits.push_back({.destination_room = room_id}); | 149 | rooms_[from_room_id].exits.push_back({.source_room = from_room_id, .destination_room = room_id}); |
147 | break; | 150 | break; |
148 | } | 151 | } |
149 | case YAML::NodeType::Map: { | 152 | case YAML::NodeType::Map: { |
@@ -424,6 +427,55 @@ struct GameData { | |||
424 | } | 427 | } |
425 | } | 428 | } |
426 | 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 | |||
427 | if (room_it.second["paintings"]) { | 479 | if (room_it.second["paintings"]) { |
428 | for (const auto &painting : room_it.second["paintings"]) { | 480 | for (const auto &painting : room_it.second["paintings"]) { |
429 | std::string internal_id = painting["id"].as<std::string>(); | 481 | std::string internal_id = painting["id"].as<std::string>(); |
@@ -477,23 +529,47 @@ struct GameData { | |||
477 | progressive_item_name)); | 529 | progressive_item_name)); |
478 | } | 530 | } |
479 | 531 | ||
480 | int index = 1; | 532 | if (progression_it.second["doors"]) { |
481 | for (const auto &stage : progression_it.second) { | 533 | int index = 1; |
482 | int door_id = -1; | 534 | for (const auto &stage : progression_it.second["doors"]) { |
535 | int door_id = -1; | ||
483 | 536 | ||
484 | if (stage.IsScalar()) { | 537 | if (stage.IsScalar()) { |
485 | door_id = | 538 | door_id = |
486 | AddOrGetDoor(rooms_[room_id].name, stage.as<std::string>()); | 539 | AddOrGetDoor(rooms_[room_id].name, stage.as<std::string>()); |
487 | } else { | 540 | } else { |
488 | door_id = AddOrGetDoor(stage["room"].as<std::string>(), | 541 | door_id = AddOrGetDoor(stage["room"].as<std::string>(), |
489 | 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++; | ||
490 | } | 550 | } |
551 | } | ||
491 | 552 | ||
492 | doors_[door_id].progressives.push_back( | 553 | if (progression_it.second["panel_doors"]) { |
493 | {.item_name = progressive_item_name, | 554 | int index = 1; |
494 | .ap_item_id = progressive_item_id, | 555 | for (const auto &stage : progression_it.second["panel_doors"]) { |
495 | .quantity = index}); | 556 | int panel_door_id = -1; |
496 | 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 | } | ||
497 | } | 573 | } |
498 | } | 574 | } |
499 | } | 575 | } |
@@ -752,6 +828,18 @@ struct GameData { | |||
752 | return panel_by_id_[full_name]; | 828 | return panel_by_id_[full_name]; |
753 | } | 829 | } |
754 | 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 | |||
755 | int AddOrGetArea(std::string area) { | 843 | int AddOrGetArea(std::string area) { |
756 | if (!area_by_id_.count(area)) { | 844 | if (!area_by_id_.count(area)) { |
757 | if (loaded_area_data_) { | 845 | if (loaded_area_data_) { |
@@ -802,6 +890,10 @@ const std::vector<Door> &GD_GetDoors() { return GetState().doors_; } | |||
802 | 890 | ||
803 | 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); } |
804 | 892 | ||
893 | const PanelDoor &GD_GetPanelDoor(int panel_door_id) { | ||
894 | return GetState().panel_doors_.at(panel_door_id); | ||
895 | } | ||
896 | |||
805 | int GD_GetDoorByName(const std::string &name) { | 897 | int GD_GetDoorByName(const std::string &name) { |
806 | return GetState().door_by_id_.at(name); | 898 | return GetState().door_by_id_.at(name); |
807 | } | 899 | } |