OK, here are the other bugs. They are in CvGame::normalizeAddExtras(). That function has five main loops, which I'll name.
L1: Just calculates the best and worst starting location values.
L2: Adds forests.
L3: Counts ocean food, coast food, land food, and water tiles.
L4: Adds resources.
L5: Adds hills.
1st Bug:
In L3, instead of counting water tiles in the BFC, it counts all 20 tiles. Later on this will imply that bLandBias is always true instead of only being true if more than half the BFC tiles are water.
Here is the relevant code:
Code:
iWaterCount++;
if (pLoopPlot->isWater())
{
...
To fix the bug, move "iWaterCount++;" inside the test for whether the plot is water.
Note: It is theoretically possible that bugs 2-4 are not actually bugs but are actually a weird feature. I will explain this possibility after saying what they are.
2nd Bug:
In L4 - search for "(bLandBias" - there is the following if statement:
Code:
if (bLandBias && !(pLoopPlot->isWater()) && pLoopPlot->getBonusType() != NO_BONUS)
What it's trying to do is notice situations where you have many water tiles, and where you are looking at a land tile that the main code failed to place a resource on because of a feature (forest). The idea is to maybe remove the forest in this case, and try again.
To fix it, replace the "!= NO_BONUS" with "== NO_BONUS".
3rd Bug:
Within the aforementioned if statement, there is this code:
Code:
pLoopPlot->setFeatureType(NO_FEATURE);
if (getSorenRandNum(2, "Clear feature do add bonus") == 0)
{
...
What it does is remove the feature, then if the random test succeeds try to place a resource there. It seems pretty likely that the removal of the feature is meant to happen inside the test, and this is another mistake like the one in the first bug.
Fix: move "pLoopPlot->setFeatureType(NO_FEATURE);" inside the if block.
4th Bug:
This requires a bit of background. In the first section of L4, where it is trying to add resources normally, there is this code:
Code:
pLoopPlot->setBonusType((BonusTypes)iK);
iCount++;
iCoastFoodCount += bCoast ? 1 : 0;
iOceanFoodCount += bOcean ? 1 : 0;
iOtherCount += !(bCoast || bOcean) ? 1 : 0;
break;
But in the second loop - which only applies to land tiles - there is this code:
Code:
pLoopPlot->setBonusType((BonusTypes)iK);
iCount++;
iCoastFoodCount += bCoast ? 1 : 0;
iOceanFoodCount += bOcean ? 1 : 0;
break;
It's the same except it's missing the line "iOtherCount += !(bCoast || bOcean) ? 1 : 0;" which it should not be missing; in fact, that line is the only one of the three lines like it that could apply on a land tile. Without this change, it will not count resources that it placed this way.
Fix: make the inside of the second loop look like the inside of the first loop by adding that line.
OK, now it is possible that what I called bugs 2-4 are actually how it is supposed to work. Here's what that would mean in a normal game:
The second part of L4, which only triggers on a land plot in a city which is more than half water, is supposed to do this instead:
-If we successfully placed a resource on a land plot with a forest (we have to have placed it, because the whole pair of resource-adding blocks is in an if statement which tests that there is no resource there),
-If our city is more than half water and has 3+ seafood,
-Then remove that forest
-And based on a die roll, sometimes replace the resource (fur or deer - which also implies this is a tundra forest) with a different resource.
I consider this a possibility because it simultaneously explains the test for a resource (bug 2) and the lack of incrementing the placed resources count (bug 4). However, as a feature, it doesn't make much sense. With default XML and start era all it does is kill tundra forests and then maybe replace the fur or deer with something else that lives in the tundra. (It also messes up iCount which, to be fair, is never used.)
I think it makes a lot more sense as "we don't want to place only water resources but the outlook isn't good because we have more than half water tiles, have already placed 3 water resources, and we are unable to place a resource on this tile without removing the forest".