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 c98f532..0567623 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp | |||
@@ -43,11 +43,13 @@ struct GameData { | |||
43 | std::vector<Room> rooms_; | 43 | std::vector<Room> rooms_; |
44 | std::vector<Door> doors_; | 44 | std::vector<Door> doors_; |
45 | std::vector<Panel> panels_; | 45 | std::vector<Panel> panels_; |
46 | std::vector<PanelDoor> panel_doors_; | ||
46 | std::vector<MapArea> map_areas_; | 47 | std::vector<MapArea> map_areas_; |
47 | 48 | ||
48 | std::map<std::string, int> room_by_id_; | 49 | std::map<std::string, int> room_by_id_; |
49 | std::map<std::string, int> door_by_id_; | 50 | std::map<std::string, int> door_by_id_; |
50 | std::map<std::string, int> panel_by_id_; | 51 | std::map<std::string, int> panel_by_id_; |
52 | std::map<std::string, int> panel_doors_by_id_; | ||
51 | std::map<std::string, int> area_by_id_; | 53 | std::map<std::string, int> area_by_id_; |
52 | 54 | ||
53 | std::vector<int> door_definition_order_; | 55 | std::vector<int> door_definition_order_; |
@@ -421,6 +423,59 @@ struct GameData { | |||
421 | } | 423 | } |
422 | } | 424 | } |
423 | 425 | ||
426 | if (room_it.second["panel_doors"]) { | ||
427 | for (const auto &panel_door_it : room_it.second["panel_doors"]) { | ||
428 | std::string panel_door_name = panel_door_it.first.as<std::string>(); | ||
429 | int panel_door_id = | ||
430 | AddOrGetPanelDoor(rooms_[room_id].name, panel_door_name); | ||
431 | |||
432 | for (const auto &panel_node : panel_door_it.second["panels"]) { | ||
433 | int panel_id = -1; | ||
434 | |||
435 | if (panel_node.IsScalar()) { | ||
436 | panel_id = AddOrGetPanel(rooms_[room_id].name, | ||
437 | panel_node.as<std::string>()); | ||
438 | } else { | ||
439 | panel_id = AddOrGetPanel(panel_node["room"].as<std::string>(), | ||
440 | panel_node["panel"].as<std::string>()); | ||
441 | } | ||
442 | |||
443 | Panel &panel = panels_[panel_id]; | ||
444 | panel.panel_door = panel_door_id; | ||
445 | } | ||
446 | |||
447 | if (ids_config["panel_doors"] && | ||
448 | ids_config["panel_doors"][rooms_[room_id].name] && | ||
449 | ids_config["panel_doors"][rooms_[room_id].name] | ||
450 | [panel_door_name]) { | ||
451 | panel_doors_[panel_door_id].ap_item_id = | ||
452 | ids_config["panel_doors"][rooms_[room_id].name][panel_door_name] | ||
453 | .as<int>(); | ||
454 | } else { | ||
455 | std::ostringstream errmsg; | ||
456 | errmsg << "Missing AP item ID for panel door " | ||
457 | << rooms_[room_id].name << " - " << panel_door_name; | ||
458 | TrackerLog(errmsg.str()); | ||
459 | } | ||
460 | |||
461 | if (panel_door_it.second["panel_group"]) { | ||
462 | std::string panel_group = | ||
463 | panel_door_it.second["panel_group"].as<std::string>(); | ||
464 | |||
465 | if (ids_config["panel_groups"] && | ||
466 | ids_config["panel_groups"][panel_group]) { | ||
467 | panel_doors_[panel_door_id].group_ap_item_id = | ||
468 | ids_config["panel_groups"][panel_group].as<int>(); | ||
469 | } else { | ||
470 | std::ostringstream errmsg; | ||
471 | errmsg << "Missing AP item ID for panel door group " | ||
472 | << panel_group; | ||
473 | TrackerLog(errmsg.str()); | ||
474 | } | ||
475 | } | ||
476 | } | ||
477 | } | ||
478 | |||
424 | if (room_it.second["paintings"]) { | 479 | if (room_it.second["paintings"]) { |
425 | for (const auto &painting : room_it.second["paintings"]) { | 480 | for (const auto &painting : room_it.second["paintings"]) { |
426 | std::string painting_id = painting["id"].as<std::string>(); | 481 | std::string painting_id = painting["id"].as<std::string>(); |
@@ -474,23 +529,47 @@ struct GameData { | |||
474 | TrackerLog(errmsg.str()); | 529 | TrackerLog(errmsg.str()); |
475 | } | 530 | } |
476 | 531 | ||
477 | int index = 1; | 532 | if (progression_it.second["doors"]) { |
478 | for (const auto &stage : progression_it.second) { | 533 | int index = 1; |
479 | int door_id = -1; | 534 | for (const auto &stage : progression_it.second["doors"]) { |
535 | int door_id = -1; | ||
536 | |||
537 | if (stage.IsScalar()) { | ||
538 | door_id = | ||
539 | AddOrGetDoor(rooms_[room_id].name, stage.as<std::string>()); | ||
540 | } else { | ||
541 | door_id = AddOrGetDoor(stage["room"].as<std::string>(), | ||
542 | stage["door"].as<std::string>()); | ||
543 | } | ||
480 | 544 | ||
481 | if (stage.IsScalar()) { | 545 | doors_[door_id].progressives.push_back( |
482 | door_id = | 546 | {.item_name = progressive_item_name, |
483 | AddOrGetDoor(rooms_[room_id].name, stage.as<std::string>()); | 547 | .ap_item_id = progressive_item_id, |
484 | } else { | 548 | .quantity = index}); |
485 | door_id = AddOrGetDoor(stage["room"].as<std::string>(), | 549 | index++; |
486 | stage["door"].as<std::string>()); | ||
487 | } | 550 | } |
551 | } | ||
552 | |||
553 | if (progression_it.second["panel_doors"]) { | ||
554 | int index = 1; | ||
555 | for (const auto &stage : progression_it.second["panel_doors"]) { | ||
556 | int panel_door_id = -1; | ||
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 | } | ||
488 | 566 | ||
489 | doors_[door_id].progressives.push_back( | 567 | panel_doors_[panel_door_id].progressives.push_back( |
490 | {.item_name = progressive_item_name, | 568 | {.item_name = progressive_item_name, |
491 | .ap_item_id = progressive_item_id, | 569 | .ap_item_id = progressive_item_id, |
492 | .quantity = index}); | 570 | .quantity = index}); |
493 | index++; | 571 | index++; |
572 | } | ||
494 | } | 573 | } |
495 | } | 574 | } |
496 | } | 575 | } |
@@ -641,6 +720,18 @@ struct GameData { | |||
641 | return panel_by_id_[full_name]; | 720 | return panel_by_id_[full_name]; |
642 | } | 721 | } |
643 | 722 | ||
723 | int AddOrGetPanelDoor(std::string room, std::string panel) { | ||
724 | std::string full_name = room + " - " + panel; | ||
725 | |||
726 | if (!panel_doors_by_id_.count(full_name)) { | ||
727 | int panel_door_id = panel_doors_.size(); | ||
728 | panel_doors_by_id_[full_name] = panel_door_id; | ||
729 | panel_doors_.push_back({}); | ||
730 | } | ||
731 | |||
732 | return panel_doors_by_id_[full_name]; | ||
733 | } | ||
734 | |||
644 | int AddOrGetArea(std::string area) { | 735 | int AddOrGetArea(std::string area) { |
645 | if (!area_by_id_.count(area)) { | 736 | if (!area_by_id_.count(area)) { |
646 | if (loaded_area_data_) { | 737 | if (loaded_area_data_) { |
@@ -677,6 +768,10 @@ const std::vector<Door> &GD_GetDoors() { return GetState().doors_; } | |||
677 | 768 | ||
678 | const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } | 769 | const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } |
679 | 770 | ||
771 | const PanelDoor &GD_GetPanelDoor(int panel_door_id) { | ||
772 | return GetState().panel_doors_.at(panel_door_id); | ||
773 | } | ||
774 | |||
680 | int GD_GetDoorByName(const std::string &name) { | 775 | int GD_GetDoorByName(const std::string &name) { |
681 | return GetState().door_by_id_.at(name); | 776 | return GetState().door_by_id_.at(name); |
682 | } | 777 | } |