Paasky
Good News Everyone!
If you want to re-create the error you must download my WWII europe mod (2megs, click on the sig) and then download the attached events.py.
As for the problem: Upon loading civ with wwii europe, the game gives a huge bunch of errors. They are:
File "CvEventInterface", line 26, in onEvent (this comes 16 times)
File "CvEventManager", line 170, in handleEvent
AttributeError:
CvWWIIsfnbEvents instance has no attribute 'EventHandlerMap'
Then it just begins from the start, but the eventinterface comes only once. This goes on for such a long tme, I have no idea when it stops.
Line 26 in EventInterface contains:
Line 170 in EventManager contains:
As for what's causing it: The file worked perfectly until I added a piece of code taken from an older, made for civ4, python file.
The purpose of the code is to simulate winter, by changing terrain to snow & back randomly. The plots are divided into 4 'sectors', each of them have different possibilities of snow depending on the week. For example, on week 5 the possibility of snow in Iceland is 100%, while in hungary it is 90%.
The code is in 3 parts:
In def __init__(self):
These are where certain plots of the map are stored, and the possibility of snow on any particular week. (I used etc as the same sort of stuff goes on for a looooooong time. Check the attached file for the complete code)
In def onBeginGameTurn(self, argslist):
This part sends the different sectors & weeks into the actual terrain-changing code.
In def snowcheck(self, sector, sectorweek):
This part then changes the terrain of the plots to TERRIAN_SNOW or back to the original TERRIAN_ (found in the sectors)
The code used to work perfectly in civ4, but for some reason it now gives this strange error. Does anyone have any idea how to fix it?
As for the problem: Upon loading civ with wwii europe, the game gives a huge bunch of errors. They are:
File "CvEventInterface", line 26, in onEvent (this comes 16 times)
File "CvEventManager", line 170, in handleEvent
AttributeError:
CvWWIIsfnbEvents instance has no attribute 'EventHandlerMap'
Then it just begins from the start, but the eventinterface comes only once. This goes on for such a long tme, I have no idea when it stops.
Line 26 in EventInterface contains:
Code:
24 def onEvent(argsList):
25 'Called when a game event happens - return 1 if the event was consumed'
26 return getEventManager().handleEvent(argsList)
Line 170 in EventManager contains:
Code:
170 if self.EventHandlerMap.has_key(tag):
171 fxn = self.EventHandlerMap[tag]
172 ret = fxn(argsList[1:idx])
173 return ret
As for what's causing it: The file worked perfectly until I added a piece of code taken from an older, made for civ4, python file.
The purpose of the code is to simulate winter, by changing terrain to snow & back randomly. The plots are divided into 4 'sectors', each of them have different possibilities of snow depending on the week. For example, on week 5 the possibility of snow in Iceland is 100%, while in hungary it is 90%.
The code is in 3 parts:
In def __init__(self):
Code:
self.sector1 = { '52,39':'TUNDRA','53,39':'TUNDRA',etc}
self.sector1week = { 1:100, 9:90, etc }
self.sector2 = { '39,34':'GRASS','40,34':'GRASS',etc}
self.sector2week = { 1:100, 7:90, etc }
self.sector3 = { '20,22':'GRASS','21,22':'GRASS',etc}
self.sector3week = { 1:100, 5:90, etc }
self.sector4 = { '20,21':'GRASS',etc}
self.sector4week = { 1:100, 3:90, etc }
In def onBeginGameTurn(self, argslist):
Code:
self.week = (iGameTurn % 48) + 1
self.snowcheck(self.sector1, self.sector1week)
self.snowcheck(self.sector2, self.sector2week)
self.snowcheck(self.sector3, self.sector3week)
self.snowcheck(self.sector4, self.sector4week)
In def snowcheck(self, sector, sectorweek):
Code:
loopcount = 1
weekcheck = self.week
chance = 0
while loopcount:
try: #If we can find the week stored exit the loop. If not we check the week before.
chance = sectorweek[weekcheck]
loopcount = 0
except:
loopcount = 1 #Just in case.
if weekcheck == 0:
weekcheck = 48
else:
weekcheck -= 1
for i in sector.keys():
coord = string.split(i, ",") #Splits the string into ["x", "y"]
if CyGame().getSorenRandNum(101, 'snow making!') <= chance: #If the snow chance exceeds the random number make snow.
CyMap().plot(int(coord[0]), int(coord[1])).setTerrainType(gc.getInfoTypeForString('TERRAIN_SNOW'), True, True)
else: #If the snow chance is lower than the random num return it to original terrain.
terrain = gc.getInfoTypeForString('TERRAIN_' + sector[i])
CyMap().plot(int(coord[0]), int(coord[1])).setTerrainType(terrain, True, True)
The code used to work perfectly in civ4, but for some reason it now gives this strange error. Does anyone have any idea how to fix it?