From 724f8092c4808cdad47316e00949c04ee797acb5 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 19 Aug 2025 20:19:48 -0400 Subject: Store IDs in a yaml file This is much more efficient than the txtpb format, and we only need an interface for it in C++ since the IDs will be packed into the binary proto representation. --- tools/assign_ids/main.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'tools/assign_ids') 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 @@ #include #include "proto/human.pb.h" +#include "util/ids_yaml_format.h" #include "util/naming.h" namespace com::fourisland::lingo2_archipelago { @@ -34,7 +35,7 @@ class AssignIds { void Run() { std::filesystem::path datadir_path = mapdir_; - std::filesystem::path ids_path = datadir_path / "ids.txtpb"; + std::filesystem::path ids_path = datadir_path / "ids.yaml"; ReadIds(ids_path); @@ -46,7 +47,11 @@ class AssignIds { } void ReadIds(std::filesystem::path path) { - id_mappings_ = ReadMessageFromFile(path.string()); + if (!std::filesystem::exists(path)) { + return; + } + + id_mappings_ = ReadIdsFromYaml(path.string()); for (const auto& [_, map] : id_mappings_.maps()) { for (const auto& [_, id] : map.doors()) { @@ -86,13 +91,7 @@ class AssignIds { } void WriteIds(std::filesystem::path path) { - std::string output; - google::protobuf::TextFormat::PrintToString(id_mappings_, &output); - - { - std::ofstream outputfile(path.string()); - outputfile << output; - } + WriteIdsAsYaml(id_mappings_, path.string()); } void ProcessMaps(std::filesystem::path path) { -- cgit 1.4.1