Python exception help - merging BUG and Extra

NikNaks

Deity
Joined
Jul 25, 2006
Messages
2,972
Location
England
A carry-over from this thread, I was wondering if anyone would be able to give me an idea where to look to solve this issue. Basically, the game interface is blanked with the following Python exceptions.

We get:
Code:
Traceback (most recent call last):

  File "BugUtil", line 691, in <lambda>

  File "BugEventManager", line 570, in preGameStart

  File "CvAppInterface", line 70, in preGameStart

  File "CvScreensInterface", line 83, in showTechChooser

  File "CvTechChooser", line 231, in interfaceScreen

  File "CvTechChooser", line 243, in ConstructTabs

  File "CvTechChooser", line 280, in DrawTechChooser

  File "CvTechChooser", line 324, in placeTechs

AttributeError: type object 'CvPythonExtensions.WidgetTypes' has no attribute 'WIDGET_TECH_CHOOSER_ERA'
ERR: Python function preGameStart failed, module CvAppInterface
... and then:
Code:
Traceback (most recent call last):

  File "CvScreensInterface", line 72, in showMainInterface

  File "CvMainInterface", line 428, in interfaceScreen

  File "CvMainInterface", line 346, in initState

  File "PLE", line 180, in PLE_CalcConstants

  File "PLE", line 851, in getMaxRow

ZeroDivisionError: integer division or modulo by zero
ERR: Python function showMainInterface failed, module CvScreensInterface

It's an easily repeatable exception, so it seems I've just borked something in the merge, but I have no clue where to start looking. The files are simply BUG's and Extra's, with the few conflicting files merged together using the patch in the thread. However, the lines causing the exception weren't touched by the merge, and they're so minor, I think it's probably more to do with something that Extra relies upon that BUG has rewritten (like one of the screens). If anyone's seen anything like this before, or has an idea what might be causing it, please let me know!

Obviously, if there's already a merge of Extra and BUG, please point me thattaway instead. :)
 
There is basically something missing, somewhere in your mod. The game interface is blank because this exception takes place at startup and makes the game quit drawing (if that is the correct term) it. So the blank interface is just a symptom - not the actual error. Or in tech speech:
Python function preGameStart failed
This is what is missing, in plain English:
'CvPythonExtensions.WidgetTypes' has no attribute 'WIDGET_TECH_CHOOSER_ERA'
Seems to me like your mod is missing a "widget", then. Someone else could probably help you out further with what you need to do in order to supply such a thing.
 
No, I was actually mistaken. :D

Its not a widget that is missing, its actually a WidgetType. Somewhere, there should be a WIDGET_TECH_CHOOSER_ERA defined. Not sure where, though, but search the source for both mods you're using and try to locate where it should be.
 
I had a run through it and I could only find it defined in CvTechChooser and the BUG config file. The entry in the Python is here:

Code:
# BUG - Tech Era Colors - start
			szTechRecordShadow = sPanelWidget + "TechRecordShadow" + str(i)
			iShadowOffset = 9
			screen.attachPanelAt( sPanel, szTechRecordShadow, u"", u"", True, False, PanelStyles.PANEL_STYLE_TECH, iX - 6 + iShadowOffset, iY - 6 + iShadowOffset, self.getXStart() + 6, 12 + ( self.BOX_INCREMENT_HEIGHT * self.PIXEL_INCREMENT ), [B]WidgetTypes.WIDGET_TECH_CHOOSER_ERA[/B], gc.getTechInfo(i).getEra(), -1 )
			self.setTechPanelShadowColor(screen, szTechRecordShadow, gc.getTechInfo(i).getEra())
			screen.hide( szTechRecordShadow )
# BUG - Tech Era Colors - end

From this, it seems the definition is actually in the config files, but as there are no other errors, I don't see how those files couldn't have loaded.
 
No, no... that code is just where the WidgetType is used (or referenced) - not where its defined. It would either be defined in the SDK or the XML, dunno which, but I'd bet on the former.
 
Hm. The weird thing is that BUG doesn't have a DLL in its basic form, so that might suggest it's a BULL-only feature. Which would make this even more confusing. Could it be that BUG is designed not to call this function if the DLL isn't included, but that Extra is calling it anyway? That wouldn't explain the error in BugUtil, though. :/
 
Did you make any changes to the init.xml file?

The WIDGET_TECH_CHOOSER_ERA widget type is defined in the "BUG Advisors.xml" file, so you need to be loading that in the mods section of your init.xml file (and the file itself needs to exist in your Config folder). It is normally the 3rd thing after the "Mods" comment.

That widget type requires that you have a CvTechChooser.py file that has a getEraDescription function in it. I.E. you must have the BUG version of this file in your Python\Screens folder. However, since the error is in that file you presumably have a version of the file with this stuff in it (unless perhaps it is a file you did a merge on). The colors themselves are defined in the "Not Just Another Game Clock.xml" file, so you also need to be loading that in your init.xml.
 
No, I hadn't touched those, but that might hold the key.

Would there be any reason for config files not to load from CustomAssets if there is a mod running? I find that unlikely.

The other option is that Extra has modified a file that calls the tech chooser before init has loaded it. Could that be possible?

EDIT: It looks like BUG was completely unable to load Config files from CustomAssets in this situation, so copying them over to the Extra mod's directory solved the issue. I'm just waiting to hear back from someone else to see if this solves the issue.
 
Back
Top Bottom