diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-09-07 15:42:00 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-09-07 15:42:00 -0400 |
commit | d79984b099c3f762b95d3b4257bef113d3a8d6ee (patch) | |
tree | bcb647c4734b9ddecb465f818e06efc899482f4e /tools/datapacker | |
parent | 8ab6132f99e9a033c170310b2d88a7312e46a153 (diff) | |
download | lingo2-archipelago-d79984b099c3f762b95d3b4257bef113d3a8d6ee.tar.gz lingo2-archipelago-d79984b099c3f762b95d3b4257bef113d3a8d6ee.tar.bz2 lingo2-archipelago-d79984b099c3f762b95d3b4257bef113d3a8d6ee.zip |
Added door groups
Diffstat (limited to 'tools/datapacker')
-rw-r--r-- | tools/datapacker/container.cpp | 17 | ||||
-rw-r--r-- | tools/datapacker/container.h | 3 | ||||
-rw-r--r-- | tools/datapacker/main.cpp | 31 |
3 files changed, 51 insertions, 0 deletions
diff --git a/tools/datapacker/container.cpp b/tools/datapacker/container.cpp index 624caf8..4a656b3 100644 --- a/tools/datapacker/container.cpp +++ b/tools/datapacker/container.cpp | |||
@@ -348,6 +348,23 @@ uint64_t Container::FindOrAddProgressive(std::string prog_name) { | |||
348 | } | 348 | } |
349 | } | 349 | } |
350 | 350 | ||
351 | uint64_t Container::FindOrAddDoorGroup(std::string group_name) { | ||
352 | auto it = door_group_id_by_name_.find(group_name); | ||
353 | |||
354 | if (it == door_group_id_by_name_.end()) { | ||
355 | uint64_t new_id = all_objects_.door_groups_size(); | ||
356 | DoorGroup* door_group = all_objects_.add_door_groups(); | ||
357 | door_group->set_id(new_id); | ||
358 | door_group->set_name(group_name); | ||
359 | |||
360 | door_group_id_by_name_[group_name] = new_id; | ||
361 | |||
362 | return new_id; | ||
363 | } else { | ||
364 | return it->second; | ||
365 | } | ||
366 | } | ||
367 | |||
351 | void Container::AddConnection(const Connection& connection) { | 368 | void Container::AddConnection(const Connection& connection) { |
352 | *all_objects_.add_connections() = connection; | 369 | *all_objects_.add_connections() = connection; |
353 | } | 370 | } |
diff --git a/tools/datapacker/container.h b/tools/datapacker/container.h index 8cec560..bc02ba4 100644 --- a/tools/datapacker/container.h +++ b/tools/datapacker/container.h | |||
@@ -62,6 +62,8 @@ class Container { | |||
62 | 62 | ||
63 | uint64_t FindOrAddProgressive(std::string prog_name); | 63 | uint64_t FindOrAddProgressive(std::string prog_name); |
64 | 64 | ||
65 | uint64_t FindOrAddDoorGroup(std::string group_name); | ||
66 | |||
65 | AllObjects& all_objects() { return all_objects_; } | 67 | AllObjects& all_objects() { return all_objects_; } |
66 | 68 | ||
67 | private: | 69 | private: |
@@ -85,6 +87,7 @@ class Container { | |||
85 | door_id_by_map_door_names_; | 87 | door_id_by_map_door_names_; |
86 | std::map<std::string, uint64_t> ending_id_by_name_; | 88 | std::map<std::string, uint64_t> ending_id_by_name_; |
87 | std::map<std::string, uint64_t> progressive_id_by_name_; | 89 | std::map<std::string, uint64_t> progressive_id_by_name_; |
90 | std::map<std::string, uint64_t> door_group_id_by_name_; | ||
88 | }; | 91 | }; |
89 | 92 | ||
90 | } // namespace com::fourisland::lingo2_archipelago | 93 | } // namespace com::fourisland::lingo2_archipelago |
diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index 595647d..c72462d 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 | { |
@@ -577,6 +578,31 @@ class DataPacker { | |||
577 | } | 578 | } |
578 | } | 579 | } |
579 | 580 | ||
581 | void ProcessDoorGroupsFile(std::filesystem::path path) { | ||
582 | if (!std::filesystem::exists(path)) { | ||
583 | return; | ||
584 | } | ||
585 | |||
586 | auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string()); | ||
587 | |||
588 | for (const HumanDoorGroup& h_group : h_groups.door_groups()) { | ||
589 | ProcessDoorGroup(h_group); | ||
590 | } | ||
591 | } | ||
592 | |||
593 | void ProcessDoorGroup(const HumanDoorGroup& h_group) { | ||
594 | uint64_t group_id = container_.FindOrAddDoorGroup(h_group.name()); | ||
595 | DoorGroup& group = *container_.all_objects().mutable_door_groups(group_id); | ||
596 | |||
597 | group.set_type(h_group.type()); | ||
598 | |||
599 | for (const DoorIdentifier& di : h_group.doors()) { | ||
600 | uint64_t door_id = | ||
601 | container_.FindOrAddDoor(di.map(), di.name(), std::nullopt); | ||
602 | group.add_doors(door_id); | ||
603 | } | ||
604 | } | ||
605 | |||
580 | void ProcessIdsFile(std::filesystem::path path) { | 606 | void ProcessIdsFile(std::filesystem::path path) { |
581 | auto ids = ReadIdsFromYaml(path.string()); | 607 | auto ids = ReadIdsFromYaml(path.string()); |
582 | 608 | ||
@@ -631,6 +657,11 @@ class DataPacker { | |||
631 | uint64_t prog_id = container_.FindOrAddProgressive(prog_name); | 657 | uint64_t prog_id = container_.FindOrAddProgressive(prog_name); |
632 | container_.all_objects().mutable_progressives(prog_id)->set_ap_id(ap_id); | 658 | container_.all_objects().mutable_progressives(prog_id)->set_ap_id(ap_id); |
633 | } | 659 | } |
660 | |||
661 | for (const auto& [group_name, ap_id] : ids.door_groups()) { | ||
662 | uint64_t group_id = container_.FindOrAddDoorGroup(group_name); | ||
663 | container_.all_objects().mutable_door_groups(group_id)->set_ap_id(ap_id); | ||
664 | } | ||
634 | } | 665 | } |
635 | 666 | ||
636 | std::string mapdir_; | 667 | std::string mapdir_; |