diff options
Diffstat (limited to 'tools/validator')
| -rw-r--r-- | tools/validator/human_processor.cpp | 153 | ||||
| -rw-r--r-- | tools/validator/structs.h | 26 | ||||
| -rw-r--r-- | tools/validator/validator.cpp | 172 |
3 files changed, 343 insertions, 8 deletions
| diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index 0f63936..2c978bf 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 | ||
| 17 | namespace com::fourisland::lingo2_archipelago { | 18 | namespace com::fourisland::lingo2_archipelago { |
| 18 | namespace { | 19 | namespace { |
| @@ -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: |
| @@ -391,7 +394,9 @@ class HumanProcessor { | |||
| 391 | } | 394 | } |
| 392 | } else if (human_connection.has_from()) { | 395 | } else if (human_connection.has_from()) { |
| 393 | ProcessSingleConnection(human_connection, human_connection.from(), | 396 | ProcessSingleConnection(human_connection, human_connection.from(), |
| 394 | current_map_name); | 397 | current_map_name, |
| 398 | /*is_target=*/!human_connection.oneway() && | ||
| 399 | !human_connection.bypass_target_door()); | ||
| 395 | } | 400 | } |
| 396 | 401 | ||
| 397 | if (human_connection.has_to_room()) { | 402 | if (human_connection.has_to_room()) { |
| @@ -407,8 +412,9 @@ class HumanProcessor { | |||
| 407 | std::cout << "A global connection used to_room." << std::endl; | 412 | std::cout << "A global connection used to_room." << std::endl; |
| 408 | } | 413 | } |
| 409 | } else if (human_connection.has_to()) { | 414 | } else if (human_connection.has_to()) { |
| 410 | ProcessSingleConnection(human_connection, human_connection.to(), | 415 | ProcessSingleConnection( |
| 411 | current_map_name); | 416 | human_connection, human_connection.to(), current_map_name, |
| 417 | /*is_target=*/!human_connection.bypass_target_door()); | ||
| 412 | } | 418 | } |
| 413 | 419 | ||
| 414 | if (human_connection.has_door()) { | 420 | if (human_connection.has_door()) { |
| @@ -429,7 +435,7 @@ class HumanProcessor { | |||
| 429 | void ProcessSingleConnection( | 435 | void ProcessSingleConnection( |
| 430 | const HumanConnection& human_connection, | 436 | const HumanConnection& human_connection, |
| 431 | const HumanConnection::Endpoint& endpoint, | 437 | const HumanConnection::Endpoint& endpoint, |
| 432 | const std::optional<std::string>& current_map_name) { | 438 | const std::optional<std::string>& current_map_name, bool is_target) { |
| 433 | if (endpoint.has_room()) { | 439 | if (endpoint.has_room()) { |
| 434 | auto room_identifier = | 440 | auto room_identifier = |
| 435 | GetCompleteRoomIdentifier(endpoint.room(), current_map_name); | 441 | GetCompleteRoomIdentifier(endpoint.room(), current_map_name); |
| @@ -448,6 +454,11 @@ class HumanProcessor { | |||
| 448 | if (painting_identifier) { | 454 | if (painting_identifier) { |
| 449 | PaintingInfo& painting_info = info_.paintings[*painting_identifier]; | 455 | PaintingInfo& painting_info = info_.paintings[*painting_identifier]; |
| 450 | painting_info.connections_referenced_by.push_back(human_connection); | 456 | painting_info.connections_referenced_by.push_back(human_connection); |
| 457 | |||
| 458 | if (is_target) { | ||
| 459 | painting_info.target_connections_referenced_by.push_back( | ||
| 460 | human_connection); | ||
| 461 | } | ||
| 451 | } else { | 462 | } else { |
| 452 | // Not sure where else to store this right now. | 463 | // Not sure where else to store this right now. |
| 453 | std::cout | 464 | std::cout |
| @@ -460,6 +471,11 @@ class HumanProcessor { | |||
| 460 | if (port_identifier) { | 471 | if (port_identifier) { |
| 461 | PortInfo& port_info = info_.ports[*port_identifier]; | 472 | PortInfo& port_info = info_.ports[*port_identifier]; |
| 462 | port_info.connections_referenced_by.push_back(human_connection); | 473 | port_info.connections_referenced_by.push_back(human_connection); |
| 474 | |||
| 475 | if (is_target) { | ||
| 476 | port_info.target_connections_referenced_by.push_back( | ||
| 477 | human_connection); | ||
| 478 | } | ||
| 463 | } else { | 479 | } else { |
| 464 | // Not sure where else to store this right now. | 480 | // Not sure where else to store this right now. |
| 465 | std::cout | 481 | std::cout |
| @@ -477,12 +493,137 @@ class HumanProcessor { | |||
| 477 | panel_info.proxies[endpoint.panel().answer()] | 493 | panel_info.proxies[endpoint.panel().answer()] |
| 478 | .connections_referenced_by.push_back(human_connection); | 494 | .connections_referenced_by.push_back(human_connection); |
| 479 | } | 495 | } |
| 496 | |||
| 497 | if (is_target) { | ||
| 498 | panel_info.target_connections_referenced_by.push_back( | ||
| 499 | human_connection); | ||
| 500 | } | ||
| 501 | } | ||
| 502 | } | ||
| 503 | } | ||
| 504 | |||
| 505 | void ProcessProgressivesFile(std::filesystem::path path) { | ||
| 506 | if (!std::filesystem::exists(path)) { | ||
| 507 | return; | ||
| 508 | } | ||
| 509 | |||
| 510 | auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string()); | ||
| 511 | |||
| 512 | for (const HumanProgressive& h_prog : h_progs.progressives()) { | ||
| 513 | ProcessProgressive(h_prog); | ||
| 514 | } | ||
| 515 | } | ||
| 516 | |||
| 517 | void ProcessProgressive(const HumanProgressive& h_prog) { | ||
| 518 | ProgressiveInfo& prog_info = info_.progressives[h_prog.name()]; | ||
| 519 | prog_info.definitions.push_back(h_prog); | ||
| 520 | |||
| 521 | for (const DoorIdentifier& di : h_prog.doors()) { | ||
| 522 | if (!di.has_map()) { | ||
| 523 | prog_info.malformed_doors.push_back(di); | ||
| 524 | continue; | ||
| 525 | } | ||
| 526 | |||
| 527 | DoorInfo& door_info = info_.doors[di]; | ||
| 528 | door_info.progressives_referenced_by.push_back(h_prog.name()); | ||
| 529 | } | ||
| 530 | } | ||
| 531 | |||
| 532 | void ProcessDoorGroupsFile(std::filesystem::path path) { | ||
| 533 | if (!std::filesystem::exists(path)) { | ||
| 534 | return; | ||
| 535 | } | ||
| 536 | |||
| 537 | auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string()); | ||
| 538 | |||
| 539 | for (const HumanDoorGroup& h_group : h_groups.door_groups()) { | ||
| 540 | ProcessDoorGroup(h_group); | ||
| 541 | } | ||
| 542 | } | ||
| 543 | |||
| 544 | void ProcessDoorGroup(const HumanDoorGroup& h_group) { | ||
| 545 | DoorGroupInfo& group_info = info_.door_groups[h_group.name()]; | ||
| 546 | group_info.definitions.push_back(h_group); | ||
| 547 | |||
| 548 | for (const DoorIdentifier& di : h_group.doors()) { | ||
| 549 | if (!di.has_map()) { | ||
| 550 | group_info.malformed_doors.push_back(di); | ||
| 551 | continue; | ||
| 480 | } | 552 | } |
| 553 | |||
| 554 | DoorInfo& door_info = info_.doors[di]; | ||
| 555 | door_info.door_groups_referenced_by.push_back(h_group.name()); | ||
| 481 | } | 556 | } |
| 482 | } | 557 | } |
| 483 | 558 | ||
| 484 | void ProcessIdsFile(std::filesystem::path path) { | 559 | void ProcessIdsFile(std::filesystem::path path) { |
| 485 | // Ignore this for now. | 560 | auto ids = ReadIdsFromYaml(path.string()); |
| 561 | |||
| 562 | DoorIdentifier di; | ||
| 563 | PanelIdentifier pi; | ||
| 564 | KeyholderIdentifier ki; | ||
| 565 | |||
| 566 | for (const auto& [map_name, map] : ids.maps()) { | ||
| 567 | di.set_map(map_name); | ||
| 568 | pi.set_map(map_name); | ||
| 569 | ki.set_map(map_name); | ||
| 570 | |||
| 571 | for (const auto& [door_name, ap_id] : map.doors()) { | ||
| 572 | di.set_name(door_name); | ||
| 573 | |||
| 574 | DoorInfo& door_info = info_.doors[di]; | ||
| 575 | door_info.has_id = true; | ||
| 576 | } | ||
| 577 | |||
| 578 | for (const auto& [room_name, room] : map.rooms()) { | ||
| 579 | pi.set_room(room_name); | ||
| 580 | ki.set_room(room_name); | ||
| 581 | |||
| 582 | for (const auto& [panel_name, ap_id] : room.panels()) { | ||
| 583 | pi.set_name(panel_name); | ||
| 584 | |||
| 585 | PanelInfo& panel_info = info_.panels[pi]; | ||
| 586 | panel_info.has_id = true; | ||
| 587 | } | ||
| 588 | |||
| 589 | for (const auto& [mastery_name, ap_id] : room.masteries()) { | ||
| 590 | // TODO: Mastery | ||
| 591 | } | ||
| 592 | |||
| 593 | for (const auto& [keyholder_name, ap_id] : room.keyholders()) { | ||
| 594 | ki.set_name(keyholder_name); | ||
| 595 | |||
| 596 | KeyholderInfo& keyholder_info = info_.keyholders[ki]; | ||
| 597 | keyholder_info.has_id = true; | ||
| 598 | } | ||
| 599 | } | ||
| 600 | } | ||
| 601 | |||
| 602 | for (const auto& [tag, id] : ids.special()) { | ||
| 603 | // TODO: Specials | ||
| 604 | } | ||
| 605 | |||
| 606 | for (const auto& [letter_name, ap_id] : ids.letters()) { | ||
| 607 | LetterIdentifier li = | ||
| 608 | std::make_tuple(letter_name[0], letter_name[1] == '2'); | ||
| 609 | LetterInfo& letter_info = info_.letters[li]; | ||
| 610 | letter_info.has_id = true; | ||
| 611 | } | ||
| 612 | |||
| 613 | for (const auto& [ending_name, ap_id] : ids.endings()) { | ||
| 614 | EndingInfo& ending_info = info_.endings[ending_name]; | ||
| 615 | ending_info.has_id = true; | ||
| 616 | } | ||
| 617 | |||
| 618 | for (const auto& [prog_name, ap_id] : ids.progressives()) { | ||
| 619 | ProgressiveInfo& prog_info = info_.progressives[prog_name]; | ||
| 620 | prog_info.has_id = true; | ||
| 621 | } | ||
| 622 | |||
| 623 | for (const auto& [group_name, ap_id] : ids.door_groups()) { | ||
| 624 | DoorGroupInfo& group_info = info_.door_groups[group_name]; | ||
| 625 | group_info.has_id = true; | ||
| 626 | } | ||
| 486 | } | 627 | } |
| 487 | 628 | ||
| 488 | std::string mapdir_; | 629 | std::string mapdir_; |
| diff --git a/tools/validator/structs.h b/tools/validator/structs.h index 0ca96fe..d1d45f2 100644 --- a/tools/validator/structs.h +++ b/tools/validator/structs.h | |||
| @@ -39,12 +39,15 @@ struct RoomInfo { | |||
| 39 | 39 | ||
| 40 | struct DoorInfo { | 40 | struct DoorInfo { |
| 41 | std::vector<HumanDoor> definitions; | 41 | std::vector<HumanDoor> definitions; |
| 42 | bool has_id = false; | ||
| 42 | 43 | ||
| 43 | std::vector<HumanConnection> connections_referenced_by; | 44 | std::vector<HumanConnection> connections_referenced_by; |
| 44 | std::vector<DoorIdentifier> doors_referenced_by; | 45 | std::vector<DoorIdentifier> doors_referenced_by; |
| 45 | std::vector<PanelIdentifier> panels_referenced_by; | 46 | std::vector<PanelIdentifier> panels_referenced_by; |
| 46 | std::vector<PaintingIdentifier> paintings_referenced_by; | 47 | std::vector<PaintingIdentifier> paintings_referenced_by; |
| 47 | std::vector<PortIdentifier> ports_referenced_by; | 48 | std::vector<PortIdentifier> ports_referenced_by; |
| 49 | std::vector<std::string> progressives_referenced_by; | ||
| 50 | std::vector<std::string> door_groups_referenced_by; | ||
| 48 | 51 | ||
| 49 | MalformedIdentifiers malformed_identifiers; | 52 | MalformedIdentifiers malformed_identifiers; |
| 50 | }; | 53 | }; |
| @@ -53,12 +56,14 @@ struct PortInfo { | |||
| 53 | std::vector<HumanPort> definitions; | 56 | std::vector<HumanPort> definitions; |
| 54 | 57 | ||
| 55 | std::vector<HumanConnection> connections_referenced_by; | 58 | std::vector<HumanConnection> connections_referenced_by; |
| 59 | std::vector<HumanConnection> target_connections_referenced_by; | ||
| 56 | }; | 60 | }; |
| 57 | 61 | ||
| 58 | struct PaintingInfo { | 62 | struct PaintingInfo { |
| 59 | std::vector<HumanPainting> definitions; | 63 | std::vector<HumanPainting> definitions; |
| 60 | 64 | ||
| 61 | std::vector<HumanConnection> connections_referenced_by; | 65 | std::vector<HumanConnection> connections_referenced_by; |
| 66 | std::vector<HumanConnection> target_connections_referenced_by; | ||
| 62 | std::vector<DoorIdentifier> doors_referenced_by; | 67 | std::vector<DoorIdentifier> doors_referenced_by; |
| 63 | }; | 68 | }; |
| 64 | 69 | ||
| @@ -71,10 +76,12 @@ struct ProxyInfo { | |||
| 71 | 76 | ||
| 72 | struct PanelInfo { | 77 | struct PanelInfo { |
| 73 | std::vector<HumanPanel> definitions; | 78 | std::vector<HumanPanel> definitions; |
| 79 | bool has_id = false; | ||
| 74 | 80 | ||
| 75 | std::string map_area_name; | 81 | std::string map_area_name; |
| 76 | 82 | ||
| 77 | std::vector<HumanConnection> connections_referenced_by; | 83 | std::vector<HumanConnection> connections_referenced_by; |
| 84 | std::vector<HumanConnection> target_connections_referenced_by; | ||
| 78 | std::vector<DoorIdentifier> doors_referenced_by; | 85 | std::vector<DoorIdentifier> doors_referenced_by; |
| 79 | 86 | ||
| 80 | std::map<std::string, ProxyInfo> proxies; | 87 | std::map<std::string, ProxyInfo> proxies; |
| @@ -82,6 +89,7 @@ struct PanelInfo { | |||
| 82 | 89 | ||
| 83 | struct KeyholderInfo { | 90 | struct KeyholderInfo { |
| 84 | std::vector<HumanKeyholder> definitions; | 91 | std::vector<HumanKeyholder> definitions; |
| 92 | bool has_id = false; | ||
| 85 | 93 | ||
| 86 | std::vector<DoorIdentifier> doors_referenced_by; | 94 | std::vector<DoorIdentifier> doors_referenced_by; |
| 87 | }; | 95 | }; |
| @@ -90,10 +98,12 @@ using LetterIdentifier = std::tuple<char, bool>; | |||
| 90 | 98 | ||
| 91 | struct LetterInfo { | 99 | struct LetterInfo { |
| 92 | std::vector<RoomIdentifier> defined_in; | 100 | std::vector<RoomIdentifier> defined_in; |
| 101 | bool has_id = false; | ||
| 93 | }; | 102 | }; |
| 94 | 103 | ||
| 95 | struct EndingInfo { | 104 | struct EndingInfo { |
| 96 | std::vector<RoomIdentifier> defined_in; | 105 | std::vector<RoomIdentifier> defined_in; |
| 106 | bool has_id = false; | ||
| 97 | 107 | ||
| 98 | std::vector<DoorIdentifier> doors_referenced_by; | 108 | std::vector<DoorIdentifier> doors_referenced_by; |
| 99 | }; | 109 | }; |
| @@ -102,6 +112,20 @@ struct PanelNameInfo { | |||
| 102 | std::vector<PanelIdentifier> panels_used_by; | 112 | std::vector<PanelIdentifier> panels_used_by; |
| 103 | }; | 113 | }; |
| 104 | 114 | ||
| 115 | struct ProgressiveInfo { | ||
| 116 | std::vector<HumanProgressive> definitions; | ||
| 117 | bool has_id = false; | ||
| 118 | |||
| 119 | std::vector<DoorIdentifier> malformed_doors; | ||
| 120 | }; | ||
| 121 | |||
| 122 | struct DoorGroupInfo { | ||
| 123 | std::vector<HumanDoorGroup> definitions; | ||
| 124 | bool has_id = false; | ||
| 125 | |||
| 126 | std::vector<DoorIdentifier> malformed_doors; | ||
| 127 | }; | ||
| 128 | |||
| 105 | struct CollectedInfo { | 129 | struct CollectedInfo { |
| 106 | std::map<std::string, MapInfo> maps; | 130 | std::map<std::string, MapInfo> maps; |
| 107 | std::map<RoomIdentifier, RoomInfo, RoomIdentifierLess> rooms; | 131 | std::map<RoomIdentifier, RoomInfo, RoomIdentifierLess> rooms; |
| @@ -114,6 +138,8 @@ struct CollectedInfo { | |||
| 114 | std::map<LetterIdentifier, LetterInfo> letters; | 138 | std::map<LetterIdentifier, LetterInfo> letters; |
| 115 | std::map<std::string, EndingInfo> endings; | 139 | std::map<std::string, EndingInfo> endings; |
| 116 | std::map<std::string, PanelNameInfo> panel_names; | 140 | std::map<std::string, PanelNameInfo> panel_names; |
| 141 | std::map<std::string, ProgressiveInfo> progressives; | ||
| 142 | std::map<std::string, DoorGroupInfo> door_groups; | ||
| 117 | }; | 143 | }; |
| 118 | 144 | ||
| 119 | } // namespace com::fourisland::lingo2_archipelago | 145 | } // namespace com::fourisland::lingo2_archipelago |
| diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index 9c66e09..dd41f5c 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp | |||
| @@ -45,6 +45,12 @@ class Validator { | |||
| 45 | for (const auto& [panel_name, panel_info] : info_.panel_names) { | 45 | for (const auto& [panel_name, panel_info] : info_.panel_names) { |
| 46 | ValidatePanelName(panel_name, panel_info); | 46 | ValidatePanelName(panel_name, panel_info); |
| 47 | } | 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); | ||
| 53 | } | ||
| 48 | } | 54 | } |
| 49 | 55 | ||
| 50 | private: | 56 | private: |
| @@ -100,7 +106,8 @@ class Validator { | |||
| 100 | return false; | 106 | return false; |
| 101 | } | 107 | } |
| 102 | 108 | ||
| 103 | if (h_door.keyholders_size() > 0 || h_door.endings_size() > 0) { | 109 | if (h_door.keyholders_size() > 0 || h_door.endings_size() > 0 || |
| 110 | h_door.complete_at() > 0) { | ||
| 104 | return true; | 111 | return true; |
| 105 | } | 112 | } |
| 106 | 113 | ||
| @@ -164,6 +171,20 @@ class Validator { | |||
| 164 | std::cout << " CONNECTION " << connection.ShortDebugString() | 171 | std::cout << " CONNECTION " << connection.ShortDebugString() |
| 165 | << std::endl; | 172 | << std::endl; |
| 166 | } | 173 | } |
| 174 | |||
| 175 | for (const std::string& prog_name : | ||
| 176 | door_info.progressives_referenced_by) { | ||
| 177 | std::cout << " PROGRESSIVE " << prog_name << std::endl; | ||
| 178 | } | ||
| 179 | |||
| 180 | for (const std::string& group_name : | ||
| 181 | door_info.door_groups_referenced_by) { | ||
| 182 | std::cout << " DOOR GROUP " << group_name << std::endl; | ||
| 183 | } | ||
| 184 | |||
| 185 | if (door_info.has_id) { | ||
| 186 | std::cout << " An AP ID is present." << std::endl; | ||
| 187 | } | ||
| 167 | } else if (door_info.definitions.size() > 1) { | 188 | } else if (door_info.definitions.size() > 1) { |
| 168 | std::cout << "Door " << door_identifier.ShortDebugString() | 189 | std::cout << "Door " << door_identifier.ShortDebugString() |
| 169 | << " was defined multiple times." << std::endl; | 190 | << " was defined multiple times." << std::endl; |
| @@ -207,6 +228,17 @@ class Validator { | |||
| 207 | << " is a location that depends on double_letters." | 228 | << " is a location that depends on double_letters." |
| 208 | << std::endl; | 229 | << std::endl; |
| 209 | } | 230 | } |
| 231 | |||
| 232 | bool needs_id = (h_door.type() != DoorType::EVENT); | ||
| 233 | if (door_info.has_id != needs_id) { | ||
| 234 | if (needs_id) { | ||
| 235 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 236 | << " is missing an AP ID." << std::endl; | ||
| 237 | } else { | ||
| 238 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 239 | << " should not have an AP ID." << std::endl; | ||
| 240 | } | ||
| 241 | } | ||
| 210 | } | 242 | } |
| 211 | } | 243 | } |
| 212 | 244 | ||
| @@ -225,6 +257,22 @@ class Validator { | |||
| 225 | std::cout << "Port " << port_identifier.ShortDebugString() | 257 | std::cout << "Port " << port_identifier.ShortDebugString() |
| 226 | << " was defined multiple times." << std::endl; | 258 | << " was defined multiple times." << std::endl; |
| 227 | } | 259 | } |
| 260 | |||
| 261 | if (!port_info.target_connections_referenced_by.empty()) { | ||
| 262 | for (const HumanPort& port : port_info.definitions) { | ||
| 263 | if (port.has_required_door()) { | ||
| 264 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 265 | << " has a required door but is the target of a connection:" | ||
| 266 | << std::endl; | ||
| 267 | |||
| 268 | for (const HumanConnection& connection : | ||
| 269 | port_info.target_connections_referenced_by) { | ||
| 270 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 271 | << std::endl; | ||
| 272 | } | ||
| 273 | } | ||
| 274 | } | ||
| 275 | } | ||
| 228 | } | 276 | } |
| 229 | 277 | ||
| 230 | void ValidatePainting(const PaintingIdentifier& painting_identifier, | 278 | void ValidatePainting(const PaintingIdentifier& painting_identifier, |
| @@ -248,6 +296,22 @@ class Validator { | |||
| 248 | std::cout << "Painting " << painting_identifier.ShortDebugString() | 296 | std::cout << "Painting " << painting_identifier.ShortDebugString() |
| 249 | << " was defined multiple times." << std::endl; | 297 | << " was defined multiple times." << std::endl; |
| 250 | } | 298 | } |
| 299 | |||
| 300 | if (!painting_info.target_connections_referenced_by.empty()) { | ||
| 301 | for (const HumanPainting& painting : painting_info.definitions) { | ||
| 302 | if (painting.has_required_door()) { | ||
| 303 | std::cout << "Painting " << painting_identifier.ShortDebugString() | ||
| 304 | << " has a required door but is the target of a connection:" | ||
| 305 | << std::endl; | ||
| 306 | |||
| 307 | for (const HumanConnection& connection : | ||
| 308 | painting_info.target_connections_referenced_by) { | ||
| 309 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 310 | << std::endl; | ||
| 311 | } | ||
| 312 | } | ||
| 313 | } | ||
| 314 | } | ||
| 251 | } | 315 | } |
| 252 | 316 | ||
| 253 | void ValidatePanel(const PanelIdentifier& panel_identifier, | 317 | void ValidatePanel(const PanelIdentifier& panel_identifier, |
| @@ -272,6 +336,10 @@ class Validator { | |||
| 272 | std::cout << " CONNECTION " << connection.ShortDebugString() | 336 | std::cout << " CONNECTION " << connection.ShortDebugString() |
| 273 | << std::endl; | 337 | << std::endl; |
| 274 | } | 338 | } |
| 339 | |||
| 340 | if (panel_info.has_id) { | ||
| 341 | std::cout << " An AP ID is present." << std::endl; | ||
| 342 | } | ||
| 275 | } else if (panel_info.definitions.size() > 1) { | 343 | } else if (panel_info.definitions.size() > 1) { |
| 276 | std::cout << "Panel " << panel_identifier.ShortDebugString() | 344 | std::cout << "Panel " << panel_identifier.ShortDebugString() |
| 277 | << " was defined multiple times." << std::endl; | 345 | << " was defined multiple times." << std::endl; |
| @@ -300,6 +368,27 @@ class Validator { | |||
| 300 | << "\" was defined multiple times." << std::endl; | 368 | << "\" was defined multiple times." << std::endl; |
| 301 | } | 369 | } |
| 302 | } | 370 | } |
| 371 | |||
| 372 | if (!panel_info.has_id) { | ||
| 373 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 374 | << " is missing an AP ID." << std::endl; | ||
| 375 | } | ||
| 376 | |||
| 377 | if (!panel_info.target_connections_referenced_by.empty()) { | ||
| 378 | for (const HumanPanel& panel : panel_info.definitions) { | ||
| 379 | if (panel.has_required_door()) { | ||
| 380 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 381 | << " has a required door but is the target of a connection:" | ||
| 382 | << std::endl; | ||
| 383 | |||
| 384 | for (const HumanConnection& connection : | ||
| 385 | panel_info.target_connections_referenced_by) { | ||
| 386 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 387 | << std::endl; | ||
| 388 | } | ||
| 389 | } | ||
| 390 | } | ||
| 391 | } | ||
| 303 | } | 392 | } |
| 304 | 393 | ||
| 305 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, | 394 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, |
| @@ -313,10 +402,28 @@ class Validator { | |||
| 313 | std::cout << " DOOR " << door_identifier.ShortDebugString() | 402 | std::cout << " DOOR " << door_identifier.ShortDebugString() |
| 314 | << std::endl; | 403 | << std::endl; |
| 315 | } | 404 | } |
| 405 | |||
| 406 | if (keyholder_info.has_id) { | ||
| 407 | std::cout << " An AP ID is present." << std::endl; | ||
| 408 | } | ||
| 316 | } else if (keyholder_info.definitions.size() > 1) { | 409 | } else if (keyholder_info.definitions.size() > 1) { |
| 317 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | 410 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() |
| 318 | << " was defined multiple times." << std::endl; | 411 | << " was defined multiple times." << std::endl; |
| 319 | } | 412 | } |
| 413 | |||
| 414 | for (const HumanKeyholder& h_keyholder : keyholder_info.definitions) { | ||
| 415 | bool needs_id = (h_keyholder.has_key()); | ||
| 416 | |||
| 417 | if (needs_id != keyholder_info.has_id) { | ||
| 418 | if (needs_id) { | ||
| 419 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
| 420 | << " is missing an AP ID." << std::endl; | ||
| 421 | } else { | ||
| 422 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
| 423 | << " should not have an AP ID." << std::endl; | ||
| 424 | } | ||
| 425 | } | ||
| 426 | } | ||
| 320 | } | 427 | } |
| 321 | 428 | ||
| 322 | void ValidateLetter(const LetterIdentifier& letter_identifier, | 429 | void ValidateLetter(const LetterIdentifier& letter_identifier, |
| @@ -324,7 +431,14 @@ class Validator { | |||
| 324 | std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + | 431 | std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + |
| 325 | (std::get<1>(letter_identifier) ? "2" : "1"); | 432 | (std::get<1>(letter_identifier) ? "2" : "1"); |
| 326 | 433 | ||
| 327 | if (letter_info.defined_in.size() > 1) { | 434 | if (letter_info.defined_in.empty()) { |
| 435 | std::cout << "Letter " << letter_name | ||
| 436 | << " has no definition, but was referenced:" << std::endl; | ||
| 437 | |||
| 438 | if (letter_info.has_id) { | ||
| 439 | std::cout << " An AP ID is present." << std::endl; | ||
| 440 | } | ||
| 441 | } else if (letter_info.defined_in.size() > 1) { | ||
| 328 | std::cout << "Letter " << letter_name | 442 | std::cout << "Letter " << letter_name |
| 329 | << " was defined in multiple places:" << std::endl; | 443 | << " was defined in multiple places:" << std::endl; |
| 330 | 444 | ||
| @@ -332,6 +446,11 @@ class Validator { | |||
| 332 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | 446 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; |
| 333 | } | 447 | } |
| 334 | } | 448 | } |
| 449 | |||
| 450 | if (!letter_info.has_id) { | ||
| 451 | std::cout << "Letter " << letter_name << " is missing an AP ID." | ||
| 452 | << std::endl; | ||
| 453 | } | ||
| 335 | } | 454 | } |
| 336 | 455 | ||
| 337 | void ValidateEnding(const std::string& ending_name, | 456 | void ValidateEnding(const std::string& ending_name, |
| @@ -345,6 +464,10 @@ class Validator { | |||
| 345 | std::cout << " DOOR " << door_identifier.ShortDebugString() | 464 | std::cout << " DOOR " << door_identifier.ShortDebugString() |
| 346 | << std::endl; | 465 | << std::endl; |
| 347 | } | 466 | } |
| 467 | |||
| 468 | if (ending_info.has_id) { | ||
| 469 | std::cout << " An AP ID is present." << std::endl; | ||
| 470 | } | ||
| 348 | } else if (ending_info.defined_in.size() > 1) { | 471 | } else if (ending_info.defined_in.size() > 1) { |
| 349 | std::cout << "Ending " << ending_name | 472 | std::cout << "Ending " << ending_name |
| 350 | << " was defined in multiple places:" << std::endl; | 473 | << " was defined in multiple places:" << std::endl; |
| @@ -353,6 +476,11 @@ class Validator { | |||
| 353 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | 476 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; |
| 354 | } | 477 | } |
| 355 | } | 478 | } |
| 479 | |||
| 480 | if (!ending_info.has_id) { | ||
| 481 | std::cout << "Ending " << ending_name << " is missing an AP ID." | ||
| 482 | << std::endl; | ||
| 483 | } | ||
| 356 | } | 484 | } |
| 357 | 485 | ||
| 358 | void ValidatePanelName(const std::string& panel_name, | 486 | void ValidatePanelName(const std::string& panel_name, |
| @@ -369,6 +497,46 @@ class Validator { | |||
| 369 | } | 497 | } |
| 370 | } | 498 | } |
| 371 | 499 | ||
| 500 | void ValidateProgressive(const std::string& prog_name, | ||
| 501 | const ProgressiveInfo& prog_info) const { | ||
| 502 | if (prog_info.definitions.empty()) { | ||
| 503 | std::cout << "Progressive \"" << prog_name | ||
| 504 | << "\" has no definition, but was referenced:" << std::endl; | ||
| 505 | |||
| 506 | if (prog_info.has_id) { | ||
| 507 | std::cout << " An AP ID is present." << std::endl; | ||
| 508 | } | ||
| 509 | } else if (prog_info.definitions.size() > 1) { | ||
| 510 | std::cout << "Progressive \"" << prog_name | ||
| 511 | << "\" has multiple definitions." << std::endl; | ||
| 512 | } | ||
| 513 | |||
| 514 | if (!prog_info.has_id) { | ||
| 515 | std::cout << "Progressive \"" << prog_name << "\" is missing an AP ID." | ||
| 516 | << std::endl; | ||
| 517 | } | ||
| 518 | } | ||
| 519 | |||
| 520 | void ValidateDoorGroup(const std::string& group_name, | ||
| 521 | const DoorGroupInfo& group_info) const { | ||
| 522 | if (group_info.definitions.empty()) { | ||
| 523 | std::cout << "Door group \"" << group_name | ||
| 524 | << "\" has no definition, but was referenced:" << std::endl; | ||
| 525 | |||
| 526 | if (group_info.has_id) { | ||
| 527 | std::cout << " An AP ID is present." << std::endl; | ||
| 528 | } | ||
| 529 | } else if (group_info.definitions.size() > 1) { | ||
| 530 | std::cout << "Door group \"" << group_name | ||
| 531 | << "\" has multiple definitions." << std::endl; | ||
| 532 | } | ||
| 533 | |||
| 534 | if (!group_info.has_id) { | ||
| 535 | std::cout << "Door group \"" << group_name << "\" is missing an AP ID." | ||
| 536 | << std::endl; | ||
| 537 | } | ||
| 538 | } | ||
| 539 | |||
| 372 | const CollectedInfo& info_; | 540 | const CollectedInfo& info_; |
| 373 | }; | 541 | }; |
| 374 | 542 | ||
