diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/assign_ids/main.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
| diff --git a/tools/assign_ids/main.cpp b/tools/assign_ids/main.cpp index ee55338..3e16f78 100644 --- a/tools/assign_ids/main.cpp +++ b/tools/assign_ids/main.cpp | |||
| @@ -44,6 +44,7 @@ class AssignIds { | |||
| 44 | ProcessSpecialIds(); | 44 | ProcessSpecialIds(); |
| 45 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); | 45 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); |
| 46 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); | 46 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); |
| 47 | ProcessGlobalMetadataFile(datadir_path / "metadata.txtpb"); | ||
| 47 | 48 | ||
| 48 | WriteIds(ids_path); | 49 | WriteIds(ids_path); |
| 49 | 50 | ||
| @@ -288,6 +289,23 @@ class AssignIds { | |||
| 288 | } | 289 | } |
| 289 | } | 290 | } |
| 290 | 291 | ||
| 292 | void ProcessGlobalMetadataFile(std::filesystem::path path) { | ||
| 293 | if (!std::filesystem::exists(path)) { | ||
| 294 | return; | ||
| 295 | } | ||
| 296 | |||
| 297 | auto h_metadata = ReadMessageFromFile<HumanGlobalMetadata>(path.string()); | ||
| 298 | auto& specials = *output_.mutable_special(); | ||
| 299 | |||
| 300 | for (const std::string& h_special : h_metadata.special_names()) { | ||
| 301 | if (!id_mappings_.special().contains(h_special)) { | ||
| 302 | specials[h_special] = next_id_++; | ||
| 303 | } else { | ||
| 304 | specials[h_special] = id_mappings_.special().at(h_special); | ||
| 305 | } | ||
| 306 | } | ||
| 307 | } | ||
| 308 | |||
| 291 | private: | 309 | private: |
| 292 | void UpdateNextId(const google::protobuf::Map<std::string, uint64_t>& ids) { | 310 | void UpdateNextId(const google::protobuf::Map<std::string, uint64_t>& ids) { |
| 293 | for (const auto& [_, id] : ids) { | 311 | for (const auto& [_, id] : ids) { |
