Hello,
I encountered a few bugs with the resurrection on the release version of the mod (using linux+wine6.5, i also installed all the module proposed by the installer). I'll give a description of when it happens in-game, what i have gathered on the problems and the workaround i applied. I'll name the bug 1,2 (Bug 2 is exactly the one encountered
here) and 3 and give the log and the save the turn before the problem happens.
Playing China (no civilization switch) on the 3000BC scenario on marathon speed, after a collapse the viking civilization resurrect itself turn 871 as its cities kept were all independent at the time. Bug 1 happens and stop the resurrection limiting the viking to the city of Copenhagen.
Bug 1:
In the function
doResurrection of
Stability.py :
- A list of units to flip lFlippedUnits or relocate lRelocatedUnits is made by the call of flipOrRelocateGarrison including units inside the city.
- When completeCityFlip is called bFlipUnits is true
- In completeCityFlip when flipUnitsInCityBefore is called some units are killed
- After the city flip flipOrRelocateGarrison tries to flip unit that were already destroyed by the flip.
I tried two workaround to correct this bug first to set
bFlipUnits to false here in check resurrection
Code:
if pOwner.isBarbarian() or pOwner.isMinorCiv(): #1591 stability.py
#completeCityFlip(city, iPlayer, iOwner, 100, False, True, True, True) #original
completeCityFlip(city, iPlayer, iOwner, 100, False, True, True)
else:
completeCityFlip(city, iPlayer, iOwner, 75, False, True, True)
Then after failing to correct the bug by changing
RFCUtils.py to its version as of commit
f8ee4ba2083c4b33cfdfc74cfda2bf9980f78c0c (as commit on the file showed bugfixes where made for unit manipulation) i commented the lines responsible for removing units in
flipUnitsInCityBefore
Code:
def flipUnitsInCityBefore(tCityPlot, iNewOwner, iOldOwner): #123 RFCUtils.py
plotUnits = units.at(tCityPlot).owner(iOldOwner)
flippingUnits = plotUnits.where(lambda unit: not is_minor(unit) or (not unit.isAnimal() and not unit.isFound()))
#removedUnits = plotUnits.where(lambda unit: not unit.isCargo()
data.lFlippingUnits = [unit.getUnitType() for unit in flippingUnits]
#for unit in removedUnits:
#unit.kill(False, -1)
I didn't try to modify
flipOrRelocateGarrison as not handling the garrison here seems to lead to unwanted behavior for the flip of a civilization owned by a major civ, the true solution i tried to implement was to filter the garrison from the
lFlippedUnits just before the flip by comparing unit and city location like this :
Code:
if pOwner.isBarbarian() or pOwner.isMinorCiv(): #1591 stability.py
filter(lamdba unit : location(unit) != location(city),lFlippedUnits)
completeCityFlip(city, iPlayer, iOwner, 100, False, True, True, True) #original
It didn't work, but i tested under the hypothesis that only
lFlippedUnits would be of importance and filtering
lRelocatedUnits may allow to stop the exception from happening.
Bug 2:
Already reported
here changing
RFCUtils.py and corrected in the git version (as of commit
f8ee4ba2083c4b33cfdfc74cfda2bf9980f78c0c, no new exception were introduced for this resurrection as i tried to change just
completeCityFlip and the whole file
)
Bug 3:
Still in
doResurrection of
Stability.py :
- When trying to add former colonies, the check to insure that cities in lCityList are not in the list does not actually work and cities added in getResurrectionCities are added again
- The script do its work until it encounter one of the duplicate city, as the city flip invalidated the city an exception is thrown when calling city.isCapital()
I worked around this problem by applying the following modification to the loop.
Code:
lCityLocation = [location(city) for city in lCityList] #1560 added
# add former colonies that are still free
for city in players.minor().alive().cities().where(lambda city: city.getOriginalOwner() == iPlayer):
if pPlayer.getSettlerValue(city.getX(), city.getY()) >= 90:
#if city not in lCityList: #original
if location(city) not in lCityLocation:
lCityList.append(city)
AFAIK this could work as a fix to this bug
.
Hoping this is as useful as can be.