diff options
Diffstat (limited to 'tools/validator/validator.cpp')
| -rw-r--r-- | tools/validator/validator.cpp | 226 |
1 files changed, 220 insertions, 6 deletions
| diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index f5524c3..fe36be7 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp | |||
| @@ -45,6 +45,12 @@ class Validator { | |||
| 45 | for (const auto& [panel_name, panel_info] : info_.panel_names) { | 45 | for (const auto& [panel_name, panel_info] : info_.panel_names) { |
| 46 | ValidatePanelName(panel_name, panel_info); | 46 | ValidatePanelName(panel_name, panel_info); |
| 47 | } | 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); | ||
| 53 | } | ||
| 48 | } | 54 | } |
| 49 | 55 | ||
| 50 | private: | 56 | private: |
| @@ -63,6 +69,11 @@ class Validator { | |||
| 63 | << " is not defined in the game file." << std::endl; | 69 | << " is not defined in the game file." << std::endl; |
| 64 | } | 70 | } |
| 65 | } | 71 | } |
| 72 | |||
| 73 | if (map_info.malformed_worldport_entrance) { | ||
| 74 | std::cout << "The worldport entrance for map " << map_name | ||
| 75 | << " is malformed." << std::endl; | ||
| 76 | } | ||
| 66 | } | 77 | } |
| 67 | 78 | ||
| 68 | void ValidateRoom(const RoomIdentifier& room_identifier, | 79 | void ValidateRoom(const RoomIdentifier& room_identifier, |
| @@ -100,7 +111,8 @@ class Validator { | |||
| 100 | return false; | 111 | return false; |
| 101 | } | 112 | } |
| 102 | 113 | ||
| 103 | if (h_door.keyholders_size() > 0 || h_door.endings_size() > 0) { | 114 | if (h_door.keyholders_size() > 0 || h_door.white_ending() || |
| 115 | h_door.complete_at() > 0) { | ||
| 104 | return true; | 116 | return true; |
| 105 | } | 117 | } |
| 106 | 118 | ||
| @@ -164,6 +176,20 @@ class Validator { | |||
| 164 | std::cout << " CONNECTION " << connection.ShortDebugString() | 176 | std::cout << " CONNECTION " << connection.ShortDebugString() |
| 165 | << std::endl; | 177 | << std::endl; |
| 166 | } | 178 | } |
| 179 | |||
| 180 | for (const std::string& prog_name : | ||
| 181 | door_info.progressives_referenced_by) { | ||
| 182 | std::cout << " PROGRESSIVE " << prog_name << std::endl; | ||
| 183 | } | ||
| 184 | |||
| 185 | for (const std::string& group_name : | ||
| 186 | door_info.door_groups_referenced_by) { | ||
| 187 | std::cout << " DOOR GROUP " << group_name << std::endl; | ||
| 188 | } | ||
| 189 | |||
| 190 | if (door_info.has_id) { | ||
| 191 | std::cout << " An AP ID is present." << std::endl; | ||
| 192 | } | ||
| 167 | } else if (door_info.definitions.size() > 1) { | 193 | } else if (door_info.definitions.size() > 1) { |
| 168 | std::cout << "Door " << door_identifier.ShortDebugString() | 194 | std::cout << "Door " << door_identifier.ShortDebugString() |
| 169 | << " was defined multiple times." << std::endl; | 195 | << " was defined multiple times." << std::endl; |
| @@ -198,6 +224,33 @@ class Validator { | |||
| 198 | std::cout << "Door " << door_identifier.ShortDebugString() | 224 | std::cout << "Door " << door_identifier.ShortDebugString() |
| 199 | << " needs an explicit location name." << std::endl; | 225 | << " needs an explicit location name." << std::endl; |
| 200 | } | 226 | } |
| 227 | |||
| 228 | if (h_door.type() == DoorType::STANDARD || | ||
| 229 | h_door.type() == DoorType::LOCATION_ONLY || | ||
| 230 | h_door.type() == DoorType::GRAVESTONE || h_door.legacy_location()) { | ||
| 231 | if (h_door.double_letters()) { | ||
| 232 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 233 | << " is a location that depends on double_letters." | ||
| 234 | << std::endl; | ||
| 235 | } | ||
| 236 | |||
| 237 | if (!h_door.has_location_room()) { | ||
| 238 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 239 | << " is missing a location_room." << std::endl; | ||
| 240 | } | ||
| 241 | } | ||
| 242 | |||
| 243 | bool needs_id = (h_door.type() != DoorType::EVENT || h_door.latch() || | ||
| 244 | h_door.legacy_location()); | ||
| 245 | if (door_info.has_id != needs_id) { | ||
| 246 | if (needs_id) { | ||
| 247 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 248 | << " is missing an AP ID." << std::endl; | ||
| 249 | } else { | ||
| 250 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 251 | << " should not have an AP ID." << std::endl; | ||
| 252 | } | ||
| 253 | } | ||
| 201 | } | 254 | } |
| 202 | } | 255 | } |
| 203 | 256 | ||
| @@ -212,10 +265,57 @@ class Validator { | |||
| 212 | std::cout << " CONNECTION " << connection.ShortDebugString() | 265 | std::cout << " CONNECTION " << connection.ShortDebugString() |
| 213 | << std::endl; | 266 | << std::endl; |
| 214 | } | 267 | } |
| 268 | |||
| 269 | for (const std::string& map_name : port_info.map_worldport_entrances) { | ||
| 270 | std::cout << " MAP (worldport_entrance) " << map_name << std::endl; | ||
| 271 | } | ||
| 272 | |||
| 273 | if (port_info.has_id) { | ||
| 274 | std::cout << " An AP ID is present." << std::endl; | ||
| 275 | } | ||
| 215 | } else if (port_info.definitions.size() > 1) { | 276 | } else if (port_info.definitions.size() > 1) { |
| 216 | std::cout << "Port " << port_identifier.ShortDebugString() | 277 | std::cout << "Port " << port_identifier.ShortDebugString() |
| 217 | << " was defined multiple times." << std::endl; | 278 | << " was defined multiple times." << std::endl; |
| 218 | } | 279 | } |
| 280 | |||
| 281 | if (!port_info.target_connections_referenced_by.empty()) { | ||
| 282 | for (const HumanPort& port : port_info.definitions) { | ||
| 283 | if (port.has_required_door()) { | ||
| 284 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 285 | << " has a required door but is the target of a connection:" | ||
| 286 | << std::endl; | ||
| 287 | |||
| 288 | for (const HumanConnection& connection : | ||
| 289 | port_info.target_connections_referenced_by) { | ||
| 290 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 291 | << std::endl; | ||
| 292 | } | ||
| 293 | } | ||
| 294 | } | ||
| 295 | } | ||
| 296 | |||
| 297 | for (const HumanPort& port : port_info.definitions) { | ||
| 298 | if (!port.no_shuffle()) { | ||
| 299 | if (!port.has_destination()) { | ||
| 300 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 301 | << " is shuffleable and missing a destination." | ||
| 302 | << std::endl; | ||
| 303 | } | ||
| 304 | if (!port.has_rotation()) { | ||
| 305 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 306 | << " is shuffleable and missing a rotation." << std::endl; | ||
| 307 | } | ||
| 308 | if (!port_info.has_id) { | ||
| 309 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 310 | << " is missing an AP ID." << std::endl; | ||
| 311 | } | ||
| 312 | } else { | ||
| 313 | if (port_info.has_id) { | ||
| 314 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 315 | << " should not have an AP ID." << std::endl; | ||
| 316 | } | ||
| 317 | } | ||
| 318 | } | ||
| 219 | } | 319 | } |
| 220 | 320 | ||
| 221 | void ValidatePainting(const PaintingIdentifier& painting_identifier, | 321 | void ValidatePainting(const PaintingIdentifier& painting_identifier, |
| @@ -239,6 +339,22 @@ class Validator { | |||
| 239 | std::cout << "Painting " << painting_identifier.ShortDebugString() | 339 | std::cout << "Painting " << painting_identifier.ShortDebugString() |
| 240 | << " was defined multiple times." << std::endl; | 340 | << " was defined multiple times." << std::endl; |
| 241 | } | 341 | } |
| 342 | |||
| 343 | if (!painting_info.target_connections_referenced_by.empty()) { | ||
| 344 | for (const HumanPainting& painting : painting_info.definitions) { | ||
| 345 | if (painting.has_required_door()) { | ||
| 346 | std::cout << "Painting " << painting_identifier.ShortDebugString() | ||
| 347 | << " has a required door but is the target of a connection:" | ||
| 348 | << std::endl; | ||
| 349 | |||
| 350 | for (const HumanConnection& connection : | ||
| 351 | painting_info.target_connections_referenced_by) { | ||
| 352 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 353 | << std::endl; | ||
| 354 | } | ||
| 355 | } | ||
| 356 | } | ||
| 357 | } | ||
| 242 | } | 358 | } |
| 243 | 359 | ||
| 244 | void ValidatePanel(const PanelIdentifier& panel_identifier, | 360 | void ValidatePanel(const PanelIdentifier& panel_identifier, |
| @@ -263,6 +379,10 @@ class Validator { | |||
| 263 | std::cout << " CONNECTION " << connection.ShortDebugString() | 379 | std::cout << " CONNECTION " << connection.ShortDebugString() |
| 264 | << std::endl; | 380 | << std::endl; |
| 265 | } | 381 | } |
| 382 | |||
| 383 | if (panel_info.has_id) { | ||
| 384 | std::cout << " An AP ID is present." << std::endl; | ||
| 385 | } | ||
| 266 | } else if (panel_info.definitions.size() > 1) { | 386 | } else if (panel_info.definitions.size() > 1) { |
| 267 | std::cout << "Panel " << panel_identifier.ShortDebugString() | 387 | std::cout << "Panel " << panel_identifier.ShortDebugString() |
| 268 | << " was defined multiple times." << std::endl; | 388 | << " was defined multiple times." << std::endl; |
| @@ -291,6 +411,27 @@ class Validator { | |||
| 291 | << "\" was defined multiple times." << std::endl; | 411 | << "\" was defined multiple times." << std::endl; |
| 292 | } | 412 | } |
| 293 | } | 413 | } |
| 414 | |||
| 415 | if (!panel_info.has_id) { | ||
| 416 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 417 | << " is missing an AP ID." << std::endl; | ||
| 418 | } | ||
| 419 | |||
| 420 | if (!panel_info.target_connections_referenced_by.empty()) { | ||
| 421 | for (const HumanPanel& panel : panel_info.definitions) { | ||
| 422 | if (panel.has_required_door()) { | ||
| 423 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 424 | << " has a required door but is the target of a connection:" | ||
| 425 | << std::endl; | ||
| 426 | |||
| 427 | for (const HumanConnection& connection : | ||
| 428 | panel_info.target_connections_referenced_by) { | ||
| 429 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 430 | << std::endl; | ||
| 431 | } | ||
| 432 | } | ||
| 433 | } | ||
| 434 | } | ||
| 294 | } | 435 | } |
| 295 | 436 | ||
| 296 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, | 437 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, |
| @@ -304,10 +445,28 @@ class Validator { | |||
| 304 | std::cout << " DOOR " << door_identifier.ShortDebugString() | 445 | std::cout << " DOOR " << door_identifier.ShortDebugString() |
| 305 | << std::endl; | 446 | << std::endl; |
| 306 | } | 447 | } |
| 448 | |||
| 449 | if (keyholder_info.has_id) { | ||
| 450 | std::cout << " An AP ID is present." << std::endl; | ||
| 451 | } | ||
| 307 | } else if (keyholder_info.definitions.size() > 1) { | 452 | } else if (keyholder_info.definitions.size() > 1) { |
| 308 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | 453 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() |
| 309 | << " was defined multiple times." << std::endl; | 454 | << " was defined multiple times." << std::endl; |
| 310 | } | 455 | } |
| 456 | |||
| 457 | for (const HumanKeyholder& h_keyholder : keyholder_info.definitions) { | ||
| 458 | bool needs_id = (h_keyholder.has_key()); | ||
| 459 | |||
| 460 | if (needs_id != keyholder_info.has_id) { | ||
| 461 | if (needs_id) { | ||
| 462 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
| 463 | << " is missing an AP ID." << std::endl; | ||
| 464 | } else { | ||
| 465 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
| 466 | << " should not have an AP ID." << std::endl; | ||
| 467 | } | ||
| 468 | } | ||
| 469 | } | ||
| 311 | } | 470 | } |
| 312 | 471 | ||
| 313 | void ValidateLetter(const LetterIdentifier& letter_identifier, | 472 | void ValidateLetter(const LetterIdentifier& letter_identifier, |
| @@ -315,7 +474,14 @@ class Validator { | |||
| 315 | std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + | 474 | std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + |
| 316 | (std::get<1>(letter_identifier) ? "2" : "1"); | 475 | (std::get<1>(letter_identifier) ? "2" : "1"); |
| 317 | 476 | ||
| 318 | if (letter_info.defined_in.size() > 1) { | 477 | if (letter_info.defined_in.empty()) { |
| 478 | std::cout << "Letter " << letter_name | ||
| 479 | << " has no definition, but was referenced:" << std::endl; | ||
| 480 | |||
| 481 | if (letter_info.has_id) { | ||
| 482 | std::cout << " An AP ID is present." << std::endl; | ||
| 483 | } | ||
| 484 | } else if (letter_info.defined_in.size() > 1) { | ||
| 319 | std::cout << "Letter " << letter_name | 485 | std::cout << "Letter " << letter_name |
| 320 | << " was defined in multiple places:" << std::endl; | 486 | << " was defined in multiple places:" << std::endl; |
| 321 | 487 | ||
| @@ -323,6 +489,11 @@ class Validator { | |||
| 323 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | 489 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; |
| 324 | } | 490 | } |
| 325 | } | 491 | } |
| 492 | |||
| 493 | if (!letter_info.has_id) { | ||
| 494 | std::cout << "Letter " << letter_name << " is missing an AP ID." | ||
| 495 | << std::endl; | ||
| 496 | } | ||
| 326 | } | 497 | } |
| 327 | 498 | ||
| 328 | void ValidateEnding(const std::string& ending_name, | 499 | void ValidateEnding(const std::string& ending_name, |
| @@ -331,10 +502,8 @@ class Validator { | |||
| 331 | std::cout << "Ending " << ending_name | 502 | std::cout << "Ending " << ending_name |
| 332 | << " has no definition, but was referenced:" << std::endl; | 503 | << " has no definition, but was referenced:" << std::endl; |
| 333 | 504 | ||
| 334 | for (const DoorIdentifier& door_identifier : | 505 | if (ending_info.has_id) { |
| 335 | ending_info.doors_referenced_by) { | 506 | std::cout << " An AP ID is present." << std::endl; |
| 336 | std::cout << " DOOR " << door_identifier.ShortDebugString() | ||
| 337 | << std::endl; | ||
| 338 | } | 507 | } |
| 339 | } else if (ending_info.defined_in.size() > 1) { | 508 | } else if (ending_info.defined_in.size() > 1) { |
| 340 | std::cout << "Ending " << ending_name | 509 | std::cout << "Ending " << ending_name |
| @@ -344,6 +513,11 @@ class Validator { | |||
| 344 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | 513 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; |
| 345 | } | 514 | } |
| 346 | } | 515 | } |
| 516 | |||
| 517 | if (!ending_info.has_id) { | ||
| 518 | std::cout << "Ending " << ending_name << " is missing an AP ID." | ||
| 519 | << std::endl; | ||
| 520 | } | ||
| 347 | } | 521 | } |
| 348 | 522 | ||
| 349 | void ValidatePanelName(const std::string& panel_name, | 523 | void ValidatePanelName(const std::string& panel_name, |
| @@ -360,6 +534,46 @@ class Validator { | |||
| 360 | } | 534 | } |
| 361 | } | 535 | } |
| 362 | 536 | ||
| 537 | void ValidateProgressive(const std::string& prog_name, | ||
| 538 | const ProgressiveInfo& prog_info) const { | ||
| 539 | if (prog_info.definitions.empty()) { | ||
| 540 | std::cout << "Progressive \"" << prog_name | ||
| 541 | << "\" has no definition, but was referenced:" << std::endl; | ||
| 542 | |||
| 543 | if (prog_info.has_id) { | ||
| 544 | std::cout << " An AP ID is present." << std::endl; | ||
| 545 | } | ||
| 546 | } else if (prog_info.definitions.size() > 1) { | ||
| 547 | std::cout << "Progressive \"" << prog_name | ||
| 548 | << "\" has multiple definitions." << std::endl; | ||
| 549 | } | ||
| 550 | |||
| 551 | if (!prog_info.has_id) { | ||
| 552 | std::cout << "Progressive \"" << prog_name << "\" is missing an AP ID." | ||
| 553 | << std::endl; | ||
| 554 | } | ||
| 555 | } | ||
| 556 | |||
| 557 | void ValidateDoorGroup(const std::string& group_name, | ||
| 558 | const DoorGroupInfo& group_info) const { | ||
| 559 | if (group_info.definitions.empty()) { | ||
| 560 | std::cout << "Door group \"" << group_name | ||
| 561 | << "\" has no definition, but was referenced:" << std::endl; | ||
| 562 | |||
| 563 | if (group_info.has_id) { | ||
| 564 | std::cout << " An AP ID is present." << std::endl; | ||
| 565 | } | ||
| 566 | } else if (group_info.definitions.size() > 1) { | ||
| 567 | std::cout << "Door group \"" << group_name | ||
| 568 | << "\" has multiple definitions." << std::endl; | ||
| 569 | } | ||
| 570 | |||
| 571 | if (!group_info.has_id) { | ||
| 572 | std::cout << "Door group \"" << group_name << "\" is missing an AP ID." | ||
| 573 | << std::endl; | ||
| 574 | } | ||
| 575 | } | ||
| 576 | |||
| 363 | const CollectedInfo& info_; | 577 | const CollectedInfo& info_; |
| 364 | }; | 578 | }; |
| 365 | 579 | ||
