CIVILIZATION IV:iNoc

No problem. I am trying to add the ability to give a civilization traits, just the way a leader has traits. The problems I am having are not in functionality, but in the interface. I made the civilopedia background box half as wide, and made another box next to it to display the info on traits. Like this:

Spoiler :
attachment.php


But with the Background box filled in. I already explained that if a line in CvInfoInterface2.cpp is commented out, the background box works but I get an error. (Because according to python, the method I exposed is invalid) Like so.

Spoiler :
attachment.php


As you can see, the Pedia box displays, but I get a well-justified error.
Also, the code that adds the background text is not even in the same method as the code for adding the traits box. That is why I am confused.
 

Attachments

  • (6-24-12)_PeciaCivScreenError.JPG
    (6-24-12)_PeciaCivScreenError.JPG
    157.9 KB · Views: 202
Hm... did you actually define gc.getNumTraitInfos() anywhere? Becouse I am not sure if just defining it as an array will automaticly generate that.
 
What do you mean? It's a method that returns the number of TraitInfos.
 
Exactly, is it defined somewhere? Since it's in your tweak area I have to check. Same for all your methods. At this point all that remains is to go through every one of them to check if you have missed a line somewhere.

Let's try some quick tricks. If you have done any of these before note that you did not say and don't get offended for me suggesting them. First, go into your code on def placeDoubleSpeedTechs(self): and add a fixed line. Basically tell python to create one fixed tech reference to say tech[0] what ever that is regardless of any conditions. That way you can tell if it's calling your function at all or if its failing to do it in the first place.
 
Ummm... gc.getNumTraitInfos is not something I added. It's a built-in gamecore method. And placeDoubleSpeedTechs works fine and has worked fine for quite a while. I have not modified it. Double Speed Techs has nothing to do with this. It has no relation to either placeText or placeTraits.
 
Through some debugging, I discovered that when this line

Code:
screen.addPanel(panelName, localText.getText("TXT_KEY_PEDIA_TRAITS", ()), "", True, True, self.X_TRAITS, self.Y_TEXT, self.W_TEXT, self.H_TEXT, PanelStyles.PANEL_STYLE_BLUE50)

is commented out, the background text works but the panel is missing, and when it is not commented the background text does not work but the panel is there.

EDIT: I managed to get it to work, for now, by commenting out the last line,

Code:
screen.attachMultilineText(panelName, "Text", szText, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)

But I get the feeling that even if there was information to display, it would not be displayed.

EDIT2: Yeah, I was right.
 
I found the problem. How on earth did I overlook this one?
 
I found the problem. How on earth did I overlook this one?
In my personally experience. That exact phrase is the one most commonly used by professional programmers. :D
 
Or maybe not. I'm so confused.
 
I found out that CyGameTextMgr::getTraitHelp was not exposed to python (Which failed to give an error because the line calling that method was not called unless a condition was true that I had not made true yet). I exposed it to python. This was the 'How could I have overlooked this one.'

When things refused to work, I changed the entire placeTraits method to be like the similar method in CvBuil...

GOT IT!!! I think. For some reason, it turns out that CvCivilizationInfo::isCivilizationTrait never returns true.

IT WORKS IT WORKS IT WORKS IT WORKS!!

Sort of. I can make it display a list of all the traits and their effects in the proper box, but not make it only display the traits that the given civilization has. Yet. I will continue working on it, but that was a big breakthrough.

EDIT: :blush: I forgot to copy the changed version of CvCivilizationInfos.xml
 
Something really weird happened while I was debugging. I was getting an error that said that it could not find the infotype IMPROVEMENT_FOREST_PRESERVE. I found this really weird. After all, IMPROVEMENT_FOREST_PRESERVE is right there in the improvementinfos file, which I have not changed. So why can't it find it? Any ideas?
 
Might be an error in the XML file. Either in the section for the improvement it self or in the ones just before it. Check all the tags carefully. Also if I may dare to be so bold. You could make a habit of always attaching the relevant XML or other files for us to play around with when you hit a problem.
 
I have not changed CIV4ImprovementInfos.xml or it's schema file in my memory. And I have never had a problem like this before.
 
TraitInfos. I've made some major changes there.
 
I am assuming you added tag to the trait info that is a reference to an improvement that did not exist in the original trait info.

The trait infos file is loaded before the improvement infos file (you can see this in the xml.log file), so at the time it is loaded the definitions for the improvement types don't exist. This is resolved via "readpass3" functionality. If the trait info file is not already using that, then it has to be added. If it is using that already, then you just have to modify your specific new improvement related stuff to use it. In essence you store the text string for the tag in a string type variable and translate it later, during the readpass3 stage of processing which happens after all the XML files have been loaded and is used to resolve just such situations.

The other possibility is to reverse the logic, more or less, and add a tag that specifies the trait in the improvement info so you avoid the load order problem. Example: if you wanted the ability for a trait to give an city an extra point of happiness for each one of a specified improvement in a city's BFC then instead of having an ExtraHappyImprovement in the trait info, you could have an ExtraHappyTrait in the improvement info. The logic for using them is similar. For the first, you loop over all the trait types and if the civ has the trait check to see if it specifies an improvement and then if it finds one you check they city for a count of that improvement type. In the second case you can loop over all the improvement types to see if if there is an improvement that specifies a trait that this civ has and if so you check the city for a count of that improvement type.

(Note: I have never actually had to add a readpass3 type thing myself. Lots of people around here have, though. Maybe even you, in which case this is just a reminder to do the sort of thing you did before.)
 
Ah. I have dealt with this before. How did I not see this coming?
 
Back
Top Bottom