Bug - UnitUtil Fails with WoC modules

Afforess

The White Wizard
Joined
Jul 31, 2007
Messages
12,239
Location
Austin, Texas
I noticed after I made a WoC modules that just forced some units to require a building before they can be built, that when starting a map it says UnitUtil - Failed. I know the XML is 100% syntactically correct, but (BUG 4.0 in case you need to know) the Civilopedia section for UNITS ONLY won't show any contents. I can go to the buildings and see that it correctly says "Required To Build..."

WoC XML:
Spoiler :

Code:
        <UnitInfo>
            <Class>UNIT_SPEARMAN</Class>
            <Type>UNIT_SPEARMAN</Type>
            <PrereqBuilding>BUILDING_FORGE</PrereqBuilding>
        </UnitInfo>
        <UnitInfo>
            <Class>UNIT_SPEARMAN</Class>
            <Type>UNIT_ZULU_IMPI</Type>
            <PrereqBuilding>BUILDING_FORGE</PrereqBuilding>
        </UnitInfo>
        <UnitInfo>
            <Class>UNIT_SPEARMAN</Class>
            <Type>UNIT_MAYA_HOLKAN</Type>
            <PrereqBuilding>BUILDING_FORGE</PrereqBuilding>
        </UnitInfo>


I imagine that the problem is that the UnitUtil's expects a full, regular XML file for units, not the abbreviated WoC version, and thus fails to read it correctly.
 
UnitUtil, like all the BUG code, inspects the CvFooInfo objects. It doesn't read the XML files (BTS does that for BUG). Can you post the PythonErr.log file after trying to open the page for the units in Sevopedia so I can see the Python exception?
 
Same error over and over:

Traceback (most recent call last):

File "CvScreensInterface", line 419, in pediaMain

File "SevoPediaMain", line 248, in pediaJump

File "SevoPediaMain", line 307, in showContents

File "SevoPediaMain", line 450, in placeUnits

File "SevoPediaMain", line 750, in placeItems

RuntimeError: unidentifiable C++ exception
ERR: Python function pediaMain failed, module CvScreensInterface

Also, I never touched those files, and niether did Zappara, so they are official BUG 4.0, and I get no XML errors on loading, and the buildings do correctly show the requirements. Just the Units Civilopedia page fails.
 
There's no message in the log about UnitUtil? :(

Edit: Are you sure that SevoPediaMain.py hasn't been changed at all? Line 750 is not in the placeItems() function. In fact, it's a function definition itself that surely doesn't call any C++ functions:

Code:
def link(self, szLink):

The reason the unit page shows the required buildings in the list of attributes is because that is generated by CvGameTextMgr, unless someone added icons for the required buildings to the screen.
 
There's no message in the log about UnitUtil? :(

Nope. The bug itself is just confined to the Civilopedia Unit Page not showing (at least, that's the only visible bug.)

When I start a new game, it says UnitUtil failed, but other than that, nothing else happens...

Edit:
Sorry, I was wrong. I started up a new game. Here's the expection:
Traceback (most recent call last):
File "BugInit", line 98, in callInits
File "UnitUtil", line 63, in init
AttributeError: 'NoneType' object has no attribute 'getDefaultUnitIndex'
 
The problem with UnitUtil is that it is finding a unit without a unit class:

Code:
		classInfo = gc.getUnitClassInfo(unitInfo.getUnitClassType())
		eGenericUnit = classInfo.getDefaultUnitIndex()

classInfo is coming back None which means that getUnitClassType() is returning -1 or some other invalid UnitClassTypes value. This is an XML problem with one of the new units in your mod.
 
The problem with SevoPediaMain is that one of your new units has an invalid button. When it calls getButton() on the CvUnitInfo, it's getting some C++ exception. Or the button it gets is being passed to setTableText() which throws that exception. To find out which, change SevoPediaMain line 750 to this:

Code:
[B]szButton = info(item[1]).getButton()[/B]
screen.setTableText(self.ITEM_LIST_ID, 0, i, u"<font=3>" + item[0] + u"</font>", [B]szButton[/B], widget, data1, data2, CvUtil.FONT_LEFT_JUSTIFY)

Then reopen the screen. You'll still get the problem, but now look at the log file. If it still says line 750 in placeItems(), the problem is accessing the button. If it says 751, it means that the EXE doesn't like whatever value you entered for the button.
 
The thing is, this is a modmod, and adds NO new units, just adds prereqs for existing ones. All of those units are already in the main UnitInfos, this is just a module.

View attachment 231432

Also, if I had mistyped something, I should get a LoadXML error, right?
 
Are you absolutely sure that you get no errors when you run the original mod without your prereq changes? BUG knows nothing of building prereqs, so adding that specific feature should not be able to affect BUG at all. If one unit had an incorrect unit class, getInfoTypeForString() would return -1 which would get stored as the class for that unit, causing UnitUtil to break; it may not display an error while loading the XML.

You could fix UnitUtil to ignore units that have invalid classes, but you'd only be masking an underlying error, and the Strategic Advantages screen would show incomplete information.
 
Are you absolutely sure that you get no errors when you run the original mod without your prereq changes? BUG knows nothing of building prereqs, so adding that specific feature should not be able to affect BUG at all. If one unit had an incorrect unit class, getInfoTypeForString() would return -1 which would get stored as the class for that unit, causing UnitUtil to break; it may not display an error while loading the XML.

You could fix UnitUtil to ignore units that have invalid classes, but you'd only be masking an underlying error, and the Strategic Advantages screen would show incomplete information.

Yes. That's why I was so confused by the BUG failure that I opened a thread. I start the game and it loads without any errors, none whatsoever. If you look at my XML you will see that I made spearmen require the forge. It shows it correctly on the forge page:
Spoiler :

Fullscreen%20capture%2010172009%2035050%20PM.jpg

 
The text under Special Abilities is pulled from the SDK's CvGameTextMgr; that's why it works. BTW, why are the <Class>es specifying unit types instead of classes?

<Class>UNIT_SPEARMAN</Class>​

instead of

<Class>UNITCLASS_SPEARMAN</Class>​
 
The text under Special Abilities is pulled from the SDK's CvGameTextMgr; that's why it works. BTW, why are the <Class>es specifying unit types instead of classes?
<Class>UNIT_SPEARMAN</Class>​
instead of
<Class>UNITCLASS_SPEARMAN</Class>​

And that would be the cause of all my problems...

Case closed, my fault. BUG's still flawless. ;)
 
That fixed it? How strange that it showed the correct requirements in the Special Abilities given the wrong type of object! :crazyeye: Glad it works, though.

BUG's still flawless. ;)

Was there ever any doubt? :rolleyes: :lol:
 
Back
Top Bottom