Hi !
While merging Unicode patch for CivIV, i encountered some weird errors in a python module that we added: ANDAutomationsTab.py
Its goal is to create an automation tab in the BUG options.
While playing in Russian, the creation fails with:
The involved code is:
Now that the names are coming in local codepage, there are others characters than ASCII. I would willingly accuse UTF as the guilty, but all others BUG tabs correctly render UTF now...
Any idea ?
EDIT: I think this loop makes the game to crash:
I don't understand what is the point of this. Couldn't we loop over CityID instead of names ? That would be more crash-proof.
While merging Unicode patch for CivIV, i encountered some weird errors in a python module that we added: ANDAutomationsTab.py
Its goal is to create an automation tab in the BUG options.
While playing in Russian, the creation fails with:
Code:
Traceback (most recent call last):
File "CvScreensInterface", line 947, in handleInput
File "CvMainInterface", line 6596, in handleInput
File "BugOptionsScreen", line 42, in showOptionsScreen
File "BugOptionsScreen", line 142, in interfaceScreen
File "BugOptionsScreen", line 149, in createTabs
File "ANDAutomationsTab", line 286, in create
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcf in position 0: ordinal not in range(128)
ERR: Python function handleInput failed, module CvScreensInterface
The involved code is:
Code:
for iI in range(gc.getNumBuildInfos()):
if (team.isHasTech(gc.getBuildInfo(iI).getTechPrereq())):
columnKey = self.determineColumnPlacement(5, iCount, (col1, col2, col3, col4, col5))
control = str(remove_diacriticals(player.getNameKey() + gc.getBuildInfo(iI).getDescription() + "Check"))
bEnabled = player.isAutomatedCanBuild(iI)
szNewDescription = g_BuildNames[iI]
screen.attachCheckBox(columnKey, control, szNewDescription , "CvOptionsScreenCallbackInterface", "handleNationalAutomatedBuildCheckboxClicked", control, bEnabled)
screen.setToolTip(control, BugUtil.getText("TXT_KEY_NATIONAL_AUTOMATED_WORKERS_CAN_BUILD", szNewDescription))
iCount += 1
Any idea ?
EDIT: I think this loop makes the game to crash:
Code:
while(loopCity):
if (szName.rfind(ANDAutomationsTab.remove_diacriticals(loopCity.getName())) > -1):
for iI in range(CyGlobalContext().getNumBuildInfos()):
if (szName.rfind(CyGlobalContext().getBuildInfo(iI).getDescription()) > -1):
CyMessageControl().sendModNetMessage(AutomatedSettings.getCanAutoBuildEventID(), CyGlobalContext().getGame().getActivePlayer(), loopCity.getID(), iI, int(bValue))
#loopCity.setAutomatedCanBuild(iI, bValue)
return 1
(loopCity, iter) = player.nextCity(iter, False)
return 0
I don't understand what is the point of this. Couldn't we loop over CityID instead of names ? That would be more crash-proof.