diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-09-04 15:46:25 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-09-04 15:46:25 -0400 |
commit | a752ab325cf46d35a90606a354775799977dccb0 (patch) | |
tree | 66541b3ed6e820deb1d9e61cd9e10c874fb3a878 /tools/assign_ids | |
parent | 05d3219f4496104cdf8d96aaacbdd41f7e0dbed2 (diff) | |
download | lingo2-archipelago-a752ab325cf46d35a90606a354775799977dccb0.tar.gz lingo2-archipelago-a752ab325cf46d35a90606a354775799977dccb0.tar.bz2 lingo2-archipelago-a752ab325cf46d35a90606a354775799977dccb0.zip |
[Data] Strip unnecessary AP IDs
This was causing issues in the client, specifically for The Ancient.
Diffstat (limited to 'tools/assign_ids')
-rw-r--r-- | tools/assign_ids/main.cpp | 77 |
1 files changed, 61 insertions, 16 deletions
diff --git a/tools/assign_ids/main.cpp b/tools/assign_ids/main.cpp index 6eb41e3..e3add66 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 | ProcessSpecialIds(); | ||
43 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); | 44 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); |
44 | 45 | ||
45 | WriteIds(ids_path); | 46 | WriteIds(ids_path); |
@@ -72,7 +73,7 @@ class AssignIds { | |||
72 | } | 73 | } |
73 | 74 | ||
74 | void WriteIds(std::filesystem::path path) { | 75 | void WriteIds(std::filesystem::path path) { |
75 | WriteIdsAsYaml(id_mappings_, path.string()); | 76 | WriteIdsAsYaml(output_, path.string()); |
76 | } | 77 | } |
77 | 78 | ||
78 | void ProcessMaps(std::filesystem::path path) { | 79 | void ProcessMaps(std::filesystem::path path) { |
@@ -109,14 +110,18 @@ class AssignIds { | |||
109 | return; | 110 | return; |
110 | } | 111 | } |
111 | 112 | ||
113 | auto& maps = *output_.mutable_maps(); | ||
114 | auto& doors = *maps[current_map_name].mutable_doors(); | ||
115 | |||
112 | if (!id_mappings_.maps().contains(current_map_name) || | 116 | if (!id_mappings_.maps().contains(current_map_name) || |
113 | !id_mappings_.maps() | 117 | !id_mappings_.maps() |
114 | .at(current_map_name) | 118 | .at(current_map_name) |
115 | .doors() | 119 | .doors() |
116 | .contains(h_door.name())) { | 120 | .contains(h_door.name())) { |
117 | auto& maps = *id_mappings_.mutable_maps(); | ||
118 | auto& doors = *maps[current_map_name].mutable_doors(); | ||
119 | doors[h_door.name()] = next_id_++; | 121 | doors[h_door.name()] = next_id_++; |
122 | } else { | ||
123 | doors[h_door.name()] = | ||
124 | id_mappings_.maps().at(current_map_name).doors().at(h_door.name()); | ||
120 | } | 125 | } |
121 | } | 126 | } |
122 | 127 | ||
@@ -131,6 +136,10 @@ class AssignIds { | |||
131 | void ProcessRoom(const HumanRoom& h_room, | 136 | void ProcessRoom(const HumanRoom& h_room, |
132 | const std::string& current_map_name) { | 137 | const std::string& current_map_name) { |
133 | for (const HumanPanel& h_panel : h_room.panels()) { | 138 | for (const HumanPanel& h_panel : h_room.panels()) { |
139 | auto& maps = *output_.mutable_maps(); | ||
140 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
141 | auto& panels = *rooms[h_room.name()].mutable_panels(); | ||
142 | |||
134 | if (!id_mappings_.maps().contains(current_map_name) || | 143 | if (!id_mappings_.maps().contains(current_map_name) || |
135 | !id_mappings_.maps() | 144 | !id_mappings_.maps() |
136 | .at(current_map_name) | 145 | .at(current_map_name) |
@@ -142,23 +151,33 @@ class AssignIds { | |||
142 | .at(h_room.name()) | 151 | .at(h_room.name()) |
143 | .panels() | 152 | .panels() |
144 | .contains(h_panel.name())) { | 153 | .contains(h_panel.name())) { |
145 | auto& maps = *id_mappings_.mutable_maps(); | ||
146 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
147 | auto& panels = *rooms[h_room.name()].mutable_panels(); | ||
148 | panels[h_panel.name()] = next_id_++; | 154 | panels[h_panel.name()] = next_id_++; |
155 | } else { | ||
156 | panels[h_panel.name()] = id_mappings_.maps() | ||
157 | .at(current_map_name) | ||
158 | .rooms() | ||
159 | .at(h_room.name()) | ||
160 | .panels() | ||
161 | .at(h_panel.name()); | ||
149 | } | 162 | } |
150 | } | 163 | } |
151 | 164 | ||
152 | for (const HumanLetter& h_letter : h_room.letters()) { | 165 | for (const HumanLetter& h_letter : h_room.letters()) { |
153 | std::string lettername = GetLetterName(h_letter.key(), h_letter.level2()); | 166 | std::string lettername = GetLetterName(h_letter.key(), h_letter.level2()); |
154 | 167 | ||
168 | auto& letters = *output_.mutable_letters(); | ||
155 | if (!id_mappings_.letters().contains(lettername)) { | 169 | if (!id_mappings_.letters().contains(lettername)) { |
156 | auto& letters = *id_mappings_.mutable_letters(); | ||
157 | letters[lettername] = next_id_++; | 170 | letters[lettername] = next_id_++; |
171 | } else { | ||
172 | letters[lettername] = id_mappings_.letters().at(lettername); | ||
158 | } | 173 | } |
159 | } | 174 | } |
160 | 175 | ||
161 | for (const HumanMastery& h_mastery : h_room.masteries()) { | 176 | for (const HumanMastery& h_mastery : h_room.masteries()) { |
177 | auto& maps = *output_.mutable_maps(); | ||
178 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
179 | auto& masteries = *rooms[h_room.name()].mutable_masteries(); | ||
180 | |||
162 | if (!id_mappings_.maps().contains(current_map_name) || | 181 | if (!id_mappings_.maps().contains(current_map_name) || |
163 | !id_mappings_.maps() | 182 | !id_mappings_.maps() |
164 | .at(current_map_name) | 183 | .at(current_map_name) |
@@ -170,17 +189,24 @@ class AssignIds { | |||
170 | .at(h_room.name()) | 189 | .at(h_room.name()) |
171 | .masteries() | 190 | .masteries() |
172 | .contains(h_mastery.name())) { | 191 | .contains(h_mastery.name())) { |
173 | auto& maps = *id_mappings_.mutable_maps(); | ||
174 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
175 | auto& masteries = *rooms[h_room.name()].mutable_masteries(); | ||
176 | masteries[h_mastery.name()] = next_id_++; | 192 | masteries[h_mastery.name()] = next_id_++; |
193 | } else { | ||
194 | masteries[h_mastery.name()] = id_mappings_.maps() | ||
195 | .at(current_map_name) | ||
196 | .rooms() | ||
197 | .at(h_room.name()) | ||
198 | .masteries() | ||
199 | .at(h_mastery.name()); | ||
177 | } | 200 | } |
178 | } | 201 | } |
179 | 202 | ||
180 | for (const HumanEnding& h_ending : h_room.endings()) { | 203 | for (const HumanEnding& h_ending : h_room.endings()) { |
204 | auto& endings = *output_.mutable_endings(); | ||
205 | |||
181 | if (!id_mappings_.endings().contains(h_ending.name())) { | 206 | if (!id_mappings_.endings().contains(h_ending.name())) { |
182 | auto& endings = *id_mappings_.mutable_endings(); | ||
183 | endings[h_ending.name()] = next_id_++; | 207 | endings[h_ending.name()] = next_id_++; |
208 | } else { | ||
209 | endings[h_ending.name()] = id_mappings_.endings().at(h_ending.name()); | ||
184 | } | 210 | } |
185 | } | 211 | } |
186 | 212 | ||
@@ -189,6 +215,10 @@ class AssignIds { | |||
189 | continue; | 215 | continue; |
190 | } | 216 | } |
191 | 217 | ||
218 | auto& maps = *output_.mutable_maps(); | ||
219 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
220 | auto& keyholders = *rooms[h_room.name()].mutable_keyholders(); | ||
221 | |||
192 | if (!id_mappings_.maps().contains(current_map_name) || | 222 | if (!id_mappings_.maps().contains(current_map_name) || |
193 | !id_mappings_.maps() | 223 | !id_mappings_.maps() |
194 | .at(current_map_name) | 224 | .at(current_map_name) |
@@ -200,25 +230,39 @@ class AssignIds { | |||
200 | .at(h_room.name()) | 230 | .at(h_room.name()) |
201 | .keyholders() | 231 | .keyholders() |
202 | .contains(h_keyholder.name())) { | 232 | .contains(h_keyholder.name())) { |
203 | auto& maps = *id_mappings_.mutable_maps(); | ||
204 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
205 | auto& keyholders = *rooms[h_room.name()].mutable_keyholders(); | ||
206 | keyholders[h_keyholder.name()] = next_id_++; | 233 | keyholders[h_keyholder.name()] = next_id_++; |
234 | } else { | ||
235 | keyholders[h_keyholder.name()] = id_mappings_.maps() | ||
236 | .at(current_map_name) | ||
237 | .rooms() | ||
238 | .at(h_room.name()) | ||
239 | .keyholders() | ||
240 | .at(h_keyholder.name()); | ||
207 | } | 241 | } |
208 | } | 242 | } |
209 | } | 243 | } |
210 | 244 | ||
245 | void ProcessSpecialIds() { | ||
246 | auto& specials = *output_.mutable_special(); | ||
247 | |||
248 | for (const auto& [special_name, ap_id] : id_mappings_.special()) { | ||
249 | specials[special_name] = ap_id; | ||
250 | } | ||
251 | } | ||
252 | |||
211 | void ProcessProgressivesFile(std::filesystem::path path) { | 253 | void ProcessProgressivesFile(std::filesystem::path path) { |
212 | if (!std::filesystem::exists(path)) { | 254 | if (!std::filesystem::exists(path)) { |
213 | return; | 255 | return; |
214 | } | 256 | } |
215 | 257 | ||
216 | auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string()); | 258 | auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string()); |
217 | auto& progs = *id_mappings_.mutable_progressives(); | 259 | auto& progs = *output_.mutable_progressives(); |
218 | 260 | ||
219 | for (const HumanProgressive& h_prog : h_progs.progressives()) { | 261 | for (const HumanProgressive& h_prog : h_progs.progressives()) { |
220 | if (!progs.contains(h_prog.name())) { | 262 | if (!id_mappings_.progressives().contains(h_prog.name())) { |
221 | progs[h_prog.name()] = next_id_++; | 263 | progs[h_prog.name()] = next_id_++; |
264 | } else { | ||
265 | progs[h_prog.name()] = id_mappings_.progressives().at(h_prog.name()); | ||
222 | } | 266 | } |
223 | } | 267 | } |
224 | } | 268 | } |
@@ -237,6 +281,7 @@ class AssignIds { | |||
237 | uint64_t next_id_ = 1; | 281 | uint64_t next_id_ = 1; |
238 | 282 | ||
239 | IdMappings id_mappings_; | 283 | IdMappings id_mappings_; |
284 | IdMappings output_; | ||
240 | }; | 285 | }; |
241 | 286 | ||
242 | } // namespace | 287 | } // namespace |