diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/assign_ids/main.cpp | 54 | ||||
| -rw-r--r-- | tools/datapacker/main.cpp | 64 | ||||
| -rw-r--r-- | tools/util/godot_scene.cpp | 6 | ||||
| -rw-r--r-- | tools/util/ids_yaml_format.cpp | 13 | ||||
| -rw-r--r-- | tools/validator/human_processor.cpp | 66 | ||||
| -rw-r--r-- | tools/validator/structs.h | 9 | ||||
| -rw-r--r-- | tools/validator/validator.cpp | 116 | ||||
| -rw-r--r-- | tools/validator/validator.h | 2 |
8 files changed, 288 insertions, 42 deletions
| diff --git a/tools/assign_ids/main.cpp b/tools/assign_ids/main.cpp index d212767..4cf7c3f 100644 --- a/tools/assign_ids/main.cpp +++ b/tools/assign_ids/main.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | #include <google/protobuf/text_format.h> | 2 | #include <google/protobuf/text_format.h> |
| 3 | 3 | ||
| 4 | #include <cstdint> | 4 | #include <cstdint> |
| 5 | #include <filesystem> | ||
| 5 | #include <fstream> | 6 | #include <fstream> |
| 6 | #include <iostream> | 7 | #include <iostream> |
| 7 | #include <map> | 8 | #include <map> |
| @@ -43,6 +44,7 @@ class AssignIds { | |||
| 43 | ProcessSpecialIds(); | 44 | ProcessSpecialIds(); |
| 44 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); | 45 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); |
| 45 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); | 46 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); |
| 47 | ProcessGlobalMetadataFile(datadir_path / "metadata.txtpb"); | ||
| 46 | 48 | ||
| 47 | WriteIds(ids_path); | 49 | WriteIds(ids_path); |
| 48 | 50 | ||
| @@ -63,6 +65,7 @@ class AssignIds { | |||
| 63 | UpdateNextId(room.panels()); | 65 | UpdateNextId(room.panels()); |
| 64 | UpdateNextId(room.masteries()); | 66 | UpdateNextId(room.masteries()); |
| 65 | UpdateNextId(room.keyholders()); | 67 | UpdateNextId(room.keyholders()); |
| 68 | UpdateNextId(room.ports()); | ||
| 66 | } | 69 | } |
| 67 | } | 70 | } |
| 68 | 71 | ||
| @@ -109,7 +112,8 @@ class AssignIds { | |||
| 109 | 112 | ||
| 110 | void ProcessDoor(const HumanDoor& h_door, | 113 | void ProcessDoor(const HumanDoor& h_door, |
| 111 | const std::string& current_map_name) { | 114 | const std::string& current_map_name) { |
| 112 | if (h_door.type() == DoorType::EVENT) { | 115 | if (h_door.type() == DoorType::EVENT && !h_door.latch() && |
| 116 | !h_door.legacy_location()) { | ||
| 113 | return; | 117 | return; |
| 114 | } | 118 | } |
| 115 | 119 | ||
| @@ -243,6 +247,37 @@ class AssignIds { | |||
| 243 | .at(h_keyholder.name()); | 247 | .at(h_keyholder.name()); |
| 244 | } | 248 | } |
| 245 | } | 249 | } |
| 250 | |||
| 251 | for (const HumanPort& h_port : h_room.ports()) { | ||
| 252 | if (h_port.no_shuffle()) { | ||
| 253 | continue; | ||
| 254 | } | ||
| 255 | |||
| 256 | auto& maps = *output_.mutable_maps(); | ||
| 257 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
| 258 | auto& ports = *rooms[h_room.name()].mutable_ports(); | ||
| 259 | |||
| 260 | if (!id_mappings_.maps().contains(current_map_name) || | ||
| 261 | !id_mappings_.maps() | ||
| 262 | .at(current_map_name) | ||
| 263 | .rooms() | ||
| 264 | .contains(h_room.name()) || | ||
| 265 | !id_mappings_.maps() | ||
| 266 | .at(current_map_name) | ||
| 267 | .rooms() | ||
| 268 | .at(h_room.name()) | ||
| 269 | .ports() | ||
| 270 | .contains(h_port.name())) { | ||
| 271 | ports[h_port.name()] = next_id_++; | ||
| 272 | } else { | ||
| 273 | ports[h_port.name()] = id_mappings_.maps() | ||
| 274 | .at(current_map_name) | ||
| 275 | .rooms() | ||
| 276 | .at(h_room.name()) | ||
| 277 | .ports() | ||
| 278 | .at(h_port.name()); | ||
| 279 | } | ||
| 280 | } | ||
| 246 | } | 281 | } |
| 247 | 282 | ||
| 248 | void ProcessSpecialIds() { | 283 | void ProcessSpecialIds() { |
| @@ -287,6 +322,23 @@ class AssignIds { | |||
| 287 | } | 322 | } |
| 288 | } | 323 | } |
| 289 | 324 | ||
| 325 | void ProcessGlobalMetadataFile(std::filesystem::path path) { | ||
| 326 | if (!std::filesystem::exists(path)) { | ||
| 327 | return; | ||
| 328 | } | ||
| 329 | |||
| 330 | auto h_metadata = ReadMessageFromFile<HumanGlobalMetadata>(path.string()); | ||
| 331 | auto& specials = *output_.mutable_special(); | ||
| 332 | |||
| 333 | for (const std::string& h_special : h_metadata.special_names()) { | ||
| 334 | if (!id_mappings_.special().contains(h_special)) { | ||
| 335 | specials[h_special] = next_id_++; | ||
| 336 | } else { | ||
| 337 | specials[h_special] = id_mappings_.special().at(h_special); | ||
| 338 | } | ||
| 339 | } | ||
| 340 | } | ||
| 341 | |||
| 290 | private: | 342 | private: |
| 291 | void UpdateNextId(const google::protobuf::Map<std::string, uint64_t>& ids) { | 343 | void UpdateNextId(const google::protobuf::Map<std::string, uint64_t>& ids) { |
| 292 | for (const auto& [_, id] : ids) { | 344 | for (const auto& [_, id] : ids) { |
| diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index c72462d..8109bf5 100644 --- a/tools/datapacker/main.cpp +++ b/tools/datapacker/main.cpp | |||
| @@ -45,6 +45,7 @@ class DataPacker { | |||
| 45 | ProcessMaps(datadir_path); | 45 | ProcessMaps(datadir_path); |
| 46 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); | 46 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); |
| 47 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); | 47 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); |
| 48 | ProcessGlobalMetadataFile(datadir_path / "metadata.txtpb"); | ||
| 48 | ProcessIdsFile(datadir_path / "ids.yaml"); | 49 | ProcessIdsFile(datadir_path / "ids.yaml"); |
| 49 | 50 | ||
| 50 | { | 51 | { |
| @@ -87,9 +88,17 @@ class DataPacker { | |||
| 87 | uint64_t map_id = container_.FindOrAddMap(map_name); | 88 | uint64_t map_id = container_.FindOrAddMap(map_name); |
| 88 | Map& map = *container_.all_objects().mutable_maps(map_id); | 89 | Map& map = *container_.all_objects().mutable_maps(map_id); |
| 89 | 90 | ||
| 91 | map.set_type(metadata.type()); | ||
| 92 | |||
| 90 | if (metadata.has_display_name()) { | 93 | if (metadata.has_display_name()) { |
| 91 | map.set_display_name(metadata.display_name()); | 94 | map.set_display_name(metadata.display_name()); |
| 92 | } | 95 | } |
| 96 | |||
| 97 | if (metadata.has_worldport_entrance()) { | ||
| 98 | map.set_worldport_entrance(container_.FindOrAddPort( | ||
| 99 | map_name, metadata.worldport_entrance().room(), | ||
| 100 | metadata.worldport_entrance().name(), std::nullopt, std::nullopt)); | ||
| 101 | } | ||
| 93 | } | 102 | } |
| 94 | 103 | ||
| 95 | void ProcessRooms(std::filesystem::path path, | 104 | void ProcessRooms(std::filesystem::path path, |
| @@ -238,7 +247,14 @@ class DataPacker { | |||
| 238 | Port& port = *container_.all_objects().mutable_ports(port_id); | 247 | Port& port = *container_.all_objects().mutable_ports(port_id); |
| 239 | 248 | ||
| 240 | port.set_path(h_port.path()); | 249 | port.set_path(h_port.path()); |
| 241 | port.set_orientation(h_port.orientation()); | 250 | port.set_display_name(h_port.display_name()); |
| 251 | |||
| 252 | if (h_port.no_shuffle()) { | ||
| 253 | port.set_no_shuffle(h_port.no_shuffle()); | ||
| 254 | } else { | ||
| 255 | *port.mutable_destination() = h_port.destination(); | ||
| 256 | port.set_rotation(h_port.rotation()); | ||
| 257 | } | ||
| 242 | 258 | ||
| 243 | // Setting this explicitly because the Godot protobuf doesn't support | 259 | // Setting this explicitly because the Godot protobuf doesn't support |
| 244 | // custom defaults. | 260 | // custom defaults. |
| @@ -345,8 +361,8 @@ class DataPacker { | |||
| 345 | h_door.receivers().begin(), h_door.receivers().end(), | 361 | h_door.receivers().begin(), h_door.receivers().end(), |
| 346 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); | 362 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); |
| 347 | std::copy( | 363 | std::copy( |
| 348 | h_door.switches().begin(), h_door.switches().end(), | 364 | h_door.senders().begin(), h_door.senders().end(), |
| 349 | google::protobuf::RepeatedFieldBackInserter(door.mutable_switches())); | 365 | google::protobuf::RepeatedFieldBackInserter(door.mutable_senders())); |
| 350 | 366 | ||
| 351 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { | 367 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { |
| 352 | std::optional<std::string> map_name = | 368 | std::optional<std::string> map_name = |
| @@ -395,8 +411,8 @@ class DataPacker { | |||
| 395 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); | 411 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); |
| 396 | } | 412 | } |
| 397 | 413 | ||
| 398 | for (const std::string& ending_name : h_door.endings()) { | 414 | if (h_door.has_white_ending()) { |
| 399 | door.add_endings(container_.FindOrAddEnding(ending_name)); | 415 | door.set_white_ending(h_door.white_ending()); |
| 400 | } | 416 | } |
| 401 | 417 | ||
| 402 | if (h_door.has_control_center_color()) { | 418 | if (h_door.has_control_center_color()) { |
| @@ -416,6 +432,14 @@ class DataPacker { | |||
| 416 | if (h_door.has_double_letters()) { | 432 | if (h_door.has_double_letters()) { |
| 417 | door.set_double_letters(h_door.double_letters()); | 433 | door.set_double_letters(h_door.double_letters()); |
| 418 | } | 434 | } |
| 435 | |||
| 436 | if (h_door.has_latch()) { | ||
| 437 | door.set_latch(h_door.latch()); | ||
| 438 | } | ||
| 439 | |||
| 440 | if (h_door.has_legacy_location()) { | ||
| 441 | door.set_legacy_location(h_door.legacy_location()); | ||
| 442 | } | ||
| 419 | } | 443 | } |
| 420 | 444 | ||
| 421 | void ProcessConnectionsFile(std::filesystem::path path, | 445 | void ProcessConnectionsFile(std::filesystem::path path, |
| @@ -472,6 +496,21 @@ class DataPacker { | |||
| 472 | r_connection.set_roof_access(human_connection.roof_access()); | 496 | r_connection.set_roof_access(human_connection.roof_access()); |
| 473 | } | 497 | } |
| 474 | 498 | ||
| 499 | if (human_connection.has_purple_ending()) { | ||
| 500 | f_connection.set_purple_ending(human_connection.purple_ending()); | ||
| 501 | r_connection.set_purple_ending(human_connection.purple_ending()); | ||
| 502 | } | ||
| 503 | |||
| 504 | if (human_connection.has_cyan_ending()) { | ||
| 505 | f_connection.set_cyan_ending(human_connection.cyan_ending()); | ||
| 506 | r_connection.set_cyan_ending(human_connection.cyan_ending()); | ||
| 507 | } | ||
| 508 | |||
| 509 | if (human_connection.has_vanilla_only()) { | ||
| 510 | f_connection.set_vanilla_only(human_connection.vanilla_only()); | ||
| 511 | r_connection.set_vanilla_only(human_connection.vanilla_only()); | ||
| 512 | } | ||
| 513 | |||
| 475 | container_.AddConnection(f_connection); | 514 | container_.AddConnection(f_connection); |
| 476 | if (!human_connection.oneway()) { | 515 | if (!human_connection.oneway()) { |
| 477 | container_.AddConnection(r_connection); | 516 | container_.AddConnection(r_connection); |
| @@ -603,6 +642,15 @@ class DataPacker { | |||
| 603 | } | 642 | } |
| 604 | } | 643 | } |
| 605 | 644 | ||
| 645 | void ProcessGlobalMetadataFile(std::filesystem::path path) { | ||
| 646 | if (!std::filesystem::exists(path)) { | ||
| 647 | return; | ||
| 648 | } | ||
| 649 | |||
| 650 | auto h_metadata = ReadMessageFromFile<HumanGlobalMetadata>(path.string()); | ||
| 651 | *container_.all_objects().mutable_version() = h_metadata.version(); | ||
| 652 | } | ||
| 653 | |||
| 606 | void ProcessIdsFile(std::filesystem::path path) { | 654 | void ProcessIdsFile(std::filesystem::path path) { |
| 607 | auto ids = ReadIdsFromYaml(path.string()); | 655 | auto ids = ReadIdsFromYaml(path.string()); |
| 608 | 656 | ||
| @@ -635,6 +683,12 @@ class DataPacker { | |||
| 635 | .mutable_keyholders(keyholder_id) | 683 | .mutable_keyholders(keyholder_id) |
| 636 | ->set_ap_id(ap_id); | 684 | ->set_ap_id(ap_id); |
| 637 | } | 685 | } |
| 686 | |||
| 687 | for (const auto& [port_name, ap_id] : room.ports()) { | ||
| 688 | uint64_t port_id = container_.FindOrAddPort( | ||
| 689 | map_name, room_name, port_name, std::nullopt, std::nullopt); | ||
| 690 | container_.all_objects().mutable_ports(port_id)->set_ap_id(ap_id); | ||
| 691 | } | ||
| 638 | } | 692 | } |
| 639 | } | 693 | } |
| 640 | 694 | ||
| diff --git a/tools/util/godot_scene.cpp b/tools/util/godot_scene.cpp index 1e77c9e..f788d21 100644 --- a/tools/util/godot_scene.cpp +++ b/tools/util/godot_scene.cpp | |||
| @@ -1,10 +1,8 @@ | |||
| 1 | #include "godot_scene.h" | 1 | #include "godot_scene.h" |
| 2 | 2 | ||
| 3 | #include <absl/strings/str_split.h> | ||
| 4 | #include <absl/strings/string_view.h> | ||
| 5 | |||
| 6 | #include <fstream> | 3 | #include <fstream> |
| 7 | #include <sstream> | 4 | #include <sstream> |
| 5 | #include <string_view> | ||
| 8 | #include <variant> | 6 | #include <variant> |
| 9 | 7 | ||
| 10 | namespace com::fourisland::lingo2_archipelago { | 8 | namespace com::fourisland::lingo2_archipelago { |
| @@ -23,7 +21,7 @@ struct Heading { | |||
| 23 | GodotInstanceType instance_type; | 21 | GodotInstanceType instance_type; |
| 24 | }; | 22 | }; |
| 25 | 23 | ||
| 26 | Heading ParseTscnHeading(absl::string_view line) { | 24 | Heading ParseTscnHeading(std::string_view line) { |
| 27 | std::string original_line(line); | 25 | std::string original_line(line); |
| 28 | Heading heading; | 26 | Heading heading; |
| 29 | 27 | ||
| diff --git a/tools/util/ids_yaml_format.cpp b/tools/util/ids_yaml_format.cpp index 71bfd63..5b9113b 100644 --- a/tools/util/ids_yaml_format.cpp +++ b/tools/util/ids_yaml_format.cpp | |||
| @@ -64,6 +64,13 @@ IdMappings ReadIdsFromYaml(const std::string& filename) { | |||
| 64 | keyholder_it.second.as<uint64_t>(); | 64 | keyholder_it.second.as<uint64_t>(); |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| 67 | |||
| 68 | if (room_it.second["ports"]) { | ||
| 69 | for (const auto& port_it : room_it.second["ports"]) { | ||
| 70 | (*room_ids.mutable_ports())[port_it.first.as<std::string>()] = | ||
| 71 | port_it.second.as<uint64_t>(); | ||
| 72 | } | ||
| 73 | } | ||
| 67 | } | 74 | } |
| 68 | } | 75 | } |
| 69 | 76 | ||
| @@ -146,6 +153,12 @@ void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) { | |||
| 146 | keyholder_id; | 153 | keyholder_id; |
| 147 | }); | 154 | }); |
| 148 | 155 | ||
| 156 | OperateOnSortedMap( | ||
| 157 | room_ids.ports(), | ||
| 158 | [&room_node](const std::string& port_name, uint64_t port_id) { | ||
| 159 | room_node["ports"][port_name] = port_id; | ||
| 160 | }); | ||
| 161 | |||
| 149 | map_node["rooms"][room_name] = std::move(room_node); | 162 | map_node["rooms"][room_name] = std::move(room_node); |
| 150 | }); | 163 | }); |
| 151 | 164 | ||
| diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index 561225e..ffa9765 100644 --- a/tools/validator/human_processor.cpp +++ b/tools/validator/human_processor.cpp | |||
| @@ -77,6 +77,21 @@ class HumanProcessor { | |||
| 77 | for (const std::string& path : metadata.excluded_nodes()) { | 77 | for (const std::string& path : metadata.excluded_nodes()) { |
| 78 | map_info.game_nodes[path].uses++; | 78 | map_info.game_nodes[path].uses++; |
| 79 | } | 79 | } |
| 80 | |||
| 81 | for (const std::string& path : metadata.custom_nodes()) { | ||
| 82 | map_info.game_nodes[path].defined = true; | ||
| 83 | } | ||
| 84 | |||
| 85 | if (metadata.has_worldport_entrance()) { | ||
| 86 | auto port_identifier = GetCompletePortIdentifier( | ||
| 87 | metadata.worldport_entrance(), current_map_name, std::nullopt); | ||
| 88 | if (port_identifier) { | ||
| 89 | PortInfo& port_info = info_.ports[*port_identifier]; | ||
| 90 | port_info.map_worldport_entrances.push_back(current_map_name); | ||
| 91 | } else { | ||
| 92 | map_info.malformed_worldport_entrance = metadata.worldport_entrance(); | ||
| 93 | } | ||
| 94 | } | ||
| 80 | } | 95 | } |
| 81 | 96 | ||
| 82 | void ProcessRooms(std::filesystem::path path, | 97 | void ProcessRooms(std::filesystem::path path, |
| @@ -358,11 +373,6 @@ class HumanProcessor { | |||
| 358 | DoorInfo& other_door_info = info_.doors[complete_door_identifier]; | 373 | DoorInfo& other_door_info = info_.doors[complete_door_identifier]; |
| 359 | other_door_info.doors_referenced_by.push_back(door_identifier); | 374 | other_door_info.doors_referenced_by.push_back(door_identifier); |
| 360 | } | 375 | } |
| 361 | |||
| 362 | for (const std::string& ei : h_door.endings()) { | ||
| 363 | EndingInfo& ending_info = info_.endings[ei]; | ||
| 364 | ending_info.doors_referenced_by.push_back(door_identifier); | ||
| 365 | } | ||
| 366 | } | 376 | } |
| 367 | 377 | ||
| 368 | void ProcessConnectionsFile(std::filesystem::path path, | 378 | void ProcessConnectionsFile(std::filesystem::path path, |
| @@ -394,7 +404,9 @@ class HumanProcessor { | |||
| 394 | } | 404 | } |
| 395 | } else if (human_connection.has_from()) { | 405 | } else if (human_connection.has_from()) { |
| 396 | ProcessSingleConnection(human_connection, human_connection.from(), | 406 | ProcessSingleConnection(human_connection, human_connection.from(), |
| 397 | current_map_name); | 407 | current_map_name, |
| 408 | /*is_target=*/!human_connection.oneway() && | ||
| 409 | !human_connection.bypass_target_door()); | ||
| 398 | } | 410 | } |
| 399 | 411 | ||
| 400 | if (human_connection.has_to_room()) { | 412 | if (human_connection.has_to_room()) { |
| @@ -410,8 +422,9 @@ class HumanProcessor { | |||
| 410 | std::cout << "A global connection used to_room." << std::endl; | 422 | std::cout << "A global connection used to_room." << std::endl; |
| 411 | } | 423 | } |
| 412 | } else if (human_connection.has_to()) { | 424 | } else if (human_connection.has_to()) { |
| 413 | ProcessSingleConnection(human_connection, human_connection.to(), | 425 | ProcessSingleConnection( |
| 414 | current_map_name); | 426 | human_connection, human_connection.to(), current_map_name, |
| 427 | /*is_target=*/!human_connection.bypass_target_door()); | ||
| 415 | } | 428 | } |
| 416 | 429 | ||
| 417 | if (human_connection.has_door()) { | 430 | if (human_connection.has_door()) { |
| @@ -432,7 +445,7 @@ class HumanProcessor { | |||
| 432 | void ProcessSingleConnection( | 445 | void ProcessSingleConnection( |
| 433 | const HumanConnection& human_connection, | 446 | const HumanConnection& human_connection, |
| 434 | const HumanConnection::Endpoint& endpoint, | 447 | const HumanConnection::Endpoint& endpoint, |
| 435 | const std::optional<std::string>& current_map_name) { | 448 | const std::optional<std::string>& current_map_name, bool is_target) { |
| 436 | if (endpoint.has_room()) { | 449 | if (endpoint.has_room()) { |
| 437 | auto room_identifier = | 450 | auto room_identifier = |
| 438 | GetCompleteRoomIdentifier(endpoint.room(), current_map_name); | 451 | GetCompleteRoomIdentifier(endpoint.room(), current_map_name); |
| @@ -451,6 +464,11 @@ class HumanProcessor { | |||
| 451 | if (painting_identifier) { | 464 | if (painting_identifier) { |
| 452 | PaintingInfo& painting_info = info_.paintings[*painting_identifier]; | 465 | PaintingInfo& painting_info = info_.paintings[*painting_identifier]; |
| 453 | painting_info.connections_referenced_by.push_back(human_connection); | 466 | painting_info.connections_referenced_by.push_back(human_connection); |
| 467 | |||
| 468 | if (is_target) { | ||
| 469 | painting_info.target_connections_referenced_by.push_back( | ||
| 470 | human_connection); | ||
| 471 | } | ||
| 454 | } else { | 472 | } else { |
| 455 | // Not sure where else to store this right now. | 473 | // Not sure where else to store this right now. |
| 456 | std::cout | 474 | std::cout |
| @@ -463,6 +481,11 @@ class HumanProcessor { | |||
| 463 | if (port_identifier) { | 481 | if (port_identifier) { |
| 464 | PortInfo& port_info = info_.ports[*port_identifier]; | 482 | PortInfo& port_info = info_.ports[*port_identifier]; |
| 465 | port_info.connections_referenced_by.push_back(human_connection); | 483 | port_info.connections_referenced_by.push_back(human_connection); |
| 484 | |||
| 485 | if (is_target) { | ||
| 486 | port_info.target_connections_referenced_by.push_back( | ||
| 487 | human_connection); | ||
| 488 | } | ||
| 466 | } else { | 489 | } else { |
| 467 | // Not sure where else to store this right now. | 490 | // Not sure where else to store this right now. |
| 468 | std::cout | 491 | std::cout |
| @@ -480,6 +503,11 @@ class HumanProcessor { | |||
| 480 | panel_info.proxies[endpoint.panel().answer()] | 503 | panel_info.proxies[endpoint.panel().answer()] |
| 481 | .connections_referenced_by.push_back(human_connection); | 504 | .connections_referenced_by.push_back(human_connection); |
| 482 | } | 505 | } |
| 506 | |||
| 507 | if (is_target) { | ||
| 508 | panel_info.target_connections_referenced_by.push_back( | ||
| 509 | human_connection); | ||
| 510 | } | ||
| 483 | } | 511 | } |
| 484 | } | 512 | } |
| 485 | } | 513 | } |
| @@ -542,12 +570,14 @@ class HumanProcessor { | |||
| 542 | auto ids = ReadIdsFromYaml(path.string()); | 570 | auto ids = ReadIdsFromYaml(path.string()); |
| 543 | 571 | ||
| 544 | DoorIdentifier di; | 572 | DoorIdentifier di; |
| 545 | PanelIdentifier pi; | 573 | PanelIdentifier pai; |
| 574 | PortIdentifier poi; | ||
| 546 | KeyholderIdentifier ki; | 575 | KeyholderIdentifier ki; |
| 547 | 576 | ||
| 548 | for (const auto& [map_name, map] : ids.maps()) { | 577 | for (const auto& [map_name, map] : ids.maps()) { |
| 549 | di.set_map(map_name); | 578 | di.set_map(map_name); |
| 550 | pi.set_map(map_name); | 579 | pai.set_map(map_name); |
| 580 | poi.set_map(map_name); | ||
| 551 | ki.set_map(map_name); | 581 | ki.set_map(map_name); |
| 552 | 582 | ||
| 553 | for (const auto& [door_name, ap_id] : map.doors()) { | 583 | for (const auto& [door_name, ap_id] : map.doors()) { |
| @@ -558,13 +588,14 @@ class HumanProcessor { | |||
| 558 | } | 588 | } |
| 559 | 589 | ||
| 560 | for (const auto& [room_name, room] : map.rooms()) { | 590 | for (const auto& [room_name, room] : map.rooms()) { |
| 561 | pi.set_room(room_name); | 591 | pai.set_room(room_name); |
| 592 | poi.set_room(room_name); | ||
| 562 | ki.set_room(room_name); | 593 | ki.set_room(room_name); |
| 563 | 594 | ||
| 564 | for (const auto& [panel_name, ap_id] : room.panels()) { | 595 | for (const auto& [panel_name, ap_id] : room.panels()) { |
| 565 | pi.set_name(panel_name); | 596 | pai.set_name(panel_name); |
| 566 | 597 | ||
| 567 | PanelInfo& panel_info = info_.panels[pi]; | 598 | PanelInfo& panel_info = info_.panels[pai]; |
| 568 | panel_info.has_id = true; | 599 | panel_info.has_id = true; |
| 569 | } | 600 | } |
| 570 | 601 | ||
| @@ -578,6 +609,13 @@ class HumanProcessor { | |||
| 578 | KeyholderInfo& keyholder_info = info_.keyholders[ki]; | 609 | KeyholderInfo& keyholder_info = info_.keyholders[ki]; |
| 579 | keyholder_info.has_id = true; | 610 | keyholder_info.has_id = true; |
| 580 | } | 611 | } |
| 612 | |||
| 613 | for (const auto& [port_name, ap_id] : room.ports()) { | ||
| 614 | poi.set_name(port_name); | ||
| 615 | |||
| 616 | PortInfo& port_info = info_.ports[poi]; | ||
| 617 | port_info.has_id = true; | ||
| 618 | } | ||
| 581 | } | 619 | } |
| 582 | } | 620 | } |
| 583 | 621 | ||
| diff --git a/tools/validator/structs.h b/tools/validator/structs.h index 17ed33a..62974a8 100644 --- a/tools/validator/structs.h +++ b/tools/validator/structs.h | |||
| @@ -27,6 +27,8 @@ struct GameNodeInfo { | |||
| 27 | 27 | ||
| 28 | struct MapInfo { | 28 | struct MapInfo { |
| 29 | std::map<std::string, GameNodeInfo> game_nodes; | 29 | std::map<std::string, GameNodeInfo> game_nodes; |
| 30 | |||
| 31 | std::optional<PortIdentifier> malformed_worldport_entrance; | ||
| 30 | }; | 32 | }; |
| 31 | 33 | ||
| 32 | struct RoomInfo { | 34 | struct RoomInfo { |
| @@ -54,14 +56,18 @@ struct DoorInfo { | |||
| 54 | 56 | ||
| 55 | struct PortInfo { | 57 | struct PortInfo { |
| 56 | std::vector<HumanPort> definitions; | 58 | std::vector<HumanPort> definitions; |
| 59 | bool has_id = false; | ||
| 57 | 60 | ||
| 58 | std::vector<HumanConnection> connections_referenced_by; | 61 | std::vector<HumanConnection> connections_referenced_by; |
| 62 | std::vector<HumanConnection> target_connections_referenced_by; | ||
| 63 | std::vector<std::string> map_worldport_entrances; | ||
| 59 | }; | 64 | }; |
| 60 | 65 | ||
| 61 | struct PaintingInfo { | 66 | struct PaintingInfo { |
| 62 | std::vector<HumanPainting> definitions; | 67 | std::vector<HumanPainting> definitions; |
| 63 | 68 | ||
| 64 | std::vector<HumanConnection> connections_referenced_by; | 69 | std::vector<HumanConnection> connections_referenced_by; |
| 70 | std::vector<HumanConnection> target_connections_referenced_by; | ||
| 65 | std::vector<DoorIdentifier> doors_referenced_by; | 71 | std::vector<DoorIdentifier> doors_referenced_by; |
| 66 | }; | 72 | }; |
| 67 | 73 | ||
| @@ -79,6 +85,7 @@ struct PanelInfo { | |||
| 79 | std::string map_area_name; | 85 | std::string map_area_name; |
| 80 | 86 | ||
| 81 | std::vector<HumanConnection> connections_referenced_by; | 87 | std::vector<HumanConnection> connections_referenced_by; |
| 88 | std::vector<HumanConnection> target_connections_referenced_by; | ||
| 82 | std::vector<DoorIdentifier> doors_referenced_by; | 89 | std::vector<DoorIdentifier> doors_referenced_by; |
| 83 | 90 | ||
| 84 | std::map<std::string, ProxyInfo> proxies; | 91 | std::map<std::string, ProxyInfo> proxies; |
| @@ -101,8 +108,6 @@ struct LetterInfo { | |||
| 101 | struct EndingInfo { | 108 | struct EndingInfo { |
| 102 | std::vector<RoomIdentifier> defined_in; | 109 | std::vector<RoomIdentifier> defined_in; |
| 103 | bool has_id = false; | 110 | bool has_id = false; |
| 104 | |||
| 105 | std::vector<DoorIdentifier> doors_referenced_by; | ||
| 106 | }; | 111 | }; |
| 107 | 112 | ||
| 108 | struct PanelNameInfo { | 113 | struct PanelNameInfo { |
| diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index 4149caa..fe36be7 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp | |||
| @@ -69,6 +69,11 @@ class Validator { | |||
| 69 | << " is not defined in the game file." << std::endl; | 69 | << " is not defined in the game file." << std::endl; |
| 70 | } | 70 | } |
| 71 | } | 71 | } |
| 72 | |||
| 73 | if (map_info.malformed_worldport_entrance) { | ||
| 74 | std::cout << "The worldport entrance for map " << map_name | ||
| 75 | << " is malformed." << std::endl; | ||
| 76 | } | ||
| 72 | } | 77 | } |
| 73 | 78 | ||
| 74 | void ValidateRoom(const RoomIdentifier& room_identifier, | 79 | void ValidateRoom(const RoomIdentifier& room_identifier, |
| @@ -106,7 +111,8 @@ class Validator { | |||
| 106 | return false; | 111 | return false; |
| 107 | } | 112 | } |
| 108 | 113 | ||
| 109 | if (h_door.keyholders_size() > 0 || h_door.endings_size() > 0) { | 114 | if (h_door.keyholders_size() > 0 || h_door.white_ending() || |
| 115 | h_door.complete_at() > 0) { | ||
| 110 | return true; | 116 | return true; |
| 111 | } | 117 | } |
| 112 | 118 | ||
| @@ -219,16 +225,23 @@ class Validator { | |||
| 219 | << " needs an explicit location name." << std::endl; | 225 | << " needs an explicit location name." << std::endl; |
| 220 | } | 226 | } |
| 221 | 227 | ||
| 222 | if (h_door.double_letters() && | 228 | if (h_door.type() == DoorType::STANDARD || |
| 223 | (h_door.type() == DoorType::STANDARD || | 229 | h_door.type() == DoorType::LOCATION_ONLY || |
| 224 | h_door.type() == DoorType::LOCATION_ONLY || | 230 | h_door.type() == DoorType::GRAVESTONE || h_door.legacy_location()) { |
| 225 | h_door.type() == DoorType::GRAVESTONE)) { | 231 | if (h_door.double_letters()) { |
| 226 | std::cout << "Door " << door_identifier.ShortDebugString() | 232 | std::cout << "Door " << door_identifier.ShortDebugString() |
| 227 | << " is a location that depends on double_letters." | 233 | << " is a location that depends on double_letters." |
| 228 | << std::endl; | 234 | << std::endl; |
| 235 | } | ||
| 236 | |||
| 237 | if (!h_door.has_location_room()) { | ||
| 238 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 239 | << " is missing a location_room." << std::endl; | ||
| 240 | } | ||
| 229 | } | 241 | } |
| 230 | 242 | ||
| 231 | bool needs_id = (h_door.type() != DoorType::EVENT); | 243 | bool needs_id = (h_door.type() != DoorType::EVENT || h_door.latch() || |
| 244 | h_door.legacy_location()); | ||
| 232 | if (door_info.has_id != needs_id) { | 245 | if (door_info.has_id != needs_id) { |
| 233 | if (needs_id) { | 246 | if (needs_id) { |
| 234 | std::cout << "Door " << door_identifier.ShortDebugString() | 247 | std::cout << "Door " << door_identifier.ShortDebugString() |
| @@ -252,10 +265,57 @@ class Validator { | |||
| 252 | std::cout << " CONNECTION " << connection.ShortDebugString() | 265 | std::cout << " CONNECTION " << connection.ShortDebugString() |
| 253 | << std::endl; | 266 | << std::endl; |
| 254 | } | 267 | } |
| 268 | |||
| 269 | for (const std::string& map_name : port_info.map_worldport_entrances) { | ||
| 270 | std::cout << " MAP (worldport_entrance) " << map_name << std::endl; | ||
| 271 | } | ||
| 272 | |||
| 273 | if (port_info.has_id) { | ||
| 274 | std::cout << " An AP ID is present." << std::endl; | ||
| 275 | } | ||
| 255 | } else if (port_info.definitions.size() > 1) { | 276 | } else if (port_info.definitions.size() > 1) { |
| 256 | std::cout << "Port " << port_identifier.ShortDebugString() | 277 | std::cout << "Port " << port_identifier.ShortDebugString() |
| 257 | << " was defined multiple times." << std::endl; | 278 | << " was defined multiple times." << std::endl; |
| 258 | } | 279 | } |
| 280 | |||
| 281 | if (!port_info.target_connections_referenced_by.empty()) { | ||
| 282 | for (const HumanPort& port : port_info.definitions) { | ||
| 283 | if (port.has_required_door()) { | ||
| 284 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 285 | << " has a required door but is the target of a connection:" | ||
| 286 | << std::endl; | ||
| 287 | |||
| 288 | for (const HumanConnection& connection : | ||
| 289 | port_info.target_connections_referenced_by) { | ||
| 290 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 291 | << std::endl; | ||
| 292 | } | ||
| 293 | } | ||
| 294 | } | ||
| 295 | } | ||
| 296 | |||
| 297 | for (const HumanPort& port : port_info.definitions) { | ||
| 298 | if (!port.no_shuffle()) { | ||
| 299 | if (!port.has_destination()) { | ||
| 300 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 301 | << " is shuffleable and missing a destination." | ||
| 302 | << std::endl; | ||
| 303 | } | ||
| 304 | if (!port.has_rotation()) { | ||
| 305 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 306 | << " is shuffleable and missing a rotation." << std::endl; | ||
| 307 | } | ||
| 308 | if (!port_info.has_id) { | ||
| 309 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 310 | << " is missing an AP ID." << std::endl; | ||
| 311 | } | ||
| 312 | } else { | ||
| 313 | if (port_info.has_id) { | ||
| 314 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 315 | << " should not have an AP ID." << std::endl; | ||
| 316 | } | ||
| 317 | } | ||
| 318 | } | ||
| 259 | } | 319 | } |
| 260 | 320 | ||
| 261 | void ValidatePainting(const PaintingIdentifier& painting_identifier, | 321 | void ValidatePainting(const PaintingIdentifier& painting_identifier, |
| @@ -279,6 +339,22 @@ class Validator { | |||
| 279 | std::cout << "Painting " << painting_identifier.ShortDebugString() | 339 | std::cout << "Painting " << painting_identifier.ShortDebugString() |
| 280 | << " was defined multiple times." << std::endl; | 340 | << " was defined multiple times." << std::endl; |
| 281 | } | 341 | } |
| 342 | |||
| 343 | if (!painting_info.target_connections_referenced_by.empty()) { | ||
| 344 | for (const HumanPainting& painting : painting_info.definitions) { | ||
| 345 | if (painting.has_required_door()) { | ||
| 346 | std::cout << "Painting " << painting_identifier.ShortDebugString() | ||
| 347 | << " has a required door but is the target of a connection:" | ||
| 348 | << std::endl; | ||
| 349 | |||
| 350 | for (const HumanConnection& connection : | ||
| 351 | painting_info.target_connections_referenced_by) { | ||
| 352 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 353 | << std::endl; | ||
| 354 | } | ||
| 355 | } | ||
| 356 | } | ||
| 357 | } | ||
| 282 | } | 358 | } |
| 283 | 359 | ||
| 284 | void ValidatePanel(const PanelIdentifier& panel_identifier, | 360 | void ValidatePanel(const PanelIdentifier& panel_identifier, |
| @@ -340,6 +416,22 @@ class Validator { | |||
| 340 | std::cout << "Panel " << panel_identifier.ShortDebugString() | 416 | std::cout << "Panel " << panel_identifier.ShortDebugString() |
| 341 | << " is missing an AP ID." << std::endl; | 417 | << " is missing an AP ID." << std::endl; |
| 342 | } | 418 | } |
| 419 | |||
| 420 | if (!panel_info.target_connections_referenced_by.empty()) { | ||
| 421 | for (const HumanPanel& panel : panel_info.definitions) { | ||
| 422 | if (panel.has_required_door()) { | ||
| 423 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 424 | << " has a required door but is the target of a connection:" | ||
| 425 | << std::endl; | ||
| 426 | |||
| 427 | for (const HumanConnection& connection : | ||
| 428 | panel_info.target_connections_referenced_by) { | ||
| 429 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 430 | << std::endl; | ||
| 431 | } | ||
| 432 | } | ||
| 433 | } | ||
| 434 | } | ||
| 343 | } | 435 | } |
| 344 | 436 | ||
| 345 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, | 437 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, |
| @@ -410,12 +502,6 @@ class Validator { | |||
| 410 | std::cout << "Ending " << ending_name | 502 | std::cout << "Ending " << ending_name |
| 411 | << " has no definition, but was referenced:" << std::endl; | 503 | << " has no definition, but was referenced:" << std::endl; |
| 412 | 504 | ||
| 413 | for (const DoorIdentifier& door_identifier : | ||
| 414 | ending_info.doors_referenced_by) { | ||
| 415 | std::cout << " DOOR " << door_identifier.ShortDebugString() | ||
| 416 | << std::endl; | ||
| 417 | } | ||
| 418 | |||
| 419 | if (ending_info.has_id) { | 505 | if (ending_info.has_id) { |
| 420 | std::cout << " An AP ID is present." << std::endl; | 506 | std::cout << " An AP ID is present." << std::endl; |
| 421 | } | 507 | } |
| 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 | ||
| 4 | namespace com::fourisland::lingo2_archipelago { | 4 | namespace com::fourisland::lingo2_archipelago { |
