diff options
Diffstat (limited to 'tools/datapacker/main.cpp')
-rw-r--r-- | tools/datapacker/main.cpp | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index 595647d..c640de6 100644 --- a/tools/datapacker/main.cpp +++ b/tools/datapacker/main.cpp | |||
@@ -44,6 +44,7 @@ class DataPacker { | |||
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"); | 46 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); |
47 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); | ||
47 | ProcessIdsFile(datadir_path / "ids.yaml"); | 48 | ProcessIdsFile(datadir_path / "ids.yaml"); |
48 | 49 | ||
49 | { | 50 | { |
@@ -343,9 +344,6 @@ class DataPacker { | |||
343 | std::copy( | 344 | std::copy( |
344 | h_door.receivers().begin(), h_door.receivers().end(), | 345 | h_door.receivers().begin(), h_door.receivers().end(), |
345 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); | 346 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); |
346 | std::copy( | ||
347 | h_door.switches().begin(), h_door.switches().end(), | ||
348 | google::protobuf::RepeatedFieldBackInserter(door.mutable_switches())); | ||
349 | 347 | ||
350 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { | 348 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { |
351 | std::optional<std::string> map_name = | 349 | std::optional<std::string> map_name = |
@@ -577,6 +575,31 @@ class DataPacker { | |||
577 | } | 575 | } |
578 | } | 576 | } |
579 | 577 | ||
578 | void ProcessDoorGroupsFile(std::filesystem::path path) { | ||
579 | if (!std::filesystem::exists(path)) { | ||
580 | return; | ||
581 | } | ||
582 | |||
583 | auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string()); | ||
584 | |||
585 | for (const HumanDoorGroup& h_group : h_groups.door_groups()) { | ||
586 | ProcessDoorGroup(h_group); | ||
587 | } | ||
588 | } | ||
589 | |||
590 | void ProcessDoorGroup(const HumanDoorGroup& h_group) { | ||
591 | uint64_t group_id = container_.FindOrAddDoorGroup(h_group.name()); | ||
592 | DoorGroup& group = *container_.all_objects().mutable_door_groups(group_id); | ||
593 | |||
594 | group.set_type(h_group.type()); | ||
595 | |||
596 | for (const DoorIdentifier& di : h_group.doors()) { | ||
597 | uint64_t door_id = | ||
598 | container_.FindOrAddDoor(di.map(), di.name(), std::nullopt); | ||
599 | group.add_doors(door_id); | ||
600 | } | ||
601 | } | ||
602 | |||
580 | void ProcessIdsFile(std::filesystem::path path) { | 603 | void ProcessIdsFile(std::filesystem::path path) { |
581 | auto ids = ReadIdsFromYaml(path.string()); | 604 | auto ids = ReadIdsFromYaml(path.string()); |
582 | 605 | ||
@@ -631,6 +654,11 @@ class DataPacker { | |||
631 | uint64_t prog_id = container_.FindOrAddProgressive(prog_name); | 654 | uint64_t prog_id = container_.FindOrAddProgressive(prog_name); |
632 | container_.all_objects().mutable_progressives(prog_id)->set_ap_id(ap_id); | 655 | container_.all_objects().mutable_progressives(prog_id)->set_ap_id(ap_id); |
633 | } | 656 | } |
657 | |||
658 | for (const auto& [group_name, ap_id] : ids.door_groups()) { | ||
659 | uint64_t group_id = container_.FindOrAddDoorGroup(group_name); | ||
660 | container_.all_objects().mutable_door_groups(group_id)->set_ap_id(ap_id); | ||
661 | } | ||
634 | } | 662 | } |
635 | 663 | ||
636 | std::string mapdir_; | 664 | std::string mapdir_; |