diff options
Diffstat (limited to 'tools/assign_ids')
| -rw-r--r-- | tools/assign_ids/main.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
| diff --git a/tools/assign_ids/main.cpp b/tools/assign_ids/main.cpp index 92f3ea4..2471bc5 100644 --- a/tools/assign_ids/main.cpp +++ b/tools/assign_ids/main.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include <string> | 9 | #include <string> |
| 10 | 10 | ||
| 11 | #include "proto/human.pb.h" | 11 | #include "proto/human.pb.h" |
| 12 | #include "util/ids_yaml_format.h" | ||
| 12 | #include "util/naming.h" | 13 | #include "util/naming.h" |
| 13 | 14 | ||
| 14 | namespace com::fourisland::lingo2_archipelago { | 15 | namespace com::fourisland::lingo2_archipelago { |
| @@ -34,7 +35,7 @@ class AssignIds { | |||
| 34 | 35 | ||
| 35 | void Run() { | 36 | void Run() { |
| 36 | std::filesystem::path datadir_path = mapdir_; | 37 | std::filesystem::path datadir_path = mapdir_; |
| 37 | std::filesystem::path ids_path = datadir_path / "ids.txtpb"; | 38 | std::filesystem::path ids_path = datadir_path / "ids.yaml"; |
| 38 | 39 | ||
| 39 | ReadIds(ids_path); | 40 | ReadIds(ids_path); |
| 40 | 41 | ||
| @@ -46,7 +47,11 @@ class AssignIds { | |||
| 46 | } | 47 | } |
| 47 | 48 | ||
| 48 | void ReadIds(std::filesystem::path path) { | 49 | void ReadIds(std::filesystem::path path) { |
| 49 | id_mappings_ = ReadMessageFromFile<IdMappings>(path.string()); | 50 | if (!std::filesystem::exists(path)) { |
| 51 | return; | ||
| 52 | } | ||
| 53 | |||
| 54 | id_mappings_ = ReadIdsFromYaml(path.string()); | ||
| 50 | 55 | ||
| 51 | for (const auto& [_, map] : id_mappings_.maps()) { | 56 | for (const auto& [_, map] : id_mappings_.maps()) { |
| 52 | for (const auto& [_, id] : map.doors()) { | 57 | for (const auto& [_, id] : map.doors()) { |
| @@ -86,13 +91,7 @@ class AssignIds { | |||
| 86 | } | 91 | } |
| 87 | 92 | ||
| 88 | void WriteIds(std::filesystem::path path) { | 93 | void WriteIds(std::filesystem::path path) { |
| 89 | std::string output; | 94 | WriteIdsAsYaml(id_mappings_, path.string()); |
| 90 | google::protobuf::TextFormat::PrintToString(id_mappings_, &output); | ||
| 91 | |||
| 92 | { | ||
| 93 | std::ofstream outputfile(path.string()); | ||
| 94 | outputfile << output; | ||
| 95 | } | ||
| 96 | } | 95 | } |
| 97 | 96 | ||
| 98 | void ProcessMaps(std::filesystem::path path) { | 97 | void ProcessMaps(std::filesystem::path path) { |
