ripple01
Emperor
Hello all,
I've been working on an ambitious project to merge two large mods, K-Mod and RevDCM. So far, it has been going pretty well, and I have been able to get a .DLL compiled, and the game loads and plays pretty much without issue. However, I do have a couple of problems stumping me that I am hoping someone can assist with. I have not modified either of these files, so if you have RevDCM the line #'s match the original files.
1)
Traceback (most recent call last):
File "BugEventManager", line 361, in _handleDefaultEvent
File "BarbarianCiv", line 151, in onBeginGameTurn
File "BarbarianCiv", line 917, in checkBarbCities
File "BarbarianCiv", line 1000, in createMinorCiv
RuntimeError: unidentifiable C++ exception
Here is an excerpt from the createMinorCiv function: (I have bolded and italicized the line generating the unidentifiable C++ exception)
2)
Traceback (most recent call last):
File "BugEventManager", line 361, in _handleDefaultEvent
File "Revolution", line 7002, in onModNetMessage
File "Revolution", line 4996, in revolutionNetworkPopupHandler
File "Revolution", line 5545, in processRevolution
RuntimeError: unidentifiable C++ exception
Here is an excerpt from the processRevolution function: (I have bolded and italicized the line causing the unidentifiable C++ exception)
The major issue I've noticed so far is that sometimes when a minor civ is created, the city will have 0 population and as such will never grow. This is obviously not supposed to happen. I suspect it has something to do with the first exception.
When I've got the major bugs sorted out, I will release this merge for interested modders. If you can help me sort this out, you'll be helping out a # of other modders down the road. Many thanks for looking.
I've been working on an ambitious project to merge two large mods, K-Mod and RevDCM. So far, it has been going pretty well, and I have been able to get a .DLL compiled, and the game loads and plays pretty much without issue. However, I do have a couple of problems stumping me that I am hoping someone can assist with. I have not modified either of these files, so if you have RevDCM the line #'s match the original files.
1)
Traceback (most recent call last):
File "BugEventManager", line 361, in _handleDefaultEvent
File "BarbarianCiv", line 151, in onBeginGameTurn
File "BarbarianCiv", line 917, in checkBarbCities
File "BarbarianCiv", line 1000, in createMinorCiv
RuntimeError: unidentifiable C++ exception
Here is an excerpt from the createMinorCiv function: (I have bolded and italicized the line generating the unidentifiable C++ exception)
Code:
newTeam.setIsMinorCiv( True, False )
if( not newPlayer.isAlive() ) :
if( self.LOG_DEBUG ) : CvUtil.pyPrint(" BC - Setting new player alive")
newPlayer.setNewPlayerAlive(True)
civName = newPlayer.getCivilizationDescription(0)
leadName = newPlayer.getName()
if( self.LOG_DEBUG ) : CvUtil.pyPrint(" BC - Minor civ %s (lead by %s) has formed in %s! Turn: %d, Year: %d"%(civName,leadName,cityString,game.getElapsedGameTurns(),game.getTurnYear(game.getElapsedGameTurns())))
# Add replay message
mess = localText.getText("TXT_KEY_BARBCIV_FORM_MINOR", ())%(civName,cityString)
mess = mess[0].capitalize() + mess[1:]
game.addReplayMessage( ReplayMessageTypes.REPLAY_MESSAGE_MAJOR_EVENT, newPlayer.getID(), mess, cityList[0].getX(), cityList[0].getY(), gc.getInfoTypeForString("COLOR_HIGHLIGHT_TEXT"))
for i,giftCity in enumerate(cityList) :
#giftCity.changePopulation(1)
# Using following method to acquire city produces 'revolted and joined' replay messages
[B][I]giftCity.plot().setOwner( newPlayer.getID() )[/I][/B]
# Note: city acquisition may invalidate previous city pointer, so have to create new list of cities
cityList = pyNewPlayer.getCityList()
capital = newPlayer.getCapitalCity()
# Now setup generic new civ, no special types for minors
# Gold
newPlayer.changeGold( 70 + game.getSorenRandNum(100,'BarbarianCiv: give money') )
# Tech
self.giveTechs( iNewPlayer, closeTeams, bNewWorldScenario )
# Units
iNumBarbDefenders = gc.getHandicapInfo( game.getHandicapType() ).getBarbarianInitialDefenders()
[iWorker, iSettler, iScout, iBestDefender, iCounter, iAttack, iMobile, iAttackCity, iAssaultShip] = self.getUnitsForPlayer( iNewPlayer )
# Buildings
[iLibrary, iGranary, iBarracks, iMarket, iWalls, iLighthouse, iForge, iMonument] = self.getBuildingsForPlayer( iNewPlayer )
# Put stuff in cities
for i,city in enumerate(cityList) :
cityX = city.getX()
cityY = city.getY()
pCity = city.GetCy()
self.setupFormerBarbCity(pCity, newPlayer.getID(), iBestDefender, int(iNumBarbDefenders*self.militaryStrength + 0.5))
# Adjust Population
iPop = pCity.getPopulation()
pCity.setPopulation( max([self.minPopulation, min([iPop, self.minPopulation + 1 + 2*newPlayer.getCurrentEra() - i])]) )
if( bNewWorldScenario and self.iNewWorldPolicy > 0 ) :
if( self.iNewWorldPolicy > 1 and not bNonBarbCivUnits ) :
if( len(closeTeams) < 2 and iEra < 2 ) :
iNewPop = max([min([self.minPopulation,iPop]),iPop - 1])
pCity.setPopulation(max([iNewPop,self.minPopulation]))
if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint(" BC - %s has population %d (adj from %d)"%(pCity.getName(),pCity.getPopulation(),iPop))
# Extra units
if(iWorker != -1):
pyNewPlayer.initUnit(iWorker,cityX,cityY,1)
attackUnits = list()
if( iEra > 0 ) :
if( iCounter == iBestDefender ) :
attackUnits.append( newPlayer.initUnit(iAttack,cityX,cityY,UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH ) )
else :
attackUnits.append( newPlayer.initUnit(iCounter,cityX,cityY,UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH ) )
# Buildings
if( i == 0 ) :
if( not bNewWorldScenario or bForeignCivCities or self.iNewWorldPolicy == 0 ) :
if( city.canConstruct( iBarracks ) ) :
if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint(" BC - Constructing %s in %s"%(PyInfo.BuildingInfo(iBarracks).getDescription(),city.getName()))
city.setNumRealBuildingIdx(iBarracks,1)
if( iEra > 0 and city.canConstruct( iGranary ) ) :
if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint(" BC - Constructing %s in %s"%(PyInfo.BuildingInfo(iGranary).getDescription(),city.getName()))
city.setNumRealBuildingIdx(iGranary,1)
if( iEra > 1 and city.canConstruct( iWalls ) ) :
if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint(" BC - Constructing %s in %s"%(PyInfo.BuildingInfo(iWalls).getDescription(),city.getName()))
city.setNumRealBuildingIdx(iWalls,1)
if( iEra > 1 and city.canConstruct( iForge ) ) :
if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint(" BC - Constructing %s in %s"%(PyInfo.BuildingInfo(iForge).getDescription(),city.getName()))
city.setNumRealBuildingIdx(iForge,1)
2)
Traceback (most recent call last):
File "BugEventManager", line 361, in _handleDefaultEvent
File "Revolution", line 7002, in onModNetMessage
File "Revolution", line 4996, in revolutionNetworkPopupHandler
File "Revolution", line 5545, in processRevolution
RuntimeError: unidentifiable C++ exception
Here is an excerpt from the processRevolution function: (I have bolded and italicized the line causing the unidentifiable C++ exception)
Code:
#***********************************
# Acquire city
#joinPlayer.acquireCity( pCity, False, True )
if( self.LOG_DEBUG ) : CvUtil.pyPrint(" Revolt - Population of %s before is %d"%(pCity.getName(),pCity.getPopulation()))
if( self.LOG_DEBUG ) : CvUtil.pyPrint(" Revolt - Check city culture is %d, at %d, %d"%(pCity.getCulture(pPlayer.getID()), pCity.getX(),pCity.getY()))
cityPlot = pCity.plot()
if( pCity.getCulture( pPlayer.getID() ) == 0 ) :
if( self.LOG_DEBUG ) : CvUtil.pyPrint(" Revolt - Forcing culture > 0")
pCity.setCulture( pPlayer.getID(), 1, True )
try :
pCity.plot().setOwner( pRevPlayer.getID() )
except :
print "ERROR in grant independence"
print "ERROR: Failed to set owner of city, %s at plot %d, %d"%(pCity.getName(),cityPlot.getX(),cityPlot.getY())
#print "City culture is %d"%(pCity.getCulture(pPlayer.getID()))
#pCity = cityPlot.getPlotCity()
#print "Post culture in %s is %d"%(pCity.getName(),pCity.getCulture(pPlayer.getID()))
#pRevPlayer.acquireCity( pCity, False, False )
#RevData.initCity(pCity)
# City has become invalid, will cause game to crash if left
print "Destroying city so game can continue"
[B][I]pCity.kill()[/I][/B]
continue
pCity = cityPlot.getPlotCity()
if( self.LOG_DEBUG ) : CvUtil.pyPrint(" Revolt - Population of %s after is %d"%(pCity.getName(),pCity.getPopulation()))
if( pCity.getPopulation() < 1 ) :
if( self.LOG_DEBUG ) : CvUtil.pyPrint(" Revolt - Error! City %s is empty"%(pCity.getName()))
#*************************************
# Save most buildings - should some be destroyed?
for [buildingClass,iNum] in buildingClassList :
buildingType = gc.getCivilizationInfo(pRevPlayer.getCivilizationType()).getCivilizationBuildings(buildingClass)
if( pCity.getNumRealBuilding(buildingType) < iNum ) :
buildingInfo = gc.getBuildingInfo(buildingType)
if( not buildingInfo.isGovernmentCenter() ) :
if( self.LOG_DEBUG ) : CvUtil.pyPrint(" Revolt - Building %s saved"%(buildingInfo.getDescription()))
pCity.setNumRealBuilding( buildingType, iNum )
#if( self.LOG_DEBUG ) : CvUtil.pyPrint(" Revolt - %s at %d, %d"%(pCity.getName(),pCity.getX(),pCity.getY()))
if( self.LOG_DEBUG ) : CvUtil.pyPrint(" Revolt - Culture in %s: %d, plot %d"%(pCity.getName(),pCity.getCulture(pPlayer.getID()),pCity.plot().getCulture(pPlayer.getID())))
newCulVal = int( self.revCultureModifier*max([1.0*pCity.getCulture(pPlayer.getID()),pCity.countTotalCultureTimes100()/200]) )
newPlotVal = int( self.revCultureModifier*max([1.2*pCity.plot().getCulture(pPlayer.getID()),pCity.plot().countTotalCulture()/2]) )
RevUtils.giveCityCulture( pCity, pRevPlayer.getID(), newCulVal, newPlotVal, overwriteHigher = False )
ix = pCity.getX()
iy = pCity.getY()
The major issue I've noticed so far is that sometimes when a minor civ is created, the city will have 0 population and as such will never grow. This is obviously not supposed to happen. I suspect it has something to do with the first exception.
When I've got the major bugs sorted out, I will release this merge for interested modders. If you can help me sort this out, you'll be helping out a # of other modders down the road. Many thanks for looking.