about summary refs log tree commit diff stats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/assign_ids/main.cpp116
-rw-r--r--tools/datapacker/container.cpp17
-rw-r--r--tools/datapacker/container.h3
-rw-r--r--tools/datapacker/main.cpp45
-rw-r--r--tools/util/godot_scene.cpp6
-rw-r--r--tools/util/ids_yaml_format.cpp12
-rw-r--r--tools/validator/human_processor.cpp125
-rw-r--r--tools/validator/structs.h18
-rw-r--r--tools/validator/validator.cpp158
9 files changed, 469 insertions, 31 deletions
diff --git a/tools/assign_ids/main.cpp b/tools/assign_ids/main.cpp index 6eb41e3..3e16f78 100644 --- a/tools/assign_ids/main.cpp +++ b/tools/assign_ids/main.cpp
@@ -2,6 +2,7 @@
2#include <google/protobuf/text_format.h> 2#include <google/protobuf/text_format.h>
3 3
4#include <cstdint> 4#include <cstdint>
5#include <filesystem>
5#include <fstream> 6#include <fstream>
6#include <iostream> 7#include <iostream>
7#include <map> 8#include <map>
@@ -40,7 +41,10 @@ class AssignIds {
40 ReadIds(ids_path); 41 ReadIds(ids_path);
41 42
42 ProcessMaps(datadir_path); 43 ProcessMaps(datadir_path);
44 ProcessSpecialIds();
43 ProcessProgressivesFile(datadir_path / "progressives.txtpb"); 45 ProcessProgressivesFile(datadir_path / "progressives.txtpb");
46 ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb");
47 ProcessGlobalMetadataFile(datadir_path / "metadata.txtpb");
44 48
45 WriteIds(ids_path); 49 WriteIds(ids_path);
46 50
@@ -60,6 +64,7 @@ class AssignIds {
60 for (const auto& [_, room] : map.rooms()) { 64 for (const auto& [_, room] : map.rooms()) {
61 UpdateNextId(room.panels()); 65 UpdateNextId(room.panels());
62 UpdateNextId(room.masteries()); 66 UpdateNextId(room.masteries());
67 UpdateNextId(room.keyholders());
63 } 68 }
64 } 69 }
65 70
@@ -67,12 +72,13 @@ class AssignIds {
67 UpdateNextId(id_mappings_.letters()); 72 UpdateNextId(id_mappings_.letters());
68 UpdateNextId(id_mappings_.endings()); 73 UpdateNextId(id_mappings_.endings());
69 UpdateNextId(id_mappings_.progressives()); 74 UpdateNextId(id_mappings_.progressives());
75 UpdateNextId(id_mappings_.door_groups());
70 76
71 next_id_++; 77 next_id_++;
72 } 78 }
73 79
74 void WriteIds(std::filesystem::path path) { 80 void WriteIds(std::filesystem::path path) {
75 WriteIdsAsYaml(id_mappings_, path.string()); 81 WriteIdsAsYaml(output_, path.string());
76 } 82 }
77 83
78 void ProcessMaps(std::filesystem::path path) { 84 void ProcessMaps(std::filesystem::path path) {
@@ -109,14 +115,18 @@ class AssignIds {
109 return; 115 return;
110 } 116 }
111 117
118 auto& maps = *output_.mutable_maps();
119 auto& doors = *maps[current_map_name].mutable_doors();
120
112 if (!id_mappings_.maps().contains(current_map_name) || 121 if (!id_mappings_.maps().contains(current_map_name) ||
113 !id_mappings_.maps() 122 !id_mappings_.maps()
114 .at(current_map_name) 123 .at(current_map_name)
115 .doors() 124 .doors()
116 .contains(h_door.name())) { 125 .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_++; 126 doors[h_door.name()] = next_id_++;
127 } else {
128 doors[h_door.name()] =
129 id_mappings_.maps().at(current_map_name).doors().at(h_door.name());
120 } 130 }
121 } 131 }
122 132
@@ -131,6 +141,10 @@ class AssignIds {
131 void ProcessRoom(const HumanRoom& h_room, 141 void ProcessRoom(const HumanRoom& h_room,
132 const std::string& current_map_name) { 142 const std::string& current_map_name) {
133 for (const HumanPanel& h_panel : h_room.panels()) { 143 for (const HumanPanel& h_panel : h_room.panels()) {
144 auto& maps = *output_.mutable_maps();
145 auto& rooms = *maps[current_map_name].mutable_rooms();
146 auto& panels = *rooms[h_room.name()].mutable_panels();
147
134 if (!id_mappings_.maps().contains(current_map_name) || 148 if (!id_mappings_.maps().contains(current_map_name) ||
135 !id_mappings_.maps() 149 !id_mappings_.maps()
136 .at(current_map_name) 150 .at(current_map_name)
@@ -142,23 +156,33 @@ class AssignIds {
142 .at(h_room.name()) 156 .at(h_room.name())
143 .panels() 157 .panels()
144 .contains(h_panel.name())) { 158 .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_++; 159 panels[h_panel.name()] = next_id_++;
160 } else {
161 panels[h_panel.name()] = id_mappings_.maps()
162 .at(current_map_name)
163 .rooms()
164 .at(h_room.name())
165 .panels()
166 .at(h_panel.name());
149 } 167 }
150 } 168 }
151 169
152 for (const HumanLetter& h_letter : h_room.letters()) { 170 for (const HumanLetter& h_letter : h_room.letters()) {
153 std::string lettername = GetLetterName(h_letter.key(), h_letter.level2()); 171 std::string lettername = GetLetterName(h_letter.key(), h_letter.level2());
154 172
173 auto& letters = *output_.mutable_letters();
155 if (!id_mappings_.letters().contains(lettername)) { 174 if (!id_mappings_.letters().contains(lettername)) {
156 auto& letters = *id_mappings_.mutable_letters();
157 letters[lettername] = next_id_++; 175 letters[lettername] = next_id_++;
176 } else {
177 letters[lettername] = id_mappings_.letters().at(lettername);
158 } 178 }
159 } 179 }
160 180
161 for (const HumanMastery& h_mastery : h_room.masteries()) { 181 for (const HumanMastery& h_mastery : h_room.masteries()) {
182 auto& maps = *output_.mutable_maps();
183 auto& rooms = *maps[current_map_name].mutable_rooms();
184 auto& masteries = *rooms[h_room.name()].mutable_masteries();
185
162 if (!id_mappings_.maps().contains(current_map_name) || 186 if (!id_mappings_.maps().contains(current_map_name) ||
163 !id_mappings_.maps() 187 !id_mappings_.maps()
164 .at(current_map_name) 188 .at(current_map_name)
@@ -170,17 +194,24 @@ class AssignIds {
170 .at(h_room.name()) 194 .at(h_room.name())
171 .masteries() 195 .masteries()
172 .contains(h_mastery.name())) { 196 .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_++; 197 masteries[h_mastery.name()] = next_id_++;
198 } else {
199 masteries[h_mastery.name()] = id_mappings_.maps()
200 .at(current_map_name)
201 .rooms()
202 .at(h_room.name())
203 .masteries()
204 .at(h_mastery.name());
177 } 205 }
178 } 206 }
179 207
180 for (const HumanEnding& h_ending : h_room.endings()) { 208 for (const HumanEnding& h_ending : h_room.endings()) {
209 auto& endings = *output_.mutable_endings();
210
181 if (!id_mappings_.endings().contains(h_ending.name())) { 211 if (!id_mappings_.endings().contains(h_ending.name())) {
182 auto& endings = *id_mappings_.mutable_endings();
183 endings[h_ending.name()] = next_id_++; 212 endings[h_ending.name()] = next_id_++;
213 } else {
214 endings[h_ending.name()] = id_mappings_.endings().at(h_ending.name());
184 } 215 }
185 } 216 }
186 217
@@ -189,6 +220,10 @@ class AssignIds {
189 continue; 220 continue;
190 } 221 }
191 222
223 auto& maps = *output_.mutable_maps();
224 auto& rooms = *maps[current_map_name].mutable_rooms();
225 auto& keyholders = *rooms[h_room.name()].mutable_keyholders();
226
192 if (!id_mappings_.maps().contains(current_map_name) || 227 if (!id_mappings_.maps().contains(current_map_name) ||
193 !id_mappings_.maps() 228 !id_mappings_.maps()
194 .at(current_map_name) 229 .at(current_map_name)
@@ -200,25 +235,73 @@ class AssignIds {
200 .at(h_room.name()) 235 .at(h_room.name())
201 .keyholders() 236 .keyholders()
202 .contains(h_keyholder.name())) { 237 .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_++; 238 keyholders[h_keyholder.name()] = next_id_++;
239 } else {
240 keyholders[h_keyholder.name()] = id_mappings_.maps()
241 .at(current_map_name)
242 .rooms()
243 .at(h_room.name())
244 .keyholders()
245 .at(h_keyholder.name());
207 } 246 }
208 } 247 }
209 } 248 }
210 249
250 void ProcessSpecialIds() {
251 auto& specials = *output_.mutable_special();
252
253 for (const auto& [special_name, ap_id] : id_mappings_.special()) {
254 specials[special_name] = ap_id;
255 }
256 }
257
211 void ProcessProgressivesFile(std::filesystem::path path) { 258 void ProcessProgressivesFile(std::filesystem::path path) {
212 if (!std::filesystem::exists(path)) { 259 if (!std::filesystem::exists(path)) {
213 return; 260 return;
214 } 261 }
215 262
216 auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string()); 263 auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string());
217 auto& progs = *id_mappings_.mutable_progressives(); 264 auto& progs = *output_.mutable_progressives();
218 265
219 for (const HumanProgressive& h_prog : h_progs.progressives()) { 266 for (const HumanProgressive& h_prog : h_progs.progressives()) {
220 if (!progs.contains(h_prog.name())) { 267 if (!id_mappings_.progressives().contains(h_prog.name())) {
221 progs[h_prog.name()] = next_id_++; 268 progs[h_prog.name()] = next_id_++;
269 } else {
270 progs[h_prog.name()] = id_mappings_.progressives().at(h_prog.name());
271 }
272 }
273 }
274
275 void ProcessDoorGroupsFile(std::filesystem::path path) {
276 if (!std::filesystem::exists(path)) {
277 return;
278 }
279
280 auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string());
281 auto& groups = *output_.mutable_door_groups();
282
283 for (const HumanDoorGroup& h_group : h_groups.door_groups()) {
284 if (!id_mappings_.door_groups().contains(h_group.name())) {
285 groups[h_group.name()] = next_id_++;
286 } else {
287 groups[h_group.name()] = id_mappings_.door_groups().at(h_group.name());
288 }
289 }
290 }
291
292 void ProcessGlobalMetadataFile(std::filesystem::path path) {
293 if (!std::filesystem::exists(path)) {
294 return;
295 }
296
297 auto h_metadata = ReadMessageFromFile<HumanGlobalMetadata>(path.string());
298 auto& specials = *output_.mutable_special();
299
300 for (const std::string& h_special : h_metadata.special_names()) {
301 if (!id_mappings_.special().contains(h_special)) {
302 specials[h_special] = next_id_++;
303 } else {
304 specials[h_special] = id_mappings_.special().at(h_special);
222 } 305 }
223 } 306 }
224 } 307 }
@@ -237,6 +320,7 @@ class AssignIds {
237 uint64_t next_id_ = 1; 320 uint64_t next_id_ = 1;
238 321
239 IdMappings id_mappings_; 322 IdMappings id_mappings_;
323 IdMappings output_;
240}; 324};
241 325
242} // namespace 326} // namespace
diff --git a/tools/datapacker/container.cpp b/tools/datapacker/container.cpp index 624caf8..4a656b3 100644 --- a/tools/datapacker/container.cpp +++ b/tools/datapacker/container.cpp
@@ -348,6 +348,23 @@ uint64_t Container::FindOrAddProgressive(std::string prog_name) {
348 } 348 }
349} 349}
350 350
351uint64_t Container::FindOrAddDoorGroup(std::string group_name) {
352 auto it = door_group_id_by_name_.find(group_name);
353
354 if (it == door_group_id_by_name_.end()) {
355 uint64_t new_id = all_objects_.door_groups_size();
356 DoorGroup* door_group = all_objects_.add_door_groups();
357 door_group->set_id(new_id);
358 door_group->set_name(group_name);
359
360 door_group_id_by_name_[group_name] = new_id;
361
362 return new_id;
363 } else {
364 return it->second;
365 }
366}
367
351void Container::AddConnection(const Connection& connection) { 368void Container::AddConnection(const Connection& connection) {
352 *all_objects_.add_connections() = connection; 369 *all_objects_.add_connections() = connection;
353} 370}
diff --git a/tools/datapacker/container.h b/tools/datapacker/container.h index 8cec560..bc02ba4 100644 --- a/tools/datapacker/container.h +++ b/tools/datapacker/container.h
@@ -62,6 +62,8 @@ class Container {
62 62
63 uint64_t FindOrAddProgressive(std::string prog_name); 63 uint64_t FindOrAddProgressive(std::string prog_name);
64 64
65 uint64_t FindOrAddDoorGroup(std::string group_name);
66
65 AllObjects& all_objects() { return all_objects_; } 67 AllObjects& all_objects() { return all_objects_; }
66 68
67 private: 69 private:
@@ -85,6 +87,7 @@ class Container {
85 door_id_by_map_door_names_; 87 door_id_by_map_door_names_;
86 std::map<std::string, uint64_t> ending_id_by_name_; 88 std::map<std::string, uint64_t> ending_id_by_name_;
87 std::map<std::string, uint64_t> progressive_id_by_name_; 89 std::map<std::string, uint64_t> progressive_id_by_name_;
90 std::map<std::string, uint64_t> door_group_id_by_name_;
88}; 91};
89 92
90} // namespace com::fourisland::lingo2_archipelago 93} // namespace com::fourisland::lingo2_archipelago
diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index 595647d..c13a4df 100644 --- a/tools/datapacker/main.cpp +++ b/tools/datapacker/main.cpp
@@ -44,6 +44,8 @@ class DataPacker {
44 ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); 44 ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt);
45 ProcessMaps(datadir_path); 45 ProcessMaps(datadir_path);
46 ProcessProgressivesFile(datadir_path / "progressives.txtpb"); 46 ProcessProgressivesFile(datadir_path / "progressives.txtpb");
47 ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb");
48 ProcessGlobalMetadataFile(datadir_path / "metadata.txtpb");
47 ProcessIdsFile(datadir_path / "ids.yaml"); 49 ProcessIdsFile(datadir_path / "ids.yaml");
48 50
49 { 51 {
@@ -344,8 +346,8 @@ class DataPacker {
344 h_door.receivers().begin(), h_door.receivers().end(), 346 h_door.receivers().begin(), h_door.receivers().end(),
345 google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); 347 google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers()));
346 std::copy( 348 std::copy(
347 h_door.switches().begin(), h_door.switches().end(), 349 h_door.senders().begin(), h_door.senders().end(),
348 google::protobuf::RepeatedFieldBackInserter(door.mutable_switches())); 350 google::protobuf::RepeatedFieldBackInserter(door.mutable_senders()));
349 351
350 for (const PaintingIdentifier& pi : h_door.move_paintings()) { 352 for (const PaintingIdentifier& pi : h_door.move_paintings()) {
351 std::optional<std::string> map_name = 353 std::optional<std::string> map_name =
@@ -577,6 +579,40 @@ class DataPacker {
577 } 579 }
578 } 580 }
579 581
582 void ProcessDoorGroupsFile(std::filesystem::path path) {
583 if (!std::filesystem::exists(path)) {
584 return;
585 }
586
587 auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string());
588
589 for (const HumanDoorGroup& h_group : h_groups.door_groups()) {
590 ProcessDoorGroup(h_group);
591 }
592 }
593
594 void ProcessDoorGroup(const HumanDoorGroup& h_group) {
595 uint64_t group_id = container_.FindOrAddDoorGroup(h_group.name());
596 DoorGroup& group = *container_.all_objects().mutable_door_groups(group_id);
597
598 group.set_type(h_group.type());
599
600 for (const DoorIdentifier& di : h_group.doors()) {
601 uint64_t door_id =
602 container_.FindOrAddDoor(di.map(), di.name(), std::nullopt);
603 group.add_doors(door_id);
604 }
605 }
606
607 void ProcessGlobalMetadataFile(std::filesystem::path path) {
608 if (!std::filesystem::exists(path)) {
609 return;
610 }
611
612 auto h_metadata = ReadMessageFromFile<HumanGlobalMetadata>(path.string());
613 container_.all_objects().set_version(h_metadata.version());
614 }
615
580 void ProcessIdsFile(std::filesystem::path path) { 616 void ProcessIdsFile(std::filesystem::path path) {
581 auto ids = ReadIdsFromYaml(path.string()); 617 auto ids = ReadIdsFromYaml(path.string());
582 618
@@ -631,6 +667,11 @@ class DataPacker {
631 uint64_t prog_id = container_.FindOrAddProgressive(prog_name); 667 uint64_t prog_id = container_.FindOrAddProgressive(prog_name);
632 container_.all_objects().mutable_progressives(prog_id)->set_ap_id(ap_id); 668 container_.all_objects().mutable_progressives(prog_id)->set_ap_id(ap_id);
633 } 669 }
670
671 for (const auto& [group_name, ap_id] : ids.door_groups()) {
672 uint64_t group_id = container_.FindOrAddDoorGroup(group_name);
673 container_.all_objects().mutable_door_groups(group_id)->set_ap_id(ap_id);
674 }
634 } 675 }
635 676
636 std::string mapdir_; 677 std::string mapdir_;
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 67c21d6..71bfd63 100644 --- a/tools/util/ids_yaml_format.cpp +++ b/tools/util/ids_yaml_format.cpp
@@ -104,6 +104,13 @@ IdMappings ReadIdsFromYaml(const std::string& filename) {
104 } 104 }
105 } 105 }
106 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
107 return result; 114 return result;
108} 115}
109 116
@@ -171,6 +178,11 @@ void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) {
171 result["progressives"][prog_name] = prog_id; 178 result["progressives"][prog_name] = prog_id;
172 }); 179 });
173 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
174 std::ofstream output_stream(filename); 186 std::ofstream output_stream(filename);
175 output_stream << result << std::endl; 187 output_stream << result << std::endl;
176} 188}
diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index 49e7578..2c978bf 100644 --- a/tools/validator/human_processor.cpp +++ b/tools/validator/human_processor.cpp
@@ -13,6 +13,7 @@
13#include <string> 13#include <string>
14 14
15#include "structs.h" 15#include "structs.h"
16#include "util/ids_yaml_format.h"
16 17
17namespace com::fourisland::lingo2_archipelago { 18namespace com::fourisland::lingo2_archipelago {
18namespace { 19namespace {
@@ -42,7 +43,8 @@ class HumanProcessor {
42 ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); 43 ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt);
43 ProcessMaps(datadir_path); 44 ProcessMaps(datadir_path);
44 ProcessProgressivesFile(datadir_path / "progressives.txtpb"); 45 ProcessProgressivesFile(datadir_path / "progressives.txtpb");
45 ProcessIdsFile(datadir_path / "ids.txtpb"); 46 ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb");
47 ProcessIdsFile(datadir_path / "ids.yaml");
46 } 48 }
47 49
48 private: 50 private:
@@ -392,7 +394,9 @@ class HumanProcessor {
392 } 394 }
393 } else if (human_connection.has_from()) { 395 } else if (human_connection.has_from()) {
394 ProcessSingleConnection(human_connection, human_connection.from(), 396 ProcessSingleConnection(human_connection, human_connection.from(),
395 current_map_name); 397 current_map_name,
398 /*is_target=*/!human_connection.oneway() &&
399 !human_connection.bypass_target_door());
396 } 400 }
397 401
398 if (human_connection.has_to_room()) { 402 if (human_connection.has_to_room()) {
@@ -408,8 +412,9 @@ class HumanProcessor {
408 std::cout << "A global connection used to_room." << std::endl; 412 std::cout << "A global connection used to_room." << std::endl;
409 } 413 }
410 } else if (human_connection.has_to()) { 414 } else if (human_connection.has_to()) {
411 ProcessSingleConnection(human_connection, human_connection.to(), 415 ProcessSingleConnection(
412 current_map_name); 416 human_connection, human_connection.to(), current_map_name,
417 /*is_target=*/!human_connection.bypass_target_door());
413 } 418 }
414 419
415 if (human_connection.has_door()) { 420 if (human_connection.has_door()) {
@@ -430,7 +435,7 @@ class HumanProcessor {
430 void ProcessSingleConnection( 435 void ProcessSingleConnection(
431 const HumanConnection& human_connection, 436 const HumanConnection& human_connection,
432 const HumanConnection::Endpoint& endpoint, 437 const HumanConnection::Endpoint& endpoint,
433 const std::optional<std::string>& current_map_name) { 438 const std::optional<std::string>& current_map_name, bool is_target) {
434 if (endpoint.has_room()) { 439 if (endpoint.has_room()) {
435 auto room_identifier = 440 auto room_identifier =
436 GetCompleteRoomIdentifier(endpoint.room(), current_map_name); 441 GetCompleteRoomIdentifier(endpoint.room(), current_map_name);
@@ -449,6 +454,11 @@ class HumanProcessor {
449 if (painting_identifier) { 454 if (painting_identifier) {
450 PaintingInfo& painting_info = info_.paintings[*painting_identifier]; 455 PaintingInfo& painting_info = info_.paintings[*painting_identifier];
451 painting_info.connections_referenced_by.push_back(human_connection); 456 painting_info.connections_referenced_by.push_back(human_connection);
457
458 if (is_target) {
459 painting_info.target_connections_referenced_by.push_back(
460 human_connection);
461 }
452 } else { 462 } else {
453 // Not sure where else to store this right now. 463 // Not sure where else to store this right now.
454 std::cout 464 std::cout
@@ -461,6 +471,11 @@ class HumanProcessor {
461 if (port_identifier) { 471 if (port_identifier) {
462 PortInfo& port_info = info_.ports[*port_identifier]; 472 PortInfo& port_info = info_.ports[*port_identifier];
463 port_info.connections_referenced_by.push_back(human_connection); 473 port_info.connections_referenced_by.push_back(human_connection);
474
475 if (is_target) {
476 port_info.target_connections_referenced_by.push_back(
477 human_connection);
478 }
464 } else { 479 } else {
465 // Not sure where else to store this right now. 480 // Not sure where else to store this right now.
466 std::cout 481 std::cout
@@ -478,6 +493,11 @@ class HumanProcessor {
478 panel_info.proxies[endpoint.panel().answer()] 493 panel_info.proxies[endpoint.panel().answer()]
479 .connections_referenced_by.push_back(human_connection); 494 .connections_referenced_by.push_back(human_connection);
480 } 495 }
496
497 if (is_target) {
498 panel_info.target_connections_referenced_by.push_back(
499 human_connection);
500 }
481 } 501 }
482 } 502 }
483 } 503 }
@@ -509,8 +529,101 @@ class HumanProcessor {
509 } 529 }
510 } 530 }
511 531
532 void ProcessDoorGroupsFile(std::filesystem::path path) {
533 if (!std::filesystem::exists(path)) {
534 return;
535 }
536
537 auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string());
538
539 for (const HumanDoorGroup& h_group : h_groups.door_groups()) {
540 ProcessDoorGroup(h_group);
541 }
542 }
543
544 void ProcessDoorGroup(const HumanDoorGroup& h_group) {
545 DoorGroupInfo& group_info = info_.door_groups[h_group.name()];
546 group_info.definitions.push_back(h_group);
547
548 for (const DoorIdentifier& di : h_group.doors()) {
549 if (!di.has_map()) {
550 group_info.malformed_doors.push_back(di);
551 continue;
552 }
553
554 DoorInfo& door_info = info_.doors[di];
555 door_info.door_groups_referenced_by.push_back(h_group.name());
556 }
557 }
558
512 void ProcessIdsFile(std::filesystem::path path) { 559 void ProcessIdsFile(std::filesystem::path path) {
513 // Ignore this for now. 560 auto ids = ReadIdsFromYaml(path.string());
561
562 DoorIdentifier di;
563 PanelIdentifier pi;
564 KeyholderIdentifier ki;
565
566 for (const auto& [map_name, map] : ids.maps()) {
567 di.set_map(map_name);
568 pi.set_map(map_name);
569 ki.set_map(map_name);
570
571 for (const auto& [door_name, ap_id] : map.doors()) {
572 di.set_name(door_name);
573
574 DoorInfo& door_info = info_.doors[di];
575 door_info.has_id = true;
576 }
577
578 for (const auto& [room_name, room] : map.rooms()) {
579 pi.set_room(room_name);
580 ki.set_room(room_name);
581
582 for (const auto& [panel_name, ap_id] : room.panels()) {
583 pi.set_name(panel_name);
584
585 PanelInfo& panel_info = info_.panels[pi];
586 panel_info.has_id = true;
587 }
588
589 for (const auto& [mastery_name, ap_id] : room.masteries()) {
590 // TODO: Mastery
591 }
592
593 for (const auto& [keyholder_name, ap_id] : room.keyholders()) {
594 ki.set_name(keyholder_name);
595
596 KeyholderInfo& keyholder_info = info_.keyholders[ki];
597 keyholder_info.has_id = true;
598 }
599 }
600 }
601
602 for (const auto& [tag, id] : ids.special()) {
603 // TODO: Specials
604 }
605
606 for (const auto& [letter_name, ap_id] : ids.letters()) {
607 LetterIdentifier li =
608 std::make_tuple(letter_name[0], letter_name[1] == '2');
609 LetterInfo& letter_info = info_.letters[li];
610 letter_info.has_id = true;
611 }
612
613 for (const auto& [ending_name, ap_id] : ids.endings()) {
614 EndingInfo& ending_info = info_.endings[ending_name];
615 ending_info.has_id = true;
616 }
617
618 for (const auto& [prog_name, ap_id] : ids.progressives()) {
619 ProgressiveInfo& prog_info = info_.progressives[prog_name];
620 prog_info.has_id = true;
621 }
622
623 for (const auto& [group_name, ap_id] : ids.door_groups()) {
624 DoorGroupInfo& group_info = info_.door_groups[group_name];
625 group_info.has_id = true;
626 }
514 } 627 }
515 628
516 std::string mapdir_; 629 std::string mapdir_;
diff --git a/tools/validator/structs.h b/tools/validator/structs.h index 717fccf..d1d45f2 100644 --- a/tools/validator/structs.h +++ b/tools/validator/structs.h
@@ -39,6 +39,7 @@ struct RoomInfo {
39 39
40struct DoorInfo { 40struct DoorInfo {
41 std::vector<HumanDoor> definitions; 41 std::vector<HumanDoor> definitions;
42 bool has_id = false;
42 43
43 std::vector<HumanConnection> connections_referenced_by; 44 std::vector<HumanConnection> connections_referenced_by;
44 std::vector<DoorIdentifier> doors_referenced_by; 45 std::vector<DoorIdentifier> doors_referenced_by;
@@ -46,6 +47,7 @@ struct DoorInfo {
46 std::vector<PaintingIdentifier> paintings_referenced_by; 47 std::vector<PaintingIdentifier> paintings_referenced_by;
47 std::vector<PortIdentifier> ports_referenced_by; 48 std::vector<PortIdentifier> ports_referenced_by;
48 std::vector<std::string> progressives_referenced_by; 49 std::vector<std::string> progressives_referenced_by;
50 std::vector<std::string> door_groups_referenced_by;
49 51
50 MalformedIdentifiers malformed_identifiers; 52 MalformedIdentifiers malformed_identifiers;
51}; 53};
@@ -54,12 +56,14 @@ struct PortInfo {
54 std::vector<HumanPort> definitions; 56 std::vector<HumanPort> definitions;
55 57
56 std::vector<HumanConnection> connections_referenced_by; 58 std::vector<HumanConnection> connections_referenced_by;
59 std::vector<HumanConnection> target_connections_referenced_by;
57}; 60};
58 61
59struct PaintingInfo { 62struct PaintingInfo {
60 std::vector<HumanPainting> definitions; 63 std::vector<HumanPainting> definitions;
61 64
62 std::vector<HumanConnection> connections_referenced_by; 65 std::vector<HumanConnection> connections_referenced_by;
66 std::vector<HumanConnection> target_connections_referenced_by;
63 std::vector<DoorIdentifier> doors_referenced_by; 67 std::vector<DoorIdentifier> doors_referenced_by;
64}; 68};
65 69
@@ -72,10 +76,12 @@ struct ProxyInfo {
72 76
73struct PanelInfo { 77struct PanelInfo {
74 std::vector<HumanPanel> definitions; 78 std::vector<HumanPanel> definitions;
79 bool has_id = false;
75 80
76 std::string map_area_name; 81 std::string map_area_name;
77 82
78 std::vector<HumanConnection> connections_referenced_by; 83 std::vector<HumanConnection> connections_referenced_by;
84 std::vector<HumanConnection> target_connections_referenced_by;
79 std::vector<DoorIdentifier> doors_referenced_by; 85 std::vector<DoorIdentifier> doors_referenced_by;
80 86
81 std::map<std::string, ProxyInfo> proxies; 87 std::map<std::string, ProxyInfo> proxies;
@@ -83,6 +89,7 @@ struct PanelInfo {
83 89
84struct KeyholderInfo { 90struct KeyholderInfo {
85 std::vector<HumanKeyholder> definitions; 91 std::vector<HumanKeyholder> definitions;
92 bool has_id = false;
86 93
87 std::vector<DoorIdentifier> doors_referenced_by; 94 std::vector<DoorIdentifier> doors_referenced_by;
88}; 95};
@@ -91,10 +98,12 @@ using LetterIdentifier = std::tuple<char, bool>;
91 98
92struct LetterInfo { 99struct LetterInfo {
93 std::vector<RoomIdentifier> defined_in; 100 std::vector<RoomIdentifier> defined_in;
101 bool has_id = false;
94}; 102};
95 103
96struct EndingInfo { 104struct EndingInfo {
97 std::vector<RoomIdentifier> defined_in; 105 std::vector<RoomIdentifier> defined_in;
106 bool has_id = false;
98 107
99 std::vector<DoorIdentifier> doors_referenced_by; 108 std::vector<DoorIdentifier> doors_referenced_by;
100}; 109};
@@ -105,6 +114,14 @@ struct PanelNameInfo {
105 114
106struct ProgressiveInfo { 115struct ProgressiveInfo {
107 std::vector<HumanProgressive> definitions; 116 std::vector<HumanProgressive> definitions;
117 bool has_id = false;
118
119 std::vector<DoorIdentifier> malformed_doors;
120};
121
122struct DoorGroupInfo {
123 std::vector<HumanDoorGroup> definitions;
124 bool has_id = false;
108 125
109 std::vector<DoorIdentifier> malformed_doors; 126 std::vector<DoorIdentifier> malformed_doors;
110}; 127};
@@ -122,6 +139,7 @@ struct CollectedInfo {
122 std::map<std::string, EndingInfo> endings; 139 std::map<std::string, EndingInfo> endings;
123 std::map<std::string, PanelNameInfo> panel_names; 140 std::map<std::string, PanelNameInfo> panel_names;
124 std::map<std::string, ProgressiveInfo> progressives; 141 std::map<std::string, ProgressiveInfo> progressives;
142 std::map<std::string, DoorGroupInfo> door_groups;
125}; 143};
126 144
127} // namespace com::fourisland::lingo2_archipelago 145} // namespace com::fourisland::lingo2_archipelago
diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index fd004d7..dd41f5c 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp
@@ -48,6 +48,9 @@ class Validator {
48 for (const auto& [prog_name, prog_info] : info_.progressives) { 48 for (const auto& [prog_name, prog_info] : info_.progressives) {
49 ValidateProgressive(prog_name, prog_info); 49 ValidateProgressive(prog_name, prog_info);
50 } 50 }
51 for (const auto& [group_name, group_info] : info_.door_groups) {
52 ValidateDoorGroup(group_name, group_info);
53 }
51 } 54 }
52 55
53 private: 56 private:
@@ -103,7 +106,8 @@ class Validator {
103 return false; 106 return false;
104 } 107 }
105 108
106 if (h_door.keyholders_size() > 0 || h_door.endings_size() > 0) { 109 if (h_door.keyholders_size() > 0 || h_door.endings_size() > 0 ||
110 h_door.complete_at() > 0) {
107 return true; 111 return true;
108 } 112 }
109 113
@@ -172,6 +176,15 @@ class Validator {
172 door_info.progressives_referenced_by) { 176 door_info.progressives_referenced_by) {
173 std::cout << " PROGRESSIVE " << prog_name << std::endl; 177 std::cout << " PROGRESSIVE " << prog_name << std::endl;
174 } 178 }
179
180 for (const std::string& group_name :
181 door_info.door_groups_referenced_by) {
182 std::cout << " DOOR GROUP " << group_name << std::endl;
183 }
184
185 if (door_info.has_id) {
186 std::cout << " An AP ID is present." << std::endl;
187 }
175 } else if (door_info.definitions.size() > 1) { 188 } else if (door_info.definitions.size() > 1) {
176 std::cout << "Door " << door_identifier.ShortDebugString() 189 std::cout << "Door " << door_identifier.ShortDebugString()
177 << " was defined multiple times." << std::endl; 190 << " was defined multiple times." << std::endl;
@@ -215,6 +228,17 @@ class Validator {
215 << " is a location that depends on double_letters." 228 << " is a location that depends on double_letters."
216 << std::endl; 229 << std::endl;
217 } 230 }
231
232 bool needs_id = (h_door.type() != DoorType::EVENT);
233 if (door_info.has_id != needs_id) {
234 if (needs_id) {
235 std::cout << "Door " << door_identifier.ShortDebugString()
236 << " is missing an AP ID." << std::endl;
237 } else {
238 std::cout << "Door " << door_identifier.ShortDebugString()
239 << " should not have an AP ID." << std::endl;
240 }
241 }
218 } 242 }
219 } 243 }
220 244
@@ -233,6 +257,22 @@ class Validator {
233 std::cout << "Port " << port_identifier.ShortDebugString() 257 std::cout << "Port " << port_identifier.ShortDebugString()
234 << " was defined multiple times." << std::endl; 258 << " was defined multiple times." << std::endl;
235 } 259 }
260
261 if (!port_info.target_connections_referenced_by.empty()) {
262 for (const HumanPort& port : port_info.definitions) {
263 if (port.has_required_door()) {
264 std::cout << "Port " << port_identifier.ShortDebugString()
265 << " has a required door but is the target of a connection:"
266 << std::endl;
267
268 for (const HumanConnection& connection :
269 port_info.target_connections_referenced_by) {
270 std::cout << " CONNECTION " << connection.ShortDebugString()
271 << std::endl;
272 }
273 }
274 }
275 }
236 } 276 }
237 277
238 void ValidatePainting(const PaintingIdentifier& painting_identifier, 278 void ValidatePainting(const PaintingIdentifier& painting_identifier,
@@ -256,6 +296,22 @@ class Validator {
256 std::cout << "Painting " << painting_identifier.ShortDebugString() 296 std::cout << "Painting " << painting_identifier.ShortDebugString()
257 << " was defined multiple times." << std::endl; 297 << " was defined multiple times." << std::endl;
258 } 298 }
299
300 if (!painting_info.target_connections_referenced_by.empty()) {
301 for (const HumanPainting& painting : painting_info.definitions) {
302 if (painting.has_required_door()) {
303 std::cout << "Painting " << painting_identifier.ShortDebugString()
304 << " has a required door but is the target of a connection:"
305 << std::endl;
306
307 for (const HumanConnection& connection :
308 painting_info.target_connections_referenced_by) {
309 std::cout << " CONNECTION " << connection.ShortDebugString()
310 << std::endl;
311 }
312 }
313 }
314 }
259 } 315 }
260 316
261 void ValidatePanel(const PanelIdentifier& panel_identifier, 317 void ValidatePanel(const PanelIdentifier& panel_identifier,
@@ -280,6 +336,10 @@ class Validator {
280 std::cout << " CONNECTION " << connection.ShortDebugString() 336 std::cout << " CONNECTION " << connection.ShortDebugString()
281 << std::endl; 337 << std::endl;
282 } 338 }
339
340 if (panel_info.has_id) {
341 std::cout << " An AP ID is present." << std::endl;
342 }
283 } else if (panel_info.definitions.size() > 1) { 343 } else if (panel_info.definitions.size() > 1) {
284 std::cout << "Panel " << panel_identifier.ShortDebugString() 344 std::cout << "Panel " << panel_identifier.ShortDebugString()
285 << " was defined multiple times." << std::endl; 345 << " was defined multiple times." << std::endl;
@@ -308,6 +368,27 @@ class Validator {
308 << "\" was defined multiple times." << std::endl; 368 << "\" was defined multiple times." << std::endl;
309 } 369 }
310 } 370 }
371
372 if (!panel_info.has_id) {
373 std::cout << "Panel " << panel_identifier.ShortDebugString()
374 << " is missing an AP ID." << std::endl;
375 }
376
377 if (!panel_info.target_connections_referenced_by.empty()) {
378 for (const HumanPanel& panel : panel_info.definitions) {
379 if (panel.has_required_door()) {
380 std::cout << "Panel " << panel_identifier.ShortDebugString()
381 << " has a required door but is the target of a connection:"
382 << std::endl;
383
384 for (const HumanConnection& connection :
385 panel_info.target_connections_referenced_by) {
386 std::cout << " CONNECTION " << connection.ShortDebugString()
387 << std::endl;
388 }
389 }
390 }
391 }
311 } 392 }
312 393
313 void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, 394 void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier,
@@ -321,10 +402,28 @@ class Validator {
321 std::cout << " DOOR " << door_identifier.ShortDebugString() 402 std::cout << " DOOR " << door_identifier.ShortDebugString()
322 << std::endl; 403 << std::endl;
323 } 404 }
405
406 if (keyholder_info.has_id) {
407 std::cout << " An AP ID is present." << std::endl;
408 }
324 } else if (keyholder_info.definitions.size() > 1) { 409 } else if (keyholder_info.definitions.size() > 1) {
325 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() 410 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
326 << " was defined multiple times." << std::endl; 411 << " was defined multiple times." << std::endl;
327 } 412 }
413
414 for (const HumanKeyholder& h_keyholder : keyholder_info.definitions) {
415 bool needs_id = (h_keyholder.has_key());
416
417 if (needs_id != keyholder_info.has_id) {
418 if (needs_id) {
419 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
420 << " is missing an AP ID." << std::endl;
421 } else {
422 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
423 << " should not have an AP ID." << std::endl;
424 }
425 }
426 }
328 } 427 }
329 428
330 void ValidateLetter(const LetterIdentifier& letter_identifier, 429 void ValidateLetter(const LetterIdentifier& letter_identifier,
@@ -332,7 +431,14 @@ class Validator {
332 std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + 431 std::string letter_name = std::string(1, std::get<0>(letter_identifier)) +
333 (std::get<1>(letter_identifier) ? "2" : "1"); 432 (std::get<1>(letter_identifier) ? "2" : "1");
334 433
335 if (letter_info.defined_in.size() > 1) { 434 if (letter_info.defined_in.empty()) {
435 std::cout << "Letter " << letter_name
436 << " has no definition, but was referenced:" << std::endl;
437
438 if (letter_info.has_id) {
439 std::cout << " An AP ID is present." << std::endl;
440 }
441 } else if (letter_info.defined_in.size() > 1) {
336 std::cout << "Letter " << letter_name 442 std::cout << "Letter " << letter_name
337 << " was defined in multiple places:" << std::endl; 443 << " was defined in multiple places:" << std::endl;
338 444
@@ -340,6 +446,11 @@ class Validator {
340 std::cout << " " << room_identifier.ShortDebugString() << std::endl; 446 std::cout << " " << room_identifier.ShortDebugString() << std::endl;
341 } 447 }
342 } 448 }
449
450 if (!letter_info.has_id) {
451 std::cout << "Letter " << letter_name << " is missing an AP ID."
452 << std::endl;
453 }
343 } 454 }
344 455
345 void ValidateEnding(const std::string& ending_name, 456 void ValidateEnding(const std::string& ending_name,
@@ -353,6 +464,10 @@ class Validator {
353 std::cout << " DOOR " << door_identifier.ShortDebugString() 464 std::cout << " DOOR " << door_identifier.ShortDebugString()
354 << std::endl; 465 << std::endl;
355 } 466 }
467
468 if (ending_info.has_id) {
469 std::cout << " An AP ID is present." << std::endl;
470 }
356 } else if (ending_info.defined_in.size() > 1) { 471 } else if (ending_info.defined_in.size() > 1) {
357 std::cout << "Ending " << ending_name 472 std::cout << "Ending " << ending_name
358 << " was defined in multiple places:" << std::endl; 473 << " was defined in multiple places:" << std::endl;
@@ -361,6 +476,11 @@ class Validator {
361 std::cout << " " << room_identifier.ShortDebugString() << std::endl; 476 std::cout << " " << room_identifier.ShortDebugString() << std::endl;
362 } 477 }
363 } 478 }
479
480 if (!ending_info.has_id) {
481 std::cout << "Ending " << ending_name << " is missing an AP ID."
482 << std::endl;
483 }
364 } 484 }
365 485
366 void ValidatePanelName(const std::string& panel_name, 486 void ValidatePanelName(const std::string& panel_name,
@@ -379,10 +499,42 @@ class Validator {
379 499
380 void ValidateProgressive(const std::string& prog_name, 500 void ValidateProgressive(const std::string& prog_name,
381 const ProgressiveInfo& prog_info) const { 501 const ProgressiveInfo& prog_info) const {
382 if (prog_info.definitions.size() > 1) { 502 if (prog_info.definitions.empty()) {
503 std::cout << "Progressive \"" << prog_name
504 << "\" has no definition, but was referenced:" << std::endl;
505
506 if (prog_info.has_id) {
507 std::cout << " An AP ID is present." << std::endl;
508 }
509 } else if (prog_info.definitions.size() > 1) {
383 std::cout << "Progressive \"" << prog_name 510 std::cout << "Progressive \"" << prog_name
384 << "\" has multiple definitions." << std::endl; 511 << "\" has multiple definitions." << std::endl;
385 } 512 }
513
514 if (!prog_info.has_id) {
515 std::cout << "Progressive \"" << prog_name << "\" is missing an AP ID."
516 << std::endl;
517 }
518 }
519
520 void ValidateDoorGroup(const std::string& group_name,
521 const DoorGroupInfo& group_info) const {
522 if (group_info.definitions.empty()) {
523 std::cout << "Door group \"" << group_name
524 << "\" has no definition, but was referenced:" << std::endl;
525
526 if (group_info.has_id) {
527 std::cout << " An AP ID is present." << std::endl;
528 }
529 } else if (group_info.definitions.size() > 1) {
530 std::cout << "Door group \"" << group_name
531 << "\" has multiple definitions." << std::endl;
532 }
533
534 if (!group_info.has_id) {
535 std::cout << "Door group \"" << group_name << "\" is missing an AP ID."
536 << std::endl;
537 }
386 } 538 }
387 539
388 const CollectedInfo& info_; 540 const CollectedInfo& info_;