diff options
Diffstat (limited to 'tools/assign_ids/main.cpp')
| -rw-r--r-- | tools/assign_ids/main.cpp | 35 |
1 files changed, 32 insertions, 3 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 | ||
