Dresden
Emperor
- Joined
- Jul 10, 2008
- Messages
- 1,081
I've been going through the diffs between the unofficial patch source (0.19) and the original 3.17 source to see which changes I wanted to incorporate into my personal game core and I don't understand the fix for the forest spam bug in CvGame::normalizeAddExtras(). (i.e. The game filling your starting location with forests before it tries to place extra resources.)
Based upon my reading of SevenSpirits' details for fixing it, the forest-adding code is supposed to be moved from its original placement before the resource-adding loop to a later position either after the resource-adder or further down after the hill adder. Quoting part of the linked post:
Further muddying the waters, Bhruic talked about a different fix in a reply (#1310) to the above quoted post. After reading his comment and looking at that source, that fix did involve essentially copying the forest loop but it also reinstated the randomizer so that the first pass-through didn't cover every tile. Since the second version of the forest loop matches Bhruic's second loop it seems like this fix was intended. However, in the sources for 0.19, the randomizer clause is still commented out meaning this is different from the Bhruic fix too.
So which of the following is right?
Based upon my reading of SevenSpirits' details for fixing it, the forest-adding code is supposed to be moved from its original placement before the resource-adding loop to a later position either after the resource-adder or further down after the hill adder. Quoting part of the linked post:
Note the phrases "move the forest-adding code" and "cut and paste." However, in the current unofficial patch source, that section of code seems not to have been moved but instead copied as it exists in both its original position and in one of the recommended spots after the resource function.I think the best fix is to move the forest-adding code to below the resource-placing code.
[...]
To implement this change, you just need to cut and paste a block of code. Here is the block in question:
Spoiler :Code:shuffleArray(aiShuffle, NUM_CITY_PLOTS, getMapRand()); for (iJ = 0; iJ < NUM_CITY_PLOTS; iJ++) { if (GET_PLAYER((PlayerTypes)iI).AI_foundValue(pStartingPlot->getX_INLINE(), pStartingPlot->getY_INLINE(), -1, true) >= iTargetValue) { break; } { pLoopPlot = plotCity(pStartingPlot->getX_INLINE(), pStartingPlot->getY_INLINE(), aiShuffle[iJ]); if (pLoopPlot != NULL) { if (pLoopPlot != pStartingPlot) { if (pLoopPlot->getBonusType() == NO_BONUS) { if (pLoopPlot->getFeatureType() == NO_FEATURE) { for (iK = 0; iK < GC.getNumFeatureInfos(); iK++) { if ((GC.getFeatureInfo((FeatureTypes)iK).getYieldChange(YIELD_FOOD) + GC.getFeatureInfo((FeatureTypes)iK).getYieldChange(YIELD_PRODUCTION)) > 0) { if (pLoopPlot->canHaveFeature((FeatureTypes)iK)) { pLoopPlot->setFeatureType((FeatureTypes)iK); iCount++; break; } } } } iFeatureCount += (pLoopPlot->getFeatureType() != NO_FEATURE) ? 1 : 0; } } } } }
It's near the beginning of CvGame::normalizeAddExtras(). It starts with the first mention in that function of shuffleArray.
There are three loops in the function preceded by shuffleArray. The second one is for resources and the third for hills. Paste the indicated code after either the second or the third such loop.
Note that the code I mentioned is preceded by
int iFeatureCount = 0;
Leave that line where it is and (trust me) it will all work out. There's another reference to iFeatureCount in the function but it is conveniently unreachable (and inconsequential).
Further muddying the waters, Bhruic talked about a different fix in a reply (#1310) to the above quoted post. After reading his comment and looking at that source, that fix did involve essentially copying the forest loop but it also reinstated the randomizer so that the first pass-through didn't cover every tile. Since the second version of the forest loop matches Bhruic's second loop it seems like this fix was intended. However, in the sources for 0.19, the randomizer clause is still commented out meaning this is different from the Bhruic fix too.
So which of the following is right?
- This patch implemented Bhruic's fix. If so, shouldn't the randomizer clause for the first pass be reinstated?
- This patch implemented SevenSpirits' suggestion. If so, shouldn't the first forest-adding loop be removed?
- This patch implemented its own fix different from the previous two. If so, could somebody explain it to me?
- None of the above. In that case, I'm hopelessly confused...