I saw Afforess posted this in the 3.19 bug thread. Since FfH also allows increase to capacity, I wanted to report it here.
Best wishes,
Breunor
Jdog5000, I've found the cause of a rare-ish CTD, and a possible fix for it.
In CvPlayerAI.cpp, in the function "TechTypes CvPlayerAI::AI_bestTech(int iMaxPathLength, bool bIgnoreCost, bool bAsync, TechTypes eIgnoreTech, AdvisorTypes eIgnoreAdvisor) const" There is a section where in rare instances, the formula divides by 0.
The code in question is this section:
Code:
int iNewCapacity = kLoopUnit.getMoves() * kLoopUnit.getCargoSpace();
int iOldCapacity = GC.getUnitInfo(eExistingUnit).getMoves() * GC.getUnitInfo(eExistingUnit).getCargoSpace();
iAssaultValue += (800 * (iNewCapacity - iOldCapacity)) / iOldCapacity;
In Vanilla BTS, the iOldCapacity is never 0, but in Rise of Mankind (and possibly other mods), there is a promotion that adds an extra cargo space to ships, even to ships without preexisting cargo space. If the AI gave this promotion to a ship without cargo space, the iOldCapacity would be 0, and the function would divide by 0. I fixed this by changing that segment of code into this:
Code:
int iNewCapacity = kLoopUnit.getMoves() * kLoopUnit.getCargoSpace();
int iOldCapacity = GC.getUnitInfo(eExistingUnit).getMoves() * GC.getUnitInfo(eExistingUnit).getCargoSpace();
if (iOldCapacity <= 0)
{iAssaultValue += (600 * iNewCapacity);}
else
{iAssaultValue += (800 * (iNewCapacity - iOldCapacity)) / iOldCapacity;}
That fixed the CTD and allow me to go to the next turn. I would appreciate it if this fix made it into the next UP.
__________________
Best wishes,
Breunor
Jdog5000, I've found the cause of a rare-ish CTD, and a possible fix for it.
In CvPlayerAI.cpp, in the function "TechTypes CvPlayerAI::AI_bestTech(int iMaxPathLength, bool bIgnoreCost, bool bAsync, TechTypes eIgnoreTech, AdvisorTypes eIgnoreAdvisor) const" There is a section where in rare instances, the formula divides by 0.
The code in question is this section:
Code:
int iNewCapacity = kLoopUnit.getMoves() * kLoopUnit.getCargoSpace();
int iOldCapacity = GC.getUnitInfo(eExistingUnit).getMoves() * GC.getUnitInfo(eExistingUnit).getCargoSpace();
iAssaultValue += (800 * (iNewCapacity - iOldCapacity)) / iOldCapacity;
In Vanilla BTS, the iOldCapacity is never 0, but in Rise of Mankind (and possibly other mods), there is a promotion that adds an extra cargo space to ships, even to ships without preexisting cargo space. If the AI gave this promotion to a ship without cargo space, the iOldCapacity would be 0, and the function would divide by 0. I fixed this by changing that segment of code into this:
Code:
int iNewCapacity = kLoopUnit.getMoves() * kLoopUnit.getCargoSpace();
int iOldCapacity = GC.getUnitInfo(eExistingUnit).getMoves() * GC.getUnitInfo(eExistingUnit).getCargoSpace();
if (iOldCapacity <= 0)
{iAssaultValue += (600 * iNewCapacity);}
else
{iAssaultValue += (800 * (iNewCapacity - iOldCapacity)) / iOldCapacity;}
That fixed the CTD and allow me to go to the next turn. I would appreciate it if this fix made it into the next UP.
__________________