Hi everybody,
I'm trying to implement a land reclamation system where a land reclamation boat turns a coastal tile into grass land.
This is the function that actually converts sea into land:
When running this, the game keeps crashing. It must have sth to do with the units on the plot, because according to WinDbg the commands that are causing the crash are things like
CvPlot::headUnitNode()
CvArea::getNumUnits()
Does anyone have an idea? Thanks in advance.
I'm trying to implement a land reclamation system where a land reclamation boat turns a coastal tile into grass land.
This is the function that actually converts sea into land:
Code:
void CvPlot::reclameLand()
{
CvPlot* pPlot;
CLLNode<IDInfo>* pUnitNode;
CvUnit* pLoopUnit;
// Get the unit out of the way first
pUnitNode = headUnitNode();
while (pUnitNode != NULL)
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);
pLoopUnit->kill(false);
}
// Now turn water into land
setPlotType(PLOT_LAND,true,true);
for (int iK = 0; iK < NUM_DIRECTION_TYPES; iK++)
{
CvPlot* pLoopPlot = plotDirection(getX_INLINE(), getY_INLINE(), ((DirectionTypes)iK));
if (pLoopPlot != NULL)
{
pLoopPlot->updateSymbols();
pLoopPlot->updateFeatureSymbol(true);
pLoopPlot->updateSymbolDisplay();
pLoopPlot->updateRiverSymbol(true, true);
pLoopPlot->updateMinimapColor();
}
if (!pLoopPlot->isWater())
{
setArea(pLoopPlot->getArea());
}
}
gDLL->getEngineIFace()->RebuildAllPlots();
gDLL->getEngineIFace()->SetDirty(CultureBorders_DIRTY_BIT, true);
}
}
When running this, the game keeps crashing. It must have sth to do with the units on the plot, because according to WinDbg the commands that are causing the crash are things like
CvPlot::headUnitNode()
CvArea::getNumUnits()
Does anyone have an idea? Thanks in advance.