diff options
Diffstat (limited to 'tools/validator/validator.cpp')
| -rw-r--r-- | tools/validator/validator.cpp | 158 |
1 files changed, 155 insertions, 3 deletions
| diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index fd004d7..dd41f5c 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp | |||
| @@ -48,6 +48,9 @@ class Validator { | |||
| 48 | for (const auto& [prog_name, prog_info] : info_.progressives) { | 48 | for (const auto& [prog_name, prog_info] : info_.progressives) { |
| 49 | ValidateProgressive(prog_name, prog_info); | 49 | ValidateProgressive(prog_name, prog_info); |
| 50 | } | 50 | } |
| 51 | for (const auto& [group_name, group_info] : info_.door_groups) { | ||
| 52 | ValidateDoorGroup(group_name, group_info); | ||
| 53 | } | ||
| 51 | } | 54 | } |
| 52 | 55 | ||
| 53 | private: | 56 | private: |
| @@ -103,7 +106,8 @@ class Validator { | |||
| 103 | return false; | 106 | return false; |
| 104 | } | 107 | } |
| 105 | 108 | ||
| 106 | if (h_door.keyholders_size() > 0 || h_door.endings_size() > 0) { | 109 | if (h_door.keyholders_size() > 0 || h_door.endings_size() > 0 || |
| 110 | h_door.complete_at() > 0) { | ||
| 107 | return true; | 111 | return true; |
| 108 | } | 112 | } |
| 109 | 113 | ||
| @@ -172,6 +176,15 @@ class Validator { | |||
| 172 | door_info.progressives_referenced_by) { | 176 | door_info.progressives_referenced_by) { |
| 173 | std::cout << " PROGRESSIVE " << prog_name << std::endl; | 177 | std::cout << " PROGRESSIVE " << prog_name << std::endl; |
| 174 | } | 178 | } |
| 179 | |||
| 180 | for (const std::string& group_name : | ||
| 181 | door_info.door_groups_referenced_by) { | ||
| 182 | std::cout << " DOOR GROUP " << group_name << std::endl; | ||
| 183 | } | ||
| 184 | |||
| 185 | if (door_info.has_id) { | ||
| 186 | std::cout << " An AP ID is present." << std::endl; | ||
| 187 | } | ||
| 175 | } else if (door_info.definitions.size() > 1) { | 188 | } else if (door_info.definitions.size() > 1) { |
| 176 | std::cout << "Door " << door_identifier.ShortDebugString() | 189 | std::cout << "Door " << door_identifier.ShortDebugString() |
| 177 | << " was defined multiple times." << std::endl; | 190 | << " was defined multiple times." << std::endl; |
| @@ -215,6 +228,17 @@ class Validator { | |||
| 215 | << " is a location that depends on double_letters." | 228 | << " is a location that depends on double_letters." |
| 216 | << std::endl; | 229 | << std::endl; |
| 217 | } | 230 | } |
| 231 | |||
| 232 | bool needs_id = (h_door.type() != DoorType::EVENT); | ||
| 233 | if (door_info.has_id != needs_id) { | ||
| 234 | if (needs_id) { | ||
| 235 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 236 | << " is missing an AP ID." << std::endl; | ||
| 237 | } else { | ||
| 238 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 239 | << " should not have an AP ID." << std::endl; | ||
| 240 | } | ||
| 241 | } | ||
| 218 | } | 242 | } |
| 219 | } | 243 | } |
| 220 | 244 | ||
| @@ -233,6 +257,22 @@ class Validator { | |||
| 233 | std::cout << "Port " << port_identifier.ShortDebugString() | 257 | std::cout << "Port " << port_identifier.ShortDebugString() |
| 234 | << " was defined multiple times." << std::endl; | 258 | << " was defined multiple times." << std::endl; |
| 235 | } | 259 | } |
| 260 | |||
| 261 | if (!port_info.target_connections_referenced_by.empty()) { | ||
| 262 | for (const HumanPort& port : port_info.definitions) { | ||
| 263 | if (port.has_required_door()) { | ||
| 264 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 265 | << " has a required door but is the target of a connection:" | ||
| 266 | << std::endl; | ||
| 267 | |||
| 268 | for (const HumanConnection& connection : | ||
| 269 | port_info.target_connections_referenced_by) { | ||
| 270 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 271 | << std::endl; | ||
| 272 | } | ||
| 273 | } | ||
| 274 | } | ||
| 275 | } | ||
| 236 | } | 276 | } |
| 237 | 277 | ||
| 238 | void ValidatePainting(const PaintingIdentifier& painting_identifier, | 278 | void ValidatePainting(const PaintingIdentifier& painting_identifier, |
| @@ -256,6 +296,22 @@ class Validator { | |||
| 256 | std::cout << "Painting " << painting_identifier.ShortDebugString() | 296 | std::cout << "Painting " << painting_identifier.ShortDebugString() |
| 257 | << " was defined multiple times." << std::endl; | 297 | << " was defined multiple times." << std::endl; |
| 258 | } | 298 | } |
| 299 | |||
| 300 | if (!painting_info.target_connections_referenced_by.empty()) { | ||
| 301 | for (const HumanPainting& painting : painting_info.definitions) { | ||
| 302 | if (painting.has_required_door()) { | ||
| 303 | std::cout << "Painting " << painting_identifier.ShortDebugString() | ||
| 304 | << " has a required door but is the target of a connection:" | ||
| 305 | << std::endl; | ||
| 306 | |||
| 307 | for (const HumanConnection& connection : | ||
| 308 | painting_info.target_connections_referenced_by) { | ||
| 309 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 310 | << std::endl; | ||
| 311 | } | ||
| 312 | } | ||
| 313 | } | ||
| 314 | } | ||
| 259 | } | 315 | } |
| 260 | 316 | ||
| 261 | void ValidatePanel(const PanelIdentifier& panel_identifier, | 317 | void ValidatePanel(const PanelIdentifier& panel_identifier, |
| @@ -280,6 +336,10 @@ class Validator { | |||
| 280 | std::cout << " CONNECTION " << connection.ShortDebugString() | 336 | std::cout << " CONNECTION " << connection.ShortDebugString() |
| 281 | << std::endl; | 337 | << std::endl; |
| 282 | } | 338 | } |
| 339 | |||
| 340 | if (panel_info.has_id) { | ||
| 341 | std::cout << " An AP ID is present." << std::endl; | ||
| 342 | } | ||
| 283 | } else if (panel_info.definitions.size() > 1) { | 343 | } else if (panel_info.definitions.size() > 1) { |
| 284 | std::cout << "Panel " << panel_identifier.ShortDebugString() | 344 | std::cout << "Panel " << panel_identifier.ShortDebugString() |
| 285 | << " was defined multiple times." << std::endl; | 345 | << " was defined multiple times." << std::endl; |
| @@ -308,6 +368,27 @@ class Validator { | |||
| 308 | << "\" was defined multiple times." << std::endl; | 368 | << "\" was defined multiple times." << std::endl; |
| 309 | } | 369 | } |
| 310 | } | 370 | } |
| 371 | |||
| 372 | if (!panel_info.has_id) { | ||
| 373 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 374 | << " is missing an AP ID." << std::endl; | ||
| 375 | } | ||
| 376 | |||
| 377 | if (!panel_info.target_connections_referenced_by.empty()) { | ||
| 378 | for (const HumanPanel& panel : panel_info.definitions) { | ||
| 379 | if (panel.has_required_door()) { | ||
| 380 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 381 | << " has a required door but is the target of a connection:" | ||
| 382 | << std::endl; | ||
| 383 | |||
| 384 | for (const HumanConnection& connection : | ||
| 385 | panel_info.target_connections_referenced_by) { | ||
| 386 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 387 | << std::endl; | ||
| 388 | } | ||
| 389 | } | ||
| 390 | } | ||
| 391 | } | ||
| 311 | } | 392 | } |
| 312 | 393 | ||
| 313 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, | 394 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, |
| @@ -321,10 +402,28 @@ class Validator { | |||
| 321 | std::cout << " DOOR " << door_identifier.ShortDebugString() | 402 | std::cout << " DOOR " << door_identifier.ShortDebugString() |
| 322 | << std::endl; | 403 | << std::endl; |
| 323 | } | 404 | } |
| 405 | |||
| 406 | if (keyholder_info.has_id) { | ||
| 407 | std::cout << " An AP ID is present." << std::endl; | ||
| 408 | } | ||
| 324 | } else if (keyholder_info.definitions.size() > 1) { | 409 | } else if (keyholder_info.definitions.size() > 1) { |
| 325 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | 410 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() |
| 326 | << " was defined multiple times." << std::endl; | 411 | << " was defined multiple times." << std::endl; |
| 327 | } | 412 | } |
| 413 | |||
| 414 | for (const HumanKeyholder& h_keyholder : keyholder_info.definitions) { | ||
| 415 | bool needs_id = (h_keyholder.has_key()); | ||
| 416 | |||
| 417 | if (needs_id != keyholder_info.has_id) { | ||
| 418 | if (needs_id) { | ||
| 419 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
| 420 | << " is missing an AP ID." << std::endl; | ||
| 421 | } else { | ||
| 422 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
| 423 | << " should not have an AP ID." << std::endl; | ||
| 424 | } | ||
| 425 | } | ||
| 426 | } | ||
| 328 | } | 427 | } |
| 329 | 428 | ||
| 330 | void ValidateLetter(const LetterIdentifier& letter_identifier, | 429 | void ValidateLetter(const LetterIdentifier& letter_identifier, |
| @@ -332,7 +431,14 @@ class Validator { | |||
| 332 | std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + | 431 | std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + |
| 333 | (std::get<1>(letter_identifier) ? "2" : "1"); | 432 | (std::get<1>(letter_identifier) ? "2" : "1"); |
| 334 | 433 | ||
| 335 | if (letter_info.defined_in.size() > 1) { | 434 | if (letter_info.defined_in.empty()) { |
| 435 | std::cout << "Letter " << letter_name | ||
| 436 | << " has no definition, but was referenced:" << std::endl; | ||
| 437 | |||
| 438 | if (letter_info.has_id) { | ||
| 439 | std::cout << " An AP ID is present." << std::endl; | ||
| 440 | } | ||
| 441 | } else if (letter_info.defined_in.size() > 1) { | ||
| 336 | std::cout << "Letter " << letter_name | 442 | std::cout << "Letter " << letter_name |
| 337 | << " was defined in multiple places:" << std::endl; | 443 | << " was defined in multiple places:" << std::endl; |
| 338 | 444 | ||
| @@ -340,6 +446,11 @@ class Validator { | |||
| 340 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | 446 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; |
| 341 | } | 447 | } |
| 342 | } | 448 | } |
| 449 | |||
| 450 | if (!letter_info.has_id) { | ||
| 451 | std::cout << "Letter " << letter_name << " is missing an AP ID." | ||
| 452 | << std::endl; | ||
| 453 | } | ||
| 343 | } | 454 | } |
| 344 | 455 | ||
| 345 | void ValidateEnding(const std::string& ending_name, | 456 | void ValidateEnding(const std::string& ending_name, |
| @@ -353,6 +464,10 @@ class Validator { | |||
| 353 | std::cout << " DOOR " << door_identifier.ShortDebugString() | 464 | std::cout << " DOOR " << door_identifier.ShortDebugString() |
| 354 | << std::endl; | 465 | << std::endl; |
| 355 | } | 466 | } |
| 467 | |||
| 468 | if (ending_info.has_id) { | ||
| 469 | std::cout << " An AP ID is present." << std::endl; | ||
| 470 | } | ||
| 356 | } else if (ending_info.defined_in.size() > 1) { | 471 | } else if (ending_info.defined_in.size() > 1) { |
| 357 | std::cout << "Ending " << ending_name | 472 | std::cout << "Ending " << ending_name |
| 358 | << " was defined in multiple places:" << std::endl; | 473 | << " was defined in multiple places:" << std::endl; |
| @@ -361,6 +476,11 @@ class Validator { | |||
| 361 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | 476 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; |
| 362 | } | 477 | } |
| 363 | } | 478 | } |
| 479 | |||
| 480 | if (!ending_info.has_id) { | ||
| 481 | std::cout << "Ending " << ending_name << " is missing an AP ID." | ||
| 482 | << std::endl; | ||
| 483 | } | ||
| 364 | } | 484 | } |
| 365 | 485 | ||
| 366 | void ValidatePanelName(const std::string& panel_name, | 486 | void ValidatePanelName(const std::string& panel_name, |
| @@ -379,10 +499,42 @@ class Validator { | |||
| 379 | 499 | ||
| 380 | void ValidateProgressive(const std::string& prog_name, | 500 | void ValidateProgressive(const std::string& prog_name, |
| 381 | const ProgressiveInfo& prog_info) const { | 501 | const ProgressiveInfo& prog_info) const { |
| 382 | if (prog_info.definitions.size() > 1) { | 502 | if (prog_info.definitions.empty()) { |
| 503 | std::cout << "Progressive \"" << prog_name | ||
| 504 | << "\" has no definition, but was referenced:" << std::endl; | ||
| 505 | |||
| 506 | if (prog_info.has_id) { | ||
| 507 | std::cout << " An AP ID is present." << std::endl; | ||
| 508 | } | ||
| 509 | } else if (prog_info.definitions.size() > 1) { | ||
| 383 | std::cout << "Progressive \"" << prog_name | 510 | std::cout << "Progressive \"" << prog_name |
| 384 | << "\" has multiple definitions." << std::endl; | 511 | << "\" has multiple definitions." << std::endl; |
| 385 | } | 512 | } |
| 513 | |||
| 514 | if (!prog_info.has_id) { | ||
| 515 | std::cout << "Progressive \"" << prog_name << "\" is missing an AP ID." | ||
| 516 | << std::endl; | ||
| 517 | } | ||
| 518 | } | ||
| 519 | |||
| 520 | void ValidateDoorGroup(const std::string& group_name, | ||
| 521 | const DoorGroupInfo& group_info) const { | ||
| 522 | if (group_info.definitions.empty()) { | ||
| 523 | std::cout << "Door group \"" << group_name | ||
| 524 | << "\" has no definition, but was referenced:" << std::endl; | ||
| 525 | |||
| 526 | if (group_info.has_id) { | ||
| 527 | std::cout << " An AP ID is present." << std::endl; | ||
| 528 | } | ||
| 529 | } else if (group_info.definitions.size() > 1) { | ||
| 530 | std::cout << "Door group \"" << group_name | ||
| 531 | << "\" has multiple definitions." << std::endl; | ||
| 532 | } | ||
| 533 | |||
| 534 | if (!group_info.has_id) { | ||
| 535 | std::cout << "Door group \"" << group_name << "\" is missing an AP ID." | ||
| 536 | << std::endl; | ||
| 537 | } | ||
| 386 | } | 538 | } |
| 387 | 539 | ||
| 388 | const CollectedInfo& info_; | 540 | const CollectedInfo& info_; |
