MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / closeScreen

Method closeScreen

game/ui/general/aequipscreen.cpp:1616–1765  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1614}
1615
1616void AEquipScreen::closeScreen()
1617{
1618 // Try to dump gear
1619 if (config().getBool("OpenApoc.NewFeature.StoreDroppedEquipment"))
1620 {
1621 for (auto &entry : vehicleItems)
1622 {
1623 if (!entry.second.empty())
1624 {
1625 // First unload clips
1626 std::list<sp<AEquipment>> clips;
1627 for (auto &e : entry.second)
1628 {
1629 auto clip = e->unloadAmmo();
1630 if (clip)
1631 {
1632 clips.push_back(clip);
1633 }
1634 }
1635 for (auto &c : clips)
1636 {
1637 entry.second.push_back(c);
1638 }
1639 // Then create cargo (ferry to vehicle's home base)
1640 for (auto &e : entry.second)
1641 {
1642 int price = 0;
1643 entry.first->cargo.emplace_back(
1644 *state, e->type, e->type->type == AEquipmentType::Type::Ammo ? e->ammo : 1,
1645 price, nullptr, entry.first->homeBuilding);
1646 }
1647 }
1648 }
1649 for (auto &entry : buildingItems)
1650 {
1651 if (!entry.second.empty())
1652 {
1653 // First unload clips
1654 std::list<sp<AEquipment>> clips;
1655 for (auto &e : entry.second)
1656 {
1657 auto clip = e->unloadAmmo();
1658 if (clip)
1659 {
1660 clips.push_back(clip);
1661 }
1662 }
1663 for (auto &c : clips)
1664 {
1665 entry.second.push_back(c);
1666 }
1667 // Then create cargo (ferry to current base)
1668 for (auto &e : entry.second)
1669 {
1670 int price = 0;
1671 entry.first->cargo.emplace_back(
1672 *state, e->type, e->type->type == AEquipmentType::Type::Ammo ? e->ammo : 1,
1673 price, nullptr, state->current_base->building);

Callers 1

attemptCloseScreenMethod · 0.95

Calls 10

getBoolMethod · 0.80
emptyMethod · 0.80
unloadAmmoMethod · 0.80
getPlayerMethod · 0.80
withinMethod · 0.80
endMethod · 0.80
stageQueueCommandMethod · 0.80
getMethod · 0.45
beginMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected