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/validator | |
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/validator')
-rw-r--r-- | tools/validator/human_processor.cpp | 66 | ||||
-rw-r--r-- | tools/validator/structs.h | 6 | ||||
-rw-r--r-- | tools/validator/validator.cpp | 79 |
3 files changed, 147 insertions, 4 deletions
diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index 49e7578..5720ba9 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 | ||
17 | namespace com::fourisland::lingo2_archipelago { | 18 | namespace com::fourisland::lingo2_archipelago { |
18 | namespace { | 19 | namespace { |
@@ -42,7 +43,7 @@ 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 | ProcessIdsFile(datadir_path / "ids.yaml"); |
46 | } | 47 | } |
47 | 48 | ||
48 | private: | 49 | private: |
@@ -510,7 +511,68 @@ class HumanProcessor { | |||
510 | } | 511 | } |
511 | 512 | ||
512 | void ProcessIdsFile(std::filesystem::path path) { | 513 | void ProcessIdsFile(std::filesystem::path path) { |
513 | // Ignore this for now. | 514 | auto ids = ReadIdsFromYaml(path.string()); |
515 | |||
516 | DoorIdentifier di; | ||
517 | PanelIdentifier pi; | ||
518 | KeyholderIdentifier ki; | ||
519 | |||
520 | for (const auto& [map_name, map] : ids.maps()) { | ||
521 | di.set_map(map_name); | ||
522 | pi.set_map(map_name); | ||
523 | ki.set_map(map_name); | ||
524 | |||
525 | for (const auto& [door_name, ap_id] : map.doors()) { | ||
526 | di.set_name(door_name); | ||
527 | |||
528 | DoorInfo& door_info = info_.doors[di]; | ||
529 | door_info.has_id = true; | ||
530 | } | ||
531 | |||
532 | for (const auto& [room_name, room] : map.rooms()) { | ||
533 | pi.set_room(room_name); | ||
534 | ki.set_room(room_name); | ||
535 | |||
536 | for (const auto& [panel_name, ap_id] : room.panels()) { | ||
537 | pi.set_name(panel_name); | ||
538 | |||
539 | PanelInfo& panel_info = info_.panels[pi]; | ||
540 | panel_info.has_id = true; | ||
541 | } | ||
542 | |||
543 | for (const auto& [mastery_name, ap_id] : room.masteries()) { | ||
544 | // TODO: Mastery | ||
545 | } | ||
546 | |||
547 | for (const auto& [keyholder_name, ap_id] : room.keyholders()) { | ||
548 | ki.set_name(keyholder_name); | ||
549 | |||
550 | KeyholderInfo& keyholder_info = info_.keyholders[ki]; | ||
551 | keyholder_info.has_id = true; | ||
552 | } | ||
553 | } | ||
554 | } | ||
555 | |||
556 | for (const auto& [tag, id] : ids.special()) { | ||
557 | // TODO: Specials | ||
558 | } | ||
559 | |||
560 | for (const auto& [letter_name, ap_id] : ids.letters()) { | ||
561 | LetterIdentifier li = | ||
562 | std::make_tuple(letter_name[0], letter_name[1] == '2'); | ||
563 | LetterInfo& letter_info = info_.letters[li]; | ||
564 | letter_info.has_id = true; | ||
565 | } | ||
566 | |||
567 | for (const auto& [ending_name, ap_id] : ids.endings()) { | ||
568 | EndingInfo& ending_info = info_.endings[ending_name]; | ||
569 | ending_info.has_id = true; | ||
570 | } | ||
571 | |||
572 | for (const auto& [prog_name, ap_id] : ids.progressives()) { | ||
573 | ProgressiveInfo& prog_info = info_.progressives[prog_name]; | ||
574 | prog_info.has_id = true; | ||
575 | } | ||
514 | } | 576 | } |
515 | 577 | ||
516 | std::string mapdir_; | 578 | std::string mapdir_; |
diff --git a/tools/validator/structs.h b/tools/validator/structs.h index 717fccf..e24ed3d 100644 --- a/tools/validator/structs.h +++ b/tools/validator/structs.h | |||
@@ -39,6 +39,7 @@ struct RoomInfo { | |||
39 | 39 | ||
40 | struct DoorInfo { | 40 | struct 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; |
@@ -72,6 +73,7 @@ struct ProxyInfo { | |||
72 | 73 | ||
73 | struct PanelInfo { | 74 | struct PanelInfo { |
74 | std::vector<HumanPanel> definitions; | 75 | std::vector<HumanPanel> definitions; |
76 | bool has_id = false; | ||
75 | 77 | ||
76 | std::string map_area_name; | 78 | std::string map_area_name; |
77 | 79 | ||
@@ -83,6 +85,7 @@ struct PanelInfo { | |||
83 | 85 | ||
84 | struct KeyholderInfo { | 86 | struct KeyholderInfo { |
85 | std::vector<HumanKeyholder> definitions; | 87 | std::vector<HumanKeyholder> definitions; |
88 | bool has_id = false; | ||
86 | 89 | ||
87 | std::vector<DoorIdentifier> doors_referenced_by; | 90 | std::vector<DoorIdentifier> doors_referenced_by; |
88 | }; | 91 | }; |
@@ -91,10 +94,12 @@ using LetterIdentifier = std::tuple<char, bool>; | |||
91 | 94 | ||
92 | struct LetterInfo { | 95 | struct LetterInfo { |
93 | std::vector<RoomIdentifier> defined_in; | 96 | std::vector<RoomIdentifier> defined_in; |
97 | bool has_id = false; | ||
94 | }; | 98 | }; |
95 | 99 | ||
96 | struct EndingInfo { | 100 | struct EndingInfo { |
97 | std::vector<RoomIdentifier> defined_in; | 101 | std::vector<RoomIdentifier> defined_in; |
102 | bool has_id = false; | ||
98 | 103 | ||
99 | std::vector<DoorIdentifier> doors_referenced_by; | 104 | std::vector<DoorIdentifier> doors_referenced_by; |
100 | }; | 105 | }; |
@@ -105,6 +110,7 @@ struct PanelNameInfo { | |||
105 | 110 | ||
106 | struct ProgressiveInfo { | 111 | struct ProgressiveInfo { |
107 | std::vector<HumanProgressive> definitions; | 112 | std::vector<HumanProgressive> definitions; |
113 | bool has_id = false; | ||
108 | 114 | ||
109 | std::vector<DoorIdentifier> malformed_doors; | 115 | std::vector<DoorIdentifier> malformed_doors; |
110 | }; | 116 | }; |
diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index fd004d7..ab1612e 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp | |||
@@ -172,6 +172,10 @@ class Validator { | |||
172 | door_info.progressives_referenced_by) { | 172 | door_info.progressives_referenced_by) { |
173 | std::cout << " PROGRESSIVE " << prog_name << std::endl; | 173 | std::cout << " PROGRESSIVE " << prog_name << std::endl; |
174 | } | 174 | } |
175 | |||
176 | if (door_info.has_id) { | ||
177 | std::cout << " An AP ID is present." << std::endl; | ||
178 | } | ||
175 | } else if (door_info.definitions.size() > 1) { | 179 | } else if (door_info.definitions.size() > 1) { |
176 | std::cout << "Door " << door_identifier.ShortDebugString() | 180 | std::cout << "Door " << door_identifier.ShortDebugString() |
177 | << " was defined multiple times." << std::endl; | 181 | << " was defined multiple times." << std::endl; |
@@ -215,6 +219,17 @@ class Validator { | |||
215 | << " is a location that depends on double_letters." | 219 | << " is a location that depends on double_letters." |
216 | << std::endl; | 220 | << std::endl; |
217 | } | 221 | } |
222 | |||
223 | bool needs_id = (h_door.type() != DoorType::EVENT); | ||
224 | if (door_info.has_id != needs_id) { | ||
225 | if (needs_id) { | ||
226 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
227 | << " is missing an AP ID." << std::endl; | ||
228 | } else { | ||
229 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
230 | << " should not have an AP ID." << std::endl; | ||
231 | } | ||
232 | } | ||
218 | } | 233 | } |
219 | } | 234 | } |
220 | 235 | ||
@@ -280,6 +295,10 @@ class Validator { | |||
280 | std::cout << " CONNECTION " << connection.ShortDebugString() | 295 | std::cout << " CONNECTION " << connection.ShortDebugString() |
281 | << std::endl; | 296 | << std::endl; |
282 | } | 297 | } |
298 | |||
299 | if (panel_info.has_id) { | ||
300 | std::cout << " An AP ID is present." << std::endl; | ||
301 | } | ||
283 | } else if (panel_info.definitions.size() > 1) { | 302 | } else if (panel_info.definitions.size() > 1) { |
284 | std::cout << "Panel " << panel_identifier.ShortDebugString() | 303 | std::cout << "Panel " << panel_identifier.ShortDebugString() |
285 | << " was defined multiple times." << std::endl; | 304 | << " was defined multiple times." << std::endl; |
@@ -308,6 +327,11 @@ class Validator { | |||
308 | << "\" was defined multiple times." << std::endl; | 327 | << "\" was defined multiple times." << std::endl; |
309 | } | 328 | } |
310 | } | 329 | } |
330 | |||
331 | if (!panel_info.has_id) { | ||
332 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
333 | << " is missing an AP ID." << std::endl; | ||
334 | } | ||
311 | } | 335 | } |
312 | 336 | ||
313 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, | 337 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, |
@@ -321,10 +345,28 @@ class Validator { | |||
321 | std::cout << " DOOR " << door_identifier.ShortDebugString() | 345 | std::cout << " DOOR " << door_identifier.ShortDebugString() |
322 | << std::endl; | 346 | << std::endl; |
323 | } | 347 | } |
348 | |||
349 | if (keyholder_info.has_id) { | ||
350 | std::cout << " An AP ID is present." << std::endl; | ||
351 | } | ||
324 | } else if (keyholder_info.definitions.size() > 1) { | 352 | } else if (keyholder_info.definitions.size() > 1) { |
325 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | 353 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() |
326 | << " was defined multiple times." << std::endl; | 354 | << " was defined multiple times." << std::endl; |
327 | } | 355 | } |
356 | |||
357 | for (const HumanKeyholder& h_keyholder : keyholder_info.definitions) { | ||
358 | bool needs_id = (h_keyholder.has_key()); | ||
359 | |||
360 | if (needs_id != keyholder_info.has_id) { | ||
361 | if (needs_id) { | ||
362 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
363 | << " is missing an AP ID." << std::endl; | ||
364 | } else { | ||
365 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
366 | << " should not have an AP ID." << std::endl; | ||
367 | } | ||
368 | } | ||
369 | } | ||
328 | } | 370 | } |
329 | 371 | ||
330 | void ValidateLetter(const LetterIdentifier& letter_identifier, | 372 | void ValidateLetter(const LetterIdentifier& letter_identifier, |
@@ -332,7 +374,14 @@ class Validator { | |||
332 | std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + | 374 | std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + |
333 | (std::get<1>(letter_identifier) ? "2" : "1"); | 375 | (std::get<1>(letter_identifier) ? "2" : "1"); |
334 | 376 | ||
335 | if (letter_info.defined_in.size() > 1) { | 377 | if (letter_info.defined_in.empty()) { |
378 | std::cout << "Letter " << letter_name | ||
379 | << " has no definition, but was referenced:" << std::endl; | ||
380 | |||
381 | if (letter_info.has_id) { | ||
382 | std::cout << " An AP ID is present." << std::endl; | ||
383 | } | ||
384 | } else if (letter_info.defined_in.size() > 1) { | ||
336 | std::cout << "Letter " << letter_name | 385 | std::cout << "Letter " << letter_name |
337 | << " was defined in multiple places:" << std::endl; | 386 | << " was defined in multiple places:" << std::endl; |
338 | 387 | ||
@@ -340,6 +389,11 @@ class Validator { | |||
340 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | 389 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; |
341 | } | 390 | } |
342 | } | 391 | } |
392 | |||
393 | if (!letter_info.has_id) { | ||
394 | std::cout << "Letter " << letter_name << " is missing an AP ID." | ||
395 | << std::endl; | ||
396 | } | ||
343 | } | 397 | } |
344 | 398 | ||
345 | void ValidateEnding(const std::string& ending_name, | 399 | void ValidateEnding(const std::string& ending_name, |
@@ -353,6 +407,10 @@ class Validator { | |||
353 | std::cout << " DOOR " << door_identifier.ShortDebugString() | 407 | std::cout << " DOOR " << door_identifier.ShortDebugString() |
354 | << std::endl; | 408 | << std::endl; |
355 | } | 409 | } |
410 | |||
411 | if (ending_info.has_id) { | ||
412 | std::cout << " An AP ID is present." << std::endl; | ||
413 | } | ||
356 | } else if (ending_info.defined_in.size() > 1) { | 414 | } else if (ending_info.defined_in.size() > 1) { |
357 | std::cout << "Ending " << ending_name | 415 | std::cout << "Ending " << ending_name |
358 | << " was defined in multiple places:" << std::endl; | 416 | << " was defined in multiple places:" << std::endl; |
@@ -361,6 +419,11 @@ class Validator { | |||
361 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | 419 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; |
362 | } | 420 | } |
363 | } | 421 | } |
422 | |||
423 | if (!ending_info.has_id) { | ||
424 | std::cout << "Ending " << ending_name << " is missing an AP ID." | ||
425 | << std::endl; | ||
426 | } | ||
364 | } | 427 | } |
365 | 428 | ||
366 | void ValidatePanelName(const std::string& panel_name, | 429 | void ValidatePanelName(const std::string& panel_name, |
@@ -379,10 +442,22 @@ class Validator { | |||
379 | 442 | ||
380 | void ValidateProgressive(const std::string& prog_name, | 443 | void ValidateProgressive(const std::string& prog_name, |
381 | const ProgressiveInfo& prog_info) const { | 444 | const ProgressiveInfo& prog_info) const { |
382 | if (prog_info.definitions.size() > 1) { | 445 | if (prog_info.definitions.empty()) { |
446 | std::cout << "Progressive \"" << prog_name | ||
447 | << "\" has no definition, but was referenced:" << std::endl; | ||
448 | |||
449 | if (prog_info.has_id) { | ||
450 | std::cout << " An AP ID is present." << std::endl; | ||
451 | } | ||
452 | } else if (prog_info.definitions.size() > 1) { | ||
383 | std::cout << "Progressive \"" << prog_name | 453 | std::cout << "Progressive \"" << prog_name |
384 | << "\" has multiple definitions." << std::endl; | 454 | << "\" has multiple definitions." << std::endl; |
385 | } | 455 | } |
456 | |||
457 | if (!prog_info.has_id) { | ||
458 | std::cout << "Progressive \"" << prog_name << "\" is missing an AP ID." | ||
459 | << std::endl; | ||
460 | } | ||
386 | } | 461 | } |
387 | 462 | ||
388 | const CollectedInfo& info_; | 463 | const CollectedInfo& info_; |