MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / randomizeItemLocations

Method randomizeItemLocations

src/Savegame/SavedBattleGame.cpp:963–980  ·  view source on GitHub ↗

* Move all the leftover items in base defense missions to random locations in the storage facilities * @param t the tile where all our goodies are initially stored. */

Source from the content-addressed store, hash-verified

961 * @param t the tile where all our goodies are initially stored.
962 */
963void SavedBattleGame::randomizeItemLocations(Tile *t)
964{
965 if (!_storageSpace.empty())
966 {
967 for (std::vector<BattleItem*>::iterator it = t->getInventory()->begin(); it != t->getInventory()->end();)
968 {
969 if ((*it)->getSlot()->getId() == "STR_GROUND")
970 {
971 getTile(_storageSpace.at(RNG::generate(0, _storageSpace.size() -1)))->addItem(*it, (*it)->getSlot());
972 it = t->getInventory()->erase(it);
973 }
974 else
975 {
976 ++it;
977 }
978 }
979 }
980}
981/**
982 * Removes an item from the game. Eg. when ammo item is depleted.
983 * @param item The Item to remove.

Callers 1

btnOkClickMethod · 0.80

Calls 6

generateFunction · 0.85
emptyMethod · 0.45
getInventoryMethod · 0.45
getIdMethod · 0.45
getSlotMethod · 0.45
addItemMethod · 0.45

Tested by

no test coverage detected