// todo - get area counting code out of here; separate to logging void Game::logMap(const CvMap& map) const { #ifdef ALTAI_DEBUG std::ostream& os = CivLog::getLog(CvPlayerAI::getPlayer((PlayerTypes)0))->getStream(); #endif std::map<int, std::pair<int, int> > irrigatableAreaCounts; // TODO check that at least one plot in the area has fresh water if it is irrigatable for (int plotIndex = 0, plotCount = map.numPlots(); plotIndex < plotCount; ++plotIndex) { CvPlot* pPlot = map.plotByIndex(plotIndex); int irrigatableAreaID = pPlot->getIrrigatableArea(); if (irrigatableAreaID != FFreeList::INVALID_INDEX) { int subAreaID = pPlot->getSubArea(); std::map<int, std::pair<int, int> >::iterator iter = irrigatableAreaCounts.find(irrigatableAreaID); if (iter == irrigatableAreaCounts.end()) { irrigatableAreaCounts.insert(std::make_pair(irrigatableAreaID, std::make_pair(subAreaID, 1))); } else { FAssertMsg(iter->second.first == subAreaID, "Irrigatable Area has inconsistent SubArea IDs"); ++iter->second.second; } } } #ifdef ALTAI_DEBUG os << "\n"; #endif for (std::map<int, std::pair<int, int> >::const_iterator ci(irrigatableAreaCounts.begin()), ciEnd(irrigatableAreaCounts.end()); ci != ciEnd; ++ci) { boost::shared_ptr<AltAI::IrrigatableArea> pIrrigatableArea = map.getIrrigatableArea(ci->first); pIrrigatableArea->setNumTiles(ci->second.second); #ifdef ALTAI_DEBUG { os << "\nIrrigatable Area: " << ci->first << " irrigatable = " << pIrrigatableArea->isIrrigatable() << " wet = " << pIrrigatableArea->hasFreshWaterAccess() << " (Sub Area ID = " << pIrrigatableArea->getSubAreaID() << ") has: " << ci->second.second << " plots (out of " << map.getSubArea(ci->second.first)->getNumTiles() << ")\n"; } #endif if (pIrrigatableArea->isIrrigatable() && !pIrrigatableArea->hasFreshWaterAccess()) { #ifdef ALTAI_DEBUG os << "\n"; for (int plotIndex = 0, plotCount = map.numPlots(); plotIndex < plotCount; ++plotIndex) { CvPlot* pPlot = map.plotByIndex(plotIndex); int irrigatableAreaID = pPlot->getIrrigatableArea(); if (irrigatableAreaID == ci->first) { os << pPlot->getCoords() << ", "; } } os << "\n"; #endif } } #ifdef ALTAI_DEBUG os << "\n"; #endif }