diff options
Diffstat (limited to 'tools/datapacker/main.cpp')
| -rw-r--r-- | tools/datapacker/main.cpp | 161 |
1 files changed, 154 insertions, 7 deletions
| diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index d820360..8109bf5 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,17 @@ 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 | |||
| 88 | if (metadata.has_display_name()) { | 93 | if (metadata.has_display_name()) { |
| 89 | map.set_display_name(metadata.display_name()); | 94 | map.set_display_name(metadata.display_name()); |
| 90 | } | 95 | } |
| 96 | |||
| 97 | if (metadata.has_worldport_entrance()) { | ||
| 98 | map.set_worldport_entrance(container_.FindOrAddPort( | ||
| 99 | map_name, metadata.worldport_entrance().room(), | ||
| 100 | metadata.worldport_entrance().name(), std::nullopt, std::nullopt)); | ||
| 101 | } | ||
| 91 | } | 102 | } |
| 92 | 103 | ||
| 93 | void ProcessRooms(std::filesystem::path path, | 104 | void ProcessRooms(std::filesystem::path path, |
| @@ -104,7 +115,11 @@ class DataPacker { | |||
| 104 | container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); | 115 | container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); |
| 105 | Room& room = *container_.all_objects().mutable_rooms(room_id); | 116 | Room& room = *container_.all_objects().mutable_rooms(room_id); |
| 106 | 117 | ||
| 107 | room.set_display_name(h_room.display_name()); | 118 | // room.set_display_name(h_room.display_name()); |
| 119 | |||
| 120 | if (h_room.has_panel_display_name()) { | ||
| 121 | room.set_panel_display_name(h_room.panel_display_name()); | ||
| 122 | } | ||
| 108 | 123 | ||
| 109 | for (const HumanPanel& h_panel : h_room.panels()) { | 124 | for (const HumanPanel& h_panel : h_room.panels()) { |
| 110 | room.add_panels(ProcessPanel(h_panel, current_map_name, room.name())); | 125 | room.add_panels(ProcessPanel(h_panel, current_map_name, room.name())); |
| @@ -175,6 +190,10 @@ class DataPacker { | |||
| 175 | map_name, h_panel.required_room().name(), current_map_name)); | 190 | map_name, h_panel.required_room().name(), current_map_name)); |
| 176 | } | 191 | } |
| 177 | 192 | ||
| 193 | if (h_panel.has_display_name()) { | ||
| 194 | panel.set_display_name(h_panel.display_name()); | ||
| 195 | } | ||
| 196 | |||
| 178 | return panel_id; | 197 | return panel_id; |
| 179 | } | 198 | } |
| 180 | 199 | ||
| @@ -228,7 +247,14 @@ class DataPacker { | |||
| 228 | Port& port = *container_.all_objects().mutable_ports(port_id); | 247 | Port& port = *container_.all_objects().mutable_ports(port_id); |
| 229 | 248 | ||
| 230 | port.set_path(h_port.path()); | 249 | port.set_path(h_port.path()); |
| 231 | port.set_orientation(h_port.orientation()); | 250 | port.set_display_name(h_port.display_name()); |
| 251 | |||
| 252 | if (h_port.no_shuffle()) { | ||
| 253 | port.set_no_shuffle(h_port.no_shuffle()); | ||
| 254 | } else { | ||
| 255 | *port.mutable_destination() = h_port.destination(); | ||
| 256 | port.set_rotation(h_port.rotation()); | ||
| 257 | } | ||
| 232 | 258 | ||
| 233 | // Setting this explicitly because the Godot protobuf doesn't support | 259 | // Setting this explicitly because the Godot protobuf doesn't support |
| 234 | // custom defaults. | 260 | // custom defaults. |
| @@ -284,6 +310,10 @@ class DataPacker { | |||
| 284 | 310 | ||
| 285 | keyholder.set_path(h_keyholder.path()); | 311 | keyholder.set_path(h_keyholder.path()); |
| 286 | 312 | ||
| 313 | if (h_keyholder.has_key()) { | ||
| 314 | keyholder.set_key(h_keyholder.key()); | ||
| 315 | } | ||
| 316 | |||
| 287 | return keyholder_id; | 317 | return keyholder_id; |
| 288 | } | 318 | } |
| 289 | 319 | ||
| @@ -331,8 +361,8 @@ class DataPacker { | |||
| 331 | h_door.receivers().begin(), h_door.receivers().end(), | 361 | h_door.receivers().begin(), h_door.receivers().end(), |
| 332 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); | 362 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); |
| 333 | std::copy( | 363 | std::copy( |
| 334 | h_door.switches().begin(), h_door.switches().end(), | 364 | h_door.senders().begin(), h_door.senders().end(), |
| 335 | google::protobuf::RepeatedFieldBackInserter(door.mutable_switches())); | 365 | google::protobuf::RepeatedFieldBackInserter(door.mutable_senders())); |
| 336 | 366 | ||
| 337 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { | 367 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { |
| 338 | std::optional<std::string> map_name = | 368 | std::optional<std::string> map_name = |
| @@ -380,9 +410,9 @@ class DataPacker { | |||
| 380 | door.add_doors( | 410 | door.add_doors( |
| 381 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); | 411 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); |
| 382 | } | 412 | } |
| 383 | 413 | ||
| 384 | for (const std::string& ending_name : h_door.endings()) { | 414 | if (h_door.has_white_ending()) { |
| 385 | door.add_endings(container_.FindOrAddEnding(ending_name)); | 415 | door.set_white_ending(h_door.white_ending()); |
| 386 | } | 416 | } |
| 387 | 417 | ||
| 388 | if (h_door.has_control_center_color()) { | 418 | if (h_door.has_control_center_color()) { |
| @@ -394,6 +424,22 @@ class DataPacker { | |||
| 394 | } | 424 | } |
| 395 | 425 | ||
| 396 | door.set_type(h_door.type()); | 426 | door.set_type(h_door.type()); |
| 427 | |||
| 428 | if (h_door.has_location_name()) { | ||
| 429 | door.set_location_name(h_door.location_name()); | ||
| 430 | } | ||
| 431 | |||
| 432 | if (h_door.has_double_letters()) { | ||
| 433 | door.set_double_letters(h_door.double_letters()); | ||
| 434 | } | ||
| 435 | |||
| 436 | if (h_door.has_latch()) { | ||
| 437 | door.set_latch(h_door.latch()); | ||
| 438 | } | ||
| 439 | |||
| 440 | if (h_door.has_legacy_location()) { | ||
| 441 | door.set_legacy_location(h_door.legacy_location()); | ||
| 442 | } | ||
| 397 | } | 443 | } |
| 398 | 444 | ||
| 399 | void ProcessConnectionsFile(std::filesystem::path path, | 445 | void ProcessConnectionsFile(std::filesystem::path path, |
| @@ -445,6 +491,26 @@ class DataPacker { | |||
| 445 | r_connection.set_required_door(door_id); | 491 | r_connection.set_required_door(door_id); |
| 446 | } | 492 | } |
| 447 | 493 | ||
| 494 | if (human_connection.has_roof_access()) { | ||
| 495 | f_connection.set_roof_access(human_connection.roof_access()); | ||
| 496 | r_connection.set_roof_access(human_connection.roof_access()); | ||
| 497 | } | ||
| 498 | |||
| 499 | if (human_connection.has_purple_ending()) { | ||
| 500 | f_connection.set_purple_ending(human_connection.purple_ending()); | ||
| 501 | r_connection.set_purple_ending(human_connection.purple_ending()); | ||
| 502 | } | ||
| 503 | |||
| 504 | if (human_connection.has_cyan_ending()) { | ||
| 505 | f_connection.set_cyan_ending(human_connection.cyan_ending()); | ||
| 506 | r_connection.set_cyan_ending(human_connection.cyan_ending()); | ||
| 507 | } | ||
| 508 | |||
| 509 | if (human_connection.has_vanilla_only()) { | ||
| 510 | f_connection.set_vanilla_only(human_connection.vanilla_only()); | ||
| 511 | r_connection.set_vanilla_only(human_connection.vanilla_only()); | ||
| 512 | } | ||
| 513 | |||
| 448 | container_.AddConnection(f_connection); | 514 | container_.AddConnection(f_connection); |
| 449 | if (!human_connection.oneway()) { | 515 | if (!human_connection.oneway()) { |
| 450 | container_.AddConnection(r_connection); | 516 | container_.AddConnection(r_connection); |
| @@ -528,6 +594,63 @@ class DataPacker { | |||
| 528 | } | 594 | } |
| 529 | } | 595 | } |
| 530 | 596 | ||
| 597 | void ProcessProgressivesFile(std::filesystem::path path) { | ||
| 598 | if (!std::filesystem::exists(path)) { | ||
| 599 | return; | ||
| 600 | } | ||
| 601 | |||
| 602 | auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string()); | ||
| 603 | |||
| 604 | for (const HumanProgressive& h_prog : h_progs.progressives()) { | ||
| 605 | ProcessProgressive(h_prog); | ||
| 606 | } | ||
| 607 | } | ||
| 608 | |||
| 609 | void ProcessProgressive(const HumanProgressive& h_prog) { | ||
| 610 | uint64_t prog_id = container_.FindOrAddProgressive(h_prog.name()); | ||
| 611 | Progressive& prog = *container_.all_objects().mutable_progressives(prog_id); | ||
| 612 | |||
| 613 | for (const DoorIdentifier& di : h_prog.doors()) { | ||
| 614 | uint64_t door_id = | ||
| 615 | container_.FindOrAddDoor(di.map(), di.name(), std::nullopt); | ||
| 616 | prog.add_doors(door_id); | ||
| 617 | } | ||
| 618 | } | ||
| 619 | |||
| 620 | void ProcessDoorGroupsFile(std::filesystem::path path) { | ||
| 621 | if (!std::filesystem::exists(path)) { | ||
| 622 | return; | ||
| 623 | } | ||
| 624 | |||
| 625 | auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string()); | ||
| 626 | |||
| 627 | for (const HumanDoorGroup& h_group : h_groups.door_groups()) { | ||
| 628 | ProcessDoorGroup(h_group); | ||
| 629 | } | ||
| 630 | } | ||
| 631 | |||
| 632 | void ProcessDoorGroup(const HumanDoorGroup& h_group) { | ||
| 633 | uint64_t group_id = container_.FindOrAddDoorGroup(h_group.name()); | ||
| 634 | DoorGroup& group = *container_.all_objects().mutable_door_groups(group_id); | ||
| 635 | |||
| 636 | group.set_type(h_group.type()); | ||
| 637 | |||
| 638 | for (const DoorIdentifier& di : h_group.doors()) { | ||
| 639 | uint64_t door_id = | ||
| 640 | container_.FindOrAddDoor(di.map(), di.name(), std::nullopt); | ||
| 641 | group.add_doors(door_id); | ||
| 642 | } | ||
| 643 | } | ||
| 644 | |||
| 645 | void ProcessGlobalMetadataFile(std::filesystem::path path) { | ||
| 646 | if (!std::filesystem::exists(path)) { | ||
| 647 | return; | ||
| 648 | } | ||
| 649 | |||
| 650 | auto h_metadata = ReadMessageFromFile<HumanGlobalMetadata>(path.string()); | ||
| 651 | *container_.all_objects().mutable_version() = h_metadata.version(); | ||
| 652 | } | ||
| 653 | |||
| 531 | void ProcessIdsFile(std::filesystem::path path) { | 654 | void ProcessIdsFile(std::filesystem::path path) { |
| 532 | auto ids = ReadIdsFromYaml(path.string()); | 655 | auto ids = ReadIdsFromYaml(path.string()); |
| 533 | 656 | ||
| @@ -552,6 +675,20 @@ class DataPacker { | |||
| 552 | .mutable_masteries(mastery_id) | 675 | .mutable_masteries(mastery_id) |
| 553 | ->set_ap_id(ap_id); | 676 | ->set_ap_id(ap_id); |
| 554 | } | 677 | } |
| 678 | |||
| 679 | for (const auto& [keyholder_name, ap_id] : room.keyholders()) { | ||
| 680 | uint64_t keyholder_id = container_.FindOrAddKeyholder( | ||
| 681 | map_name, room_name, keyholder_name, std::nullopt, std::nullopt); | ||
| 682 | container_.all_objects() | ||
| 683 | .mutable_keyholders(keyholder_id) | ||
| 684 | ->set_ap_id(ap_id); | ||
| 685 | } | ||
| 686 | |||
| 687 | for (const auto& [port_name, ap_id] : room.ports()) { | ||
| 688 | uint64_t port_id = container_.FindOrAddPort( | ||
| 689 | map_name, room_name, port_name, std::nullopt, std::nullopt); | ||
| 690 | container_.all_objects().mutable_ports(port_id)->set_ap_id(ap_id); | ||
| 691 | } | ||
| 555 | } | 692 | } |
| 556 | } | 693 | } |
| 557 | 694 | ||
| @@ -569,6 +706,16 @@ class DataPacker { | |||
| 569 | uint64_t ending_id = container_.FindOrAddEnding(ending_name); | 706 | uint64_t ending_id = container_.FindOrAddEnding(ending_name); |
| 570 | container_.all_objects().mutable_endings(ending_id)->set_ap_id(ap_id); | 707 | container_.all_objects().mutable_endings(ending_id)->set_ap_id(ap_id); |
| 571 | } | 708 | } |
| 709 | |||
| 710 | for (const auto& [prog_name, ap_id] : ids.progressives()) { | ||
| 711 | uint64_t prog_id = container_.FindOrAddProgressive(prog_name); | ||
| 712 | container_.all_objects().mutable_progressives(prog_id)->set_ap_id(ap_id); | ||
| 713 | } | ||
| 714 | |||
| 715 | for (const auto& [group_name, ap_id] : ids.door_groups()) { | ||
| 716 | uint64_t group_id = container_.FindOrAddDoorGroup(group_name); | ||
| 717 | container_.all_objects().mutable_door_groups(group_id)->set_ap_id(ap_id); | ||
| 718 | } | ||
| 572 | } | 719 | } |
| 573 | 720 | ||
| 574 | std::string mapdir_; | 721 | std::string mapdir_; |
