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

Method calculateModuleMap

src/Savegame/SavedBattleGame.cpp:1738–1754  ·  view source on GitHub ↗

* calculate the number of map modules remaining by counting the map objects * on the top floor who have the baseModule flag set. we store this data in the grid * as outlined in the comments above, in pairs representing intial and current values. */

Source from the content-addressed store, hash-verified

1736 * as outlined in the comments above, in pairs representing intial and current values.
1737 */
1738void SavedBattleGame::calculateModuleMap()
1739{
1740 _baseModules.resize((_mapsize_x / 10), std::vector<std::pair<int, int> >((_mapsize_y / 10), std::make_pair(-1, -1)));
1741
1742 for (int x = 0; x != _mapsize_x; ++x)
1743 {
1744 for (int y = 0; y != _mapsize_y; ++y)
1745 {
1746 Tile *tile = getTile(Position(x,y,_mapsize_z-1));
1747 if (tile && tile->getMapData(MapData::O_OBJECT) && tile->getMapData(MapData::O_OBJECT)->isBaseModule())
1748 {
1749 _baseModules[x/10][y/10].first += _baseModules[x/10][y/10].first > 0 ? 1 : 2;
1750 _baseModules[x/10][y/10].second = _baseModules[x/10][y/10].first;
1751 }
1752 }
1753 }
1754}
1755
1756/**
1757 * get a pointer to the geoscape save

Callers 1

runMethod · 0.80

Calls 4

isBaseModuleMethod · 0.80
PositionClass · 0.70
resizeMethod · 0.45
getMapDataMethod · 0.45

Tested by

no test coverage detected