diff options
Diffstat (limited to 'tools/datapacker/main.cpp')
| -rw-r--r-- | tools/datapacker/main.cpp | 64 |
1 files changed, 59 insertions, 5 deletions
| diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index c72462d..8109bf5 100644 --- a/tools/datapacker/main.cpp +++ b/tools/datapacker/main.cpp | |||
| @@ -45,6 +45,7 @@ class DataPacker { | |||
| 45 | ProcessMaps(datadir_path); | 45 | ProcessMaps(datadir_path); |
| 46 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); | 46 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); |
| 47 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); | 47 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); |
| 48 | ProcessGlobalMetadataFile(datadir_path / "metadata.txtpb"); | ||
| 48 | ProcessIdsFile(datadir_path / "ids.yaml"); | 49 | ProcessIdsFile(datadir_path / "ids.yaml"); |
| 49 | 50 | ||
| 50 | { | 51 | { |
| @@ -87,9 +88,17 @@ class DataPacker { | |||
| 87 | uint64_t map_id = container_.FindOrAddMap(map_name); | 88 | uint64_t map_id = container_.FindOrAddMap(map_name); |
| 88 | Map& map = *container_.all_objects().mutable_maps(map_id); | 89 | Map& map = *container_.all_objects().mutable_maps(map_id); |
| 89 | 90 | ||
| 91 | map.set_type(metadata.type()); | ||
| 92 | |||
| 90 | if (metadata.has_display_name()) { | 93 | if (metadata.has_display_name()) { |
| 91 | map.set_display_name(metadata.display_name()); | 94 | map.set_display_name(metadata.display_name()); |
| 92 | } | 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 | } | ||
| 93 | } | 102 | } |
| 94 | 103 | ||
| 95 | void ProcessRooms(std::filesystem::path path, | 104 | void ProcessRooms(std::filesystem::path path, |
| @@ -238,7 +247,14 @@ class DataPacker { | |||
| 238 | Port& port = *container_.all_objects().mutable_ports(port_id); | 247 | Port& port = *container_.all_objects().mutable_ports(port_id); |
| 239 | 248 | ||
| 240 | port.set_path(h_port.path()); | 249 | port.set_path(h_port.path()); |
| 241 | 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 | } | ||
| 242 | 258 | ||
| 243 | // Setting this explicitly because the Godot protobuf doesn't support | 259 | // Setting this explicitly because the Godot protobuf doesn't support |
| 244 | // custom defaults. | 260 | // custom defaults. |
| @@ -345,8 +361,8 @@ class DataPacker { | |||
| 345 | h_door.receivers().begin(), h_door.receivers().end(), | 361 | h_door.receivers().begin(), h_door.receivers().end(), |
| 346 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); | 362 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); |
| 347 | std::copy( | 363 | std::copy( |
| 348 | h_door.switches().begin(), h_door.switches().end(), | 364 | h_door.senders().begin(), h_door.senders().end(), |
| 349 | google::protobuf::RepeatedFieldBackInserter(door.mutable_switches())); | 365 | google::protobuf::RepeatedFieldBackInserter(door.mutable_senders())); |
| 350 | 366 | ||
| 351 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { | 367 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { |
| 352 | std::optional<std::string> map_name = | 368 | std::optional<std::string> map_name = |
| @@ -395,8 +411,8 @@ class DataPacker { | |||
| 395 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); | 411 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); |
| 396 | } | 412 | } |
| 397 | 413 | ||
| 398 | for (const std::string& ending_name : h_door.endings()) { | 414 | if (h_door.has_white_ending()) { |
| 399 | door.add_endings(container_.FindOrAddEnding(ending_name)); | 415 | door.set_white_ending(h_door.white_ending()); |
| 400 | } | 416 | } |
| 401 | 417 | ||
| 402 | if (h_door.has_control_center_color()) { | 418 | if (h_door.has_control_center_color()) { |
| @@ -416,6 +432,14 @@ class DataPacker { | |||
| 416 | if (h_door.has_double_letters()) { | 432 | if (h_door.has_double_letters()) { |
| 417 | door.set_double_letters(h_door.double_letters()); | 433 | door.set_double_letters(h_door.double_letters()); |
| 418 | } | 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 | } | ||
| 419 | } | 443 | } |
| 420 | 444 | ||
| 421 | void ProcessConnectionsFile(std::filesystem::path path, | 445 | void ProcessConnectionsFile(std::filesystem::path path, |
| @@ -472,6 +496,21 @@ class DataPacker { | |||
| 472 | r_connection.set_roof_access(human_connection.roof_access()); | 496 | r_connection.set_roof_access(human_connection.roof_access()); |
| 473 | } | 497 | } |
| 474 | 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 | |||
| 475 | container_.AddConnection(f_connection); | 514 | container_.AddConnection(f_connection); |
| 476 | if (!human_connection.oneway()) { | 515 | if (!human_connection.oneway()) { |
| 477 | container_.AddConnection(r_connection); | 516 | container_.AddConnection(r_connection); |
| @@ -603,6 +642,15 @@ class DataPacker { | |||
| 603 | } | 642 | } |
| 604 | } | 643 | } |
| 605 | 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 | |||
| 606 | void ProcessIdsFile(std::filesystem::path path) { | 654 | void ProcessIdsFile(std::filesystem::path path) { |
| 607 | auto ids = ReadIdsFromYaml(path.string()); | 655 | auto ids = ReadIdsFromYaml(path.string()); |
| 608 | 656 | ||
| @@ -635,6 +683,12 @@ class DataPacker { | |||
| 635 | .mutable_keyholders(keyholder_id) | 683 | .mutable_keyholders(keyholder_id) |
| 636 | ->set_ap_id(ap_id); | 684 | ->set_ap_id(ap_id); |
| 637 | } | 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 | } | ||
| 638 | } | 692 | } |
| 639 | } | 693 | } |
| 640 | 694 | ||
