From a3972a65b9b443a6085a6ac40b153442e190f382 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 1 Sep 2025 12:54:46 -0400 Subject: Added progressive doors --- tools/assign_ids/main.cpp | 64 +++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 33 deletions(-) (limited to 'tools/assign_ids') 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 { ReadIds(ids_path); ProcessMaps(datadir_path); + ProcessProgressivesFile(datadir_path / "progressives.txtpb"); WriteIds(ids_path); @@ -54,44 +55,18 @@ class AssignIds { id_mappings_ = ReadIdsFromYaml(path.string()); for (const auto& [_, map] : id_mappings_.maps()) { - for (const auto& [_, id] : map.doors()) { - if (id > next_id_) { - next_id_ = id; - } - } + UpdateNextId(map.doors()); for (const auto& [_, room] : map.rooms()) { - for (const auto& [_, id] : room.panels()) { - if (id > next_id_) { - next_id_ = id; - } - } - - for (const auto& [_, id] : room.masteries()) { - if (id > next_id_) { - next_id_ = id; - } - } - } - } - - for (const auto& [_, id] : id_mappings_.special()) { - if (id > next_id_) { - next_id_ = id; + UpdateNextId(room.panels()); + UpdateNextId(room.masteries()); } } - for (const auto& [_, id] : id_mappings_.letters()) { - if (id > next_id_) { - next_id_ = id; - } - } - - for (const auto& [_, id] : id_mappings_.endings()) { - if (id > next_id_) { - next_id_ = id; - } - } + UpdateNextId(id_mappings_.special()); + UpdateNextId(id_mappings_.letters()); + UpdateNextId(id_mappings_.endings()); + UpdateNextId(id_mappings_.progressives()); next_id_++; } @@ -210,7 +185,30 @@ class AssignIds { } } + void ProcessProgressivesFile(std::filesystem::path path) { + if (!std::filesystem::exists(path)) { + return; + } + + auto h_progs = ReadMessageFromFile(path.string()); + auto& progs = *id_mappings_.mutable_progressives(); + + for (const HumanProgressive& h_prog : h_progs.progressives()) { + if (!progs.contains(h_prog.name())) { + progs[h_prog.name()] = next_id_++; + } + } + } + private: + void UpdateNextId(const google::protobuf::Map& ids) { + for (const auto& [_, id] : ids) { + if (id > next_id_) { + next_id_ = id; + } + } + } + std::string mapdir_; uint64_t next_id_ = 1; -- cgit 1.4.1