diff options
Diffstat (limited to 'tools/datapacker/main.cpp')
| -rw-r--r-- | tools/datapacker/main.cpp | 202 |
1 files changed, 195 insertions, 7 deletions
| diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index d820360..4ecde74 100644 --- a/tools/datapacker/main.cpp +++ b/tools/datapacker/main.cpp | |||
| @@ -43,6 +43,9 @@ class DataPacker { | |||
| 43 | 43 | ||
| 44 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); | 44 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); |
| 45 | ProcessMaps(datadir_path); | 45 | ProcessMaps(datadir_path); |
| 46 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); | ||
| 47 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); | ||
| 48 | ProcessGlobalMetadataFile(datadir_path / "metadata.txtpb"); | ||
| 46 | ProcessIdsFile(datadir_path / "ids.yaml"); | 49 | ProcessIdsFile(datadir_path / "ids.yaml"); |
| 47 | 50 | ||
| 48 | { | 51 | { |
| @@ -85,9 +88,28 @@ class DataPacker { | |||
| 85 | uint64_t map_id = container_.FindOrAddMap(map_name); | 88 | uint64_t map_id = container_.FindOrAddMap(map_name); |
| 86 | Map& map = *container_.all_objects().mutable_maps(map_id); | 89 | Map& map = *container_.all_objects().mutable_maps(map_id); |
| 87 | 90 | ||
| 91 | map.set_type(metadata.type()); | ||
| 92 | map.set_daedalus_only_mode(metadata.daedalus_only_mode()); | ||
| 93 | |||
| 88 | if (metadata.has_display_name()) { | 94 | if (metadata.has_display_name()) { |
| 89 | map.set_display_name(metadata.display_name()); | 95 | map.set_display_name(metadata.display_name()); |
| 90 | } | 96 | } |
| 97 | |||
| 98 | if (metadata.has_worldport_entrance()) { | ||
| 99 | map.set_worldport_entrance(container_.FindOrAddPort( | ||
| 100 | map_name, metadata.worldport_entrance().room(), | ||
| 101 | metadata.worldport_entrance().name(), std::nullopt, std::nullopt)); | ||
| 102 | } | ||
| 103 | |||
| 104 | if (metadata.has_rte_room()) { | ||
| 105 | map.set_rte_room(container_.FindOrAddRoom(map_name, metadata.rte_room(), | ||
| 106 | std::nullopt)); | ||
| 107 | } | ||
| 108 | |||
| 109 | if (metadata.has_rte_trigger_pos()) { | ||
| 110 | *map.mutable_rte_trigger_pos() = metadata.rte_trigger_pos(); | ||
| 111 | *map.mutable_rte_trigger_scale() = metadata.rte_trigger_scale(); | ||
| 112 | } | ||
| 91 | } | 113 | } |
| 92 | 114 | ||
| 93 | void ProcessRooms(std::filesystem::path path, | 115 | void ProcessRooms(std::filesystem::path path, |
| @@ -104,7 +126,15 @@ class DataPacker { | |||
| 104 | container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); | 126 | container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); |
| 105 | Room& room = *container_.all_objects().mutable_rooms(room_id); | 127 | Room& room = *container_.all_objects().mutable_rooms(room_id); |
| 106 | 128 | ||
| 107 | room.set_display_name(h_room.display_name()); | 129 | // room.set_display_name(h_room.display_name()); |
| 130 | |||
| 131 | if (h_room.has_panel_display_name()) { | ||
| 132 | room.set_panel_display_name(h_room.panel_display_name()); | ||
| 133 | } | ||
| 134 | |||
| 135 | if (h_room.has_daedalus_only_allow()) { | ||
| 136 | room.set_daedalus_only_allow(h_room.daedalus_only_allow()); | ||
| 137 | } | ||
| 108 | 138 | ||
| 109 | for (const HumanPanel& h_panel : h_room.panels()) { | 139 | for (const HumanPanel& h_panel : h_room.panels()) { |
| 110 | room.add_panels(ProcessPanel(h_panel, current_map_name, room.name())); | 140 | room.add_panels(ProcessPanel(h_panel, current_map_name, room.name())); |
| @@ -175,6 +205,14 @@ class DataPacker { | |||
| 175 | map_name, h_panel.required_room().name(), current_map_name)); | 205 | map_name, h_panel.required_room().name(), current_map_name)); |
| 176 | } | 206 | } |
| 177 | 207 | ||
| 208 | if (h_panel.has_display_name()) { | ||
| 209 | panel.set_display_name(h_panel.display_name()); | ||
| 210 | } | ||
| 211 | |||
| 212 | if (h_panel.has_exclude_from_panelsanity()) { | ||
| 213 | panel.set_exclude_from_panelsanity(h_panel.exclude_from_panelsanity()); | ||
| 214 | } | ||
| 215 | |||
| 178 | return panel_id; | 216 | return panel_id; |
| 179 | } | 217 | } |
| 180 | 218 | ||
| @@ -228,7 +266,14 @@ class DataPacker { | |||
| 228 | Port& port = *container_.all_objects().mutable_ports(port_id); | 266 | Port& port = *container_.all_objects().mutable_ports(port_id); |
| 229 | 267 | ||
| 230 | port.set_path(h_port.path()); | 268 | port.set_path(h_port.path()); |
| 231 | port.set_orientation(h_port.orientation()); | 269 | port.set_display_name(h_port.display_name()); |
| 270 | |||
| 271 | if (h_port.no_shuffle()) { | ||
| 272 | port.set_no_shuffle(h_port.no_shuffle()); | ||
| 273 | } else { | ||
| 274 | *port.mutable_destination() = h_port.destination(); | ||
| 275 | port.set_rotation(h_port.rotation()); | ||
| 276 | } | ||
| 232 | 277 | ||
| 233 | // Setting this explicitly because the Godot protobuf doesn't support | 278 | // Setting this explicitly because the Godot protobuf doesn't support |
| 234 | // custom defaults. | 279 | // custom defaults. |
| @@ -284,6 +329,10 @@ class DataPacker { | |||
| 284 | 329 | ||
| 285 | keyholder.set_path(h_keyholder.path()); | 330 | keyholder.set_path(h_keyholder.path()); |
| 286 | 331 | ||
| 332 | if (h_keyholder.has_key()) { | ||
| 333 | keyholder.set_key(h_keyholder.key()); | ||
| 334 | } | ||
| 335 | |||
| 287 | return keyholder_id; | 336 | return keyholder_id; |
| 288 | } | 337 | } |
| 289 | 338 | ||
| @@ -331,8 +380,8 @@ class DataPacker { | |||
| 331 | h_door.receivers().begin(), h_door.receivers().end(), | 380 | h_door.receivers().begin(), h_door.receivers().end(), |
| 332 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); | 381 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); |
| 333 | std::copy( | 382 | std::copy( |
| 334 | h_door.switches().begin(), h_door.switches().end(), | 383 | h_door.senders().begin(), h_door.senders().end(), |
| 335 | google::protobuf::RepeatedFieldBackInserter(door.mutable_switches())); | 384 | google::protobuf::RepeatedFieldBackInserter(door.mutable_senders())); |
| 336 | 385 | ||
| 337 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { | 386 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { |
| 338 | std::optional<std::string> map_name = | 387 | std::optional<std::string> map_name = |
| @@ -380,9 +429,9 @@ class DataPacker { | |||
| 380 | door.add_doors( | 429 | door.add_doors( |
| 381 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); | 430 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); |
| 382 | } | 431 | } |
| 383 | 432 | ||
| 384 | for (const std::string& ending_name : h_door.endings()) { | 433 | if (h_door.has_white_ending()) { |
| 385 | door.add_endings(container_.FindOrAddEnding(ending_name)); | 434 | door.set_white_ending(h_door.white_ending()); |
| 386 | } | 435 | } |
| 387 | 436 | ||
| 388 | if (h_door.has_control_center_color()) { | 437 | if (h_door.has_control_center_color()) { |
| @@ -394,6 +443,30 @@ class DataPacker { | |||
| 394 | } | 443 | } |
| 395 | 444 | ||
| 396 | door.set_type(h_door.type()); | 445 | door.set_type(h_door.type()); |
| 446 | |||
| 447 | if (h_door.has_location_name()) { | ||
| 448 | door.set_location_name(h_door.location_name()); | ||
| 449 | } | ||
| 450 | |||
| 451 | if (h_door.has_double_letters()) { | ||
| 452 | door.set_double_letters(h_door.double_letters()); | ||
| 453 | } | ||
| 454 | |||
| 455 | if (h_door.has_latch()) { | ||
| 456 | door.set_latch(h_door.latch()); | ||
| 457 | } | ||
| 458 | |||
| 459 | if (h_door.has_legacy_location()) { | ||
| 460 | door.set_legacy_location(h_door.legacy_location()); | ||
| 461 | } | ||
| 462 | |||
| 463 | if (h_door.has_daedalus_only_allow()) { | ||
| 464 | door.set_daedalus_only_allow(h_door.daedalus_only_allow()); | ||
| 465 | } | ||
| 466 | |||
| 467 | if (h_door.has_daedalus_only_always_item()) { | ||
| 468 | door.set_daedalus_only_always_item(h_door.daedalus_only_always_item()); | ||
| 469 | } | ||
| 397 | } | 470 | } |
| 398 | 471 | ||
| 399 | void ProcessConnectionsFile(std::filesystem::path path, | 472 | void ProcessConnectionsFile(std::filesystem::path path, |
| @@ -445,6 +518,31 @@ class DataPacker { | |||
| 445 | r_connection.set_required_door(door_id); | 518 | r_connection.set_required_door(door_id); |
| 446 | } | 519 | } |
| 447 | 520 | ||
| 521 | if (human_connection.has_roof_access()) { | ||
| 522 | f_connection.set_roof_access(human_connection.roof_access()); | ||
| 523 | r_connection.set_roof_access(human_connection.roof_access()); | ||
| 524 | } | ||
| 525 | |||
| 526 | if (human_connection.has_purple_ending()) { | ||
| 527 | f_connection.set_purple_ending(human_connection.purple_ending()); | ||
| 528 | r_connection.set_purple_ending(human_connection.purple_ending()); | ||
| 529 | } | ||
| 530 | |||
| 531 | if (human_connection.has_cyan_ending()) { | ||
| 532 | f_connection.set_cyan_ending(human_connection.cyan_ending()); | ||
| 533 | r_connection.set_cyan_ending(human_connection.cyan_ending()); | ||
| 534 | } | ||
| 535 | |||
| 536 | if (human_connection.has_mint_ending()) { | ||
| 537 | f_connection.set_mint_ending(human_connection.mint_ending()); | ||
| 538 | r_connection.set_mint_ending(human_connection.mint_ending()); | ||
| 539 | } | ||
| 540 | |||
| 541 | if (human_connection.has_vanilla_only()) { | ||
| 542 | f_connection.set_vanilla_only(human_connection.vanilla_only()); | ||
| 543 | r_connection.set_vanilla_only(human_connection.vanilla_only()); | ||
| 544 | } | ||
| 545 | |||
| 448 | container_.AddConnection(f_connection); | 546 | container_.AddConnection(f_connection); |
| 449 | if (!human_connection.oneway()) { | 547 | if (!human_connection.oneway()) { |
| 450 | container_.AddConnection(r_connection); | 548 | container_.AddConnection(r_connection); |
| @@ -528,6 +626,67 @@ class DataPacker { | |||
| 528 | } | 626 | } |
| 529 | } | 627 | } |
| 530 | 628 | ||
| 629 | void ProcessProgressivesFile(std::filesystem::path path) { | ||
| 630 | if (!std::filesystem::exists(path)) { | ||
| 631 | return; | ||
| 632 | } | ||
| 633 | |||
| 634 | auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string()); | ||
| 635 | |||
| 636 | for (const HumanProgressive& h_prog : h_progs.progressives()) { | ||
| 637 | ProcessProgressive(h_prog); | ||
| 638 | } | ||
| 639 | } | ||
| 640 | |||
| 641 | void ProcessProgressive(const HumanProgressive& h_prog) { | ||
| 642 | uint64_t prog_id = container_.FindOrAddProgressive(h_prog.name()); | ||
| 643 | Progressive& prog = *container_.all_objects().mutable_progressives(prog_id); | ||
| 644 | |||
| 645 | for (const DoorIdentifier& di : h_prog.doors()) { | ||
| 646 | uint64_t door_id = | ||
| 647 | container_.FindOrAddDoor(di.map(), di.name(), std::nullopt); | ||
| 648 | prog.add_doors(door_id); | ||
| 649 | } | ||
| 650 | } | ||
| 651 | |||
| 652 | void ProcessDoorGroupsFile(std::filesystem::path path) { | ||
| 653 | if (!std::filesystem::exists(path)) { | ||
| 654 | return; | ||
| 655 | } | ||
| 656 | |||
| 657 | auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string()); | ||
| 658 | |||
| 659 | for (const HumanDoorGroup& h_group : h_groups.door_groups()) { | ||
| 660 | ProcessDoorGroup(h_group); | ||
| 661 | } | ||
| 662 | } | ||
| 663 | |||
| 664 | void ProcessDoorGroup(const HumanDoorGroup& h_group) { | ||
| 665 | uint64_t group_id = container_.FindOrAddDoorGroup(h_group.name()); | ||
| 666 | DoorGroup& group = *container_.all_objects().mutable_door_groups(group_id); | ||
| 667 | |||
| 668 | group.set_type(h_group.type()); | ||
| 669 | |||
| 670 | for (const DoorIdentifier& di : h_group.doors()) { | ||
| 671 | uint64_t door_id = | ||
| 672 | container_.FindOrAddDoor(di.map(), di.name(), std::nullopt); | ||
| 673 | group.add_doors(door_id); | ||
| 674 | } | ||
| 675 | |||
| 676 | if (h_group.has_daedalus_only_always_item()) { | ||
| 677 | group.set_daedalus_only_always_item(h_group.daedalus_only_always_item()); | ||
| 678 | } | ||
| 679 | } | ||
| 680 | |||
| 681 | void ProcessGlobalMetadataFile(std::filesystem::path path) { | ||
| 682 | if (!std::filesystem::exists(path)) { | ||
| 683 | return; | ||
| 684 | } | ||
| 685 | |||
| 686 | auto h_metadata = ReadMessageFromFile<HumanGlobalMetadata>(path.string()); | ||
| 687 | *container_.all_objects().mutable_version() = h_metadata.version(); | ||
| 688 | } | ||
| 689 | |||
| 531 | void ProcessIdsFile(std::filesystem::path path) { | 690 | void ProcessIdsFile(std::filesystem::path path) { |
| 532 | auto ids = ReadIdsFromYaml(path.string()); | 691 | auto ids = ReadIdsFromYaml(path.string()); |
| 533 | 692 | ||
| @@ -552,6 +711,25 @@ class DataPacker { | |||
| 552 | .mutable_masteries(mastery_id) | 711 | .mutable_masteries(mastery_id) |
| 553 | ->set_ap_id(ap_id); | 712 | ->set_ap_id(ap_id); |
| 554 | } | 713 | } |
| 714 | |||
| 715 | for (const auto& [keyholder_name, ap_id] : room.keyholders()) { | ||
| 716 | uint64_t keyholder_id = container_.FindOrAddKeyholder( | ||
| 717 | map_name, room_name, keyholder_name, std::nullopt, std::nullopt); | ||
| 718 | container_.all_objects() | ||
| 719 | .mutable_keyholders(keyholder_id) | ||
| 720 | ->set_ap_id(ap_id); | ||
| 721 | } | ||
| 722 | |||
| 723 | for (const auto& [port_name, ap_id] : room.ports()) { | ||
| 724 | uint64_t port_id = container_.FindOrAddPort( | ||
| 725 | map_name, room_name, port_name, std::nullopt, std::nullopt); | ||
| 726 | container_.all_objects().mutable_ports(port_id)->set_ap_id(ap_id); | ||
| 727 | } | ||
| 728 | } | ||
| 729 | |||
| 730 | if (map.has_rte()) { | ||
| 731 | uint64_t map_id = container_.FindOrAddMap(map_name); | ||
| 732 | container_.all_objects().mutable_maps(map_id)->set_rte_ap_id(map.rte()); | ||
| 555 | } | 733 | } |
| 556 | } | 734 | } |
| 557 | 735 | ||
| @@ -569,6 +747,16 @@ class DataPacker { | |||
| 569 | uint64_t ending_id = container_.FindOrAddEnding(ending_name); | 747 | uint64_t ending_id = container_.FindOrAddEnding(ending_name); |
| 570 | container_.all_objects().mutable_endings(ending_id)->set_ap_id(ap_id); | 748 | container_.all_objects().mutable_endings(ending_id)->set_ap_id(ap_id); |
| 571 | } | 749 | } |
| 750 | |||
| 751 | for (const auto& [prog_name, ap_id] : ids.progressives()) { | ||
| 752 | uint64_t prog_id = container_.FindOrAddProgressive(prog_name); | ||
| 753 | container_.all_objects().mutable_progressives(prog_id)->set_ap_id(ap_id); | ||
| 754 | } | ||
| 755 | |||
| 756 | for (const auto& [group_name, ap_id] : ids.door_groups()) { | ||
| 757 | uint64_t group_id = container_.FindOrAddDoorGroup(group_name); | ||
| 758 | container_.all_objects().mutable_door_groups(group_id)->set_ap_id(ap_id); | ||
| 759 | } | ||
| 572 | } | 760 | } |
| 573 | 761 | ||
| 574 | std::string mapdir_; | 762 | std::string mapdir_; |
