diff options
Diffstat (limited to 'tools/validator')
-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 |
3 files changed, 70 insertions, 0 deletions
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 | ||