help lease, game crash when...

hrochland

Prince
Joined
Apr 9, 2006
Messages
2,511
Location
Czech Kingdom
Can someone, please, check if is this code from CvGameUtils.py OK? Above all Forest Mod part. This part does to I can build MUSEUM building in city only in that case, when is IMPROVEMENT_EXPLORETEMPLE in activ scope of activity of this one city.

Now if I click on build museum button, game is crash :(
See you any error in code, please?

Code:
	def cannotConstruct(self,argsList):
		pCity = argsList[0]
		eBuilding = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]

		### Forest Mod begins ###
		###########################################################################################
		bCannotConstruct = True
		if eBuilding == gc.getInfoTypeForString("BUILDING_MUSEUM") :
			iX = pCity.getX()
			iY = pCity.getY()
			for iiX in range(iX-1, iX+2, 1):
				for iiY in range(iY-1, iY+2, 1):
					pPlot = CyMap().plot(iiX,iiY)
					if pPlot.getOwner() == pCity.getOwner():
						if pPlot.getImprovementType() == gc.getInfoTypeForString("IMPROVEMENT_EXPLORETEMPLE"):
							bCannotConstruct = False
			if bCannotConstruct:
				return True
		###########################################################################################
		### forest Mod ends ###

		## Begin zLeaders
		if leaders.cannotConstructBuilding(pCity.getOwner(), eBuilding):
			return True
		## End zLeaders

		### MachuPicchu Mod begins ###
		###########################################################################################

		if ( eBuilding == gc.getInfoTypeForString("BUILDING_MACHU_PICCHU") ):

			### find peaks within the city radius controlled by your team ###
			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			iPID = pPlayer.getID()
			iTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()
			for iXLoop in range(iX - 2, iX + 3, 1):
				for iYLoop in range(iY - 2, iY + 3, 1):
					pPlot = CyMap().plot(iXLoop, iYLoop)
					if ( pPlot.isPlayerCityRadius(iPID)==true ):
						if ( pPlot.getTeam()==iTID ):
							if ( pPlot.isPeak()==true  ):
								return False
			return True

		###########################################################################################
		### MachuPicchu Mod ends ###

		return False
 
Have you tried to comment this part and click on the button to check if you get the bug ? The code seems good and this function is called before you're able to click on the construct building button .

Tcho !

Edit : 2 details :
- after "pPlot = CyMap().plot(iiX,iiY)" and "pPlot = CyMap().plot(iXLoop, iYLoop)" you should check if the plot is valid ( in case you're at the border of the map with no wrap : just add "if pPlot.isNone() : continue" .
- you can remove from the 2 tests in machu pichu "==true" .
 
Have you tried to comment this part and click on the button to check if you get the bug ? The code seems good and this function is called before you're able to click on the construct building button .

Tcho !

Edit : 2 details :
- after "pPlot = CyMap().plot(iiX,iiY)" and "pPlot = CyMap().plot(iXLoop, iYLoop)" you should check if the plot is valid ( in case you're at the border of the map with no wrap : just add "if pPlot.isNone() : continue" .
- you can remove from the 2 tests in machu pichu "==true" .

Thanks, Sto
but I´am not programmer. This code I was given.
But if you think Forest Mod code affected Machu Picchu code can I move Forest Mod code after Machu Picchu code? Will help it?

I'm afraid that if I delete (remove) "==true" in machu pichu, it will corupt Machu Picchu code. :(
 
But if you think Forest Mod code affected Machu Picchu code can I move Forest Mod code after Machu Picchu code? Will help it?

No that will not help . I just tell you to comment the forest MOD to check if the crash occurs even if there is not restriction ( i don't think the crash comes from the python code )

I'm afraid that if I delete (remove) "==true" in machu pichu, it will corupt Machu Picchu code. :(

No , It will not .

Tcho !
 
Thanks, Sto
I will test it
My system for work with python is: "trial and error" but I will work on it because this function is for me very eventful (crucial).
thanks
HROCHland
 
I tested Forest mod separately. Mod work good. Here is, how you wrote, Sto, at the beginning conflict between various python parts. Can someone, plese try find this conflict in code what I pasted above
Thanks
HROCHland
 
Code:
			if bCannotConstruct:
				return True
			else:
				return False

Perhaps there is a conflict with leader.... You can try that . But i don't understand why the crash occurs when you click on the button ( this function is called to make the list of available buildings in the city screen ) . Do you have the error log ?

Tcho !
 
you have to edit CivilizationIV.ini (vanilla ,warlords or BtS , the one you use for your MOD ) and set :

; Enable message logging
MessageLog = 1

; Enable the logging system
LoggingEnabled = 1

; Overwrite old network and message logs
OverwriteLogs = 1

; Set to 1 for no python exception popups
HidePythonExceptions = 0

then launch a game with the error and you can zip and attach "PythonErr.log" to the post . "PythonErr.log" is located in the log document folder (vanilla ,warlords or BtS ) .

Tcho !
 
Back
Top Bottom