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