Help in fixing python errors

Alrik2002

Warlord
Joined
May 24, 2012
Messages
214
Location
Berlin, Germany
Hi,

it´s me again with some errors which occur in a Pitboss game with one human player in a team with an ai againts several ai teams.

Within the game, no python error occurs but at the beginning of a turn, I can´t choose any action with the unit which is chosen. I can´t even end the turn. When I open the log PythonErr on the Pitboss afterwards. I´ve several failures. No failures in the logs of the computer I use for plaing.

The 1st:
Error:
Code:
Traceback (most recent call last):
  File "BugEventManager", line 362, in _handleDefaultEvent
  File "AIAutoPlay", line 151, in onBeginPlayerTurn
AttributeError: 'NoneType' object has no attribute 'isAlive'

Line 151 in AIAutoPlay (in red):
Code:
    def onBeginPlayerTurn( self, argsList ) :
        iGameTurn, iPlayer = argsList

        if( game.getAIAutoPlay() == 1 and iPlayer > game.getActivePlayer() and gc.getActivePlayer().isAlive() ) :
            # Forces isHuman checks to come through positive for everything after human players turn

            self.checkPlayer()
            game.setAIAutoPlay(0)
        
        elif( self.bSaveAllDeaths ) :
            [COLOR="Red"]if( game.getAIAutoPlay() == 0 and not gc.getActivePlayer().isAlive() and iPlayer > game.getActivePlayer() ) :[/COLOR]
                self.checkPlayer()
                game.setAIAutoPlay(0)

Could please someone help me to understand what is checked there and what goes wrong, so I can try to fix it. Thank you.
 
Now I´ve the time to post the other errors of the log. Sorry for the long post...:eek:

The 2nd:
Error:
Code:
Traceback (most recent call last):
  File "BugInit", line 93, in callInits
  File "Scoreboard", line 102, in init
  File "Scoreboard", line 153, in __init__
RuntimeError: unidentifiable C++ exception

line 153 in Scoreboard.py (in red):
Code:
class Column:
	
	def __init__(self, key, id, type=SKIP, text=None, alt=None):
		self.key = key
		self.id = id
		self.type = type
		self.text = text
		self.alt = alt
		if (type == FIXED):
			[COLOR="Red"]self.width = CyInterface().determineWidth( text )[/COLOR]
		else:
			self.width = 0
		if (key):
			columnsByKey[key] = self

The 3rd:
Error:
Code:
Traceback (most recent call last):
  File "BugEventManager", line 362, in _handleDefaultEvent
  File "autologEventManager", line 326, in onLoadGame
  File "autologEventManager", line 1466, in storeWhip
AttributeError: 'NoneType' object has no attribute 'getNumCities'

line 1466 in autologEventManager.py (in red):
Code:
	def storeWhip(self):
		# store the city whip counter
		iPlayer = gc.getActivePlayer()
		[COLOR="Red"]for i in range(0, iPlayer.getNumCities(), 1):[/COLOR]
			iCity = iPlayer.getCity(i)
			self.CityWhipCounter[i] = iCity.getHurryAngerTimer()
			self.CityConscriptCounter[i] = iCity.getConscriptAngerTimer()

The 4th:
Error:
Code:
Traceback (most recent call last):
  File "BugEventManager", line 362, in _handleDefaultEvent
  File "Civ4lerts", line 176, in onLoadGame
  File "Civ4lerts", line 237, in _reset
  File "Civ4lerts", line 299, in reset
  File "PlayerUtil", line 545, in playerCities
AttributeError: 'NoneType' object has no attribute 'firstCity'

line 545 in PlayerUtil.py (in red):
Code:
def playerCities(playerOrID, testFunc=None):
	"""
	Creates an iterator for the CyCity objects owned by the given player.
	
	If testFunc is given, only cities for which it returns True are returned.
	
	for city in PlayerUtil.playerCities(PlayerUtil.getActivePlayerID()):
		...
	"""
	player = getPlayer(playerOrID)
	[COLOR="Red"]city, iter = player.firstCity(False)[/COLOR]
	while city:
		if not city.isNone() and (testFunc is None or testFunc(city)):
			yield city
		city, iter = player.nextCity(iter, False)

additional Information:
Code:
## Utilities for dealing with Players and their Teams, Cities and Units.
##
## All functions in thie module that take a playerOrID or teamOrID as their
## parameter will accept either the CyPlayer/CyTeam object or its ID.
## Many of them will probably also accept a PyPlayer/PyTeam wrapper, but I
## recommend that you use getCy() on the object instead.
##
##   getPlayer(playerOrID)
##     Returns the CyPlayer given an ID or CyPlayer
##   getPlayerID(playerOrID)
##     Returns the ID given an ID or CyPlayer
##   getPlayerAndID(playerOrID)
##     Returns the ID and CyPlayer given an ID or CyPlayer
##
## Similar functions exist for Teams, Players and Teams together, and active
## versions that don't require an ID or object, using the active player instead.
## All of them return -1 and/or None if given -1 or None for playerOrId.
##
##   players(), teams(), teamPlayers(teamOrID)
##     Loops over players and teams matching various criteria.
##     Only valid objects that were alive at some point are returned, and they can
##     be filtered further by alive, human, barbarian, and/or minor status.
##
##   playerUnits(playerOrID, testFunc), playerCities(playerOrID, testFunc)
##     Loops over a player's units or cities.
##   getPlayerUnits(playerOrID, testFunc), getPlayerCities(playerOrID, testFunc)
##     Returns a list of a player's units or cities.

The 5th:
Error:
Code:
Traceback (most recent call last):
  File "BugEventManager", line 362, in _handleDefaultEvent
  File "Civ4lerts", line 746, in onBeginActivePlayerTurn
  File "TradeUtil", line 153, in getGoldTradePartners
  File "TradeUtil", line 268, in getTradePartnersByTeam
AttributeError: 'NoneType' object has no attribute 'getTeam'

line 268 in TradeUtil.py (in red):
Code:
def getTradePartnersByTeam(playerOrID, testFunction, *args):
	"""
	Returns a list of CyPlayers that can trade with <player>.
	
	<testFunction> is passed two CyTeams plus <args> for each viable pairing and should return a boolean value.
	"""
	player = PlayerUtil.getPlayer(playerOrID)
	[COLOR="Red"]team = PlayerUtil.getTeam(player.getTeam())[/COLOR]
	partners = []
	for partner in tradeParters(player):
		if testFunction(team, PlayerUtil.getTeam(partner.getTeam()), *args):
			partners.append(partner)
	return partners

The 6th:
Error:
Code:
Traceback (most recent call last):
  File "BugEventManager", line 362, in _handleDefaultEvent
  File "Civ4lerts", line 826, in onBeginActivePlayerTurn
  File "Civ4lerts", line 860, in check
KeyError: -1

line 860 in Civ4lerts.py (in red):
Code:
	def check(self):
		if (not Civ4lertsOpt.isShowRefusesToTalkAlert()):
			return
		eActivePlayer, activePlayer = PlayerUtil.getActivePlayerAndID()
		[COLOR="Red"]refusals = self.refusals[eActivePlayer][/COLOR]
		newRefusals = set()
		for player in PlayerUtil.players(True, False, False, False):
			if DiplomacyUtil.canContact(activePlayer, player) and not DiplomacyUtil.isWillingToTalk(player, eActivePlayer):
				newRefusals.add(player.getID())
		self.display(eActivePlayer, "TXT_KEY_CIV4LERTS_ON_WILLING_TO_TALK", refusals.difference(newRefusals))
		self.display(eActivePlayer, "TXT_KEY_CIV4LERTS_ON_REFUSES_TO_TALK", newRefusals.difference(refusals))
		self.refusals[eActivePlayer] = newRefusals

The 7th:
Error:
Code:
Traceback (most recent call last):
  File "BugEventManager", line 362, in _handleDefaultEvent
  File "Civ4lerts", line 897, in onBeginActivePlayerTurn
  File "Civ4lerts", line 936, in check
KeyError: -1

line 936 in Civ4lerts.py (in red):
Code:
	def check(self):
		if (not Civ4lertsOpt.isShowWorstEnemyAlert()):
			return
		eActivePlayer = PlayerUtil.getActivePlayerID()
		eActiveTeam, activeTeam = PlayerUtil.getActiveTeamAndID()
		[COLOR="Red"]enemies = self.enemies[eActivePlayer][/COLOR]
		newEnemies = AttitudeUtil.getWorstEnemyTeams()
		delayedMessages = {}
		for eTeam, eNewEnemy in newEnemies.iteritems():
			if activeTeam.isHasMet(eTeam):
				eOldEnemy = enemies[eTeam]
				if eOldEnemy != -1 and not gc.getTeam(eOldEnemy).isAlive():
					eOldEnemy = -1
					enemies[eTeam] = -1
				#Fuyu Assert failure fix
				if eActiveTeam != eNewEnemy and eNewEnemy != -1:
					if not activeTeam.isHasMet(eNewEnemy):
						eNewEnemy = -1
				if eOldEnemy != eNewEnemy:
					enemies[eTeam] = eNewEnemy
					if eNewEnemy == -1:
						if eOldEnemy == eActiveTeam:
							message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_YOU_NO_WORST_ENEMY", gc.getTeam(eTeam).getName())
						else:
							message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_NO_WORST_ENEMY", 
									(gc.getTeam(eTeam).getName(), gc.getTeam(eOldEnemy).getName()))
					elif eOldEnemy == -1:
						message = None # handled below
						if eNewEnemy not in delayedMessages:
							delayedMessages[eNewEnemy] = gc.getTeam(eTeam).getName()
						else:
							delayedMessages[eNewEnemy] += u", " + gc.getTeam(eTeam).getName()
					else:
						if eOldEnemy == eActiveTeam:
							message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_SWITCH_WORST_ENEMY_FROM_YOU", 
									(gc.getTeam(eTeam).getName(), gc.getTeam(eNewEnemy).getName()))
						elif eNewEnemy == eActiveTeam:
							message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_SWITCH_WORST_ENEMY_TO_YOU", 
									(gc.getTeam(eTeam).getName(), gc.getTeam(eOldEnemy).getName()))
						else:
							message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_SWITCH_WORST_ENEMY", 
									(gc.getTeam(eTeam).getName(), gc.getTeam(eNewEnemy).getName(), gc.getTeam(eOldEnemy).getName()))
					if message:
						addMessageNoIcon(eActivePlayer, message)
		for eEnemy, haters in delayedMessages.iteritems():
			if eActiveTeam == eEnemy:
				message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_YOU_WORST_ENEMY", haters)
			else:
				message = BugUtil.getText("TXT_KEY_CIV4LERTS_ON_WORST_ENEMY", (haters, gc.getTeam(eEnemy).getName()))
			addMessageNoIcon(eActivePlayer, message)

The 8th:
Error:
Code:
Traceback (most recent call last):
  File "BugEventManager", line 362, in _handleDefaultEvent
  File "MoreCiv4lerts", line 140, in onBeginActivePlayerTurn
  File "PyHelpers", line 46, in getTeam
  File "PyHelpers", line 42, in getTeamID
AttributeError: 'NoneType' object has no attribute 'getTeam'

line 42 in PyHelpers.py (in red):
Code:
	def getTeamID(self):
		' int - gets the players teamID '
		[COLOR="Red"]return self.player.getTeam()[/COLOR]
 
Thank you very much for your response. I´ve read that actually the ActivePlayer could cause problems in network-games because then everyone is the ActivePlayer on his PC, which could end in OOS. But a crash like this I never heard of.

Does anyone have any proposals how I could change the code so it doesn´t use the ActivePlayer anymore?

Thank you for your help!
 
Top Bottom