about summary refs log tree commit diff stats
path: root/tools/validator/human_processor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/validator/human_processor.cpp')
-rw-r--r--tools/validator/human_processor.cpp125
1 files changed, 119 insertions, 6 deletions
diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index 49e7578..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
17namespace com::fourisland::lingo2_archipelago { 18namespace com::fourisland::lingo2_archipelago {
18namespace { 19namespace {
@@ -42,7 +43,8 @@ class HumanProcessor {
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 ProcessProgressivesFile(datadir_path / "progressives.txtpb"); 45 ProcessProgressivesFile(datadir_path / "progressives.txtpb");
45 ProcessIdsFile(datadir_path / "ids.txtpb"); 46 ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb");
47 ProcessIdsFile(datadir_path / "ids.yaml");
46 } 48 }
47 49
48 private: 50 private:
@@ -392,7 +394,9 @@ class HumanProcessor {
392 } 394 }
393 } else if (human_connection.has_from()) { 395 } else if (human_connection.has_from()) {
394 ProcessSingleConnection(human_connection, human_connection.from(), 396 ProcessSingleConnection(human_connection, human_connection.from(),
395 current_map_name); 397 current_map_name,
398 /*is_target=*/!human_connection.oneway() &&
399 !human_connection.bypass_target_door());
396 } 400 }
397 401
398 if (human_connection.has_to_room()) { 402 if (human_connection.has_to_room()) {
@@ -408,8 +412,9 @@ class HumanProcessor {
408 std::cout << "A global connection used to_room." << std::endl; 412 std::cout << "A global connection used to_room." << std::endl;
409 } 413 }
410 } else if (human_connection.has_to()) { 414 } else if (human_connection.has_to()) {
411 ProcessSingleConnection(human_connection, human_connection.to(), 415 ProcessSingleConnection(
412 current_map_name); 416 human_connection, human_connection.to(), current_map_name,
417 /*is_target=*/!human_connection.bypass_target_door());
413 } 418 }
414 419
415 if (human_connection.has_door()) { 420 if (human_connection.has_door()) {
@@ -430,7 +435,7 @@ class HumanProcessor {
430 void ProcessSingleConnection( 435 void ProcessSingleConnection(
431 const HumanConnection& human_connection, 436 const HumanConnection& human_connection,
432 const HumanConnection::Endpoint& endpoint, 437 const HumanConnection::Endpoint& endpoint,
433 const std::optional<std::string>& current_map_name) { 438 const std::optional<std::string>& current_map_name, bool is_target) {
434 if (endpoint.has_room()) { 439 if (endpoint.has_room()) {
435 auto room_identifier = 440 auto room_identifier =
436 GetCompleteRoomIdentifier(endpoint.room(), current_map_name); 441 GetCompleteRoomIdentifier(endpoint.room(), current_map_name);
@@ -449,6 +454,11 @@ class HumanProcessor {
449 if (painting_identifier) { 454 if (painting_identifier) {
450 PaintingInfo& painting_info = info_.paintings[*painting_identifier]; 455 PaintingInfo& painting_info = info_.paintings[*painting_identifier];
451 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 }
452 } else { 462 } else {
453 // Not sure where else to store this right now. 463 // Not sure where else to store this right now.
454 std::cout 464 std::cout
@@ -461,6 +471,11 @@ class HumanProcessor {
461 if (port_identifier) { 471 if (port_identifier) {
462 PortInfo& port_info = info_.ports[*port_identifier]; 472 PortInfo& port_info = info_.ports[*port_identifier];
463 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 }
464 } else { 479 } else {
465 // Not sure where else to store this right now. 480 // Not sure where else to store this right now.
466 std::cout 481 std::cout
@@ -478,6 +493,11 @@ class HumanProcessor {
478 panel_info.proxies[endpoint.panel().answer()] 493 panel_info.proxies[endpoint.panel().answer()]
479 .connections_referenced_by.push_back(human_connection); 494 .connections_referenced_by.push_back(human_connection);
480 } 495 }
496
497 if (is_target) {
498 panel_info.target_connections_referenced_by.push_back(
499 human_connection);
500 }
481 } 501 }
482 } 502 }
483 } 503 }
@@ -509,8 +529,101 @@ class HumanProcessor {
509 } 529 }
510 } 530 }
511 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;
552 }
553
554 DoorInfo& door_info = info_.doors[di];
555 door_info.door_groups_referenced_by.push_back(h_group.name());
556 }
557 }
558
512 void ProcessIdsFile(std::filesystem::path path) { 559 void ProcessIdsFile(std::filesystem::path path) {
513 // 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 }
514 } 627 }
515 628
516 std::string mapdir_; 629 std::string mapdir_;