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/human_processor.cpp199
-rw-r--r--tools/validator/main.cpp4
-rw-r--r--tools/validator/structs.h36
-rw-r--r--tools/validator/validator.cpp247
-rw-r--r--tools/validator/validator.h2
5 files changed, 467 insertions, 21 deletions
diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index 0f63936..d6fcfa6 100644 --- a/tools/validator/human_processor.cpp +++ b/tools/validator/human_processor.cpp
@@ -13,6 +13,7 @@
13#include <string> 13#include <string>
14 14
15#include "structs.h" 15#include "structs.h"
16#include "util/ids_yaml_format.h"
16 17
17namespace com::fourisland::lingo2_archipelago { 18namespace com::fourisland::lingo2_archipelago {
18namespace { 19namespace {
@@ -41,7 +42,9 @@ class HumanProcessor {
41 42
42 ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); 43 ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt);
43 ProcessMaps(datadir_path); 44 ProcessMaps(datadir_path);
44 ProcessIdsFile(datadir_path / "ids.txtpb"); 45 ProcessProgressivesFile(datadir_path / "progressives.txtpb");
46 ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb");
47 ProcessIdsFile(datadir_path / "ids.yaml");
45 } 48 }
46 49
47 private: 50 private:
@@ -71,9 +74,35 @@ class HumanProcessor {
71 MapInfo& map_info = info_.maps[current_map_name]; 74 MapInfo& map_info = info_.maps[current_map_name];
72 75
73 auto metadata = ReadMessageFromFile<HumanMap>(path.string()); 76 auto metadata = ReadMessageFromFile<HumanMap>(path.string());
77 map_info.definitions.push_back(metadata);
78
74 for (const std::string& path : metadata.excluded_nodes()) { 79 for (const std::string& path : metadata.excluded_nodes()) {
75 map_info.game_nodes[path].uses++; 80 map_info.game_nodes[path].uses++;
76 } 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 }
77 } 106 }
78 107
79 void ProcessRooms(std::filesystem::path path, 108 void ProcessRooms(std::filesystem::path path,
@@ -355,11 +384,6 @@ class HumanProcessor {
355 DoorInfo& other_door_info = info_.doors[complete_door_identifier]; 384 DoorInfo& other_door_info = info_.doors[complete_door_identifier];
356 other_door_info.doors_referenced_by.push_back(door_identifier); 385 other_door_info.doors_referenced_by.push_back(door_identifier);
357 } 386 }
358
359 for (const std::string& ei : h_door.endings()) {
360 EndingInfo& ending_info = info_.endings[ei];
361 ending_info.doors_referenced_by.push_back(door_identifier);
362 }
363 } 387 }
364 388
365 void ProcessConnectionsFile(std::filesystem::path path, 389 void ProcessConnectionsFile(std::filesystem::path path,
@@ -391,7 +415,9 @@ class HumanProcessor {
391 } 415 }
392 } else if (human_connection.has_from()) { 416 } else if (human_connection.has_from()) {
393 ProcessSingleConnection(human_connection, human_connection.from(), 417 ProcessSingleConnection(human_connection, human_connection.from(),
394 current_map_name); 418 current_map_name,
419 /*is_target=*/!human_connection.oneway() &&
420 !human_connection.bypass_target_door());
395 } 421 }
396 422
397 if (human_connection.has_to_room()) { 423 if (human_connection.has_to_room()) {
@@ -407,8 +433,9 @@ class HumanProcessor {
407 std::cout << "A global connection used to_room." << std::endl; 433 std::cout << "A global connection used to_room." << std::endl;
408 } 434 }
409 } else if (human_connection.has_to()) { 435 } else if (human_connection.has_to()) {
410 ProcessSingleConnection(human_connection, human_connection.to(), 436 ProcessSingleConnection(
411 current_map_name); 437 human_connection, human_connection.to(), current_map_name,
438 /*is_target=*/!human_connection.bypass_target_door());
412 } 439 }
413 440
414 if (human_connection.has_door()) { 441 if (human_connection.has_door()) {
@@ -429,7 +456,7 @@ class HumanProcessor {
429 void ProcessSingleConnection( 456 void ProcessSingleConnection(
430 const HumanConnection& human_connection, 457 const HumanConnection& human_connection,
431 const HumanConnection::Endpoint& endpoint, 458 const HumanConnection::Endpoint& endpoint,
432 const std::optional<std::string>& current_map_name) { 459 const std::optional<std::string>& current_map_name, bool is_target) {
433 if (endpoint.has_room()) { 460 if (endpoint.has_room()) {
434 auto room_identifier = 461 auto room_identifier =
435 GetCompleteRoomIdentifier(endpoint.room(), current_map_name); 462 GetCompleteRoomIdentifier(endpoint.room(), current_map_name);
@@ -448,6 +475,11 @@ class HumanProcessor {
448 if (painting_identifier) { 475 if (painting_identifier) {
449 PaintingInfo& painting_info = info_.paintings[*painting_identifier]; 476 PaintingInfo& painting_info = info_.paintings[*painting_identifier];
450 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 }
451 } else { 483 } else {
452 // Not sure where else to store this right now. 484 // Not sure where else to store this right now.
453 std::cout 485 std::cout
@@ -460,6 +492,11 @@ class HumanProcessor {
460 if (port_identifier) { 492 if (port_identifier) {
461 PortInfo& port_info = info_.ports[*port_identifier]; 493 PortInfo& port_info = info_.ports[*port_identifier];
462 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 }
463 } else { 500 } else {
464 // Not sure where else to store this right now. 501 // Not sure where else to store this right now.
465 std::cout 502 std::cout
@@ -477,12 +514,152 @@ class HumanProcessor {
477 panel_info.proxies[endpoint.panel().answer()] 514 panel_info.proxies[endpoint.panel().answer()]
478 .connections_referenced_by.push_back(human_connection); 515 .connections_referenced_by.push_back(human_connection);
479 } 516 }
517
518 if (is_target) {
519 panel_info.target_connections_referenced_by.push_back(
520 human_connection);
521 }
522 }
523 }
524 }
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;
480 } 573 }
574
575 DoorInfo& door_info = info_.doors[di];
576 door_info.door_groups_referenced_by.push_back(h_group.name());
481 } 577 }
482 } 578 }
483 579
484 void ProcessIdsFile(std::filesystem::path path) { 580 void ProcessIdsFile(std::filesystem::path path) {
485 // 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 }
486 } 663 }
487 664
488 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 0ca96fe..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,10 +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;
74 88
75 std::string map_area_name; 89 std::string map_area_name;
76 90
77 std::vector<HumanConnection> connections_referenced_by; 91 std::vector<HumanConnection> connections_referenced_by;
92 std::vector<HumanConnection> target_connections_referenced_by;
78 std::vector<DoorIdentifier> doors_referenced_by; 93 std::vector<DoorIdentifier> doors_referenced_by;
79 94
80 std::map<std::string, ProxyInfo> proxies; 95 std::map<std::string, ProxyInfo> proxies;
@@ -82,6 +97,7 @@ struct PanelInfo {
82 97
83struct KeyholderInfo { 98struct KeyholderInfo {
84 std::vector<HumanKeyholder> definitions; 99 std::vector<HumanKeyholder> definitions;
100 bool has_id = false;
85 101
86 std::vector<DoorIdentifier> doors_referenced_by; 102 std::vector<DoorIdentifier> doors_referenced_by;
87}; 103};
@@ -90,18 +106,32 @@ using LetterIdentifier = std::tuple<char, bool>;
90 106
91struct LetterInfo { 107struct LetterInfo {
92 std::vector<RoomIdentifier> defined_in; 108 std::vector<RoomIdentifier> defined_in;
109 bool has_id = false;
93}; 110};
94 111
95struct EndingInfo { 112struct EndingInfo {
96 std::vector<RoomIdentifier> defined_in; 113 std::vector<RoomIdentifier> defined_in;
97 114 bool has_id = false;
98 std::vector<DoorIdentifier> doors_referenced_by;
99}; 115};
100 116
101struct PanelNameInfo { 117struct PanelNameInfo {
102 std::vector<PanelIdentifier> panels_used_by; 118 std::vector<PanelIdentifier> panels_used_by;
103}; 119};
104 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;
133};
134
105struct CollectedInfo { 135struct CollectedInfo {
106 std::map<std::string, MapInfo> maps; 136 std::map<std::string, MapInfo> maps;
107 std::map<RoomIdentifier, RoomInfo, RoomIdentifierLess> rooms; 137 std::map<RoomIdentifier, RoomInfo, RoomIdentifierLess> rooms;
@@ -114,6 +144,8 @@ struct CollectedInfo {
114 std::map<LetterIdentifier, LetterInfo> letters; 144 std::map<LetterIdentifier, LetterInfo> letters;
115 std::map<std::string, EndingInfo> endings; 145 std::map<std::string, EndingInfo> endings;
116 std::map<std::string, PanelNameInfo> panel_names; 146 std::map<std::string, PanelNameInfo> panel_names;
147 std::map<std::string, ProgressiveInfo> progressives;
148 std::map<std::string, DoorGroupInfo> door_groups;
117}; 149};
118 150
119} // namespace com::fourisland::lingo2_archipelago 151} // namespace com::fourisland::lingo2_archipelago
diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index f5524c3..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"
@@ -45,6 +46,12 @@ class Validator {
45 for (const auto& [panel_name, panel_info] : info_.panel_names) { 46 for (const auto& [panel_name, panel_info] : info_.panel_names) {
46 ValidatePanelName(panel_name, panel_info); 47 ValidatePanelName(panel_name, panel_info);
47 } 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);
54 }
48 } 55 }
49 56
50 private: 57 private:
@@ -63,6 +70,27 @@ class Validator {
63 << " is not defined in the game file." << std::endl; 70 << " is not defined in the game file." << std::endl;
64 } 71 }
65 } 72 }
73
74 if (map_info.malformed_worldport_entrance) {
75 std::cout << "The worldport entrance for map " << map_name
76 << " is malformed." << std::endl;
77 }
78
79 if (map_info.has_rte_id) {
80 if (!std::any_of(
81 map_info.definitions.begin(), map_info.definitions.end(),
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 }
93 }
66 } 94 }
67 95
68 void ValidateRoom(const RoomIdentifier& room_identifier, 96 void ValidateRoom(const RoomIdentifier& room_identifier,
@@ -88,6 +116,10 @@ class Validator {
88 std::cout << " CONNECTION " << connection.ShortDebugString() 116 std::cout << " CONNECTION " << connection.ShortDebugString()
89 << std::endl; 117 << std::endl;
90 } 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 }
91 } else if (room_info.definitions.size() > 1) { 123 } else if (room_info.definitions.size() > 1) {
92 std::cout << "Room " << room_identifier.ShortDebugString() 124 std::cout << "Room " << room_identifier.ShortDebugString()
93 << " was defined multiple times." << std::endl; 125 << " was defined multiple times." << std::endl;
@@ -100,7 +132,8 @@ class Validator {
100 return false; 132 return false;
101 } 133 }
102 134
103 if (h_door.keyholders_size() > 0 || h_door.endings_size() > 0) { 135 if (h_door.keyholders_size() > 0 || h_door.white_ending() ||
136 h_door.complete_at() > 0) {
104 return true; 137 return true;
105 } 138 }
106 139
@@ -164,6 +197,20 @@ class Validator {
164 std::cout << " CONNECTION " << connection.ShortDebugString() 197 std::cout << " CONNECTION " << connection.ShortDebugString()
165 << std::endl; 198 << std::endl;
166 } 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 }
167 } else if (door_info.definitions.size() > 1) { 214 } else if (door_info.definitions.size() > 1) {
168 std::cout << "Door " << door_identifier.ShortDebugString() 215 std::cout << "Door " << door_identifier.ShortDebugString()
169 << " was defined multiple times." << std::endl; 216 << " was defined multiple times." << std::endl;
@@ -198,6 +245,33 @@ class Validator {
198 std::cout << "Door " << door_identifier.ShortDebugString() 245 std::cout << "Door " << door_identifier.ShortDebugString()
199 << " needs an explicit location name." << std::endl; 246 << " needs an explicit location name." << std::endl;
200 } 247 }
248
249 if (h_door.type() == DoorType::STANDARD ||
250 h_door.type() == DoorType::LOCATION_ONLY ||
251 h_door.type() == DoorType::GRAVESTONE || h_door.legacy_location()) {
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 }
201 } 275 }
202 } 276 }
203 277
@@ -212,10 +286,57 @@ class Validator {
212 std::cout << " CONNECTION " << connection.ShortDebugString() 286 std::cout << " CONNECTION " << connection.ShortDebugString()
213 << std::endl; 287 << std::endl;
214 } 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 }
215 } else if (port_info.definitions.size() > 1) { 297 } else if (port_info.definitions.size() > 1) {
216 std::cout << "Port " << port_identifier.ShortDebugString() 298 std::cout << "Port " << port_identifier.ShortDebugString()
217 << " was defined multiple times." << std::endl; 299 << " was defined multiple times." << std::endl;
218 } 300 }
301
302 if (!port_info.target_connections_referenced_by.empty()) {
303 for (const HumanPort& port : port_info.definitions) {
304 if (port.has_required_door()) {
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 }
316 }
317
318 for (const HumanPort& port : port_info.definitions) {
319 if (!port.no_shuffle()) {
320 if (!port.has_destination()) {
321 std::cout << "Port " << port_identifier.ShortDebugString()
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 }
219 } 340 }
220 341
221 void ValidatePainting(const PaintingIdentifier& painting_identifier, 342 void ValidatePainting(const PaintingIdentifier& painting_identifier,
@@ -239,6 +360,22 @@ class Validator {
239 std::cout << "Painting " << painting_identifier.ShortDebugString() 360 std::cout << "Painting " << painting_identifier.ShortDebugString()
240 << " was defined multiple times." << std::endl; 361 << " was defined multiple times." << std::endl;
241 } 362 }
363
364 if (!painting_info.target_connections_referenced_by.empty()) {
365 for (const HumanPainting& painting : painting_info.definitions) {
366 if (painting.has_required_door()) {
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 }
378 }
242 } 379 }
243 380
244 void ValidatePanel(const PanelIdentifier& panel_identifier, 381 void ValidatePanel(const PanelIdentifier& panel_identifier,
@@ -263,6 +400,10 @@ class Validator {
263 std::cout << " CONNECTION " << connection.ShortDebugString() 400 std::cout << " CONNECTION " << connection.ShortDebugString()
264 << std::endl; 401 << std::endl;
265 } 402 }
403
404 if (panel_info.has_id) {
405 std::cout << " An AP ID is present." << std::endl;
406 }
266 } else if (panel_info.definitions.size() > 1) { 407 } else if (panel_info.definitions.size() > 1) {
267 std::cout << "Panel " << panel_identifier.ShortDebugString() 408 std::cout << "Panel " << panel_identifier.ShortDebugString()
268 << " was defined multiple times." << std::endl; 409 << " was defined multiple times." << std::endl;
@@ -291,6 +432,27 @@ class Validator {
291 << "\" was defined multiple times." << std::endl; 432 << "\" was defined multiple times." << std::endl;
292 } 433 }
293 } 434 }
435
436 if (!panel_info.has_id) {
437 std::cout << "Panel " << panel_identifier.ShortDebugString()
438 << " is missing an AP ID." << 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 }
455 }
294 } 456 }
295 457
296 void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, 458 void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier,
@@ -304,10 +466,28 @@ class Validator {
304 std::cout << " DOOR " << door_identifier.ShortDebugString() 466 std::cout << " DOOR " << door_identifier.ShortDebugString()
305 << std::endl; 467 << std::endl;
306 } 468 }
469
470 if (keyholder_info.has_id) {
471 std::cout << " An AP ID is present." << std::endl;
472 }
307 } else if (keyholder_info.definitions.size() > 1) { 473 } else if (keyholder_info.definitions.size() > 1) {
308 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() 474 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
309 << " was defined multiple times." << std::endl; 475 << " was defined multiple times." << std::endl;
310 } 476 }
477
478 for (const HumanKeyholder& h_keyholder : keyholder_info.definitions) {
479 bool needs_id = (h_keyholder.has_key());
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 }
311 } 491 }
312 492
313 void ValidateLetter(const LetterIdentifier& letter_identifier, 493 void ValidateLetter(const LetterIdentifier& letter_identifier,
@@ -315,7 +495,14 @@ class Validator {
315 std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + 495 std::string letter_name = std::string(1, std::get<0>(letter_identifier)) +
316 (std::get<1>(letter_identifier) ? "2" : "1"); 496 (std::get<1>(letter_identifier) ? "2" : "1");
317 497
318 if (letter_info.defined_in.size() > 1) { 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) {
319 std::cout << "Letter " << letter_name 506 std::cout << "Letter " << letter_name
320 << " was defined in multiple places:" << std::endl; 507 << " was defined in multiple places:" << std::endl;
321 508
@@ -323,6 +510,11 @@ class Validator {
323 std::cout << " " << room_identifier.ShortDebugString() << std::endl; 510 std::cout << " " << room_identifier.ShortDebugString() << std::endl;
324 } 511 }
325 } 512 }
513
514 if (!letter_info.has_id) {
515 std::cout << "Letter " << letter_name << " is missing an AP ID."
516 << std::endl;
517 }
326 } 518 }
327 519
328 void ValidateEnding(const std::string& ending_name, 520 void ValidateEnding(const std::string& ending_name,
@@ -331,10 +523,8 @@ class Validator {
331 std::cout << "Ending " << ending_name 523 std::cout << "Ending " << ending_name
332 << " has no definition, but was referenced:" << std::endl; 524 << " has no definition, but was referenced:" << std::endl;
333 525
334 for (const DoorIdentifier& door_identifier : 526 if (ending_info.has_id) {
335 ending_info.doors_referenced_by) { 527 std::cout << " An AP ID is present." << std::endl;
336 std::cout << " DOOR " << door_identifier.ShortDebugString()
337 << std::endl;
338 } 528 }
339 } else if (ending_info.defined_in.size() > 1) { 529 } else if (ending_info.defined_in.size() > 1) {
340 std::cout << "Ending " << ending_name 530 std::cout << "Ending " << ending_name
@@ -344,6 +534,11 @@ class Validator {
344 std::cout << " " << room_identifier.ShortDebugString() << std::endl; 534 std::cout << " " << room_identifier.ShortDebugString() << std::endl;
345 } 535 }
346 } 536 }
537
538 if (!ending_info.has_id) {
539 std::cout << "Ending " << ending_name << " is missing an AP ID."
540 << std::endl;
541 }
347 } 542 }
348 543
349 void ValidatePanelName(const std::string& panel_name, 544 void ValidatePanelName(const std::string& panel_name,
@@ -360,6 +555,46 @@ class Validator {
360 } 555 }
361 } 556 }
362 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 }
571
572 if (!prog_info.has_id) {
573 std::cout << "Progressive \"" << prog_name << "\" is missing an AP ID."
574 << std::endl;
575 }
576 }
577
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 }
591
592 if (!group_info.has_id) {
593 std::cout << "Door group \"" << group_name << "\" is missing an AP ID."
594 << std::endl;
595 }
596 }
597
363 const CollectedInfo& info_; 598 const CollectedInfo& info_;
364}; 599};
365 600
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 {