| 425 | } |
| 426 | |
| 427 | void RecruitScreen::attemptCloseScreen() |
| 428 | { |
| 429 | auto player = state->getPlayer(); |
| 430 | std::map<UString, int> bases; |
| 431 | int index = 0; |
| 432 | for (auto &b : state->player_bases) |
| 433 | { |
| 434 | bases[b.first] = index; |
| 435 | index++; |
| 436 | } |
| 437 | |
| 438 | int hired = 0; |
| 439 | int transferred = 0; |
| 440 | for (int i = 0; i < 8; i++) |
| 441 | { |
| 442 | for (auto &a : agentLists[i]) |
| 443 | { |
| 444 | auto agent = a->getData<Agent>(); |
| 445 | if (agent->owner != player) |
| 446 | { |
| 447 | hired++; |
| 448 | } |
| 449 | else if (bases[agent->homeBuilding->base.id] != i) |
| 450 | { |
| 451 | transferred++; |
| 452 | } |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | int fired = 0; |
| 457 | for (auto &a : agentLists[8]) |
| 458 | { |
| 459 | if (a->getData<Agent>()->owner == player) |
| 460 | { |
| 461 | auto agent = a->getData<Agent>(); |
| 462 | if (agent->owner == player) |
| 463 | { |
| 464 | fired++; |
| 465 | } |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | if (hired != 0 || fired != 0 || transferred != 0) |
| 470 | { |
| 471 | UString message = |
| 472 | format("%d %s\n%d %s", hired, tr("unit(s) hired"), fired, tr("unit(s) fired.")); |
| 473 | if (transferred > 0) |
| 474 | { |
| 475 | message = format("%s\n(%d %s)", message, transferred, tr("units(s) transferred")); |
| 476 | } |
| 477 | fw().stageQueueCommand( |
| 478 | {StageCmd::Command::PUSH, |
| 479 | mksp<MessageBox>( |
| 480 | tr("Confirm Orders"), message, MessageBox::ButtonOptions::YesNoCancel, |
| 481 | [this] { this->closeScreen(true); }, [this] { this->closeScreen(); })}); |
| 482 | } |
| 483 | else |
| 484 | { |
nothing calls this directly
no test coverage detected