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.cpp153
1 files changed, 147 insertions, 6 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
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:
@@ -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_;