| 50 | } |
| 51 | |
| 52 | void AlienContainmentScreen::closeScreen() |
| 53 | { |
| 54 | // Step 01: Check accommodation of different sorts |
| 55 | { |
| 56 | std::array<int, MAX_BASES> vecBioDelta; |
| 57 | std::array<bool, MAX_BASES> vecChanged; |
| 58 | vecBioDelta.fill(0); |
| 59 | vecChanged.fill(false); |
| 60 | |
| 61 | // Find all delta and mark all that have any changes |
| 62 | std::set<sp<TransactionControl>> linkedControls; |
| 63 | for (auto &c : transactionControls[Type::Aliens]) |
| 64 | { |
| 65 | if (linkedControls.find(c) != linkedControls.end()) |
| 66 | { |
| 67 | continue; |
| 68 | } |
| 69 | int i = 0; |
| 70 | for ([[maybe_unused]] const auto &b : state->player_bases) |
| 71 | { |
| 72 | int bioDelta = c->getBioDelta(i); |
| 73 | if (bioDelta) |
| 74 | { |
| 75 | vecBioDelta[i] += bioDelta; |
| 76 | vecChanged[i] = true; |
| 77 | } |
| 78 | i++; |
| 79 | } |
| 80 | if (c->getLinked()) |
| 81 | { |
| 82 | for (auto &l : *c->getLinked()) |
| 83 | { |
| 84 | linkedControls.insert(l.lock()); |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | // Check every base, find first bad one |
| 90 | int i = 0; |
| 91 | StateRef<Base> bad_base; |
| 92 | for (auto &b : state->player_bases) |
| 93 | { |
| 94 | if ((vecChanged[i] || forceLimits) && |
| 95 | b.second->getUsage(*state, FacilityType::Capacity::Aliens, vecBioDelta[i]) > 100) |
| 96 | { |
| 97 | bad_base = b.second->building->base; |
| 98 | break; |
| 99 | } |
| 100 | i++; |
| 101 | } |
| 102 | |
| 103 | // Found bad base |
| 104 | if (bad_base) |
| 105 | { |
| 106 | UString title(tr("Alien Containment space exceeded")); |
| 107 | UString message(tr("Alien Containment space exceeded. Destroy more Aliens!")); |
| 108 | |
| 109 | fw().stageQueueCommand( |
nothing calls this directly
no test coverage detected