about summary refs log tree commit diff stats
path: root/tools/validator
diff options
context:
space:
mode:
Diffstat (limited to 'tools/validator')
-rw-r--r--tools/validator/CMakeLists.txt3
-rw-r--r--tools/validator/human_processor.cpp225
-rw-r--r--tools/validator/main.cpp4
-rw-r--r--tools/validator/structs.h41
-rw-r--r--tools/validator/validator.cpp715
-rw-r--r--tools/validator/validator.h2
6 files changed, 768 insertions, 222 deletions
diff --git a/tools/validator/CMakeLists.txt b/tools/validator/CMakeLists.txt index 967b890..1a8fd9c 100644 --- a/tools/validator/CMakeLists.txt +++ b/tools/validator/CMakeLists.txt
@@ -1,3 +1,4 @@
1find_package(fmt REQUIRED)
1find_package(Protobuf REQUIRED) 2find_package(Protobuf REQUIRED)
2 3
3add_executable(validator 4add_executable(validator
@@ -9,4 +10,4 @@ add_executable(validator
9set_property(TARGET validator PROPERTY CXX_STANDARD 20) 10set_property(TARGET validator PROPERTY CXX_STANDARD 20)
10set_property(TARGET validator PROPERTY CXX_STANDARD_REQUIRED ON) 11set_property(TARGET validator PROPERTY CXX_STANDARD_REQUIRED ON)
11target_include_directories(validator PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/tools) 12target_include_directories(validator PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/tools)
12target_link_libraries(validator PUBLIC protos util protobuf::libprotobuf) 13target_link_libraries(validator PUBLIC protos util fmt::fmt protobuf::libprotobuf)
diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index f53dc79..d6fcfa6 100644 --- a/tools/validator/human_processor.cpp +++ b/tools/validator/human_processor.cpp
@@ -1,5 +1,6 @@
1#include "human_processor.h" 1#include "human_processor.h"
2 2
3#include <fmt/core.h>
3#include <google/protobuf/message.h> 4#include <google/protobuf/message.h>
4#include <google/protobuf/text_format.h> 5#include <google/protobuf/text_format.h>
5 6
@@ -12,6 +13,7 @@
12#include <string> 13#include <string>
13 14
14#include "structs.h" 15#include "structs.h"
16#include "util/ids_yaml_format.h"
15 17
16namespace com::fourisland::lingo2_archipelago { 18namespace com::fourisland::lingo2_archipelago {
17namespace { 19namespace {
@@ -40,7 +42,9 @@ class HumanProcessor {
40 42
41 ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); 43 ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt);
42 ProcessMaps(datadir_path); 44 ProcessMaps(datadir_path);
43 ProcessIdsFile(datadir_path / "ids.txtpb"); 45 ProcessProgressivesFile(datadir_path / "progressives.txtpb");
46 ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb");
47 ProcessIdsFile(datadir_path / "ids.yaml");
44 } 48 }
45 49
46 private: 50 private:
@@ -70,9 +74,35 @@ class HumanProcessor {
70 MapInfo& map_info = info_.maps[current_map_name]; 74 MapInfo& map_info = info_.maps[current_map_name];
71 75
72 auto metadata = ReadMessageFromFile<HumanMap>(path.string()); 76 auto metadata = ReadMessageFromFile<HumanMap>(path.string());
77 map_info.definitions.push_back(metadata);
78
73 for (const std::string& path : metadata.excluded_nodes()) { 79 for (const std::string& path : metadata.excluded_nodes()) {
74 map_info.game_nodes[path].uses++; 80 map_info.game_nodes[path].uses++;
75 } 81 }
82
83 for (const std::string& path : metadata.custom_nodes()) {
84 map_info.game_nodes[path].defined = true;
85 }
86
87 if (metadata.has_worldport_entrance()) {
88 auto port_identifier = GetCompletePortIdentifier(
89 metadata.worldport_entrance(), current_map_name, std::nullopt);
90 if (port_identifier) {
91 PortInfo& port_info = info_.ports[*port_identifier];
92 port_info.map_worldport_entrances.push_back(current_map_name);
93 } else {
94 map_info.malformed_worldport_entrance = metadata.worldport_entrance();
95 }
96 }
97
98 if (metadata.has_rte_room()) {
99 RoomIdentifier room_identifier;
100 room_identifier.set_map(current_map_name);
101 room_identifier.set_name(metadata.rte_room());
102
103 RoomInfo& room_info = info_.rooms[room_identifier];
104 room_info.map_rtes_referenced_by.push_back(current_map_name);
105 }
76 } 106 }
77 107
78 void ProcessRooms(std::filesystem::path path, 108 void ProcessRooms(std::filesystem::path path,
@@ -93,7 +123,7 @@ class HumanProcessor {
93 room_info.definitions.push_back(h_room); 123 room_info.definitions.push_back(h_room);
94 124
95 for (const HumanPanel& h_panel : h_room.panels()) { 125 for (const HumanPanel& h_panel : h_room.panels()) {
96 ProcessPanel(h_panel, current_map_name, h_room.name()); 126 ProcessPanel(h_panel, current_map_name, h_room);
97 } 127 }
98 128
99 for (const HumanPainting& h_painting : h_room.paintings()) { 129 for (const HumanPainting& h_painting : h_room.paintings()) {
@@ -123,15 +153,14 @@ class HumanProcessor {
123 153
124 void ProcessPanel(const HumanPanel& h_panel, 154 void ProcessPanel(const HumanPanel& h_panel,
125 const std::string& current_map_name, 155 const std::string& current_map_name,
126 const std::string& current_room_name) { 156 const HumanRoom& h_room) {
127 PanelIdentifier panel_identifier; 157 PanelIdentifier panel_identifier;
128 panel_identifier.set_map(current_map_name); 158 panel_identifier.set_map(current_map_name);
129 panel_identifier.set_room(current_room_name); 159 panel_identifier.set_room(h_room.name());
130 panel_identifier.set_name(h_panel.name()); 160 panel_identifier.set_name(h_panel.name());
131 161
132 PanelInfo& panel_info = info_.panels[panel_identifier]; 162 PanelInfo& panel_info = info_.panels[panel_identifier];
133 panel_info.definitions.push_back(h_panel); 163 panel_info.definitions.push_back(h_panel);
134 panel_info.proxies[h_panel.answer()].definitions.push_back(Proxy());
135 164
136 MapInfo& map_info = info_.maps[current_map_name]; 165 MapInfo& map_info = info_.maps[current_map_name];
137 map_info.game_nodes[h_panel.path()].uses++; 166 map_info.game_nodes[h_panel.path()].uses++;
@@ -156,6 +185,24 @@ class HumanProcessor {
156 RoomInfo& required_room_info = info_.rooms[required_room_identifier]; 185 RoomInfo& required_room_info = info_.rooms[required_room_identifier];
157 required_room_info.panels_referenced_by.push_back(panel_identifier); 186 required_room_info.panels_referenced_by.push_back(panel_identifier);
158 } 187 }
188
189 std::string map_area_name = current_map_name;
190 if (h_room.has_panel_display_name()) {
191 map_area_name =
192 fmt::format("{} ({})", current_map_name, h_room.panel_display_name());
193 }
194
195 panel_info.map_area_name = map_area_name;
196
197 std::string panelsanity_name;
198 if (h_panel.has_display_name()) {
199 panelsanity_name =
200 fmt::format("{} - {}", map_area_name, h_panel.display_name());
201 } else {
202 panelsanity_name = fmt::format("{} - {}", map_area_name, h_panel.name());
203 }
204 info_.panel_names[panelsanity_name].panels_used_by.push_back(
205 panel_identifier);
159 } 206 }
160 207
161 void ProcessPainting(const HumanPainting& h_painting, 208 void ProcessPainting(const HumanPainting& h_painting,
@@ -337,11 +384,6 @@ class HumanProcessor {
337 DoorInfo& other_door_info = info_.doors[complete_door_identifier]; 384 DoorInfo& other_door_info = info_.doors[complete_door_identifier];
338 other_door_info.doors_referenced_by.push_back(door_identifier); 385 other_door_info.doors_referenced_by.push_back(door_identifier);
339 } 386 }
340
341 for (const std::string& ei : h_door.endings()) {
342 EndingInfo& ending_info = info_.endings[ei];
343 ending_info.doors_referenced_by.push_back(door_identifier);
344 }
345 } 387 }
346 388
347 void ProcessConnectionsFile(std::filesystem::path path, 389 void ProcessConnectionsFile(std::filesystem::path path,
@@ -373,7 +415,9 @@ class HumanProcessor {
373 } 415 }
374 } else if (human_connection.has_from()) { 416 } else if (human_connection.has_from()) {
375 ProcessSingleConnection(human_connection, human_connection.from(), 417 ProcessSingleConnection(human_connection, human_connection.from(),
376 current_map_name); 418 current_map_name,
419 /*is_target=*/!human_connection.oneway() &&
420 !human_connection.bypass_target_door());
377 } 421 }
378 422
379 if (human_connection.has_to_room()) { 423 if (human_connection.has_to_room()) {
@@ -389,8 +433,9 @@ class HumanProcessor {
389 std::cout << "A global connection used to_room." << std::endl; 433 std::cout << "A global connection used to_room." << std::endl;
390 } 434 }
391 } else if (human_connection.has_to()) { 435 } else if (human_connection.has_to()) {
392 ProcessSingleConnection(human_connection, human_connection.to(), 436 ProcessSingleConnection(
393 current_map_name); 437 human_connection, human_connection.to(), current_map_name,
438 /*is_target=*/!human_connection.bypass_target_door());
394 } 439 }
395 440
396 if (human_connection.has_door()) { 441 if (human_connection.has_door()) {
@@ -411,7 +456,7 @@ class HumanProcessor {
411 void ProcessSingleConnection( 456 void ProcessSingleConnection(
412 const HumanConnection& human_connection, 457 const HumanConnection& human_connection,
413 const HumanConnection::Endpoint& endpoint, 458 const HumanConnection::Endpoint& endpoint,
414 const std::optional<std::string>& current_map_name) { 459 const std::optional<std::string>& current_map_name, bool is_target) {
415 if (endpoint.has_room()) { 460 if (endpoint.has_room()) {
416 auto room_identifier = 461 auto room_identifier =
417 GetCompleteRoomIdentifier(endpoint.room(), current_map_name); 462 GetCompleteRoomIdentifier(endpoint.room(), current_map_name);
@@ -430,6 +475,11 @@ class HumanProcessor {
430 if (painting_identifier) { 475 if (painting_identifier) {
431 PaintingInfo& painting_info = info_.paintings[*painting_identifier]; 476 PaintingInfo& painting_info = info_.paintings[*painting_identifier];
432 painting_info.connections_referenced_by.push_back(human_connection); 477 painting_info.connections_referenced_by.push_back(human_connection);
478
479 if (is_target) {
480 painting_info.target_connections_referenced_by.push_back(
481 human_connection);
482 }
433 } else { 483 } else {
434 // Not sure where else to store this right now. 484 // Not sure where else to store this right now.
435 std::cout 485 std::cout
@@ -442,6 +492,11 @@ class HumanProcessor {
442 if (port_identifier) { 492 if (port_identifier) {
443 PortInfo& port_info = info_.ports[*port_identifier]; 493 PortInfo& port_info = info_.ports[*port_identifier];
444 port_info.connections_referenced_by.push_back(human_connection); 494 port_info.connections_referenced_by.push_back(human_connection);
495
496 if (is_target) {
497 port_info.target_connections_referenced_by.push_back(
498 human_connection);
499 }
445 } else { 500 } else {
446 // Not sure where else to store this right now. 501 // Not sure where else to store this right now.
447 std::cout 502 std::cout
@@ -459,12 +514,152 @@ class HumanProcessor {
459 panel_info.proxies[endpoint.panel().answer()] 514 panel_info.proxies[endpoint.panel().answer()]
460 .connections_referenced_by.push_back(human_connection); 515 .connections_referenced_by.push_back(human_connection);
461 } 516 }
517
518 if (is_target) {
519 panel_info.target_connections_referenced_by.push_back(
520 human_connection);
521 }
462 } 522 }
463 } 523 }
464 } 524 }
465 525
526 void ProcessProgressivesFile(std::filesystem::path path) {
527 if (!std::filesystem::exists(path)) {
528 return;
529 }
530
531 auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string());
532
533 for (const HumanProgressive& h_prog : h_progs.progressives()) {
534 ProcessProgressive(h_prog);
535 }
536 }
537
538 void ProcessProgressive(const HumanProgressive& h_prog) {
539 ProgressiveInfo& prog_info = info_.progressives[h_prog.name()];
540 prog_info.definitions.push_back(h_prog);
541
542 for (const DoorIdentifier& di : h_prog.doors()) {
543 if (!di.has_map()) {
544 prog_info.malformed_doors.push_back(di);
545 continue;
546 }
547
548 DoorInfo& door_info = info_.doors[di];
549 door_info.progressives_referenced_by.push_back(h_prog.name());
550 }
551 }
552
553 void ProcessDoorGroupsFile(std::filesystem::path path) {
554 if (!std::filesystem::exists(path)) {
555 return;
556 }
557
558 auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string());
559
560 for (const HumanDoorGroup& h_group : h_groups.door_groups()) {
561 ProcessDoorGroup(h_group);
562 }
563 }
564
565 void ProcessDoorGroup(const HumanDoorGroup& h_group) {
566 DoorGroupInfo& group_info = info_.door_groups[h_group.name()];
567 group_info.definitions.push_back(h_group);
568
569 for (const DoorIdentifier& di : h_group.doors()) {
570 if (!di.has_map()) {
571 group_info.malformed_doors.push_back(di);
572 continue;
573 }
574
575 DoorInfo& door_info = info_.doors[di];
576 door_info.door_groups_referenced_by.push_back(h_group.name());
577 }
578 }
579
466 void ProcessIdsFile(std::filesystem::path path) { 580 void ProcessIdsFile(std::filesystem::path path) {
467 // Ignore this for now. 581 auto ids = ReadIdsFromYaml(path.string());
582
583 DoorIdentifier di;
584 PanelIdentifier pai;
585 PortIdentifier poi;
586 KeyholderIdentifier ki;
587
588 for (const auto& [map_name, map] : ids.maps()) {
589 di.set_map(map_name);
590 pai.set_map(map_name);
591 poi.set_map(map_name);
592 ki.set_map(map_name);
593
594 for (const auto& [door_name, ap_id] : map.doors()) {
595 di.set_name(door_name);
596
597 DoorInfo& door_info = info_.doors[di];
598 door_info.has_id = true;
599 }
600
601 for (const auto& [room_name, room] : map.rooms()) {
602 pai.set_room(room_name);
603 poi.set_room(room_name);
604 ki.set_room(room_name);
605
606 for (const auto& [panel_name, ap_id] : room.panels()) {
607 pai.set_name(panel_name);
608
609 PanelInfo& panel_info = info_.panels[pai];
610 panel_info.has_id = true;
611 }
612
613 for (const auto& [mastery_name, ap_id] : room.masteries()) {
614 // TODO: Mastery
615 }
616
617 for (const auto& [keyholder_name, ap_id] : room.keyholders()) {
618 ki.set_name(keyholder_name);
619
620 KeyholderInfo& keyholder_info = info_.keyholders[ki];
621 keyholder_info.has_id = true;
622 }
623
624 for (const auto& [port_name, ap_id] : room.ports()) {
625 poi.set_name(port_name);
626
627 PortInfo& port_info = info_.ports[poi];
628 port_info.has_id = true;
629 }
630 }
631
632 if (map.has_rte()) {
633 MapInfo& map_info = info_.maps[map_name];
634 map_info.has_rte_id = true;
635 }
636 }
637
638 for (const auto& [tag, id] : ids.special()) {
639 // TODO: Specials
640 }
641
642 for (const auto& [letter_name, ap_id] : ids.letters()) {
643 LetterIdentifier li =
644 std::make_tuple(letter_name[0], letter_name[1] == '2');
645 LetterInfo& letter_info = info_.letters[li];
646 letter_info.has_id = true;
647 }
648
649 for (const auto& [ending_name, ap_id] : ids.endings()) {
650 EndingInfo& ending_info = info_.endings[ending_name];
651 ending_info.has_id = true;
652 }
653
654 for (const auto& [prog_name, ap_id] : ids.progressives()) {
655 ProgressiveInfo& prog_info = info_.progressives[prog_name];
656 prog_info.has_id = true;
657 }
658
659 for (const auto& [group_name, ap_id] : ids.door_groups()) {
660 DoorGroupInfo& group_info = info_.door_groups[group_name];
661 group_info.has_id = true;
662 }
468 } 663 }
469 664
470 std::string mapdir_; 665 std::string mapdir_;
diff --git a/tools/validator/main.cpp b/tools/validator/main.cpp index 1a72e9a..6139e95 100644 --- a/tools/validator/main.cpp +++ b/tools/validator/main.cpp
@@ -21,7 +21,9 @@ void Run(const std::string& mapdir, const std::string& repodir) {
21int main(int argc, char** argv) { 21int main(int argc, char** argv) {
22 if (argc != 3) { 22 if (argc != 3) {
23 std::cout << "Incorrect argument count." << std::endl; 23 std::cout << "Incorrect argument count." << std::endl;
24 std::cout << "Usage: validator [path to map directory] [path to Lingo 2 repository]" << std::endl; 24 std::cout << "Usage: validator [path to map directory] [path to Lingo 2 "
25 "repository]"
26 << std::endl;
25 return 1; 27 return 1;
26 } 28 }
27 29
diff --git a/tools/validator/structs.h b/tools/validator/structs.h index 958038d..81a0e8f 100644 --- a/tools/validator/structs.h +++ b/tools/validator/structs.h
@@ -27,6 +27,11 @@ struct GameNodeInfo {
27 27
28struct MapInfo { 28struct MapInfo {
29 std::map<std::string, GameNodeInfo> game_nodes; 29 std::map<std::string, GameNodeInfo> game_nodes;
30
31 std::vector<HumanMap> definitions;
32 bool has_rte_id = false;
33
34 std::optional<PortIdentifier> malformed_worldport_entrance;
30}; 35};
31 36
32struct RoomInfo { 37struct RoomInfo {
@@ -35,30 +40,38 @@ struct RoomInfo {
35 std::vector<DoorIdentifier> doors_referenced_by; 40 std::vector<DoorIdentifier> doors_referenced_by;
36 std::vector<PanelIdentifier> panels_referenced_by; 41 std::vector<PanelIdentifier> panels_referenced_by;
37 std::vector<HumanConnection> connections_referenced_by; 42 std::vector<HumanConnection> connections_referenced_by;
43 std::vector<std::string> map_rtes_referenced_by;
38}; 44};
39 45
40struct DoorInfo { 46struct DoorInfo {
41 std::vector<HumanDoor> definitions; 47 std::vector<HumanDoor> definitions;
48 bool has_id = false;
42 49
43 std::vector<HumanConnection> connections_referenced_by; 50 std::vector<HumanConnection> connections_referenced_by;
44 std::vector<DoorIdentifier> doors_referenced_by; 51 std::vector<DoorIdentifier> doors_referenced_by;
45 std::vector<PanelIdentifier> panels_referenced_by; 52 std::vector<PanelIdentifier> panels_referenced_by;
46 std::vector<PaintingIdentifier> paintings_referenced_by; 53 std::vector<PaintingIdentifier> paintings_referenced_by;
47 std::vector<PortIdentifier> ports_referenced_by; 54 std::vector<PortIdentifier> ports_referenced_by;
55 std::vector<std::string> progressives_referenced_by;
56 std::vector<std::string> door_groups_referenced_by;
48 57
49 MalformedIdentifiers malformed_identifiers; 58 MalformedIdentifiers malformed_identifiers;
50}; 59};
51 60
52struct PortInfo { 61struct PortInfo {
53 std::vector<HumanPort> definitions; 62 std::vector<HumanPort> definitions;
63 bool has_id = false;
54 64
55 std::vector<HumanConnection> connections_referenced_by; 65 std::vector<HumanConnection> connections_referenced_by;
66 std::vector<HumanConnection> target_connections_referenced_by;
67 std::vector<std::string> map_worldport_entrances;
56}; 68};
57 69
58struct PaintingInfo { 70struct PaintingInfo {
59 std::vector<HumanPainting> definitions; 71 std::vector<HumanPainting> definitions;
60 72
61 std::vector<HumanConnection> connections_referenced_by; 73 std::vector<HumanConnection> connections_referenced_by;
74 std::vector<HumanConnection> target_connections_referenced_by;
62 std::vector<DoorIdentifier> doors_referenced_by; 75 std::vector<DoorIdentifier> doors_referenced_by;
63}; 76};
64 77
@@ -71,8 +84,12 @@ struct ProxyInfo {
71 84
72struct PanelInfo { 85struct PanelInfo {
73 std::vector<HumanPanel> definitions; 86 std::vector<HumanPanel> definitions;
87 bool has_id = false;
88
89 std::string map_area_name;
74 90
75 std::vector<HumanConnection> connections_referenced_by; 91 std::vector<HumanConnection> connections_referenced_by;
92 std::vector<HumanConnection> target_connections_referenced_by;
76 std::vector<DoorIdentifier> doors_referenced_by; 93 std::vector<DoorIdentifier> doors_referenced_by;
77 94
78 std::map<std::string, ProxyInfo> proxies; 95 std::map<std::string, ProxyInfo> proxies;
@@ -80,6 +97,7 @@ struct PanelInfo {
80 97
81struct KeyholderInfo { 98struct KeyholderInfo {
82 std::vector<HumanKeyholder> definitions; 99 std::vector<HumanKeyholder> definitions;
100 bool has_id = false;
83 101
84 std::vector<DoorIdentifier> doors_referenced_by; 102 std::vector<DoorIdentifier> doors_referenced_by;
85}; 103};
@@ -88,12 +106,30 @@ using LetterIdentifier = std::tuple<char, bool>;
88 106
89struct LetterInfo { 107struct LetterInfo {
90 std::vector<RoomIdentifier> defined_in; 108 std::vector<RoomIdentifier> defined_in;
109 bool has_id = false;
91}; 110};
92 111
93struct EndingInfo { 112struct EndingInfo {
94 std::vector<RoomIdentifier> defined_in; 113 std::vector<RoomIdentifier> defined_in;
114 bool has_id = false;
115};
95 116
96 std::vector<DoorIdentifier> doors_referenced_by; 117struct PanelNameInfo {
118 std::vector<PanelIdentifier> panels_used_by;
119};
120
121struct ProgressiveInfo {
122 std::vector<HumanProgressive> definitions;
123 bool has_id = false;
124
125 std::vector<DoorIdentifier> malformed_doors;
126};
127
128struct DoorGroupInfo {
129 std::vector<HumanDoorGroup> definitions;
130 bool has_id = false;
131
132 std::vector<DoorIdentifier> malformed_doors;
97}; 133};
98 134
99struct CollectedInfo { 135struct CollectedInfo {
@@ -107,6 +143,9 @@ struct CollectedInfo {
107 keyholders; 143 keyholders;
108 std::map<LetterIdentifier, LetterInfo> letters; 144 std::map<LetterIdentifier, LetterInfo> letters;
109 std::map<std::string, EndingInfo> endings; 145 std::map<std::string, EndingInfo> endings;
146 std::map<std::string, PanelNameInfo> panel_names;
147 std::map<std::string, ProgressiveInfo> progressives;
148 std::map<std::string, DoorGroupInfo> door_groups;
110}; 149};
111 150
112} // namespace com::fourisland::lingo2_archipelago 151} // namespace com::fourisland::lingo2_archipelago
diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index f802460..e9fbb74 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp
@@ -1,5 +1,6 @@
1#include "validator.h" 1#include "validator.h"
2 2
3#include <algorithm>
3#include <iostream> 4#include <iostream>
4 5
5#include "proto/human.pb.h" 6#include "proto/human.pb.h"
@@ -9,291 +10,599 @@
9namespace com::fourisland::lingo2_archipelago { 10namespace com::fourisland::lingo2_archipelago {
10namespace { 11namespace {
11 12
12void ValidateMap(const std::string& map_name, const MapInfo& map_info) { 13class Validator {
13 for (const auto& [node_path, node_info] : map_info.game_nodes) { 14 public:
14 if (node_info.uses > 1) { 15 explicit Validator(const CollectedInfo& info) : info_(info) {}
15 std::cout << "Map " << map_name << " node " << node_path
16 << " is used in multiple places." << std::endl;
17 } else if (node_info.uses == 0) {
18 std::cout << "Map " << map_name << " node " << node_path
19 << " is not used." << std::endl;
20 }
21 16
22 if (!node_info.defined) { 17 void Validate() const {
23 std::cout << "Map " << map_name << " node " << node_path 18 for (const auto& [map_name, map_info] : info_.maps) {
24 << " is not defined in the game file." << std::endl; 19 ValidateMap(map_name, map_info);
20 }
21 for (const auto& [room_identifier, room_info] : info_.rooms) {
22 ValidateRoom(room_identifier, room_info);
23 }
24 for (const auto& [door_identifier, door_info] : info_.doors) {
25 ValidateDoor(door_identifier, door_info);
26 }
27 for (const auto& [port_identifier, port_info] : info_.ports) {
28 ValidatePort(port_identifier, port_info);
29 }
30 for (const auto& [painting_identifier, painting_info] : info_.paintings) {
31 ValidatePainting(painting_identifier, painting_info);
32 }
33 for (const auto& [panel_identifier, panel_info] : info_.panels) {
34 ValidatePanel(panel_identifier, panel_info);
35 }
36 for (const auto& [keyholder_identifier, keyholder_info] :
37 info_.keyholders) {
38 ValidateKeyholder(keyholder_identifier, keyholder_info);
39 }
40 for (const auto& [letter_identifier, letter_info] : info_.letters) {
41 ValidateLetter(letter_identifier, letter_info);
42 }
43 for (const auto& [ending_name, ending_info] : info_.endings) {
44 ValidateEnding(ending_name, ending_info);
45 }
46 for (const auto& [panel_name, panel_info] : info_.panel_names) {
47 ValidatePanelName(panel_name, panel_info);
48 }
49 for (const auto& [prog_name, prog_info] : info_.progressives) {
50 ValidateProgressive(prog_name, prog_info);
51 }
52 for (const auto& [group_name, group_info] : info_.door_groups) {
53 ValidateDoorGroup(group_name, group_info);
25 } 54 }
26 } 55 }
27}
28 56
29void ValidateRoom(const RoomIdentifier& room_identifier, 57 private:
30 const RoomInfo& room_info) { 58 void ValidateMap(const std::string& map_name, const MapInfo& map_info) const {
31 if (room_info.definitions.empty()) { 59 for (const auto& [node_path, node_info] : map_info.game_nodes) {
32 std::cout << "Room " << room_identifier.ShortDebugString() 60 if (node_info.uses > 1) {
33 << " has no definition, but was referenced:" << std::endl; 61 std::cout << "Map " << map_name << " node " << node_path
62 << " is used in multiple places." << std::endl;
63 } else if (node_info.uses == 0) {
64 std::cout << "Map " << map_name << " node " << node_path
65 << " is not used." << std::endl;
66 }
34 67
35 for (const DoorIdentifier& door_identifier : 68 if (!node_info.defined) {
36 room_info.doors_referenced_by) { 69 std::cout << "Map " << map_name << " node " << node_path
37 std::cout << " DOOR " << door_identifier.ShortDebugString() 70 << " is not defined in the game file." << std::endl;
38 << std::endl; 71 }
39 } 72 }
40 73
41 for (const PanelIdentifier& panel_identifier : 74 if (map_info.malformed_worldport_entrance) {
42 room_info.panels_referenced_by) { 75 std::cout << "The worldport entrance for map " << map_name
43 std::cout << " PANEL " << panel_identifier.ShortDebugString() 76 << " is malformed." << std::endl;
44 << std::endl;
45 } 77 }
46 78
47 for (const HumanConnection& connection : 79 if (map_info.has_rte_id) {
48 room_info.connections_referenced_by) { 80 if (!std::any_of(
49 std::cout << " CONNECTION " << connection.ShortDebugString() 81 map_info.definitions.begin(), map_info.definitions.end(),
50 << std::endl; 82 [](const HumanMap& h_map) { return h_map.has_rte_room(); })) {
83 std::cout << "Map " << map_name << " has an RTE ID but no RTE room."
84 << std::endl;
85 }
86 } else {
87 if (std::any_of(
88 map_info.definitions.begin(), map_info.definitions.end(),
89 [](const HumanMap& h_map) { return h_map.has_rte_room(); })) {
90 std::cout << "Map " << map_name << " has an RTE room but no RTE ID."
91 << std::endl;
92 }
51 } 93 }
52 } else if (room_info.definitions.size() > 1) {
53 std::cout << "Room " << room_identifier.ShortDebugString()
54 << " was defined multiple times." << std::endl;
55 } 94 }
56}
57 95
58void ValidateDoor(const DoorIdentifier& door_identifier, 96 void ValidateRoom(const RoomIdentifier& room_identifier,
59 const DoorInfo& door_info) { 97 const RoomInfo& room_info) const {
60 if (door_info.definitions.empty()) { 98 if (room_info.definitions.empty()) {
61 std::cout << "Door " << door_identifier.ShortDebugString() 99 std::cout << "Room " << room_identifier.ShortDebugString()
62 << " has no definition, but was referenced:" << std::endl; 100 << " has no definition, but was referenced:" << std::endl;
63 101
64 for (const DoorIdentifier& other_door_identifier : 102 for (const DoorIdentifier& door_identifier :
65 door_info.doors_referenced_by) { 103 room_info.doors_referenced_by) {
66 std::cout << " DOOR " << other_door_identifier.ShortDebugString() 104 std::cout << " DOOR " << door_identifier.ShortDebugString()
67 << std::endl; 105 << std::endl;
106 }
107
108 for (const PanelIdentifier& panel_identifier :
109 room_info.panels_referenced_by) {
110 std::cout << " PANEL " << panel_identifier.ShortDebugString()
111 << std::endl;
112 }
113
114 for (const HumanConnection& connection :
115 room_info.connections_referenced_by) {
116 std::cout << " CONNECTION " << connection.ShortDebugString()
117 << std::endl;
118 }
119
120 for (const std::string& map_name : room_info.map_rtes_referenced_by) {
121 std::cout << " MAP RTE " << map_name << std::endl;
122 }
123 } else if (room_info.definitions.size() > 1) {
124 std::cout << "Room " << room_identifier.ShortDebugString()
125 << " was defined multiple times." << std::endl;
68 } 126 }
127 }
69 128
70 for (const PanelIdentifier& panel_identifier : 129 bool DoesDoorNeedLocationName(const HumanDoor& h_door,
71 door_info.panels_referenced_by) { 130 const std::string& map_name) const {
72 std::cout << " PANEL " << panel_identifier.ShortDebugString() 131 if (h_door.type() != DoorType::STANDARD) {
73 << std::endl; 132 return false;
74 } 133 }
75 134
76 for (const PaintingIdentifier& painting_identifier : 135 if (h_door.keyholders_size() > 0 || h_door.white_ending() ||
77 door_info.paintings_referenced_by) { 136 h_door.complete_at() > 0) {
78 std::cout << " PAINTING " << painting_identifier.ShortDebugString() 137 return true;
79 << std::endl;
80 } 138 }
81 139
82 for (const PortIdentifier& port_identifier : 140 if (h_door.panels_size() > 4) {
83 door_info.ports_referenced_by) { 141 return true;
84 std::cout << " PORT " << port_identifier.ShortDebugString()
85 << std::endl;
86 } 142 }
87 143
88 for (const HumanConnection& connection : 144 std::set<std::string> map_areas;
89 door_info.connections_referenced_by) { 145 for (const PanelIdentifier& pi : h_door.panels()) {
90 std::cout << " CONNECTION " << connection.ShortDebugString() 146 auto full_pi =
91 << std::endl; 147 GetCompletePanelIdentifierWithoutAnswer(pi, map_name, std::nullopt);
148 if (full_pi) {
149 auto panel_info_it = info_.panels.find(*full_pi);
150 if (panel_info_it != info_.panels.end()) {
151 const PanelInfo& panel_info = panel_info_it->second;
152
153 map_areas.insert(panel_info.map_area_name);
154 }
155 }
92 } 156 }
93 } else if (door_info.definitions.size() > 1) { 157
94 std::cout << "Door " << door_identifier.ShortDebugString() 158 if (map_areas.size() > 1) {
95 << " was defined multiple times." << std::endl; 159 return true;
160 }
161
162 return false;
96 } 163 }
97 164
98 if (door_info.malformed_identifiers.HasAny()) { 165 void ValidateDoor(const DoorIdentifier& door_identifier,
99 std::cout << "Door " << door_identifier.ShortDebugString() 166 const DoorInfo& door_info) const {
100 << " has malformed identifiers:" << std::endl; 167 if (door_info.definitions.empty()) {
168 std::cout << "Door " << door_identifier.ShortDebugString()
169 << " has no definition, but was referenced:" << std::endl;
101 170
102 for (const PaintingIdentifier& painting_identifier : 171 for (const DoorIdentifier& other_door_identifier :
103 door_info.malformed_identifiers.paintings) { 172 door_info.doors_referenced_by) {
104 std::cout << " PAINTING " << painting_identifier.ShortDebugString() 173 std::cout << " DOOR " << other_door_identifier.ShortDebugString()
105 << std::endl; 174 << std::endl;
106 } 175 }
107 176
108 for (const PanelIdentifier& panel_identifier : 177 for (const PanelIdentifier& panel_identifier :
109 door_info.malformed_identifiers.panels) { 178 door_info.panels_referenced_by) {
110 std::cout << " PANEL " << panel_identifier.ShortDebugString() 179 std::cout << " PANEL " << panel_identifier.ShortDebugString()
111 << std::endl; 180 << std::endl;
181 }
182
183 for (const PaintingIdentifier& painting_identifier :
184 door_info.paintings_referenced_by) {
185 std::cout << " PAINTING " << painting_identifier.ShortDebugString()
186 << std::endl;
187 }
188
189 for (const PortIdentifier& port_identifier :
190 door_info.ports_referenced_by) {
191 std::cout << " PORT " << port_identifier.ShortDebugString()
192 << std::endl;
193 }
194
195 for (const HumanConnection& connection :
196 door_info.connections_referenced_by) {
197 std::cout << " CONNECTION " << connection.ShortDebugString()
198 << std::endl;
199 }
200
201 for (const std::string& prog_name :
202 door_info.progressives_referenced_by) {
203 std::cout << " PROGRESSIVE " << prog_name << std::endl;
204 }
205
206 for (const std::string& group_name :
207 door_info.door_groups_referenced_by) {
208 std::cout << " DOOR GROUP " << group_name << std::endl;
209 }
210
211 if (door_info.has_id) {
212 std::cout << " An AP ID is present." << std::endl;
213 }
214 } else if (door_info.definitions.size() > 1) {
215 std::cout << "Door " << door_identifier.ShortDebugString()
216 << " was defined multiple times." << std::endl;
112 } 217 }
113 218
114 for (const KeyholderIdentifier& keyholder_identifier : 219 if (door_info.malformed_identifiers.HasAny()) {
115 door_info.malformed_identifiers.keyholders) { 220 std::cout << "Door " << door_identifier.ShortDebugString()
116 std::cout << " KEYHOLDER " << keyholder_identifier.ShortDebugString() 221 << " has malformed identifiers:" << std::endl;
117 << std::endl; 222
223 for (const PaintingIdentifier& painting_identifier :
224 door_info.malformed_identifiers.paintings) {
225 std::cout << " PAINTING " << painting_identifier.ShortDebugString()
226 << std::endl;
227 }
228
229 for (const PanelIdentifier& panel_identifier :
230 door_info.malformed_identifiers.panels) {
231 std::cout << " PANEL " << panel_identifier.ShortDebugString()
232 << std::endl;
233 }
234
235 for (const KeyholderIdentifier& keyholder_identifier :
236 door_info.malformed_identifiers.keyholders) {
237 std::cout << " KEYHOLDER " << keyholder_identifier.ShortDebugString()
238 << std::endl;
239 }
118 } 240 }
119 }
120}
121 241
122void ValidatePort(const PortIdentifier& port_identifier, 242 for (const HumanDoor& h_door : door_info.definitions) {
123 const PortInfo& port_info) { 243 if (DoesDoorNeedLocationName(h_door, door_identifier.map()) &&
124 if (port_info.definitions.empty()) { 244 !h_door.has_location_name()) {
125 std::cout << "Port " << port_identifier.ShortDebugString() 245 std::cout << "Door " << door_identifier.ShortDebugString()
126 << " has no definition, but was referenced:" << std::endl; 246 << " needs an explicit location name." << std::endl;
247 }
127 248
128 for (const HumanConnection& connection : 249 if (h_door.type() == DoorType::STANDARD ||
129 port_info.connections_referenced_by) { 250 h_door.type() == DoorType::LOCATION_ONLY ||
130 std::cout << " CONNECTION " << connection.ShortDebugString() 251 h_door.type() == DoorType::GRAVESTONE || h_door.legacy_location()) {
131 << std::endl; 252 if (h_door.double_letters()) {
253 std::cout << "Door " << door_identifier.ShortDebugString()
254 << " is a location that depends on double_letters."
255 << std::endl;
256 }
257
258 if (!h_door.has_location_room()) {
259 std::cout << "Door " << door_identifier.ShortDebugString()
260 << " is missing a location_room." << std::endl;
261 }
262 }
263
264 bool needs_id = (h_door.type() != DoorType::EVENT || h_door.latch() ||
265 h_door.legacy_location());
266 if (door_info.has_id != needs_id) {
267 if (needs_id) {
268 std::cout << "Door " << door_identifier.ShortDebugString()
269 << " is missing an AP ID." << std::endl;
270 } else {
271 std::cout << "Door " << door_identifier.ShortDebugString()
272 << " should not have an AP ID." << std::endl;
273 }
274 }
132 } 275 }
133 } else if (port_info.definitions.size() > 1) {
134 std::cout << "Port " << port_identifier.ShortDebugString()
135 << " was defined multiple times." << std::endl;
136 } 276 }
137}
138 277
139void ValidatePainting(const PaintingIdentifier& painting_identifier, 278 void ValidatePort(const PortIdentifier& port_identifier,
140 const PaintingInfo& painting_info) { 279 const PortInfo& port_info) const {
141 if (painting_info.definitions.empty()) { 280 if (port_info.definitions.empty()) {
142 std::cout << "Painting " << painting_identifier.ShortDebugString() 281 std::cout << "Port " << port_identifier.ShortDebugString()
143 << " has no definition, but was referenced:" << std::endl; 282 << " has no definition, but was referenced:" << std::endl;
144 283
145 for (const DoorIdentifier& door_identifier : 284 for (const HumanConnection& connection :
146 painting_info.doors_referenced_by) { 285 port_info.connections_referenced_by) {
147 std::cout << " DOOR " << door_identifier.ShortDebugString() 286 std::cout << " CONNECTION " << connection.ShortDebugString()
148 << std::endl; 287 << std::endl;
288 }
289
290 for (const std::string& map_name : port_info.map_worldport_entrances) {
291 std::cout << " MAP (worldport_entrance) " << map_name << std::endl;
292 }
293
294 if (port_info.has_id) {
295 std::cout << " An AP ID is present." << std::endl;
296 }
297 } else if (port_info.definitions.size() > 1) {
298 std::cout << "Port " << port_identifier.ShortDebugString()
299 << " was defined multiple times." << std::endl;
149 } 300 }
150 301
151 for (const HumanConnection& connection : 302 if (!port_info.target_connections_referenced_by.empty()) {
152 painting_info.connections_referenced_by) { 303 for (const HumanPort& port : port_info.definitions) {
153 std::cout << " CONNECTION " << connection.ShortDebugString() 304 if (port.has_required_door()) {
154 << std::endl; 305 std::cout << "Port " << port_identifier.ShortDebugString()
306 << " has a required door but is the target of a connection:"
307 << std::endl;
308
309 for (const HumanConnection& connection :
310 port_info.target_connections_referenced_by) {
311 std::cout << " CONNECTION " << connection.ShortDebugString()
312 << std::endl;
313 }
314 }
315 }
155 } 316 }
156 } else if (painting_info.definitions.size() > 1) {
157 std::cout << "Painting " << painting_identifier.ShortDebugString()
158 << " was defined multiple times." << std::endl;
159 }
160}
161 317
162void ValidatePanel(const PanelIdentifier& panel_identifier, 318 for (const HumanPort& port : port_info.definitions) {
163 const PanelInfo& panel_info) { 319 if (!port.no_shuffle()) {
164 if (panel_identifier.name().empty()) { 320 if (!port.has_destination()) {
165 std::cout << "Panel " << panel_identifier.ShortDebugString() 321 std::cout << "Port " << port_identifier.ShortDebugString()
166 << " has no name." << std::endl; 322 << " is shuffleable and missing a destination."
323 << std::endl;
324 }
325 if (!port.has_rotation()) {
326 std::cout << "Port " << port_identifier.ShortDebugString()
327 << " is shuffleable and missing a rotation." << std::endl;
328 }
329 if (!port_info.has_id) {
330 std::cout << "Port " << port_identifier.ShortDebugString()
331 << " is missing an AP ID." << std::endl;
332 }
333 } else {
334 if (port_info.has_id) {
335 std::cout << "Port " << port_identifier.ShortDebugString()
336 << " should not have an AP ID." << std::endl;
337 }
338 }
339 }
167 } 340 }
168 341
169 if (panel_info.definitions.empty()) { 342 void ValidatePainting(const PaintingIdentifier& painting_identifier,
170 std::cout << "Panel " << panel_identifier.ShortDebugString() 343 const PaintingInfo& painting_info) const {
171 << " has no definition, but was referenced:" << std::endl; 344 if (painting_info.definitions.empty()) {
345 std::cout << "Painting " << painting_identifier.ShortDebugString()
346 << " has no definition, but was referenced:" << std::endl;
172 347
173 for (const DoorIdentifier& door_identifier : 348 for (const DoorIdentifier& door_identifier :
174 panel_info.doors_referenced_by) { 349 painting_info.doors_referenced_by) {
175 std::cout << " DOOR " << door_identifier.ShortDebugString() 350 std::cout << " DOOR " << door_identifier.ShortDebugString()
176 << std::endl; 351 << std::endl;
352 }
353
354 for (const HumanConnection& connection :
355 painting_info.connections_referenced_by) {
356 std::cout << " CONNECTION " << connection.ShortDebugString()
357 << std::endl;
358 }
359 } else if (painting_info.definitions.size() > 1) {
360 std::cout << "Painting " << painting_identifier.ShortDebugString()
361 << " was defined multiple times." << std::endl;
177 } 362 }
178 363
179 for (const HumanConnection& connection : 364 if (!painting_info.target_connections_referenced_by.empty()) {
180 panel_info.connections_referenced_by) { 365 for (const HumanPainting& painting : painting_info.definitions) {
181 std::cout << " CONNECTION " << connection.ShortDebugString() 366 if (painting.has_required_door()) {
182 << std::endl; 367 std::cout << "Painting " << painting_identifier.ShortDebugString()
368 << " has a required door but is the target of a connection:"
369 << std::endl;
370
371 for (const HumanConnection& connection :
372 painting_info.target_connections_referenced_by) {
373 std::cout << " CONNECTION " << connection.ShortDebugString()
374 << std::endl;
375 }
376 }
377 }
183 } 378 }
184 } else if (panel_info.definitions.size() > 1) {
185 std::cout << "Panel " << panel_identifier.ShortDebugString()
186 << " was defined multiple times." << std::endl;
187 } 379 }
188 380
189 for (const auto& [answer, proxy_info] : panel_info.proxies) { 381 void ValidatePanel(const PanelIdentifier& panel_identifier,
190 if (proxy_info.definitions.empty()) { 382 const PanelInfo& panel_info) const {
383 if (panel_identifier.name().empty()) {
191 std::cout << "Panel " << panel_identifier.ShortDebugString() 384 std::cout << "Panel " << panel_identifier.ShortDebugString()
192 << " with answer \"" << answer 385 << " has no name." << std::endl;
193 << "\" has no definition, but was referenced:" << std::endl; 386 }
387
388 if (panel_info.definitions.empty()) {
389 std::cout << "Panel " << panel_identifier.ShortDebugString()
390 << " has no definition, but was referenced:" << std::endl;
194 391
195 for (const DoorIdentifier& door_identifier : 392 for (const DoorIdentifier& door_identifier :
196 proxy_info.doors_referenced_by) { 393 panel_info.doors_referenced_by) {
197 std::cout << " DOOR " << door_identifier.ShortDebugString() 394 std::cout << " DOOR " << door_identifier.ShortDebugString()
198 << std::endl; 395 << std::endl;
199 } 396 }
200 397
201 for (const HumanConnection& connection : 398 for (const HumanConnection& connection :
202 proxy_info.connections_referenced_by) { 399 panel_info.connections_referenced_by) {
203 std::cout << " CONNECTION " << connection.ShortDebugString() 400 std::cout << " CONNECTION " << connection.ShortDebugString()
204 << std::endl; 401 << std::endl;
205 } 402 }
206 } else if (proxy_info.definitions.size() > 1) { 403
404 if (panel_info.has_id) {
405 std::cout << " An AP ID is present." << std::endl;
406 }
407 } else if (panel_info.definitions.size() > 1) {
408 std::cout << "Panel " << panel_identifier.ShortDebugString()
409 << " was defined multiple times." << std::endl;
410 }
411
412 for (const auto& [answer, proxy_info] : panel_info.proxies) {
413 if (proxy_info.definitions.empty()) {
414 std::cout << "Panel " << panel_identifier.ShortDebugString()
415 << " with answer \"" << answer
416 << "\" has no definition, but was referenced:" << std::endl;
417
418 for (const DoorIdentifier& door_identifier :
419 proxy_info.doors_referenced_by) {
420 std::cout << " DOOR " << door_identifier.ShortDebugString()
421 << std::endl;
422 }
423
424 for (const HumanConnection& connection :
425 proxy_info.connections_referenced_by) {
426 std::cout << " CONNECTION " << connection.ShortDebugString()
427 << std::endl;
428 }
429 } else if (proxy_info.definitions.size() > 1) {
430 std::cout << "Panel " << panel_identifier.ShortDebugString()
431 << " with answer \"" << answer
432 << "\" was defined multiple times." << std::endl;
433 }
434 }
435
436 if (!panel_info.has_id) {
207 std::cout << "Panel " << panel_identifier.ShortDebugString() 437 std::cout << "Panel " << panel_identifier.ShortDebugString()
208 << " with answer \"" << answer 438 << " is missing an AP ID." << std::endl;
209 << "\" was defined multiple times." << std::endl; 439 }
440
441 if (!panel_info.target_connections_referenced_by.empty()) {
442 for (const HumanPanel& panel : panel_info.definitions) {
443 if (panel.has_required_door()) {
444 std::cout << "Panel " << panel_identifier.ShortDebugString()
445 << " has a required door but is the target of a connection:"
446 << std::endl;
447
448 for (const HumanConnection& connection :
449 panel_info.target_connections_referenced_by) {
450 std::cout << " CONNECTION " << connection.ShortDebugString()
451 << std::endl;
452 }
453 }
454 }
210 } 455 }
211 } 456 }
212}
213 457
214void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, 458 void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier,
215 const KeyholderInfo& keyholder_info) { 459 const KeyholderInfo& keyholder_info) const {
216 if (keyholder_info.definitions.empty()) { 460 if (keyholder_info.definitions.empty()) {
217 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() 461 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
218 << " has no definition, but was referenced:" << std::endl; 462 << " has no definition, but was referenced:" << std::endl;
463
464 for (const DoorIdentifier& door_identifier :
465 keyholder_info.doors_referenced_by) {
466 std::cout << " DOOR " << door_identifier.ShortDebugString()
467 << std::endl;
468 }
469
470 if (keyholder_info.has_id) {
471 std::cout << " An AP ID is present." << std::endl;
472 }
473 } else if (keyholder_info.definitions.size() > 1) {
474 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
475 << " was defined multiple times." << std::endl;
476 }
219 477
220 for (const DoorIdentifier& door_identifier : 478 for (const HumanKeyholder& h_keyholder : keyholder_info.definitions) {
221 keyholder_info.doors_referenced_by) { 479 bool needs_id = (h_keyholder.has_key());
222 std::cout << " DOOR " << door_identifier.ShortDebugString() 480
481 if (needs_id != keyholder_info.has_id) {
482 if (needs_id) {
483 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
484 << " is missing an AP ID." << std::endl;
485 } else {
486 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
487 << " should not have an AP ID." << std::endl;
488 }
489 }
490 }
491 }
492
493 void ValidateLetter(const LetterIdentifier& letter_identifier,
494 const LetterInfo& letter_info) const {
495 std::string letter_name = std::string(1, std::get<0>(letter_identifier)) +
496 (std::get<1>(letter_identifier) ? "2" : "1");
497
498 if (letter_info.defined_in.empty()) {
499 std::cout << "Letter " << letter_name
500 << " has no definition, but was referenced:" << std::endl;
501
502 if (letter_info.has_id) {
503 std::cout << " An AP ID is present." << std::endl;
504 }
505 } else if (letter_info.defined_in.size() > 1) {
506 std::cout << "Letter " << letter_name
507 << " was defined in multiple places:" << std::endl;
508
509 for (const RoomIdentifier& room_identifier : letter_info.defined_in) {
510 std::cout << " " << room_identifier.ShortDebugString() << std::endl;
511 }
512 }
513
514 if (!letter_info.has_id) {
515 std::cout << "Letter " << letter_name << " is missing an AP ID."
223 << std::endl; 516 << std::endl;
224 } 517 }
225 } else if (keyholder_info.definitions.size() > 1) {
226 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
227 << " was defined multiple times." << std::endl;
228 } 518 }
229}
230 519
231void ValidateLetter(const LetterIdentifier& letter_identifier, 520 void ValidateEnding(const std::string& ending_name,
232 const LetterInfo& letter_info) { 521 const EndingInfo& ending_info) const {
233 std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + 522 if (ending_info.defined_in.empty()) {
234 (std::get<1>(letter_identifier) ? "2" : "1"); 523 std::cout << "Ending " << ending_name
524 << " has no definition, but was referenced:" << std::endl;
235 525
236 if (letter_info.defined_in.size() > 1) { 526 if (ending_info.has_id) {
237 std::cout << "Letter " << letter_name 527 std::cout << " An AP ID is present." << std::endl;
238 << " was defined in multiple places:" << std::endl; 528 }
529 } else if (ending_info.defined_in.size() > 1) {
530 std::cout << "Ending " << ending_name
531 << " was defined in multiple places:" << std::endl;
532
533 for (const RoomIdentifier& room_identifier : ending_info.defined_in) {
534 std::cout << " " << room_identifier.ShortDebugString() << std::endl;
535 }
536 }
239 537
240 for (const RoomIdentifier& room_identifier : letter_info.defined_in) { 538 if (!ending_info.has_id) {
241 std::cout << " " << room_identifier.ShortDebugString() << std::endl; 539 std::cout << "Ending " << ending_name << " is missing an AP ID."
540 << std::endl;
242 } 541 }
243 } 542 }
244}
245 543
246void ValidateEnding(const std::string& ending_name, 544 void ValidatePanelName(const std::string& panel_name,
247 const EndingInfo& ending_info) { 545 const PanelNameInfo& panel_info) const {
248 if (ending_info.defined_in.empty()) { 546 if (panel_info.panels_used_by.size() > 1) {
249 std::cout << "Ending " << ending_name 547 std::cout << "The location name \"" << panel_name
250 << " has no definition, but was referenced:" << std::endl; 548 << "\" is used by multiple panels:" << std::endl;
549
550 for (const PanelIdentifier& panel_identifier :
551 panel_info.panels_used_by) {
552 std::cout << " PANEL " << panel_identifier.ShortDebugString()
553 << std::endl;
554 }
555 }
556 }
557
558 void ValidateProgressive(const std::string& prog_name,
559 const ProgressiveInfo& prog_info) const {
560 if (prog_info.definitions.empty()) {
561 std::cout << "Progressive \"" << prog_name
562 << "\" has no definition, but was referenced:" << std::endl;
563
564 if (prog_info.has_id) {
565 std::cout << " An AP ID is present." << std::endl;
566 }
567 } else if (prog_info.definitions.size() > 1) {
568 std::cout << "Progressive \"" << prog_name
569 << "\" has multiple definitions." << std::endl;
570 }
251 571
252 for (const DoorIdentifier& door_identifier : 572 if (!prog_info.has_id) {
253 ending_info.doors_referenced_by) { 573 std::cout << "Progressive \"" << prog_name << "\" is missing an AP ID."
254 std::cout << " DOOR " << door_identifier.ShortDebugString()
255 << std::endl; 574 << std::endl;
256 } 575 }
257 } else if (ending_info.defined_in.size() > 1) { 576 }
258 std::cout << "Ending " << ending_name 577
259 << " was defined in multiple places:" << std::endl; 578 void ValidateDoorGroup(const std::string& group_name,
579 const DoorGroupInfo& group_info) const {
580 if (group_info.definitions.empty()) {
581 std::cout << "Door group \"" << group_name
582 << "\" has no definition, but was referenced:" << std::endl;
583
584 if (group_info.has_id) {
585 std::cout << " An AP ID is present." << std::endl;
586 }
587 } else if (group_info.definitions.size() > 1) {
588 std::cout << "Door group \"" << group_name
589 << "\" has multiple definitions." << std::endl;
590 }
260 591
261 for (const RoomIdentifier& room_identifier : ending_info.defined_in) { 592 if (!group_info.has_id) {
262 std::cout << " " << room_identifier.ShortDebugString() << std::endl; 593 std::cout << "Door group \"" << group_name << "\" is missing an AP ID."
594 << std::endl;
263 } 595 }
264 } 596 }
265} 597
598 const CollectedInfo& info_;
599};
266 600
267} // namespace 601} // namespace
268 602
269void ValidateCollectedInfo(const CollectedInfo& info) { 603void ValidateCollectedInfo(const CollectedInfo& info) {
270 for (const auto& [map_name, map_info] : info.maps) { 604 Validator validator(info);
271 ValidateMap(map_name, map_info); 605 validator.Validate();
272 }
273 for (const auto& [room_identifier, room_info] : info.rooms) {
274 ValidateRoom(room_identifier, room_info);
275 }
276 for (const auto& [door_identifier, door_info] : info.doors) {
277 ValidateDoor(door_identifier, door_info);
278 }
279 for (const auto& [port_identifier, port_info] : info.ports) {
280 ValidatePort(port_identifier, port_info);
281 }
282 for (const auto& [painting_identifier, painting_info] : info.paintings) {
283 ValidatePainting(painting_identifier, painting_info);
284 }
285 for (const auto& [panel_identifier, panel_info] : info.panels) {
286 ValidatePanel(panel_identifier, panel_info);
287 }
288 for (const auto& [keyholder_identifier, keyholder_info] : info.keyholders) {
289 ValidateKeyholder(keyholder_identifier, keyholder_info);
290 }
291 for (const auto& [letter_identifier, letter_info] : info.letters) {
292 ValidateLetter(letter_identifier, letter_info);
293 }
294 for (const auto& [ending_name, ending_info] : info.endings) {
295 ValidateEnding(ending_name, ending_info);
296 }
297} 606}
298 607
299} // namespace com::fourisland::lingo2_archipelago 608} // namespace com::fourisland::lingo2_archipelago
diff --git a/tools/validator/validator.h b/tools/validator/validator.h index b710429..33bc7c9 100644 --- a/tools/validator/validator.h +++ b/tools/validator/validator.h
@@ -1,4 +1,4 @@
1#ifndef TOOLS_VALIDATOR_VALIDATOR_H_ 1#ifndef TOOLS_VALIDATOR_VALIDATOR_H
2#define TOOLS_VALIDATOR_VALIDATOR_H 2#define TOOLS_VALIDATOR_VALIDATOR_H
3 3
4namespace com::fourisland::lingo2_archipelago { 4namespace com::fourisland::lingo2_archipelago {