diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-04-16 11:34:49 -0400 | 
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-04-16 11:34:49 -0400 | 
| commit | 004fb711a86d91985d8e94e1b87089db2ac2cadc (patch) | |
| tree | cc3f4d384ede6e3f2705d7b98ca8afd3529aa4a1 /src/game_data.cpp | |
| parent | dc56f752bb33b4e779c5507dea03a6764d08fd0a (diff) | |
| download | lingo-ap-tracker-004fb711a86d91985d8e94e1b87089db2ac2cadc.tar.gz lingo-ap-tracker-004fb711a86d91985d8e94e1b87089db2ac2cadc.tar.bz2 lingo-ap-tracker-004fb711a86d91985d8e94e1b87089db2ac2cadc.zip  | |
Support panels mode door shuffle
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 ee818c4..eece8d7 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_; | 
| @@ -408,6 +410,59 @@ struct GameData { | |||
| 408 | } | 410 | } | 
| 409 | } | 411 | } | 
| 410 | 412 | ||
| 413 | if (room_it.second["panel_doors"]) { | ||
| 414 | for (const auto &panel_door_it : room_it.second["panel_doors"]) { | ||
| 415 | std::string panel_door_name = panel_door_it.first.as<std::string>(); | ||
| 416 | int panel_door_id = | ||
| 417 | AddOrGetPanelDoor(rooms_[room_id].name, panel_door_name); | ||
| 418 | |||
| 419 | for (const auto &panel_node : panel_door_it.second["panels"]) { | ||
| 420 | int panel_id = -1; | ||
| 421 | |||
| 422 | if (panel_node.IsScalar()) { | ||
| 423 | panel_id = AddOrGetPanel(rooms_[room_id].name, | ||
| 424 | panel_node.as<std::string>()); | ||
| 425 | } else { | ||
| 426 | panel_id = AddOrGetPanel(panel_node["room"].as<std::string>(), | ||
| 427 | panel_node["panel"].as<std::string>()); | ||
| 428 | } | ||
| 429 | |||
| 430 | Panel &panel = panels_[panel_id]; | ||
| 431 | panel.panel_door = panel_door_id; | ||
| 432 | } | ||
| 433 | |||
| 434 | if (ids_config["panel_doors"] && | ||
| 435 | ids_config["panel_doors"][rooms_[room_id].name] && | ||
| 436 | ids_config["panel_doors"][rooms_[room_id].name] | ||
| 437 | [panel_door_name]) { | ||
| 438 | panel_doors_[panel_door_id].ap_item_id = | ||
| 439 | ids_config["panel_doors"][rooms_[room_id].name][panel_door_name] | ||
| 440 | .as<int>(); | ||
| 441 | } else { | ||
| 442 | std::ostringstream errmsg; | ||
| 443 | errmsg << "Missing AP item ID for panel door " | ||
| 444 | << rooms_[room_id].name << " - " << panel_door_name; | ||
| 445 | TrackerLog(errmsg.str()); | ||
| 446 | } | ||
| 447 | |||
| 448 | if (panel_door_it.second["panel_group"]) { | ||
| 449 | std::string panel_group = | ||
| 450 | panel_door_it.second["panel_group"].as<std::string>(); | ||
| 451 | |||
| 452 | if (ids_config["panel_groups"] && | ||
| 453 | ids_config["panel_groups"][panel_group]) { | ||
| 454 | panel_doors_[panel_door_id].group_ap_item_id = | ||
| 455 | ids_config["panel_groups"][panel_group].as<int>(); | ||
| 456 | } else { | ||
| 457 | std::ostringstream errmsg; | ||
| 458 | errmsg << "Missing AP item ID for panel door group " | ||
| 459 | << panel_group; | ||
| 460 | TrackerLog(errmsg.str()); | ||
| 461 | } | ||
| 462 | } | ||
| 463 | } | ||
| 464 | } | ||
| 465 | |||
| 411 | if (room_it.second["paintings"]) { | 466 | if (room_it.second["paintings"]) { | 
| 412 | for (const auto &painting : room_it.second["paintings"]) { | 467 | for (const auto &painting : room_it.second["paintings"]) { | 
| 413 | std::string painting_id = painting["id"].as<std::string>(); | 468 | std::string painting_id = painting["id"].as<std::string>(); | 
| @@ -449,23 +504,47 @@ struct GameData { | |||
| 449 | TrackerLog(errmsg.str()); | 504 | TrackerLog(errmsg.str()); | 
| 450 | } | 505 | } | 
| 451 | 506 | ||
| 452 | int index = 1; | 507 | if (progression_it.second["doors"]) { | 
| 453 | for (const auto &stage : progression_it.second) { | 508 | int index = 1; | 
| 454 | int door_id = -1; | 509 | for (const auto &stage : progression_it.second["doors"]) { | 
| 510 | int door_id = -1; | ||
| 511 | |||
| 512 | if (stage.IsScalar()) { | ||
| 513 | door_id = | ||
| 514 | AddOrGetDoor(rooms_[room_id].name, stage.as<std::string>()); | ||
| 515 | } else { | ||
| 516 | door_id = AddOrGetDoor(stage["room"].as<std::string>(), | ||
| 517 | stage["door"].as<std::string>()); | ||
| 518 | } | ||
| 455 | 519 | ||
| 456 | if (stage.IsScalar()) { | 520 | doors_[door_id].progressives.push_back( | 
| 457 | door_id = | 521 | {.item_name = progressive_item_name, | 
| 458 | AddOrGetDoor(rooms_[room_id].name, stage.as<std::string>()); | 522 | .ap_item_id = progressive_item_id, | 
| 459 | } else { | 523 | .quantity = index}); | 
| 460 | door_id = AddOrGetDoor(stage["room"].as<std::string>(), | 524 | index++; | 
| 461 | stage["door"].as<std::string>()); | ||
| 462 | } | 525 | } | 
| 526 | } | ||
| 527 | |||
| 528 | if (progression_it.second["panel_doors"]) { | ||
| 529 | int index = 1; | ||
| 530 | for (const auto &stage : progression_it.second["panel_doors"]) { | ||
| 531 | int panel_door_id = -1; | ||
| 532 | |||
| 533 | if (stage.IsScalar()) { | ||
| 534 | panel_door_id = AddOrGetPanelDoor(rooms_[room_id].name, | ||
| 535 | stage.as<std::string>()); | ||
| 536 | } else { | ||
| 537 | panel_door_id = | ||
| 538 | AddOrGetPanelDoor(stage["room"].as<std::string>(), | ||
| 539 | stage["panel_door"].as<std::string>()); | ||
| 540 | } | ||
| 463 | 541 | ||
| 464 | doors_[door_id].progressives.push_back( | 542 | panel_doors_[panel_door_id].progressives.push_back( | 
| 465 | {.item_name = progressive_item_name, | 543 | {.item_name = progressive_item_name, | 
| 466 | .ap_item_id = progressive_item_id, | 544 | .ap_item_id = progressive_item_id, | 
| 467 | .quantity = index}); | 545 | .quantity = index}); | 
| 468 | index++; | 546 | index++; | 
| 547 | } | ||
| 469 | } | 548 | } | 
| 470 | } | 549 | } | 
| 471 | } | 550 | } | 
| @@ -643,6 +722,18 @@ struct GameData { | |||
| 643 | return panel_by_id_[full_name]; | 722 | return panel_by_id_[full_name]; | 
| 644 | } | 723 | } | 
| 645 | 724 | ||
| 725 | int AddOrGetPanelDoor(std::string room, std::string panel) { | ||
| 726 | std::string full_name = room + " - " + panel; | ||
| 727 | |||
| 728 | if (!panel_doors_by_id_.count(full_name)) { | ||
| 729 | int panel_door_id = panel_doors_.size(); | ||
| 730 | panel_doors_by_id_[full_name] = panel_door_id; | ||
| 731 | panel_doors_.push_back({}); | ||
| 732 | } | ||
| 733 | |||
| 734 | return panel_doors_by_id_[full_name]; | ||
| 735 | } | ||
| 736 | |||
| 646 | int AddOrGetArea(std::string area) { | 737 | int AddOrGetArea(std::string area) { | 
| 647 | if (!area_by_id_.count(area)) { | 738 | if (!area_by_id_.count(area)) { | 
| 648 | if (loaded_area_data_) { | 739 | if (loaded_area_data_) { | 
| @@ -679,6 +770,10 @@ const std::vector<Door> &GD_GetDoors() { return GetState().doors_; } | |||
| 679 | 770 | ||
| 680 | const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } | 771 | const Door &GD_GetDoor(int door_id) { return GetState().doors_.at(door_id); } | 
| 681 | 772 | ||
| 773 | const PanelDoor &GD_GetPanelDoor(int panel_door_id) { | ||
| 774 | return GetState().panel_doors_.at(panel_door_id); | ||
| 775 | } | ||
| 776 | |||
| 682 | const Panel &GD_GetPanel(int panel_id) { | 777 | const Panel &GD_GetPanel(int panel_id) { | 
| 683 | return GetState().panels_.at(panel_id); | 778 | return GetState().panels_.at(panel_id); | 
| 684 | } | 779 | } | 
