| 460 | } |
| 461 | |
| 462 | void Battle::initialMapPartLinkUp() |
| 463 | { |
| 464 | LogWarning("Begun initial map parts link up!"); |
| 465 | auto &mapref = *map; |
| 466 | |
| 467 | for (auto &s : this->map_parts) |
| 468 | { |
| 469 | if (!s->destroyed) |
| 470 | { |
| 471 | s->queueCollapse(); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | for (int z = 0; z < mapref.size.z; z++) |
| 476 | { |
| 477 | for (auto &s : this->map_parts) |
| 478 | { |
| 479 | if ((int)s->position.z == z && !s->destroyed && s->findSupport()) |
| 480 | { |
| 481 | s->cancelCollapse(); |
| 482 | } |
| 483 | } |
| 484 | } |
| 485 | LogWarning("Begun map parts link up cycle!"); |
| 486 | bool foundSupport; |
| 487 | // Establish support based on existing supported map parts |
| 488 | do |
| 489 | { |
| 490 | foundSupport = false; |
| 491 | for (auto &s : this->map_parts) |
| 492 | { |
| 493 | if (!s->willCollapse()) |
| 494 | { |
| 495 | continue; |
| 496 | } |
| 497 | if (s->findSupport()) |
| 498 | { |
| 499 | s->cancelCollapse(); |
| 500 | foundSupport = true; |
| 501 | } |
| 502 | } |
| 503 | } while (foundSupport); |
| 504 | |
| 505 | // Report unlinked parts |
| 506 | for (auto &mp : this->map_parts) |
| 507 | { |
| 508 | if (mp->willCollapse()) |
| 509 | { |
| 510 | auto pos = mp->tileObject->getOwningTile()->position; |
| 511 | LogWarning("MP %s SBT %d at %s is UNLINKED", mp->type.id, |
| 512 | (int)mp->type->getVanillaSupportedById(), pos); |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | LogWarning("Attempting link up of unlinked parts"); |
| 517 | // Try to link to objects of same type first, then to anything |
| 518 | for (int iteration = 0; iteration <= 2; iteration++) |
| 519 | { |
nothing calls this directly
no test coverage detected