about summary refs log tree commit diff stats
path: root/tools/validator/validator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/validator/validator.cpp')
-rw-r--r--tools/validator/validator.cpp715
1 files changed, 512 insertions, 203 deletions
diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index f802460..e9fbb74 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp
@@ -1,5 +1,6 @@
1#include "validator.h" 1#include "validator.h"
2 2
3#include <algorithm>
3#include <iostream> 4#include <iostream>
4 5
5#include "proto/human.pb.h" 6#include "proto/human.pb.h"
@@ -9,291 +10,599 @@
9namespace com::fourisland::lingo2_archipelago { 10namespace com::fourisland::lingo2_archipelago {
10namespace { 11namespace {
11 12
12void ValidateMap(const std::string& map_name, const MapInfo& map_info) { 13class Validator {
13 for (const auto& [node_path, node_info] : map_info.game_nodes) { 14 public:
14 if (node_info.uses > 1) { 15 explicit Validator(const CollectedInfo& info) : info_(info) {}
15 std::cout << "Map " << map_name << " node " << node_path
16 << " is used in multiple places." << std::endl;
17 } else if (node_info.uses == 0) {
18 std::cout << "Map " << map_name << " node " << node_path
19 << " is not used." << std::endl;
20 }
21 16
22 if (!node_info.defined) { 17 void Validate() const {
23 std::cout << "Map " << map_name << " node " << node_path 18 for (const auto& [map_name, map_info] : info_.maps) {
24 << " is not defined in the game file." << std::endl; 19 ValidateMap(map_name, map_info);
20 }
21 for (const auto& [room_identifier, room_info] : info_.rooms) {
22 ValidateRoom(room_identifier, room_info);
23 }
24 for (const auto& [door_identifier, door_info] : info_.doors) {
25 ValidateDoor(door_identifier, door_info);
26 }
27 for (const auto& [port_identifier, port_info] : info_.ports) {
28 ValidatePort(port_identifier, port_info);
29 }
30 for (const auto& [painting_identifier, painting_info] : info_.paintings) {
31 ValidatePainting(painting_identifier, painting_info);
32 }
33 for (const auto& [panel_identifier, panel_info] : info_.panels) {
34 ValidatePanel(panel_identifier, panel_info);
35 }
36 for (const auto& [keyholder_identifier, keyholder_info] :
37 info_.keyholders) {
38 ValidateKeyholder(keyholder_identifier, keyholder_info);
39 }
40 for (const auto& [letter_identifier, letter_info] : info_.letters) {
41 ValidateLetter(letter_identifier, letter_info);
42 }
43 for (const auto& [ending_name, ending_info] : info_.endings) {
44 ValidateEnding(ending_name, ending_info);
45 }
46 for (const auto& [panel_name, panel_info] : info_.panel_names) {
47 ValidatePanelName(panel_name, panel_info);
48 }
49 for (const auto& [prog_name, prog_info] : info_.progressives) {
50 ValidateProgressive(prog_name, prog_info);
51 }
52 for (const auto& [group_name, group_info] : info_.door_groups) {
53 ValidateDoorGroup(group_name, group_info);
25 } 54 }
26 } 55 }
27}
28 56
29void ValidateRoom(const RoomIdentifier& room_identifier, 57 private:
30 const RoomInfo& room_info) { 58 void ValidateMap(const std::string& map_name, const MapInfo& map_info) const {
31 if (room_info.definitions.empty()) { 59 for (const auto& [node_path, node_info] : map_info.game_nodes) {
32 std::cout << "Room " << room_identifier.ShortDebugString() 60 if (node_info.uses > 1) {
33 << " has no definition, but was referenced:" << std::endl; 61 std::cout << "Map " << map_name << " node " << node_path
62 << " is used in multiple places." << std::endl;
63 } else if (node_info.uses == 0) {
64 std::cout << "Map " << map_name << " node " << node_path
65 << " is not used." << std::endl;
66 }
34 67
35 for (const DoorIdentifier& door_identifier : 68 if (!node_info.defined) {
36 room_info.doors_referenced_by) { 69 std::cout << "Map " << map_name << " node " << node_path
37 std::cout << " DOOR " << door_identifier.ShortDebugString() 70 << " is not defined in the game file." << std::endl;
38 << std::endl; 71 }
39 } 72 }
40 73
41 for (const PanelIdentifier& panel_identifier : 74 if (map_info.malformed_worldport_entrance) {
42 room_info.panels_referenced_by) { 75 std::cout << "The worldport entrance for map " << map_name
43 std::cout << " PANEL " << panel_identifier.ShortDebugString() 76 << " is malformed." << std::endl;
44 << std::endl;
45 } 77 }
46 78
47 for (const HumanConnection& connection : 79 if (map_info.has_rte_id) {
48 room_info.connections_referenced_by) { 80 if (!std::any_of(
49 std::cout << " CONNECTION " << connection.ShortDebugString() 81 map_info.definitions.begin(), map_info.definitions.end(),
50 << std::endl; 82 [](const HumanMap& h_map) { return h_map.has_rte_room(); })) {
83 std::cout << "Map " << map_name << " has an RTE ID but no RTE room."
84 << std::endl;
85 }
86 } else {
87 if (std::any_of(
88 map_info.definitions.begin(), map_info.definitions.end(),
89 [](const HumanMap& h_map) { return h_map.has_rte_room(); })) {
90 std::cout << "Map " << map_name << " has an RTE room but no RTE ID."
91 << std::endl;
92 }
51 } 93 }
52 } else if (room_info.definitions.size() > 1) {
53 std::cout << "Room " << room_identifier.ShortDebugString()
54 << " was defined multiple times." << std::endl;
55 } 94 }
56}
57 95
58void ValidateDoor(const DoorIdentifier& door_identifier, 96 void ValidateRoom(const RoomIdentifier& room_identifier,
59 const DoorInfo& door_info) { 97 const RoomInfo& room_info) const {
60 if (door_info.definitions.empty()) { 98 if (room_info.definitions.empty()) {
61 std::cout << "Door " << door_identifier.ShortDebugString() 99 std::cout << "Room " << room_identifier.ShortDebugString()
62 << " has no definition, but was referenced:" << std::endl; 100 << " has no definition, but was referenced:" << std::endl;
63 101
64 for (const DoorIdentifier& other_door_identifier : 102 for (const DoorIdentifier& door_identifier :
65 door_info.doors_referenced_by) { 103 room_info.doors_referenced_by) {
66 std::cout << " DOOR " << other_door_identifier.ShortDebugString() 104 std::cout << " DOOR " << door_identifier.ShortDebugString()
67 << std::endl; 105 << std::endl;
106 }
107
108 for (const PanelIdentifier& panel_identifier :
109 room_info.panels_referenced_by) {
110 std::cout << " PANEL " << panel_identifier.ShortDebugString()
111 << std::endl;
112 }
113
114 for (const HumanConnection& connection :
115 room_info.connections_referenced_by) {
116 std::cout << " CONNECTION " << connection.ShortDebugString()
117 << std::endl;
118 }
119
120 for (const std::string& map_name : room_info.map_rtes_referenced_by) {
121 std::cout << " MAP RTE " << map_name << std::endl;
122 }
123 } else if (room_info.definitions.size() > 1) {
124 std::cout << "Room " << room_identifier.ShortDebugString()
125 << " was defined multiple times." << std::endl;
68 } 126 }
127 }
69 128
70 for (const PanelIdentifier& panel_identifier : 129 bool DoesDoorNeedLocationName(const HumanDoor& h_door,
71 door_info.panels_referenced_by) { 130 const std::string& map_name) const {
72 std::cout << " PANEL " << panel_identifier.ShortDebugString() 131 if (h_door.type() != DoorType::STANDARD) {
73 << std::endl; 132 return false;
74 } 133 }
75 134
76 for (const PaintingIdentifier& painting_identifier : 135 if (h_door.keyholders_size() > 0 || h_door.white_ending() ||
77 door_info.paintings_referenced_by) { 136 h_door.complete_at() > 0) {
78 std::cout << " PAINTING " << painting_identifier.ShortDebugString() 137 return true;
79 << std::endl;
80 } 138 }
81 139
82 for (const PortIdentifier& port_identifier : 140 if (h_door.panels_size() > 4) {
83 door_info.ports_referenced_by) { 141 return true;
84 std::cout << " PORT " << port_identifier.ShortDebugString()
85 << std::endl;
86 } 142 }
87 143
88 for (const HumanConnection& connection : 144 std::set<std::string> map_areas;
89 door_info.connections_referenced_by) { 145 for (const PanelIdentifier& pi : h_door.panels()) {
90 std::cout << " CONNECTION " << connection.ShortDebugString() 146 auto full_pi =
91 << std::endl; 147 GetCompletePanelIdentifierWithoutAnswer(pi, map_name, std::nullopt);
148 if (full_pi) {
149 auto panel_info_it = info_.panels.find(*full_pi);
150 if (panel_info_it != info_.panels.end()) {
151 const PanelInfo& panel_info = panel_info_it->second;
152
153 map_areas.insert(panel_info.map_area_name);
154 }
155 }
92 } 156 }
93 } else if (door_info.definitions.size() > 1) { 157
94 std::cout << "Door " << door_identifier.ShortDebugString() 158 if (map_areas.size() > 1) {
95 << " was defined multiple times." << std::endl; 159 return true;
160 }
161
162 return false;
96 } 163 }
97 164
98 if (door_info.malformed_identifiers.HasAny()) { 165 void ValidateDoor(const DoorIdentifier& door_identifier,
99 std::cout << "Door " << door_identifier.ShortDebugString() 166 const DoorInfo& door_info) const {
100 << " has malformed identifiers:" << std::endl; 167 if (door_info.definitions.empty()) {
168 std::cout << "Door " << door_identifier.ShortDebugString()
169 << " has no definition, but was referenced:" << std::endl;
101 170
102 for (const PaintingIdentifier& painting_identifier : 171 for (const DoorIdentifier& other_door_identifier :
103 door_info.malformed_identifiers.paintings) { 172 door_info.doors_referenced_by) {
104 std::cout << " PAINTING " << painting_identifier.ShortDebugString() 173 std::cout << " DOOR " << other_door_identifier.ShortDebugString()
105 << std::endl; 174 << std::endl;
106 } 175 }
107 176
108 for (const PanelIdentifier& panel_identifier : 177 for (const PanelIdentifier& panel_identifier :
109 door_info.malformed_identifiers.panels) { 178 door_info.panels_referenced_by) {
110 std::cout << " PANEL " << panel_identifier.ShortDebugString() 179 std::cout << " PANEL " << panel_identifier.ShortDebugString()
111 << std::endl; 180 << std::endl;
181 }
182
183 for (const PaintingIdentifier& painting_identifier :
184 door_info.paintings_referenced_by) {
185 std::cout << " PAINTING " << painting_identifier.ShortDebugString()
186 << std::endl;
187 }
188
189 for (const PortIdentifier& port_identifier :
190 door_info.ports_referenced_by) {
191 std::cout << " PORT " << port_identifier.ShortDebugString()
192 << std::endl;
193 }
194
195 for (const HumanConnection& connection :
196 door_info.connections_referenced_by) {
197 std::cout << " CONNECTION " << connection.ShortDebugString()
198 << std::endl;
199 }
200
201 for (const std::string& prog_name :
202 door_info.progressives_referenced_by) {
203 std::cout << " PROGRESSIVE " << prog_name << std::endl;
204 }
205
206 for (const std::string& group_name :
207 door_info.door_groups_referenced_by) {
208 std::cout << " DOOR GROUP " << group_name << std::endl;
209 }
210
211 if (door_info.has_id) {
212 std::cout << " An AP ID is present." << std::endl;
213 }
214 } else if (door_info.definitions.size() > 1) {
215 std::cout << "Door " << door_identifier.ShortDebugString()
216 << " was defined multiple times." << std::endl;
112 } 217 }
113 218
114 for (const KeyholderIdentifier& keyholder_identifier : 219 if (door_info.malformed_identifiers.HasAny()) {
115 door_info.malformed_identifiers.keyholders) { 220 std::cout << "Door " << door_identifier.ShortDebugString()
116 std::cout << " KEYHOLDER " << keyholder_identifier.ShortDebugString() 221 << " has malformed identifiers:" << std::endl;
117 << std::endl; 222
223 for (const PaintingIdentifier& painting_identifier :
224 door_info.malformed_identifiers.paintings) {
225 std::cout << " PAINTING " << painting_identifier.ShortDebugString()
226 << std::endl;
227 }
228
229 for (const PanelIdentifier& panel_identifier :
230 door_info.malformed_identifiers.panels) {
231 std::cout << " PANEL " << panel_identifier.ShortDebugString()
232 << std::endl;
233 }
234
235 for (const KeyholderIdentifier& keyholder_identifier :
236 door_info.malformed_identifiers.keyholders) {
237 std::cout << " KEYHOLDER " << keyholder_identifier.ShortDebugString()
238 << std::endl;
239 }
118 } 240 }
119 }
120}
121 241
122void ValidatePort(const PortIdentifier& port_identifier, 242 for (const HumanDoor& h_door : door_info.definitions) {
123 const PortInfo& port_info) { 243 if (DoesDoorNeedLocationName(h_door, door_identifier.map()) &&
124 if (port_info.definitions.empty()) { 244 !h_door.has_location_name()) {
125 std::cout << "Port " << port_identifier.ShortDebugString() 245 std::cout << "Door " << door_identifier.ShortDebugString()
126 << " has no definition, but was referenced:" << std::endl; 246 << " needs an explicit location name." << std::endl;
247 }
127 248
128 for (const HumanConnection& connection : 249 if (h_door.type() == DoorType::STANDARD ||
129 port_info.connections_referenced_by) { 250 h_door.type() == DoorType::LOCATION_ONLY ||
130 std::cout << " CONNECTION " << connection.ShortDebugString() 251 h_door.type() == DoorType::GRAVESTONE || h_door.legacy_location()) {
131 << std::endl; 252 if (h_door.double_letters()) {
253 std::cout << "Door " << door_identifier.ShortDebugString()
254 << " is a location that depends on double_letters."
255 << std::endl;
256 }
257
258 if (!h_door.has_location_room()) {
259 std::cout << "Door " << door_identifier.ShortDebugString()
260 << " is missing a location_room." << std::endl;
261 }
262 }
263
264 bool needs_id = (h_door.type() != DoorType::EVENT || h_door.latch() ||
265 h_door.legacy_location());
266 if (door_info.has_id != needs_id) {
267 if (needs_id) {
268 std::cout << "Door " << door_identifier.ShortDebugString()
269 << " is missing an AP ID." << std::endl;
270 } else {
271 std::cout << "Door " << door_identifier.ShortDebugString()
272 << " should not have an AP ID." << std::endl;
273 }
274 }
132 } 275 }
133 } else if (port_info.definitions.size() > 1) {
134 std::cout << "Port " << port_identifier.ShortDebugString()
135 << " was defined multiple times." << std::endl;
136 } 276 }
137}
138 277
139void ValidatePainting(const PaintingIdentifier& painting_identifier, 278 void ValidatePort(const PortIdentifier& port_identifier,
140 const PaintingInfo& painting_info) { 279 const PortInfo& port_info) const {
141 if (painting_info.definitions.empty()) { 280 if (port_info.definitions.empty()) {
142 std::cout << "Painting " << painting_identifier.ShortDebugString() 281 std::cout << "Port " << port_identifier.ShortDebugString()
143 << " has no definition, but was referenced:" << std::endl; 282 << " has no definition, but was referenced:" << std::endl;
144 283
145 for (const DoorIdentifier& door_identifier : 284 for (const HumanConnection& connection :
146 painting_info.doors_referenced_by) { 285 port_info.connections_referenced_by) {
147 std::cout << " DOOR " << door_identifier.ShortDebugString() 286 std::cout << " CONNECTION " << connection.ShortDebugString()
148 << std::endl; 287 << std::endl;
288 }
289
290 for (const std::string& map_name : port_info.map_worldport_entrances) {
291 std::cout << " MAP (worldport_entrance) " << map_name << std::endl;
292 }
293
294 if (port_info.has_id) {
295 std::cout << " An AP ID is present." << std::endl;
296 }
297 } else if (port_info.definitions.size() > 1) {
298 std::cout << "Port " << port_identifier.ShortDebugString()
299 << " was defined multiple times." << std::endl;
149 } 300 }
150 301
151 for (const HumanConnection& connection : 302 if (!port_info.target_connections_referenced_by.empty()) {
152 painting_info.connections_referenced_by) { 303 for (const HumanPort& port : port_info.definitions) {
153 std::cout << " CONNECTION " << connection.ShortDebugString() 304 if (port.has_required_door()) {
154 << std::endl; 305 std::cout << "Port " << port_identifier.ShortDebugString()
306 << " has a required door but is the target of a connection:"
307 << std::endl;
308
309 for (const HumanConnection& connection :
310 port_info.target_connections_referenced_by) {
311 std::cout << " CONNECTION " << connection.ShortDebugString()
312 << std::endl;
313 }
314 }
315 }
155 } 316 }
156 } else if (painting_info.definitions.size() > 1) {
157 std::cout << "Painting " << painting_identifier.ShortDebugString()
158 << " was defined multiple times." << std::endl;
159 }
160}
161 317
162void ValidatePanel(const PanelIdentifier& panel_identifier, 318 for (const HumanPort& port : port_info.definitions) {
163 const PanelInfo& panel_info) { 319 if (!port.no_shuffle()) {
164 if (panel_identifier.name().empty()) { 320 if (!port.has_destination()) {
165 std::cout << "Panel " << panel_identifier.ShortDebugString() 321 std::cout << "Port " << port_identifier.ShortDebugString()
166 << " has no name." << std::endl; 322 << " is shuffleable and missing a destination."
323 << std::endl;
324 }
325 if (!port.has_rotation()) {
326 std::cout << "Port " << port_identifier.ShortDebugString()
327 << " is shuffleable and missing a rotation." << std::endl;
328 }
329 if (!port_info.has_id) {
330 std::cout << "Port " << port_identifier.ShortDebugString()
331 << " is missing an AP ID." << std::endl;
332 }
333 } else {
334 if (port_info.has_id) {
335 std::cout << "Port " << port_identifier.ShortDebugString()
336 << " should not have an AP ID." << std::endl;
337 }
338 }
339 }
167 } 340 }
168 341
169 if (panel_info.definitions.empty()) { 342 void ValidatePainting(const PaintingIdentifier& painting_identifier,
170 std::cout << "Panel " << panel_identifier.ShortDebugString() 343 const PaintingInfo& painting_info) const {
171 << " has no definition, but was referenced:" << std::endl; 344 if (painting_info.definitions.empty()) {
345 std::cout << "Painting " << painting_identifier.ShortDebugString()
346 << " has no definition, but was referenced:" << std::endl;
172 347
173 for (const DoorIdentifier& door_identifier : 348 for (const DoorIdentifier& door_identifier :
174 panel_info.doors_referenced_by) { 349 painting_info.doors_referenced_by) {
175 std::cout << " DOOR " << door_identifier.ShortDebugString() 350 std::cout << " DOOR " << door_identifier.ShortDebugString()
176 << std::endl; 351 << std::endl;
352 }
353
354 for (const HumanConnection& connection :
355 painting_info.connections_referenced_by) {
356 std::cout << " CONNECTION " << connection.ShortDebugString()
357 << std::endl;
358 }
359 } else if (painting_info.definitions.size() > 1) {
360 std::cout << "Painting " << painting_identifier.ShortDebugString()
361 << " was defined multiple times." << std::endl;
177 } 362 }
178 363
179 for (const HumanConnection& connection : 364 if (!painting_info.target_connections_referenced_by.empty()) {
180 panel_info.connections_referenced_by) { 365 for (const HumanPainting& painting : painting_info.definitions) {
181 std::cout << " CONNECTION " << connection.ShortDebugString() 366 if (painting.has_required_door()) {
182 << std::endl; 367 std::cout << "Painting " << painting_identifier.ShortDebugString()
368 << " has a required door but is the target of a connection:"
369 << std::endl;
370
371 for (const HumanConnection& connection :
372 painting_info.target_connections_referenced_by) {
373 std::cout << " CONNECTION " << connection.ShortDebugString()
374 << std::endl;
375 }
376 }
377 }
183 } 378 }
184 } else if (panel_info.definitions.size() > 1) {
185 std::cout << "Panel " << panel_identifier.ShortDebugString()
186 << " was defined multiple times." << std::endl;
187 } 379 }
188 380
189 for (const auto& [answer, proxy_info] : panel_info.proxies) { 381 void ValidatePanel(const PanelIdentifier& panel_identifier,
190 if (proxy_info.definitions.empty()) { 382 const PanelInfo& panel_info) const {
383 if (panel_identifier.name().empty()) {
191 std::cout << "Panel " << panel_identifier.ShortDebugString() 384 std::cout << "Panel " << panel_identifier.ShortDebugString()
192 << " with answer \"" << answer 385 << " has no name." << std::endl;
193 << "\" has no definition, but was referenced:" << std::endl; 386 }
387
388 if (panel_info.definitions.empty()) {
389 std::cout << "Panel " << panel_identifier.ShortDebugString()
390 << " has no definition, but was referenced:" << std::endl;
194 391
195 for (const DoorIdentifier& door_identifier : 392 for (const DoorIdentifier& door_identifier :
196 proxy_info.doors_referenced_by) { 393 panel_info.doors_referenced_by) {
197 std::cout << " DOOR " << door_identifier.ShortDebugString() 394 std::cout << " DOOR " << door_identifier.ShortDebugString()
198 << std::endl; 395 << std::endl;
199 } 396 }
200 397
201 for (const HumanConnection& connection : 398 for (const HumanConnection& connection :
202 proxy_info.connections_referenced_by) { 399 panel_info.connections_referenced_by) {
203 std::cout << " CONNECTION " << connection.ShortDebugString() 400 std::cout << " CONNECTION " << connection.ShortDebugString()
204 << std::endl; 401 << std::endl;
205 } 402 }
206 } else if (proxy_info.definitions.size() > 1) { 403
404 if (panel_info.has_id) {
405 std::cout << " An AP ID is present." << std::endl;
406 }
407 } else if (panel_info.definitions.size() > 1) {
408 std::cout << "Panel " << panel_identifier.ShortDebugString()
409 << " was defined multiple times." << std::endl;
410 }
411
412 for (const auto& [answer, proxy_info] : panel_info.proxies) {
413 if (proxy_info.definitions.empty()) {
414 std::cout << "Panel " << panel_identifier.ShortDebugString()
415 << " with answer \"" << answer
416 << "\" has no definition, but was referenced:" << std::endl;
417
418 for (const DoorIdentifier& door_identifier :
419 proxy_info.doors_referenced_by) {
420 std::cout << " DOOR " << door_identifier.ShortDebugString()
421 << std::endl;
422 }
423
424 for (const HumanConnection& connection :
425 proxy_info.connections_referenced_by) {
426 std::cout << " CONNECTION " << connection.ShortDebugString()
427 << std::endl;
428 }
429 } else if (proxy_info.definitions.size() > 1) {
430 std::cout << "Panel " << panel_identifier.ShortDebugString()
431 << " with answer \"" << answer
432 << "\" was defined multiple times." << std::endl;
433 }
434 }
435
436 if (!panel_info.has_id) {
207 std::cout << "Panel " << panel_identifier.ShortDebugString() 437 std::cout << "Panel " << panel_identifier.ShortDebugString()
208 << " with answer \"" << answer 438 << " is missing an AP ID." << std::endl;
209 << "\" was defined multiple times." << std::endl; 439 }
440
441 if (!panel_info.target_connections_referenced_by.empty()) {
442 for (const HumanPanel& panel : panel_info.definitions) {
443 if (panel.has_required_door()) {
444 std::cout << "Panel " << panel_identifier.ShortDebugString()
445 << " has a required door but is the target of a connection:"
446 << std::endl;
447
448 for (const HumanConnection& connection :
449 panel_info.target_connections_referenced_by) {
450 std::cout << " CONNECTION " << connection.ShortDebugString()
451 << std::endl;
452 }
453 }
454 }
210 } 455 }
211 } 456 }
212}
213 457
214void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, 458 void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier,
215 const KeyholderInfo& keyholder_info) { 459 const KeyholderInfo& keyholder_info) const {
216 if (keyholder_info.definitions.empty()) { 460 if (keyholder_info.definitions.empty()) {
217 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() 461 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
218 << " has no definition, but was referenced:" << std::endl; 462 << " has no definition, but was referenced:" << std::endl;
463
464 for (const DoorIdentifier& door_identifier :
465 keyholder_info.doors_referenced_by) {
466 std::cout << " DOOR " << door_identifier.ShortDebugString()
467 << std::endl;
468 }
469
470 if (keyholder_info.has_id) {
471 std::cout << " An AP ID is present." << std::endl;
472 }
473 } else if (keyholder_info.definitions.size() > 1) {
474 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
475 << " was defined multiple times." << std::endl;
476 }
219 477
220 for (const DoorIdentifier& door_identifier : 478 for (const HumanKeyholder& h_keyholder : keyholder_info.definitions) {
221 keyholder_info.doors_referenced_by) { 479 bool needs_id = (h_keyholder.has_key());
222 std::cout << " DOOR " << door_identifier.ShortDebugString() 480
481 if (needs_id != keyholder_info.has_id) {
482 if (needs_id) {
483 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
484 << " is missing an AP ID." << std::endl;
485 } else {
486 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
487 << " should not have an AP ID." << std::endl;
488 }
489 }
490 }
491 }
492
493 void ValidateLetter(const LetterIdentifier& letter_identifier,
494 const LetterInfo& letter_info) const {
495 std::string letter_name = std::string(1, std::get<0>(letter_identifier)) +
496 (std::get<1>(letter_identifier) ? "2" : "1");
497
498 if (letter_info.defined_in.empty()) {
499 std::cout << "Letter " << letter_name
500 << " has no definition, but was referenced:" << std::endl;
501
502 if (letter_info.has_id) {
503 std::cout << " An AP ID is present." << std::endl;
504 }
505 } else if (letter_info.defined_in.size() > 1) {
506 std::cout << "Letter " << letter_name
507 << " was defined in multiple places:" << std::endl;
508
509 for (const RoomIdentifier& room_identifier : letter_info.defined_in) {
510 std::cout << " " << room_identifier.ShortDebugString() << std::endl;
511 }
512 }
513
514 if (!letter_info.has_id) {
515 std::cout << "Letter " << letter_name << " is missing an AP ID."
223 << std::endl; 516 << std::endl;
224 } 517 }
225 } else if (keyholder_info.definitions.size() > 1) {
226 std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
227 << " was defined multiple times." << std::endl;
228 } 518 }
229}
230 519
231void ValidateLetter(const LetterIdentifier& letter_identifier, 520 void ValidateEnding(const std::string& ending_name,
232 const LetterInfo& letter_info) { 521 const EndingInfo& ending_info) const {
233 std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + 522 if (ending_info.defined_in.empty()) {
234 (std::get<1>(letter_identifier) ? "2" : "1"); 523 std::cout << "Ending " << ending_name
524 << " has no definition, but was referenced:" << std::endl;
235 525
236 if (letter_info.defined_in.size() > 1) { 526 if (ending_info.has_id) {
237 std::cout << "Letter " << letter_name 527 std::cout << " An AP ID is present." << std::endl;
238 << " was defined in multiple places:" << std::endl; 528 }
529 } else if (ending_info.defined_in.size() > 1) {
530 std::cout << "Ending " << ending_name
531 << " was defined in multiple places:" << std::endl;
532
533 for (const RoomIdentifier& room_identifier : ending_info.defined_in) {
534 std::cout << " " << room_identifier.ShortDebugString() << std::endl;
535 }
536 }
239 537
240 for (const RoomIdentifier& room_identifier : letter_info.defined_in) { 538 if (!ending_info.has_id) {
241 std::cout << " " << room_identifier.ShortDebugString() << std::endl; 539 std::cout << "Ending " << ending_name << " is missing an AP ID."
540 << std::endl;
242 } 541 }
243 } 542 }
244}
245 543
246void ValidateEnding(const std::string& ending_name, 544 void ValidatePanelName(const std::string& panel_name,
247 const EndingInfo& ending_info) { 545 const PanelNameInfo& panel_info) const {
248 if (ending_info.defined_in.empty()) { 546 if (panel_info.panels_used_by.size() > 1) {
249 std::cout << "Ending " << ending_name 547 std::cout << "The location name \"" << panel_name
250 << " has no definition, but was referenced:" << std::endl; 548 << "\" is used by multiple panels:" << std::endl;
549
550 for (const PanelIdentifier& panel_identifier :
551 panel_info.panels_used_by) {
552 std::cout << " PANEL " << panel_identifier.ShortDebugString()
553 << std::endl;
554 }
555 }
556 }
557
558 void ValidateProgressive(const std::string& prog_name,
559 const ProgressiveInfo& prog_info) const {
560 if (prog_info.definitions.empty()) {
561 std::cout << "Progressive \"" << prog_name
562 << "\" has no definition, but was referenced:" << std::endl;
563
564 if (prog_info.has_id) {
565 std::cout << " An AP ID is present." << std::endl;
566 }
567 } else if (prog_info.definitions.size() > 1) {
568 std::cout << "Progressive \"" << prog_name
569 << "\" has multiple definitions." << std::endl;
570 }
251 571
252 for (const DoorIdentifier& door_identifier : 572 if (!prog_info.has_id) {
253 ending_info.doors_referenced_by) { 573 std::cout << "Progressive \"" << prog_name << "\" is missing an AP ID."
254 std::cout << " DOOR " << door_identifier.ShortDebugString()
255 << std::endl; 574 << std::endl;
256 } 575 }
257 } else if (ending_info.defined_in.size() > 1) { 576 }
258 std::cout << "Ending " << ending_name 577
259 << " was defined in multiple places:" << std::endl; 578 void ValidateDoorGroup(const std::string& group_name,
579 const DoorGroupInfo& group_info) const {
580 if (group_info.definitions.empty()) {
581 std::cout << "Door group \"" << group_name
582 << "\" has no definition, but was referenced:" << std::endl;
583
584 if (group_info.has_id) {
585 std::cout << " An AP ID is present." << std::endl;
586 }
587 } else if (group_info.definitions.size() > 1) {
588 std::cout << "Door group \"" << group_name
589 << "\" has multiple definitions." << std::endl;
590 }
260 591
261 for (const RoomIdentifier& room_identifier : ending_info.defined_in) { 592 if (!group_info.has_id) {
262 std::cout << " " << room_identifier.ShortDebugString() << std::endl; 593 std::cout << "Door group \"" << group_name << "\" is missing an AP ID."
594 << std::endl;
263 } 595 }
264 } 596 }
265} 597
598 const CollectedInfo& info_;
599};
266 600
267} // namespace 601} // namespace
268 602
269void ValidateCollectedInfo(const CollectedInfo& info) { 603void ValidateCollectedInfo(const CollectedInfo& info) {
270 for (const auto& [map_name, map_info] : info.maps) { 604 Validator validator(info);
271 ValidateMap(map_name, map_info); 605 validator.Validate();
272 }
273 for (const auto& [room_identifier, room_info] : info.rooms) {
274 ValidateRoom(room_identifier, room_info);
275 }
276 for (const auto& [door_identifier, door_info] : info.doors) {
277 ValidateDoor(door_identifier, door_info);
278 }
279 for (const auto& [port_identifier, port_info] : info.ports) {
280 ValidatePort(port_identifier, port_info);
281 }
282 for (const auto& [painting_identifier, painting_info] : info.paintings) {
283 ValidatePainting(painting_identifier, painting_info);
284 }
285 for (const auto& [panel_identifier, panel_info] : info.panels) {
286 ValidatePanel(panel_identifier, panel_info);
287 }
288 for (const auto& [keyholder_identifier, keyholder_info] : info.keyholders) {
289 ValidateKeyholder(keyholder_identifier, keyholder_info);
290 }
291 for (const auto& [letter_identifier, letter_info] : info.letters) {
292 ValidateLetter(letter_identifier, letter_info);
293 }
294 for (const auto& [ending_name, ending_info] : info.endings) {
295 ValidateEnding(ending_name, ending_info);
296 }
297} 606}
298 607
299} // namespace com::fourisland::lingo2_archipelago 608} // namespace com::fourisland::lingo2_archipelago