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