diff options
Diffstat (limited to 'src/game_data.cpp')
-rw-r--r-- | src/game_data.cpp | 123 |
1 files changed, 109 insertions, 14 deletions
diff --git a/src/game_data.cpp b/src/game_data.cpp index 6f1a2e4..1ccf511 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp | |||
@@ -46,6 +46,7 @@ struct GameData { | |||
46 | std::vector<Room> rooms_; | 46 | std::vector<Room> rooms_; |
47 | std::vector<Door> doors_; | 47 | std::vector<Door> doors_; |
48 | std::vector<Panel> panels_; | 48 | std::vector<Panel> panels_; |
49 | std::vector<PanelDoor> panel_doors_; | ||
49 | std::vector<MapArea> map_areas_; | 50 | std::vector<MapArea> map_areas_; |
50 | std::vector<SubwayItem> subway_items_; | 51 | std::vector<SubwayItem> subway_items_; |
51 | std::vector<PaintingExit> paintings_; | 52 | std::vector<PaintingExit> paintings_; |
@@ -53,6 +54,7 @@ struct GameData { | |||
53 | std::map<std::string, int> room_by_id_; | 54 | std::map<std::string, int> room_by_id_; |
54 | std::map<std::string, int> door_by_id_; | 55 | std::map<std::string, int> door_by_id_; |
55 | std::map<std::string, int> panel_by_id_; | 56 | std::map<std::string, int> panel_by_id_; |
57 | std::map<std::string, int> panel_doors_by_id_; | ||
56 | std::map<std::string, int> area_by_id_; | 58 | std::map<std::string, int> area_by_id_; |
57 | std::map<std::string, int> painting_by_id_; | 59 | std::map<std::string, int> painting_by_id_; |
58 | 60 | ||
@@ -424,6 +426,59 @@ struct GameData { | |||
424 | } | 426 | } |
425 | } | 427 | } |
426 | 428 | ||
429 | if (room_it.second["panel_doors"]) { | ||
430 | for (const auto &panel_door_it : room_it.second["panel_doors"]) { | ||
431 | std::string panel_door_name = panel_door_it.first.as<std::string>(); | ||
432 | int panel_door_id = | ||
433 | AddOrGetPanelDoor(rooms_[room_id].name, panel_door_name); | ||
434 | |||
435 | for (const auto &panel_node : panel_door_it.second["panels"]) { | ||
436 | int panel_id = -1; | ||
437 | |||
438 | if (panel_node.IsScalar()) { | ||
439 | panel_id = AddOrGetPanel(rooms_[room_id].name, | ||
440 | panel_node.as<std::string>()); | ||
441 | } else { | ||
442 | panel_id = AddOrGetPanel(panel_node["room"].as<std::string>(), | ||
443 | panel_node["panel"].as<std::string>()); | ||
444 | } | ||
445 | |||
446 | Panel &panel = panels_[panel_id]; | ||
447 | panel.panel_door = panel_door_id; | ||
448 | } | ||
449 | |||
450 | if (ids_config["panel_doors"] && | ||
451 | ids_config["panel_doors"][rooms_[room_id].name] && | ||
452 | ids_config["panel_doors"][rooms_[room_id].name] | ||
453 | [panel_door_name]) { | ||
454 | panel_doors_[panel_door_id].ap_item_id = | ||
455 | ids_config["panel_doors"][rooms_[room_id].name][panel_door_name] | ||
456 | .as<int>(); | ||
457 | } else { | ||
458 | std::ostringstream errmsg; | ||
459 | errmsg << "Missing AP item ID for panel door " | ||
460 | << rooms_[room_id].name << " - " << panel_door_name; | ||
461 | TrackerLog(errmsg.str()); | ||
462 | } | ||
463 | |||
464 | if (panel_door_it.second["panel_group"]) { | ||
465 | std::string panel_group = | ||
466 | panel_door_it.second["panel_group"].as<std::string>(); | ||
467 | |||
468 | if (ids_config["panel_groups"] && | ||
469 | ids_config["panel_groups"][panel_group]) { | ||
470 | panel_doors_[panel_door_id].group_ap_item_id = | ||
471 | ids_config["panel_groups"][panel_group].as<int>(); | ||
472 | } else { | ||
473 | std::ostringstream errmsg; | ||
474 | errmsg << "Missing AP item ID for panel door group " | ||
475 | << panel_group; | ||
476 | TrackerLog(errmsg.str()); | ||
477 | } | ||
478 | } | ||
479 | } | ||
480 | } | ||
481 | |||
427 | if (room_it.second["paintings"]) { | 482 | if (room_it.second["paintings"]) { |
428 | for (const auto &painting : room_it.second["paintings"]) { | 483 | for (const auto &painting : room_it.second["paintings"]) { |
429 | std::string internal_id = painting["id"].as<std::string>(); | 484 | std::string internal_id = painting["id"].as<std::string>(); |
@@ -477,23 +532,47 @@ struct GameData { | |||
477 | progressive_item_name); | 532 | progressive_item_name); |
478 | } | 533 | } |
479 | 534 | ||
480 | int index = 1; | 535 | if (progression_it.second["doors"]) { |
481 | for (const auto &stage : progression_it.second) { | 536 | int index = 1; |
482 | int door_id = -1; | 537 | for (const auto &stage : progression_it.second["doors"]) { |
538 | int door_id = -1; | ||
483 | 539 | ||
484 | if (stage.IsScalar()) { | 540 | if (stage.IsScalar()) { |
485 | door_id = | 541 | door_id = |
486 | AddOrGetDoor(rooms_[room_id].name, stage.as<std::string>()); | 542 | AddOrGetDoor(rooms_[room_id].name, stage.as<std::string>()); |
487 | } else { | 543 | } else { |
488 | door_id = AddOrGetDoor(stage["room"].as<std::string>(), | 544 | door_id = AddOrGetDoor(stage["room"].as<std::string>(), |
489 | stage["door"].as<std::string>()); | 545 | stage["door"].as<std::string>()); |
546 | } | ||
547 | |||
548 | doors_[door_id].progressives.push_back( | ||
549 | {.item_name = progressive_item_name, | ||
550 | .ap_item_id = progressive_item_id, | ||
551 | .quantity = index}); | ||
552 | index++; | ||
490 | } | 553 | } |
554 | } | ||
491 | 555 | ||
492 | doors_[door_id].progressives.push_back( | 556 | if (progression_it.second["panel_doors"]) { |
493 | {.item_name = progressive_item_name, | 557 | int index = 1; |
494 | .ap_item_id = progressive_item_id, | 558 | for (const auto &stage : progression_it.second["panel_doors"]) { |
495 | .quantity = index}); | 559 | int panel_door_id = -1; |
496 | index++; | 560 | |
561 | if (stage.IsScalar()) { | ||
562 | panel_door_id = AddOrGetPanelDoor(rooms_[room_id].name, | ||
563 | stage.as<std::string>()); | ||
564 | } else { | ||
565 | panel_door_id = | ||
566 | AddOrGetPanelDoor(stage["room"].as<std::string>(), | ||
567 | stage["panel_door"].as<std::string>()); | ||
568 | } | ||
569 | |||
570 | panel_doors_[panel_door_id].progressives.push_back( | ||
571 | {.item_name = progressive_item_name, | ||
572 | .ap_item_id = progressive_item_id, | ||
573 | .quantity = index}); | ||
574 | index++; | ||
575 | } | ||
497 | } | 576 | } |
498 | } | 577 | } |
499 | } | 578 | } |
@@ -749,6 +828,18 @@ struct GameData { | |||
749 | return panel_by_id_[full_name]; | 828 | return panel_by_id_[full_name]; |
750 | } | 829 | } |
751 | 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 | |||
752 | int AddOrGetArea(std::string area) { | 843 | int AddOrGetArea(std::string area) { |
753 | if (!area_by_id_.count(area)) { | 844 | if (!area_by_id_.count(area)) { |
754 | if (loaded_area_data_) { | 845 | if (loaded_area_data_) { |
@@ -799,6 +890,10 @@ const std::vector<Door> &GD_GetDoors() { return GetState().doors_; } | |||
799 | 890 | ||
800 | 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); } |
801 | 892 | ||
893 | const PanelDoor &GD_GetPanelDoor(int panel_door_id) { | ||
894 | return GetState().panel_doors_.at(panel_door_id); | ||
895 | } | ||
896 | |||
802 | int GD_GetDoorByName(const std::string &name) { | 897 | int GD_GetDoorByName(const std::string &name) { |
803 | return GetState().door_by_id_.at(name); | 898 | return GetState().door_by_id_.at(name); |
804 | } | 899 | } |