diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/assign_ids/main.cpp | 21 | ||||
-rw-r--r-- | tools/datapacker/container.cpp | 17 | ||||
-rw-r--r-- | tools/datapacker/container.h | 3 | ||||
-rw-r--r-- | tools/datapacker/main.cpp | 34 | ||||
-rw-r--r-- | tools/util/godot_scene.cpp | 6 | ||||
-rw-r--r-- | tools/util/ids_yaml_format.cpp | 12 | ||||
-rw-r--r-- | tools/validator/human_processor.cpp | 33 | ||||
-rw-r--r-- | tools/validator/structs.h | 9 | ||||
-rw-r--r-- | tools/validator/validator.cpp | 28 |
9 files changed, 156 insertions, 7 deletions
diff --git a/tools/assign_ids/main.cpp b/tools/assign_ids/main.cpp index e3add66..ee55338 100644 --- a/tools/assign_ids/main.cpp +++ b/tools/assign_ids/main.cpp | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <google/protobuf/text_format.h> | 2 | #include <google/protobuf/text_format.h> |
3 | 3 | ||
4 | #include <cstdint> | 4 | #include <cstdint> |
5 | #include <filesystem> | ||
5 | #include <fstream> | 6 | #include <fstream> |
6 | #include <iostream> | 7 | #include <iostream> |
7 | #include <map> | 8 | #include <map> |
@@ -42,6 +43,7 @@ class AssignIds { | |||
42 | ProcessMaps(datadir_path); | 43 | ProcessMaps(datadir_path); |
43 | ProcessSpecialIds(); | 44 | ProcessSpecialIds(); |
44 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); | 45 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); |
46 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); | ||
45 | 47 | ||
46 | WriteIds(ids_path); | 48 | WriteIds(ids_path); |
47 | 49 | ||
@@ -61,6 +63,7 @@ class AssignIds { | |||
61 | for (const auto& [_, room] : map.rooms()) { | 63 | for (const auto& [_, room] : map.rooms()) { |
62 | UpdateNextId(room.panels()); | 64 | UpdateNextId(room.panels()); |
63 | UpdateNextId(room.masteries()); | 65 | UpdateNextId(room.masteries()); |
66 | UpdateNextId(room.keyholders()); | ||
64 | } | 67 | } |
65 | } | 68 | } |
66 | 69 | ||
@@ -68,6 +71,7 @@ class AssignIds { | |||
68 | UpdateNextId(id_mappings_.letters()); | 71 | UpdateNextId(id_mappings_.letters()); |
69 | UpdateNextId(id_mappings_.endings()); | 72 | UpdateNextId(id_mappings_.endings()); |
70 | UpdateNextId(id_mappings_.progressives()); | 73 | UpdateNextId(id_mappings_.progressives()); |
74 | UpdateNextId(id_mappings_.door_groups()); | ||
71 | 75 | ||
72 | next_id_++; | 76 | next_id_++; |
73 | } | 77 | } |
@@ -267,6 +271,23 @@ class AssignIds { | |||
267 | } | 271 | } |
268 | } | 272 | } |
269 | 273 | ||
274 | void ProcessDoorGroupsFile(std::filesystem::path path) { | ||
275 | if (!std::filesystem::exists(path)) { | ||
276 | return; | ||
277 | } | ||
278 | |||
279 | auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string()); | ||
280 | auto& groups = *output_.mutable_door_groups(); | ||
281 | |||
282 | for (const HumanDoorGroup& h_group : h_groups.door_groups()) { | ||
283 | if (!id_mappings_.door_groups().contains(h_group.name())) { | ||
284 | groups[h_group.name()] = next_id_++; | ||
285 | } else { | ||
286 | groups[h_group.name()] = id_mappings_.door_groups().at(h_group.name()); | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | |||
270 | private: | 291 | private: |
271 | void UpdateNextId(const google::protobuf::Map<std::string, uint64_t>& ids) { | 292 | void UpdateNextId(const google::protobuf::Map<std::string, uint64_t>& ids) { |
272 | for (const auto& [_, id] : ids) { | 293 | for (const auto& [_, id] : ids) { |
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..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_; |
diff --git a/tools/util/godot_scene.cpp b/tools/util/godot_scene.cpp index 1e77c9e..f788d21 100644 --- a/tools/util/godot_scene.cpp +++ b/tools/util/godot_scene.cpp | |||
@@ -1,10 +1,8 @@ | |||
1 | #include "godot_scene.h" | 1 | #include "godot_scene.h" |
2 | 2 | ||
3 | #include <absl/strings/str_split.h> | ||
4 | #include <absl/strings/string_view.h> | ||
5 | |||
6 | #include <fstream> | 3 | #include <fstream> |
7 | #include <sstream> | 4 | #include <sstream> |
5 | #include <string_view> | ||
8 | #include <variant> | 6 | #include <variant> |
9 | 7 | ||
10 | namespace com::fourisland::lingo2_archipelago { | 8 | namespace com::fourisland::lingo2_archipelago { |
@@ -23,7 +21,7 @@ struct Heading { | |||
23 | GodotInstanceType instance_type; | 21 | GodotInstanceType instance_type; |
24 | }; | 22 | }; |
25 | 23 | ||
26 | Heading ParseTscnHeading(absl::string_view line) { | 24 | Heading ParseTscnHeading(std::string_view line) { |
27 | std::string original_line(line); | 25 | std::string original_line(line); |
28 | Heading heading; | 26 | Heading heading; |
29 | 27 | ||
diff --git a/tools/util/ids_yaml_format.cpp b/tools/util/ids_yaml_format.cpp index 67c21d6..71bfd63 100644 --- a/tools/util/ids_yaml_format.cpp +++ b/tools/util/ids_yaml_format.cpp | |||
@@ -104,6 +104,13 @@ IdMappings ReadIdsFromYaml(const std::string& filename) { | |||
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | if (document["door_groups"]) { | ||
108 | for (const auto& group_it : document["door_groups"]) { | ||
109 | (*result.mutable_door_groups())[group_it.first.as<std::string>()] = | ||
110 | group_it.second.as<uint64_t>(); | ||
111 | } | ||
112 | } | ||
113 | |||
107 | return result; | 114 | return result; |
108 | } | 115 | } |
109 | 116 | ||
@@ -171,6 +178,11 @@ void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) { | |||
171 | result["progressives"][prog_name] = prog_id; | 178 | result["progressives"][prog_name] = prog_id; |
172 | }); | 179 | }); |
173 | 180 | ||
181 | OperateOnSortedMap(ids.door_groups(), [&result](const std::string& group_name, | ||
182 | uint64_t group_id) { | ||
183 | result["door_groups"][group_name] = group_id; | ||
184 | }); | ||
185 | |||
174 | std::ofstream output_stream(filename); | 186 | std::ofstream output_stream(filename); |
175 | output_stream << result << std::endl; | 187 | output_stream << result << std::endl; |
176 | } | 188 | } |
diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index 5720ba9..561225e 100644 --- a/tools/validator/human_processor.cpp +++ b/tools/validator/human_processor.cpp | |||
@@ -43,6 +43,7 @@ class HumanProcessor { | |||
43 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); | 43 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); |
44 | ProcessMaps(datadir_path); | 44 | ProcessMaps(datadir_path); |
45 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); | 45 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); |
46 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); | ||
46 | ProcessIdsFile(datadir_path / "ids.yaml"); | 47 | ProcessIdsFile(datadir_path / "ids.yaml"); |
47 | } | 48 | } |
48 | 49 | ||
@@ -510,6 +511,33 @@ class HumanProcessor { | |||
510 | } | 511 | } |
511 | } | 512 | } |
512 | 513 | ||
514 | void ProcessDoorGroupsFile(std::filesystem::path path) { | ||
515 | if (!std::filesystem::exists(path)) { | ||
516 | return; | ||
517 | } | ||
518 | |||
519 | auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string()); | ||
520 | |||
521 | for (const HumanDoorGroup& h_group : h_groups.door_groups()) { | ||
522 | ProcessDoorGroup(h_group); | ||
523 | } | ||
524 | } | ||
525 | |||
526 | void ProcessDoorGroup(const HumanDoorGroup& h_group) { | ||
527 | DoorGroupInfo& group_info = info_.door_groups[h_group.name()]; | ||
528 | group_info.definitions.push_back(h_group); | ||
529 | |||
530 | for (const DoorIdentifier& di : h_group.doors()) { | ||
531 | if (!di.has_map()) { | ||
532 | group_info.malformed_doors.push_back(di); | ||
533 | continue; | ||
534 | } | ||
535 | |||
536 | DoorInfo& door_info = info_.doors[di]; | ||
537 | door_info.door_groups_referenced_by.push_back(h_group.name()); | ||
538 | } | ||
539 | } | ||
540 | |||
513 | void ProcessIdsFile(std::filesystem::path path) { | 541 | void ProcessIdsFile(std::filesystem::path path) { |
514 | auto ids = ReadIdsFromYaml(path.string()); | 542 | auto ids = ReadIdsFromYaml(path.string()); |
515 | 543 | ||
@@ -573,6 +601,11 @@ class HumanProcessor { | |||
573 | ProgressiveInfo& prog_info = info_.progressives[prog_name]; | 601 | ProgressiveInfo& prog_info = info_.progressives[prog_name]; |
574 | prog_info.has_id = true; | 602 | prog_info.has_id = true; |
575 | } | 603 | } |
604 | |||
605 | for (const auto& [group_name, ap_id] : ids.door_groups()) { | ||
606 | DoorGroupInfo& group_info = info_.door_groups[group_name]; | ||
607 | group_info.has_id = true; | ||
608 | } | ||
576 | } | 609 | } |
577 | 610 | ||
578 | std::string mapdir_; | 611 | std::string mapdir_; |
diff --git a/tools/validator/structs.h b/tools/validator/structs.h index e24ed3d..17ed33a 100644 --- a/tools/validator/structs.h +++ b/tools/validator/structs.h | |||
@@ -47,6 +47,7 @@ struct DoorInfo { | |||
47 | std::vector<PaintingIdentifier> paintings_referenced_by; | 47 | std::vector<PaintingIdentifier> paintings_referenced_by; |
48 | std::vector<PortIdentifier> ports_referenced_by; | 48 | std::vector<PortIdentifier> ports_referenced_by; |
49 | std::vector<std::string> progressives_referenced_by; | 49 | std::vector<std::string> progressives_referenced_by; |
50 | std::vector<std::string> door_groups_referenced_by; | ||
50 | 51 | ||
51 | MalformedIdentifiers malformed_identifiers; | 52 | MalformedIdentifiers malformed_identifiers; |
52 | }; | 53 | }; |
@@ -115,6 +116,13 @@ struct ProgressiveInfo { | |||
115 | std::vector<DoorIdentifier> malformed_doors; | 116 | std::vector<DoorIdentifier> malformed_doors; |
116 | }; | 117 | }; |
117 | 118 | ||
119 | struct DoorGroupInfo { | ||
120 | std::vector<HumanDoorGroup> definitions; | ||
121 | bool has_id = false; | ||
122 | |||
123 | std::vector<DoorIdentifier> malformed_doors; | ||
124 | }; | ||
125 | |||
118 | struct CollectedInfo { | 126 | struct CollectedInfo { |
119 | std::map<std::string, MapInfo> maps; | 127 | std::map<std::string, MapInfo> maps; |
120 | std::map<RoomIdentifier, RoomInfo, RoomIdentifierLess> rooms; | 128 | std::map<RoomIdentifier, RoomInfo, RoomIdentifierLess> rooms; |
@@ -128,6 +136,7 @@ struct CollectedInfo { | |||
128 | std::map<std::string, EndingInfo> endings; | 136 | std::map<std::string, EndingInfo> endings; |
129 | std::map<std::string, PanelNameInfo> panel_names; | 137 | std::map<std::string, PanelNameInfo> panel_names; |
130 | std::map<std::string, ProgressiveInfo> progressives; | 138 | std::map<std::string, ProgressiveInfo> progressives; |
139 | std::map<std::string, DoorGroupInfo> door_groups; | ||
131 | }; | 140 | }; |
132 | 141 | ||
133 | } // namespace com::fourisland::lingo2_archipelago | 142 | } // namespace com::fourisland::lingo2_archipelago |
diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index ab1612e..4149caa 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp | |||
@@ -48,6 +48,9 @@ class Validator { | |||
48 | for (const auto& [prog_name, prog_info] : info_.progressives) { | 48 | for (const auto& [prog_name, prog_info] : info_.progressives) { |
49 | ValidateProgressive(prog_name, prog_info); | 49 | ValidateProgressive(prog_name, prog_info); |
50 | } | 50 | } |
51 | for (const auto& [group_name, group_info] : info_.door_groups) { | ||
52 | ValidateDoorGroup(group_name, group_info); | ||
53 | } | ||
51 | } | 54 | } |
52 | 55 | ||
53 | private: | 56 | private: |
@@ -173,6 +176,11 @@ class Validator { | |||
173 | std::cout << " PROGRESSIVE " << prog_name << std::endl; | 176 | std::cout << " PROGRESSIVE " << prog_name << std::endl; |
174 | } | 177 | } |
175 | 178 | ||
179 | for (const std::string& group_name : | ||
180 | door_info.door_groups_referenced_by) { | ||
181 | std::cout << " DOOR GROUP " << group_name << std::endl; | ||
182 | } | ||
183 | |||
176 | if (door_info.has_id) { | 184 | if (door_info.has_id) { |
177 | std::cout << " An AP ID is present." << std::endl; | 185 | std::cout << " An AP ID is present." << std::endl; |
178 | } | 186 | } |
@@ -460,6 +468,26 @@ class Validator { | |||
460 | } | 468 | } |
461 | } | 469 | } |
462 | 470 | ||
471 | void ValidateDoorGroup(const std::string& group_name, | ||
472 | const DoorGroupInfo& group_info) const { | ||
473 | if (group_info.definitions.empty()) { | ||
474 | std::cout << "Door group \"" << group_name | ||
475 | << "\" has no definition, but was referenced:" << std::endl; | ||
476 | |||
477 | if (group_info.has_id) { | ||
478 | std::cout << " An AP ID is present." << std::endl; | ||
479 | } | ||
480 | } else if (group_info.definitions.size() > 1) { | ||
481 | std::cout << "Door group \"" << group_name | ||
482 | << "\" has multiple definitions." << std::endl; | ||
483 | } | ||
484 | |||
485 | if (!group_info.has_id) { | ||
486 | std::cout << "Door group \"" << group_name << "\" is missing an AP ID." | ||
487 | << std::endl; | ||
488 | } | ||
489 | } | ||
490 | |||
463 | const CollectedInfo& info_; | 491 | const CollectedInfo& info_; |
464 | }; | 492 | }; |
465 | 493 | ||