diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/assign_ids/main.cpp | 35 | ||||
| -rw-r--r-- | tools/datapacker/main.cpp | 5 | ||||
| -rw-r--r-- | tools/util/ids_yaml_format.cpp | 8 | ||||
| -rw-r--r-- | tools/validator/human_processor.cpp | 16 | ||||
| -rw-r--r-- | tools/validator/main.cpp | 4 | ||||
| -rw-r--r-- | tools/validator/structs.h | 4 | ||||
| -rw-r--r-- | tools/validator/validator.cpp | 21 |
7 files changed, 89 insertions, 4 deletions
| diff --git a/tools/assign_ids/main.cpp b/tools/assign_ids/main.cpp index 4cf7c3f..4a48b86 100644 --- a/tools/assign_ids/main.cpp +++ b/tools/assign_ids/main.cpp | |||
| @@ -67,6 +67,10 @@ class AssignIds { | |||
| 67 | UpdateNextId(room.keyholders()); | 67 | UpdateNextId(room.keyholders()); |
| 68 | UpdateNextId(room.ports()); | 68 | UpdateNextId(room.ports()); |
| 69 | } | 69 | } |
| 70 | |||
| 71 | if (map.has_rte()) { | ||
| 72 | UpdateNextId(map.rte()); | ||
| 73 | } | ||
| 70 | } | 74 | } |
| 71 | 75 | ||
| 72 | UpdateNextId(id_mappings_.special()); | 76 | UpdateNextId(id_mappings_.special()); |
| @@ -93,10 +97,31 @@ class AssignIds { | |||
| 93 | void ProcessMap(std::filesystem::path path) { | 97 | void ProcessMap(std::filesystem::path path) { |
| 94 | std::string map_name = path.filename().string(); | 98 | std::string map_name = path.filename().string(); |
| 95 | 99 | ||
| 100 | ProcessMapMetadata(path / "metadata.txtpb", map_name); | ||
| 96 | ProcessDoorsFile(path / "doors.txtpb", map_name); | 101 | ProcessDoorsFile(path / "doors.txtpb", map_name); |
| 97 | ProcessRooms(path / "rooms", map_name); | 102 | ProcessRooms(path / "rooms", map_name); |
| 98 | } | 103 | } |
| 99 | 104 | ||
| 105 | void ProcessMapMetadata(std::filesystem::path path, | ||
| 106 | const std::string& current_map_name) { | ||
| 107 | if (!std::filesystem::exists(path)) { | ||
| 108 | return; | ||
| 109 | } | ||
| 110 | |||
| 111 | auto metadata = ReadMessageFromFile<HumanMap>(path.string()); | ||
| 112 | auto& maps = *output_.mutable_maps(); | ||
| 113 | |||
| 114 | if (metadata.has_rte_room()) { | ||
| 115 | if (!id_mappings_.maps().contains(current_map_name) || | ||
| 116 | !id_mappings_.maps().at(current_map_name).has_rte()) { | ||
| 117 | maps[current_map_name].set_rte(next_id_++); | ||
| 118 | } else { | ||
| 119 | maps[current_map_name].set_rte( | ||
| 120 | id_mappings_.maps().at(current_map_name).rte()); | ||
| 121 | } | ||
| 122 | } | ||
| 123 | } | ||
| 124 | |||
| 100 | void ProcessDoorsFile(std::filesystem::path path, | 125 | void ProcessDoorsFile(std::filesystem::path path, |
| 101 | const std::string& current_map_name) { | 126 | const std::string& current_map_name) { |
| 102 | if (!std::filesystem::exists(path)) { | 127 | if (!std::filesystem::exists(path)) { |
| @@ -342,9 +367,13 @@ class AssignIds { | |||
| 342 | private: | 367 | private: |
| 343 | void UpdateNextId(const google::protobuf::Map<std::string, uint64_t>& ids) { | 368 | void UpdateNextId(const google::protobuf::Map<std::string, uint64_t>& ids) { |
| 344 | for (const auto& [_, id] : ids) { | 369 | for (const auto& [_, id] : ids) { |
| 345 | if (id > next_id_) { | 370 | UpdateNextId(id); |
| 346 | next_id_ = id; | 371 | } |
| 347 | } | 372 | } |
| 373 | |||
| 374 | void UpdateNextId(uint64_t id) { | ||
| 375 | if (id > next_id_) { | ||
| 376 | next_id_ = id; | ||
| 348 | } | 377 | } |
| 349 | } | 378 | } |
| 350 | 379 | ||
| diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index 953821f..4b74217 100644 --- a/tools/datapacker/main.cpp +++ b/tools/datapacker/main.cpp | |||
| @@ -100,6 +100,11 @@ class DataPacker { | |||
| 100 | map_name, metadata.worldport_entrance().room(), | 100 | map_name, metadata.worldport_entrance().room(), |
| 101 | metadata.worldport_entrance().name(), std::nullopt, std::nullopt)); | 101 | metadata.worldport_entrance().name(), std::nullopt, std::nullopt)); |
| 102 | } | 102 | } |
| 103 | |||
| 104 | if (metadata.has_rte_room()) { | ||
| 105 | map.set_rte_room(container_.FindOrAddRoom(map_name, metadata.rte_room(), | ||
| 106 | std::nullopt)); | ||
| 107 | } | ||
| 103 | } | 108 | } |
| 104 | 109 | ||
| 105 | void ProcessRooms(std::filesystem::path path, | 110 | void ProcessRooms(std::filesystem::path path, |
| diff --git a/tools/util/ids_yaml_format.cpp b/tools/util/ids_yaml_format.cpp index 5b9113b..c23c66b 100644 --- a/tools/util/ids_yaml_format.cpp +++ b/tools/util/ids_yaml_format.cpp | |||
| @@ -80,6 +80,10 @@ IdMappings ReadIdsFromYaml(const std::string& filename) { | |||
| 80 | door_it.second.as<uint64_t>(); | 80 | door_it.second.as<uint64_t>(); |
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | |||
| 84 | if (map_it.second["rte"]) { | ||
| 85 | map_ids.set_rte(map_it.second["rte"].as<uint64_t>()); | ||
| 86 | } | ||
| 83 | } | 87 | } |
| 84 | } | 88 | } |
| 85 | 89 | ||
| @@ -168,6 +172,10 @@ void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) { | |||
| 168 | map_node["doors"][door_name] = door_id; | 172 | map_node["doors"][door_name] = door_id; |
| 169 | }); | 173 | }); |
| 170 | 174 | ||
| 175 | if (map_ids.has_rte()) { | ||
| 176 | map_node["rte"] = map_ids.rte(); | ||
| 177 | } | ||
| 178 | |||
| 171 | result["maps"][map_name] = std::move(map_node); | 179 | result["maps"][map_name] = std::move(map_node); |
| 172 | }); | 180 | }); |
| 173 | 181 | ||
| diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index ffa9765..d6fcfa6 100644 --- a/tools/validator/human_processor.cpp +++ b/tools/validator/human_processor.cpp | |||
| @@ -74,6 +74,8 @@ class HumanProcessor { | |||
| 74 | MapInfo& map_info = info_.maps[current_map_name]; | 74 | MapInfo& map_info = info_.maps[current_map_name]; |
| 75 | 75 | ||
| 76 | auto metadata = ReadMessageFromFile<HumanMap>(path.string()); | 76 | auto metadata = ReadMessageFromFile<HumanMap>(path.string()); |
| 77 | map_info.definitions.push_back(metadata); | ||
| 78 | |||
| 77 | for (const std::string& path : metadata.excluded_nodes()) { | 79 | for (const std::string& path : metadata.excluded_nodes()) { |
| 78 | map_info.game_nodes[path].uses++; | 80 | map_info.game_nodes[path].uses++; |
| 79 | } | 81 | } |
| @@ -92,6 +94,15 @@ class HumanProcessor { | |||
| 92 | map_info.malformed_worldport_entrance = metadata.worldport_entrance(); | 94 | map_info.malformed_worldport_entrance = metadata.worldport_entrance(); |
| 93 | } | 95 | } |
| 94 | } | 96 | } |
| 97 | |||
| 98 | if (metadata.has_rte_room()) { | ||
| 99 | RoomIdentifier room_identifier; | ||
| 100 | room_identifier.set_map(current_map_name); | ||
| 101 | room_identifier.set_name(metadata.rte_room()); | ||
| 102 | |||
| 103 | RoomInfo& room_info = info_.rooms[room_identifier]; | ||
| 104 | room_info.map_rtes_referenced_by.push_back(current_map_name); | ||
| 105 | } | ||
| 95 | } | 106 | } |
| 96 | 107 | ||
| 97 | void ProcessRooms(std::filesystem::path path, | 108 | void ProcessRooms(std::filesystem::path path, |
| @@ -617,6 +628,11 @@ class HumanProcessor { | |||
| 617 | port_info.has_id = true; | 628 | port_info.has_id = true; |
| 618 | } | 629 | } |
| 619 | } | 630 | } |
| 631 | |||
| 632 | if (map.has_rte()) { | ||
| 633 | MapInfo& map_info = info_.maps[map_name]; | ||
| 634 | map_info.has_rte_id = true; | ||
| 635 | } | ||
| 620 | } | 636 | } |
| 621 | 637 | ||
| 622 | for (const auto& [tag, id] : ids.special()) { | 638 | for (const auto& [tag, id] : ids.special()) { |
| diff --git a/tools/validator/main.cpp b/tools/validator/main.cpp index 1a72e9a..6139e95 100644 --- a/tools/validator/main.cpp +++ b/tools/validator/main.cpp | |||
| @@ -21,7 +21,9 @@ void Run(const std::string& mapdir, const std::string& repodir) { | |||
| 21 | int main(int argc, char** argv) { | 21 | int main(int argc, char** argv) { |
| 22 | if (argc != 3) { | 22 | if (argc != 3) { |
| 23 | std::cout << "Incorrect argument count." << std::endl; | 23 | std::cout << "Incorrect argument count." << std::endl; |
| 24 | std::cout << "Usage: validator [path to map directory] [path to Lingo 2 repository]" << std::endl; | 24 | std::cout << "Usage: validator [path to map directory] [path to Lingo 2 " |
| 25 | "repository]" | ||
| 26 | << std::endl; | ||
| 25 | return 1; | 27 | return 1; |
| 26 | } | 28 | } |
| 27 | 29 | ||
| diff --git a/tools/validator/structs.h b/tools/validator/structs.h index 62974a8..81a0e8f 100644 --- a/tools/validator/structs.h +++ b/tools/validator/structs.h | |||
| @@ -28,6 +28,9 @@ struct GameNodeInfo { | |||
| 28 | struct MapInfo { | 28 | struct MapInfo { |
| 29 | std::map<std::string, GameNodeInfo> game_nodes; | 29 | std::map<std::string, GameNodeInfo> game_nodes; |
| 30 | 30 | ||
| 31 | std::vector<HumanMap> definitions; | ||
| 32 | bool has_rte_id = false; | ||
| 33 | |||
| 31 | std::optional<PortIdentifier> malformed_worldport_entrance; | 34 | std::optional<PortIdentifier> malformed_worldport_entrance; |
| 32 | }; | 35 | }; |
| 33 | 36 | ||
| @@ -37,6 +40,7 @@ struct RoomInfo { | |||
| 37 | std::vector<DoorIdentifier> doors_referenced_by; | 40 | std::vector<DoorIdentifier> doors_referenced_by; |
| 38 | std::vector<PanelIdentifier> panels_referenced_by; | 41 | std::vector<PanelIdentifier> panels_referenced_by; |
| 39 | std::vector<HumanConnection> connections_referenced_by; | 42 | std::vector<HumanConnection> connections_referenced_by; |
| 43 | std::vector<std::string> map_rtes_referenced_by; | ||
| 40 | }; | 44 | }; |
| 41 | 45 | ||
| 42 | struct DoorInfo { | 46 | struct DoorInfo { |
| diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index fe36be7..e9fbb74 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #include "validator.h" | 1 | #include "validator.h" |
| 2 | 2 | ||
| 3 | #include <algorithm> | ||
| 3 | #include <iostream> | 4 | #include <iostream> |
| 4 | 5 | ||
| 5 | #include "proto/human.pb.h" | 6 | #include "proto/human.pb.h" |
| @@ -74,6 +75,22 @@ class Validator { | |||
| 74 | std::cout << "The worldport entrance for map " << map_name | 75 | std::cout << "The worldport entrance for map " << map_name |
| 75 | << " is malformed." << std::endl; | 76 | << " is malformed." << std::endl; |
| 76 | } | 77 | } |
| 78 | |||
| 79 | if (map_info.has_rte_id) { | ||
| 80 | if (!std::any_of( | ||
| 81 | map_info.definitions.begin(), map_info.definitions.end(), | ||
| 82 | [](const HumanMap& h_map) { return h_map.has_rte_room(); })) { | ||
| 83 | std::cout << "Map " << map_name << " has an RTE ID but no RTE room." | ||
| 84 | << std::endl; | ||
| 85 | } | ||
| 86 | } else { | ||
| 87 | if (std::any_of( | ||
| 88 | map_info.definitions.begin(), map_info.definitions.end(), | ||
| 89 | [](const HumanMap& h_map) { return h_map.has_rte_room(); })) { | ||
| 90 | std::cout << "Map " << map_name << " has an RTE room but no RTE ID." | ||
| 91 | << std::endl; | ||
| 92 | } | ||
| 93 | } | ||
| 77 | } | 94 | } |
| 78 | 95 | ||
| 79 | void ValidateRoom(const RoomIdentifier& room_identifier, | 96 | void ValidateRoom(const RoomIdentifier& room_identifier, |
| @@ -99,6 +116,10 @@ class Validator { | |||
| 99 | std::cout << " CONNECTION " << connection.ShortDebugString() | 116 | std::cout << " CONNECTION " << connection.ShortDebugString() |
| 100 | << std::endl; | 117 | << std::endl; |
| 101 | } | 118 | } |
| 119 | |||
| 120 | for (const std::string& map_name : room_info.map_rtes_referenced_by) { | ||
| 121 | std::cout << " MAP RTE " << map_name << std::endl; | ||
| 122 | } | ||
| 102 | } else if (room_info.definitions.size() > 1) { | 123 | } else if (room_info.definitions.size() > 1) { |
| 103 | std::cout << "Room " << room_identifier.ShortDebugString() | 124 | std::cout << "Room " << room_identifier.ShortDebugString() |
| 104 | << " was defined multiple times." << std::endl; | 125 | << " was defined multiple times." << std::endl; |
