//The return value is the amount of treasure on board. int CvSelectionGroupAI::AI_getYieldsLoaded(short* piYields) { if (piYields != NULL) { for (int i = 0; i < NUM_YIELD_TYPES; ++i) { piYields[i] = 0; } } int iAmount = 0; CLinkList<IDInfo> unitList; buildCargoUnitList(unitList); CLLNode<IDInfo>* pUnitNode = unitList.head(); while (pUnitNode != NULL) { CvUnit* pLoopUnit = ::getUnit(pUnitNode->m_data); pUnitNode = unitList.next(pUnitNode); if (pLoopUnit->getYieldStored() > 0) { if (pLoopUnit->getUnitInfo().isTreasure()) { iAmount += pLoopUnit->getYieldStored(); } else if (pLoopUnit->getYield() != NO_YIELD) { if (piYields != NULL) { piYields[pLoopUnit->getYield()] += pLoopUnit->getYieldStored(); } } } } return iAmount; }
void CvPlotGroup::recalculatePlots() { PROFILE_FUNC(); CLLNode<XYCoords>* pPlotNode; CvPlot* pPlot; CLinkList<XYCoords> oldPlotGroup; XYCoords xy; PlayerTypes eOwner; int iCount; eOwner = getOwnerINLINE(); pPlotNode = headPlotsNode(); if (pPlotNode != NULL) { pPlot = GC.getMapINLINE().plotSorenINLINE(pPlotNode->m_data.iX, pPlotNode->m_data.iY); iCount = 0; gDLL->getFAStarIFace()->SetData(&GC.getPlotGroupFinder(), &iCount); gDLL->getFAStarIFace()->GeneratePath(&GC.getPlotGroupFinder(), pPlot->getX_INLINE(), pPlot->getY_INLINE(), -1, -1, false, eOwner); if (iCount == getLengthPlots()) { return; } } oldPlotGroup.clear(); pPlotNode = headPlotsNode(); while (pPlotNode != NULL) { pPlot = GC.getMapINLINE().plotSorenINLINE(pPlotNode->m_data.iX, pPlotNode->m_data.iY); FAssertMsg(pPlot != NULL, "Plot is not assigned a valid value"); xy.iX = pPlot->getX_INLINE(); xy.iY = pPlot->getY_INLINE(); oldPlotGroup.insertAtEnd(xy); pPlot->setPlotGroup(eOwner, NULL); pPlotNode = deletePlotsNode(pPlotNode); // will delete this PlotGroup... } pPlotNode = oldPlotGroup.head(); while (pPlotNode != NULL) { pPlot = GC.getMapINLINE().plotSorenINLINE(pPlotNode->m_data.iX, pPlotNode->m_data.iY); FAssertMsg(pPlot != NULL, "Plot is not assigned a valid value"); pPlot->updatePlotGroup(eOwner, true); pPlotNode = oldPlotGroup.deleteNode(pPlotNode); } }