The Great Apple
Big Cheese
CvPlayerAI::AI_getPlotDanger(...) scans plots to check for danger. As far as I can tell it does not check to see if the plot is visible to the AI or not. I've ran a few tests manually setting the scan range to 50 and it seems to pick up on barb units which are well out of sight distance.
The net result of this is that the AI will be able to tell that a plot is dangerous despite not being able to see the plot
Suggested fix:
The net result of this is that the AI will be able to tell that a plot is dangerous despite not being able to see the plot
Suggested fix:
Spoiler Altered code :
Code:
int CvPlayerAI::AI_getPlotDanger(CvPlot* pPlot, int iRange, bool bTestMoves)
{
PROFILE_FUNC();
CLLNode<IDInfo>* pUnitNode;
CvUnit* pLoopUnit;
CvPlot* pLoopPlot;
int iCount;
int iDX, iDY;
iCount = 0;
if (iRange == -1)
{
iRange = DANGER_RANGE;
}
for (iDX = -(iRange); iDX <= iRange; iDX++)
{
for (iDY = -(iRange); iDY <= iRange; iDY++)
{
pLoopPlot = plotXY(pPlot->getX_INLINE(), pPlot->getY_INLINE(), iDX, iDY);
if (pLoopPlot != NULL)
{
[b]// START - TGA | Fixing AI cheat | 2 September 2006
if (pLoopPlot->isVisible(getTeam(), false))
{
// END - TGA | Fixing AI cheat | 2 September 2006[/B]
if (pLoopPlot->area() == pPlot->area())
{
pUnitNode = pLoopPlot->headUnitNode();
while (pUnitNode != NULL)
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = pLoopPlot->nextUnitNode(pUnitNode);
if (atWar(pLoopUnit->getTeam(), getTeam()))
{
if (pLoopUnit->canAttack())
{
if (!(pLoopUnit->isInvisible(getTeam(), false)))
{
if (!bTestMoves || pLoopPlot->isValidRoute(pLoopUnit) || ((pLoopUnit->baseMoves() + ((!(pLoopUnit->isAnimal())) ? getAIVar(105) : 0) + ((pLoopUnit->isHuman()) ? 1 : 0)) >= stepDistance(pPlot->getX_INLINE(), pPlot->getY_INLINE(), pLoopPlot->getX_INLINE(), pLoopPlot->getY_INLINE()))) // TGA | AutoGenFunction | v0.02 | 24 August 2006
{
iCount++;
}
}
}
}
}
}
[B]// START - TGA | Fixing AI cheat | 2 September 2006
}
// END - TGA | Fixing AI cheat | 2 September 2006[/B]
}
}
}
return iCount;
}