about summary refs log tree commit diff stats
path: root/tools/util
diff options
context:
space:
mode:
Diffstat (limited to 'tools/util')
-rw-r--r--tools/util/godot_scene.cpp6
-rw-r--r--tools/util/ids_yaml_format.cpp39
2 files changed, 41 insertions, 4 deletions
diff --git a/tools/util/godot_scene.cpp b/tools/util/godot_scene.cpp index 1e77c9e..f788d21 100644 --- a/tools/util/godot_scene.cpp +++ b/tools/util/godot_scene.cpp
@@ -1,10 +1,8 @@
1#include "godot_scene.h" 1#include "godot_scene.h"
2 2
3#include <absl/strings/str_split.h>
4#include <absl/strings/string_view.h>
5
6#include <fstream> 3#include <fstream>
7#include <sstream> 4#include <sstream>
5#include <string_view>
8#include <variant> 6#include <variant>
9 7
10namespace com::fourisland::lingo2_archipelago { 8namespace com::fourisland::lingo2_archipelago {
@@ -23,7 +21,7 @@ struct Heading {
23 GodotInstanceType instance_type; 21 GodotInstanceType instance_type;
24}; 22};
25 23
26Heading ParseTscnHeading(absl::string_view line) { 24Heading ParseTscnHeading(std::string_view line) {
27 std::string original_line(line); 25 std::string original_line(line);
28 Heading heading; 26 Heading heading;
29 27
diff --git a/tools/util/ids_yaml_format.cpp b/tools/util/ids_yaml_format.cpp index f72f60e..71bfd63 100644 --- a/tools/util/ids_yaml_format.cpp +++ b/tools/util/ids_yaml_format.cpp
@@ -56,6 +56,14 @@ IdMappings ReadIdsFromYaml(const std::string& filename) {
56 mastery_it.second.as<uint64_t>(); 56 mastery_it.second.as<uint64_t>();
57 } 57 }
58 } 58 }
59
60 if (room_it.second["keyholders"]) {
61 for (const auto& keyholder_it : room_it.second["keyholders"]) {
62 (*room_ids.mutable_keyholders())[keyholder_it.first
63 .as<std::string>()] =
64 keyholder_it.second.as<uint64_t>();
65 }
66 }
59 } 67 }
60 } 68 }
61 69
@@ -89,6 +97,20 @@ IdMappings ReadIdsFromYaml(const std::string& filename) {
89 } 97 }
90 } 98 }
91 99
100 if (document["progressives"]) {
101 for (const auto& prog_it : document["progressives"]) {
102 (*result.mutable_progressives())[prog_it.first.as<std::string>()] =
103 prog_it.second.as<uint64_t>();
104 }
105 }
106
107 if (document["door_groups"]) {
108 for (const auto& group_it : document["door_groups"]) {
109 (*result.mutable_door_groups())[group_it.first.as<std::string>()] =
110 group_it.second.as<uint64_t>();
111 }
112 }
113
92 return result; 114 return result;
93} 115}
94 116
@@ -117,6 +139,13 @@ void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) {
117 mastery_id; 139 mastery_id;
118 }); 140 });
119 141
142 OperateOnSortedMap(room_ids.keyholders(),
143 [&room_node](const std::string& keyholder_name,
144 uint64_t keyholder_id) {
145 room_node["keyholders"][keyholder_name] =
146 keyholder_id;
147 });
148
120 map_node["rooms"][room_name] = std::move(room_node); 149 map_node["rooms"][room_name] = std::move(room_node);
121 }); 150 });
122 151
@@ -144,6 +173,16 @@ void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) {
144 result["special"][special_name] = special_id; 173 result["special"][special_name] = special_id;
145 }); 174 });
146 175
176 OperateOnSortedMap(ids.progressives(),
177 [&result](const std::string& prog_name, uint64_t prog_id) {
178 result["progressives"][prog_name] = prog_id;
179 });
180
181 OperateOnSortedMap(ids.door_groups(), [&result](const std::string& group_name,
182 uint64_t group_id) {
183 result["door_groups"][group_name] = group_id;
184 });
185
147 std::ofstream output_stream(filename); 186 std::ofstream output_stream(filename);
148 output_stream << result << std::endl; 187 output_stream << result << std::endl;
149} 188}