Python Exception when trying to merge with the BUG Mod

topsecret

Believer
Supporter
Joined
Feb 11, 2010
Messages
5,972
Location
At the Foot of the Cross
I am trying to merge my Middle-earth Mod with the BUG mod so I can have two versions of my mod: one with BUG and one without BUG.

Unfortunately, I am receiving a Python Exception when I start up the game.

Here's the image. I think it has something to do with the Tech Screen (obviously) but I also wonder if it has to do with the fact that I removed Great Prophets. Either way... I have no idea what to do. I dug around in the files and it says something about DefaultUnitClass.

Any ideas?
Spoiler :

Civ4ScreenShot0142.JPG

 
I would suggest that you look at line 1059 in updateTechPrefs.
 
It would be a whole lot easier to provide useful feedback if there is access to the source code. You mentioned merging, meaning we don't even know if we get the right source code by downloading your latest release.
I'll post it in this thread later today or tomorrow.
I would suggest that you look at line 1059 in updateTechPrefs.
I did, it is looking for something about a "defaultunitclass". :dunno:
 
no it wasn't. It was looping over something and you exceeded some sort of array index.
 
no it wasn't. It was looping over something and you exceeded some sort of array index.
Oh yeah, that's right - I had an error at a different line earlier. That one was DefaultUnitClass. This error is different.

I will check as soon as I can.
 
Line 1059 is in the following code block:
Code:
1057    for i, f in enumerate(FLAVORS):
            # GP icon
1059        iUnitClass = gc.getInfoTypeForString(UNIT_CLASSES[i])
            iUnitType = gc.getUnitClassInfo(iUnitClass).getDefaultUnitIndex()
            pUnitInfo = gc.getUnitInfo(iUnitType)
            iX = PREF_ICON_LEFT
            iY = PREF_ICON_TOP + 4 * i * PREF_ICON_SIZE
            screen.addDDSGFC( "GreatPerson" + str(f), pUnitInfo.getButton(), iX, iY, PREF_ICON_SIZE, PREF_ICON_SIZE, WidgetTypes.WIDGET_TECH_PREFS_ALL, f, -1 )
        self.bPrefsShowing = True
 
I figured out the error. It works! Thanks @Nightinggale and @ruff_hi :)

Apparently the code was checking for flavors and unitclasses so it could draw them on the left side of the Screen.
In this code:
Code:
FLAVORS = [ TechPrefs.FLAVOR_PRODUCTION, TechPrefs.FLAVOR_GOLD, TechPrefs.FLAVOR_SCIENCE,
            TechPrefs.FLAVOR_CULTURE; TechPrefs.FLAVOR_RELIGION ]
UNIT_CLASSES = [ "UNITCLASS_ENGINEER", "UNITCLASS_MERCHANT", "UNITCLASS_SCIENTIST",
                "UNITCLASS_ARTIST" ]
# BUG - GP Tech Prefs - end

I had removed the Great Prophet because they don't exist in my mod. The reason the error occurred is because I didn't remove the corresponding flavor (FLAVOR_RELIGION). So it was causing the index to be out of range.

When I changed the code to:
Code:
FLAVORS = [ TechPrefs.FLAVOR_PRODUCTION, TechPrefs.FLAVOR_GOLD, TechPrefs.FLAVOR_SCIENCE,
            TechPrefs.FLAVOR_CULTURE ]
UNIT_CLASSES = [ "UNITCLASS_ENGINEER", "UNITCLASS_MERCHANT", "UNITCLASS_SCIENTIST",
                "UNITCLASS_ARTIST" ]
# BUG - GP Tech Prefs - end

it works!

Thanks everyone.

If anyone wants to look at the file, I will post here, just because.
 

Attachments

  • CvTechChooser.py.txt
    61.6 KB · Views: 83
Top Bottom