diff options
Diffstat (limited to 'tools/datapacker/main.cpp')
-rw-r--r-- | tools/datapacker/main.cpp | 139 |
1 files changed, 132 insertions, 7 deletions
diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index d9fcbe2..e807d74 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 | { |
@@ -104,7 +107,11 @@ class DataPacker { | |||
104 | container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); | 107 | container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); |
105 | Room& room = *container_.all_objects().mutable_rooms(room_id); | 108 | Room& room = *container_.all_objects().mutable_rooms(room_id); |
106 | 109 | ||
107 | room.set_display_name(h_room.display_name()); | 110 | // room.set_display_name(h_room.display_name()); |
111 | |||
112 | if (h_room.has_panel_display_name()) { | ||
113 | room.set_panel_display_name(h_room.panel_display_name()); | ||
114 | } | ||
108 | 115 | ||
109 | for (const HumanPanel& h_panel : h_room.panels()) { | 116 | for (const HumanPanel& h_panel : h_room.panels()) { |
110 | room.add_panels(ProcessPanel(h_panel, current_map_name, room.name())); | 117 | room.add_panels(ProcessPanel(h_panel, current_map_name, room.name())); |
@@ -175,6 +182,10 @@ class DataPacker { | |||
175 | map_name, h_panel.required_room().name(), current_map_name)); | 182 | map_name, h_panel.required_room().name(), current_map_name)); |
176 | } | 183 | } |
177 | 184 | ||
185 | if (h_panel.has_display_name()) { | ||
186 | panel.set_display_name(h_panel.display_name()); | ||
187 | } | ||
188 | |||
178 | return panel_id; | 189 | return panel_id; |
179 | } | 190 | } |
180 | 191 | ||
@@ -184,7 +195,7 @@ class DataPacker { | |||
184 | uint64_t painting_id = container_.FindOrAddPainting( | 195 | uint64_t painting_id = container_.FindOrAddPainting( |
185 | current_map_name, current_room_name, h_painting.name(), std::nullopt, | 196 | current_map_name, current_room_name, h_painting.name(), std::nullopt, |
186 | std::nullopt); | 197 | std::nullopt); |
187 | Painting& painting = | 198 | PaintingData& painting = |
188 | *container_.all_objects().mutable_paintings(painting_id); | 199 | *container_.all_objects().mutable_paintings(painting_id); |
189 | 200 | ||
190 | painting.set_path(h_painting.path()); | 201 | painting.set_path(h_painting.path()); |
@@ -228,7 +239,14 @@ class DataPacker { | |||
228 | Port& port = *container_.all_objects().mutable_ports(port_id); | 239 | Port& port = *container_.all_objects().mutable_ports(port_id); |
229 | 240 | ||
230 | port.set_path(h_port.path()); | 241 | port.set_path(h_port.path()); |
231 | port.set_orientation(h_port.orientation()); | 242 | port.set_display_name(h_port.display_name()); |
243 | |||
244 | if (h_port.no_shuffle()) { | ||
245 | port.set_no_shuffle(h_port.no_shuffle()); | ||
246 | } else { | ||
247 | *port.mutable_destination() = h_port.destination(); | ||
248 | port.set_rotation(h_port.rotation()); | ||
249 | } | ||
232 | 250 | ||
233 | // Setting this explicitly because the Godot protobuf doesn't support | 251 | // Setting this explicitly because the Godot protobuf doesn't support |
234 | // custom defaults. | 252 | // custom defaults. |
@@ -279,11 +297,15 @@ class DataPacker { | |||
279 | uint64_t keyholder_id = container_.FindOrAddKeyholder( | 297 | uint64_t keyholder_id = container_.FindOrAddKeyholder( |
280 | current_map_name, current_room_name, h_keyholder.name(), std::nullopt, | 298 | current_map_name, current_room_name, h_keyholder.name(), std::nullopt, |
281 | std::nullopt); | 299 | std::nullopt); |
282 | Keyholder& keyholder = | 300 | KeyholderData& keyholder = |
283 | *container_.all_objects().mutable_keyholders(keyholder_id); | 301 | *container_.all_objects().mutable_keyholders(keyholder_id); |
284 | 302 | ||
285 | keyholder.set_path(h_keyholder.path()); | 303 | keyholder.set_path(h_keyholder.path()); |
286 | 304 | ||
305 | if (h_keyholder.has_key()) { | ||
306 | keyholder.set_key(h_keyholder.key()); | ||
307 | } | ||
308 | |||
287 | return keyholder_id; | 309 | return keyholder_id; |
288 | } | 310 | } |
289 | 311 | ||
@@ -331,8 +353,8 @@ class DataPacker { | |||
331 | h_door.receivers().begin(), h_door.receivers().end(), | 353 | h_door.receivers().begin(), h_door.receivers().end(), |
332 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); | 354 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); |
333 | std::copy( | 355 | std::copy( |
334 | h_door.switches().begin(), h_door.switches().end(), | 356 | h_door.senders().begin(), h_door.senders().end(), |
335 | google::protobuf::RepeatedFieldBackInserter(door.mutable_switches())); | 357 | google::protobuf::RepeatedFieldBackInserter(door.mutable_senders())); |
336 | 358 | ||
337 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { | 359 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { |
338 | std::optional<std::string> map_name = | 360 | std::optional<std::string> map_name = |
@@ -380,7 +402,7 @@ class DataPacker { | |||
380 | door.add_doors( | 402 | door.add_doors( |
381 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); | 403 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); |
382 | } | 404 | } |
383 | 405 | ||
384 | for (const std::string& ending_name : h_door.endings()) { | 406 | for (const std::string& ending_name : h_door.endings()) { |
385 | door.add_endings(container_.FindOrAddEnding(ending_name)); | 407 | door.add_endings(container_.FindOrAddEnding(ending_name)); |
386 | } | 408 | } |
@@ -394,6 +416,14 @@ class DataPacker { | |||
394 | } | 416 | } |
395 | 417 | ||
396 | door.set_type(h_door.type()); | 418 | door.set_type(h_door.type()); |
419 | |||
420 | if (h_door.has_location_name()) { | ||
421 | door.set_location_name(h_door.location_name()); | ||
422 | } | ||
423 | |||
424 | if (h_door.has_double_letters()) { | ||
425 | door.set_double_letters(h_door.double_letters()); | ||
426 | } | ||
397 | } | 427 | } |
398 | 428 | ||
399 | void ProcessConnectionsFile(std::filesystem::path path, | 429 | void ProcessConnectionsFile(std::filesystem::path path, |
@@ -445,6 +475,26 @@ class DataPacker { | |||
445 | r_connection.set_required_door(door_id); | 475 | r_connection.set_required_door(door_id); |
446 | } | 476 | } |
447 | 477 | ||
478 | if (human_connection.has_roof_access()) { | ||
479 | f_connection.set_roof_access(human_connection.roof_access()); | ||
480 | r_connection.set_roof_access(human_connection.roof_access()); | ||
481 | } | ||
482 | |||
483 | if (human_connection.has_purple_ending()) { | ||
484 | f_connection.set_purple_ending(human_connection.purple_ending()); | ||
485 | r_connection.set_purple_ending(human_connection.purple_ending()); | ||
486 | } | ||
487 | |||
488 | if (human_connection.has_cyan_ending()) { | ||
489 | f_connection.set_cyan_ending(human_connection.cyan_ending()); | ||
490 | r_connection.set_cyan_ending(human_connection.cyan_ending()); | ||
491 | } | ||
492 | |||
493 | if (human_connection.has_vanilla_only()) { | ||
494 | f_connection.set_vanilla_only(human_connection.vanilla_only()); | ||
495 | r_connection.set_vanilla_only(human_connection.vanilla_only()); | ||
496 | } | ||
497 | |||
448 | container_.AddConnection(f_connection); | 498 | container_.AddConnection(f_connection); |
449 | if (!human_connection.oneway()) { | 499 | if (!human_connection.oneway()) { |
450 | container_.AddConnection(r_connection); | 500 | container_.AddConnection(r_connection); |
@@ -528,6 +578,63 @@ class DataPacker { | |||
528 | } | 578 | } |
529 | } | 579 | } |
530 | 580 | ||
581 | void ProcessProgressivesFile(std::filesystem::path path) { | ||
582 | if (!std::filesystem::exists(path)) { | ||
583 | return; | ||
584 | } | ||
585 | |||
586 | auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string()); | ||
587 | |||
588 | for (const HumanProgressive& h_prog : h_progs.progressives()) { | ||
589 | ProcessProgressive(h_prog); | ||
590 | } | ||
591 | } | ||
592 | |||
593 | void ProcessProgressive(const HumanProgressive& h_prog) { | ||
594 | uint64_t prog_id = container_.FindOrAddProgressive(h_prog.name()); | ||
595 | Progressive& prog = *container_.all_objects().mutable_progressives(prog_id); | ||
596 | |||
597 | for (const DoorIdentifier& di : h_prog.doors()) { | ||
598 | uint64_t door_id = | ||
599 | container_.FindOrAddDoor(di.map(), di.name(), std::nullopt); | ||
600 | prog.add_doors(door_id); | ||
601 | } | ||
602 | } | ||
603 | |||
604 | void ProcessDoorGroupsFile(std::filesystem::path path) { | ||
605 | if (!std::filesystem::exists(path)) { | ||
606 | return; | ||
607 | } | ||
608 | |||
609 | auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string()); | ||
610 | |||
611 | for (const HumanDoorGroup& h_group : h_groups.door_groups()) { | ||
612 | ProcessDoorGroup(h_group); | ||
613 | } | ||
614 | } | ||
615 | |||
616 | void ProcessDoorGroup(const HumanDoorGroup& h_group) { | ||
617 | uint64_t group_id = container_.FindOrAddDoorGroup(h_group.name()); | ||
618 | DoorGroup& group = *container_.all_objects().mutable_door_groups(group_id); | ||
619 | |||
620 | group.set_type(h_group.type()); | ||
621 | |||
622 | for (const DoorIdentifier& di : h_group.doors()) { | ||
623 | uint64_t door_id = | ||
624 | container_.FindOrAddDoor(di.map(), di.name(), std::nullopt); | ||
625 | group.add_doors(door_id); | ||
626 | } | ||
627 | } | ||
628 | |||
629 | void ProcessGlobalMetadataFile(std::filesystem::path path) { | ||
630 | if (!std::filesystem::exists(path)) { | ||
631 | return; | ||
632 | } | ||
633 | |||
634 | auto h_metadata = ReadMessageFromFile<HumanGlobalMetadata>(path.string()); | ||
635 | *container_.all_objects().mutable_version() = h_metadata.version(); | ||
636 | } | ||
637 | |||
531 | void ProcessIdsFile(std::filesystem::path path) { | 638 | void ProcessIdsFile(std::filesystem::path path) { |
532 | auto ids = ReadIdsFromYaml(path.string()); | 639 | auto ids = ReadIdsFromYaml(path.string()); |
533 | 640 | ||
@@ -552,6 +659,14 @@ class DataPacker { | |||
552 | .mutable_masteries(mastery_id) | 659 | .mutable_masteries(mastery_id) |
553 | ->set_ap_id(ap_id); | 660 | ->set_ap_id(ap_id); |
554 | } | 661 | } |
662 | |||
663 | for (const auto& [keyholder_name, ap_id] : room.keyholders()) { | ||
664 | uint64_t keyholder_id = container_.FindOrAddKeyholder( | ||
665 | map_name, room_name, keyholder_name, std::nullopt, std::nullopt); | ||
666 | container_.all_objects() | ||
667 | .mutable_keyholders(keyholder_id) | ||
668 | ->set_ap_id(ap_id); | ||
669 | } | ||
555 | } | 670 | } |
556 | } | 671 | } |
557 | 672 | ||
@@ -569,6 +684,16 @@ class DataPacker { | |||
569 | uint64_t ending_id = container_.FindOrAddEnding(ending_name); | 684 | uint64_t ending_id = container_.FindOrAddEnding(ending_name); |
570 | container_.all_objects().mutable_endings(ending_id)->set_ap_id(ap_id); | 685 | container_.all_objects().mutable_endings(ending_id)->set_ap_id(ap_id); |
571 | } | 686 | } |
687 | |||
688 | for (const auto& [prog_name, ap_id] : ids.progressives()) { | ||
689 | uint64_t prog_id = container_.FindOrAddProgressive(prog_name); | ||
690 | container_.all_objects().mutable_progressives(prog_id)->set_ap_id(ap_id); | ||
691 | } | ||
692 | |||
693 | for (const auto& [group_name, ap_id] : ids.door_groups()) { | ||
694 | uint64_t group_id = container_.FindOrAddDoorGroup(group_name); | ||
695 | container_.all_objects().mutable_door_groups(group_id)->set_ap_id(ap_id); | ||
696 | } | ||
572 | } | 697 | } |
573 | 698 | ||
574 | std::string mapdir_; | 699 | std::string mapdir_; |