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.cpp59
1 files changed, 55 insertions, 4 deletions
diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index 5720ba9..2c978bf 100644 --- a/tools/validator/human_processor.cpp +++ b/tools/validator/human_processor.cpp
@@ -43,6 +43,7 @@ class HumanProcessor {
43 ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); 43 ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt);
44 ProcessMaps(datadir_path); 44 ProcessMaps(datadir_path);
45 ProcessProgressivesFile(datadir_path / "progressives.txtpb"); 45 ProcessProgressivesFile(datadir_path / "progressives.txtpb");
46 ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb");
46 ProcessIdsFile(datadir_path / "ids.yaml"); 47 ProcessIdsFile(datadir_path / "ids.yaml");
47 } 48 }
48 49
@@ -393,7 +394,9 @@ class HumanProcessor {
393 } 394 }
394 } else if (human_connection.has_from()) { 395 } else if (human_connection.has_from()) {
395 ProcessSingleConnection(human_connection, human_connection.from(), 396 ProcessSingleConnection(human_connection, human_connection.from(),
396 current_map_name); 397 current_map_name,
398 /*is_target=*/!human_connection.oneway() &&
399 !human_connection.bypass_target_door());
397 } 400 }
398 401
399 if (human_connection.has_to_room()) { 402 if (human_connection.has_to_room()) {
@@ -409,8 +412,9 @@ class HumanProcessor {
409 std::cout << "A global connection used to_room." << std::endl; 412 std::cout << "A global connection used to_room." << std::endl;
410 } 413 }
411 } else if (human_connection.has_to()) { 414 } else if (human_connection.has_to()) {
412 ProcessSingleConnection(human_connection, human_connection.to(), 415 ProcessSingleConnection(
413 current_map_name); 416 human_connection, human_connection.to(), current_map_name,
417 /*is_target=*/!human_connection.bypass_target_door());
414 } 418 }
415 419
416 if (human_connection.has_door()) { 420 if (human_connection.has_door()) {
@@ -431,7 +435,7 @@ class HumanProcessor {
431 void ProcessSingleConnection( 435 void ProcessSingleConnection(
432 const HumanConnection& human_connection, 436 const HumanConnection& human_connection,
433 const HumanConnection::Endpoint& endpoint, 437 const HumanConnection::Endpoint& endpoint,
434 const std::optional<std::string>& current_map_name) { 438 const std::optional<std::string>& current_map_name, bool is_target) {
435 if (endpoint.has_room()) { 439 if (endpoint.has_room()) {
436 auto room_identifier = 440 auto room_identifier =
437 GetCompleteRoomIdentifier(endpoint.room(), current_map_name); 441 GetCompleteRoomIdentifier(endpoint.room(), current_map_name);
@@ -450,6 +454,11 @@ class HumanProcessor {
450 if (painting_identifier) { 454 if (painting_identifier) {
451 PaintingInfo& painting_info = info_.paintings[*painting_identifier]; 455 PaintingInfo& painting_info = info_.paintings[*painting_identifier];
452 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 }
453 } else { 462 } else {
454 // Not sure where else to store this right now. 463 // Not sure where else to store this right now.
455 std::cout 464 std::cout
@@ -462,6 +471,11 @@ class HumanProcessor {
462 if (port_identifier) { 471 if (port_identifier) {
463 PortInfo& port_info = info_.ports[*port_identifier]; 472 PortInfo& port_info = info_.ports[*port_identifier];
464 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 }
465 } else { 479 } else {
466 // Not sure where else to store this right now. 480 // Not sure where else to store this right now.
467 std::cout 481 std::cout
@@ -479,6 +493,11 @@ class HumanProcessor {
479 panel_info.proxies[endpoint.panel().answer()] 493 panel_info.proxies[endpoint.panel().answer()]
480 .connections_referenced_by.push_back(human_connection); 494 .connections_referenced_by.push_back(human_connection);
481 } 495 }
496
497 if (is_target) {
498 panel_info.target_connections_referenced_by.push_back(
499 human_connection);
500 }
482 } 501 }
483 } 502 }
484 } 503 }
@@ -510,6 +529,33 @@ class HumanProcessor {
510 } 529 }
511 } 530 }
512 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
513 void ProcessIdsFile(std::filesystem::path path) { 559 void ProcessIdsFile(std::filesystem::path path) {
514 auto ids = ReadIdsFromYaml(path.string()); 560 auto ids = ReadIdsFromYaml(path.string());
515 561
@@ -573,6 +619,11 @@ class HumanProcessor {
573 ProgressiveInfo& prog_info = info_.progressives[prog_name]; 619 ProgressiveInfo& prog_info = info_.progressives[prog_name];
574 prog_info.has_id = true; 620 prog_info.has_id = true;
575 } 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 }
576 } 627 }
577 628
578 std::string mapdir_; 629 std::string mapdir_;