diff options
Diffstat (limited to 'tools/assign_ids')
| -rw-r--r-- | tools/assign_ids/main.cpp | 64 |
1 files changed, 31 insertions, 33 deletions
| diff --git a/tools/assign_ids/main.cpp b/tools/assign_ids/main.cpp index e65e5e4..3a2f347 100644 --- a/tools/assign_ids/main.cpp +++ b/tools/assign_ids/main.cpp | |||
| @@ -40,6 +40,7 @@ class AssignIds { | |||
| 40 | ReadIds(ids_path); | 40 | ReadIds(ids_path); |
| 41 | 41 | ||
| 42 | ProcessMaps(datadir_path); | 42 | ProcessMaps(datadir_path); |
| 43 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); | ||
| 43 | 44 | ||
| 44 | WriteIds(ids_path); | 45 | WriteIds(ids_path); |
| 45 | 46 | ||
| @@ -54,44 +55,18 @@ class AssignIds { | |||
| 54 | id_mappings_ = ReadIdsFromYaml(path.string()); | 55 | id_mappings_ = ReadIdsFromYaml(path.string()); |
| 55 | 56 | ||
| 56 | for (const auto& [_, map] : id_mappings_.maps()) { | 57 | for (const auto& [_, map] : id_mappings_.maps()) { |
| 57 | for (const auto& [_, id] : map.doors()) { | 58 | UpdateNextId(map.doors()); |
| 58 | if (id > next_id_) { | ||
| 59 | next_id_ = id; | ||
| 60 | } | ||
| 61 | } | ||
| 62 | 59 | ||
| 63 | for (const auto& [_, room] : map.rooms()) { | 60 | for (const auto& [_, room] : map.rooms()) { |
| 64 | for (const auto& [_, id] : room.panels()) { | 61 | UpdateNextId(room.panels()); |
| 65 | if (id > next_id_) { | 62 | UpdateNextId(room.masteries()); |
| 66 | next_id_ = id; | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | for (const auto& [_, id] : room.masteries()) { | ||
| 71 | if (id > next_id_) { | ||
| 72 | next_id_ = id; | ||
| 73 | } | ||
| 74 | } | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | for (const auto& [_, id] : id_mappings_.special()) { | ||
| 79 | if (id > next_id_) { | ||
| 80 | next_id_ = id; | ||
| 81 | } | 63 | } |
| 82 | } | 64 | } |
| 83 | 65 | ||
| 84 | for (const auto& [_, id] : id_mappings_.letters()) { | 66 | UpdateNextId(id_mappings_.special()); |
| 85 | if (id > next_id_) { | 67 | UpdateNextId(id_mappings_.letters()); |
| 86 | next_id_ = id; | 68 | UpdateNextId(id_mappings_.endings()); |
| 87 | } | 69 | UpdateNextId(id_mappings_.progressives()); |
| 88 | } | ||
| 89 | |||
| 90 | for (const auto& [_, id] : id_mappings_.endings()) { | ||
| 91 | if (id > next_id_) { | ||
| 92 | next_id_ = id; | ||
| 93 | } | ||
| 94 | } | ||
| 95 | 70 | ||
| 96 | next_id_++; | 71 | next_id_++; |
| 97 | } | 72 | } |
| @@ -210,7 +185,30 @@ class AssignIds { | |||
| 210 | } | 185 | } |
| 211 | } | 186 | } |
| 212 | 187 | ||
| 188 | void ProcessProgressivesFile(std::filesystem::path path) { | ||
| 189 | if (!std::filesystem::exists(path)) { | ||
| 190 | return; | ||
| 191 | } | ||
| 192 | |||
| 193 | auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string()); | ||
| 194 | auto& progs = *id_mappings_.mutable_progressives(); | ||
| 195 | |||
| 196 | for (const HumanProgressive& h_prog : h_progs.progressives()) { | ||
| 197 | if (!progs.contains(h_prog.name())) { | ||
| 198 | progs[h_prog.name()] = next_id_++; | ||
| 199 | } | ||
| 200 | } | ||
| 201 | } | ||
| 202 | |||
| 213 | private: | 203 | private: |
| 204 | void UpdateNextId(const google::protobuf::Map<std::string, uint64_t>& ids) { | ||
| 205 | for (const auto& [_, id] : ids) { | ||
| 206 | if (id > next_id_) { | ||
| 207 | next_id_ = id; | ||
| 208 | } | ||
| 209 | } | ||
| 210 | } | ||
| 211 | |||
| 214 | std::string mapdir_; | 212 | std::string mapdir_; |
| 215 | 213 | ||
| 216 | uint64_t next_id_ = 1; | 214 | uint64_t next_id_ = 1; |
