Python Performance and Interface Overhaul (PPIO)

Spoiler Last post :
Right clicking on various item entries on technology popup doesn't always trigger sevopedia, same with building/units selection in cities
Thanks for the report.
Also clicking on any building name in sevopedia automatically switches category to animalistic special buildings.
Already reported by Endless Rain.

There is a big problem in the pedia when the displayed text name for two objects is the same eg building Lighthouse and improvement Lighthouse, it goes to the wrong one if you want the improvement. That is why the improvement is now called "A Lighthouse". Jaguar was the previous one being both an animal and a warrior.
I'm familiar with the problem, it's a text link problem, I don't think the source of the problem lies in the pedia python files.
I'll look into it to see if it can be fixed somehow, but I think the problem lies in dll or exe.
v0.2.1 - Hotfix
  • Fixed the two latest reported bugs
 
Wow now it opens buildings in second!

Suggestion: Make improvement pages show valid features and terrains for them.

Now sevopedia can be used for example if given buildings obsoletes.
For example there is following chain: Industrial Basket Factory requires medieval Basket Masters Workshop which requires prehistoric Basket Weaver.
These requirements should be changed with replacements.
 
Last edited:
Can we have option/button to sort buildings/units/techs first by X grid of tech tree and then by Y grid if they are on same column of tech tree?

Also graphical preview for buildings is useless for now - I think like 90% of all buildings doesn't have graphical model.
 
Last edited:
It's nice for the ones that do have a model.
Well its even worse: there is less normal buildings with 3d model than buildings, that never obsolete...
I think only buildings from stock game have 3d models.
I guess we would need dedicated artists, who would create 3000 - 4000 3d building models ranging from prehistoric Alpha Male and ending with transcedant Omniverse world wonder....
 
Last edited:
v0.2.3
  • Added a "sorted by tech tree grid" sub-category to the "technologies" category called chronology. It's the same as "All Eras" sub category, except that the entries are not sorted alphabetically, but by tech three grid position.
 
We really had to keep the mem size of the mod down. All those graphic models held in memory can really make for more MAF crashes.
Yep.
Wonder if we could remove all 3D building models for RAM savings.
 
Yep.
Wonder if we could remove all 3D building models for RAM savings.
We've left in what we wanted to leave in so far as I can tell, mostly wonders and obvious cool stuff.
 
It seems like building preview should be removed - it would look like mod isn't finished :p
Unless it would be replaced with 2D pictures of buildings specially for sevopedia.

Also I like how techs do smooth transistion: prehistory->history->cotemporary->future realism->science fiction->fantasy when browsing techs chronologically.
Prehistoric - prehistory
Ancient, Classical, Medieval, Reneissance, Industrial - history
Modern, Information - cotemporary
Nanotech, Transhuman - future realism (hardest science fiction)
Galactic - science fiction
Cosmic, Trascedant - fantasy (softest science fiction)

Can technology window show what improvements they unlock too?

It seems like there is glitch when generating tech window for couple techs
Spoiler :






 
Last edited:
Can technology window show what improvements they unlock too?
They used to show what processes, buildings, units and improvements they unlock. I think they also showed what went obsolete.

Of course as soon as you start having to get information from other files things will slow down again. :lol:
 
@Thunderbrd:
I need these two functions to be exposed to python so that techs can list buildings in the requirement panel.
Spoiler Technical stuff :
PrereqBuildingClass& CvTechInfo::getPrereqBuildingClass(int iIndex)
{
return m_aPrereqBuildingClass[iIndex];
}
PrereqBuildingClass& CvTechInfo::getPrereqOrBuildingClass(int iIndex)
{
return m_aPrereqOrBuildingClass[iIndex];
}

exposed to python as in:
python::class_<CvTechInfo, python::bases<CvInfoBase> >("CvTechInfo")

Edit: v0.2.4
  • Some polish, nothing new of particular note, tech pedia no longer shows empty unit and buildings enabled panels.
EditEdit:
It seems like building preview should be removed - it would look like mod isn't finished :p
Well it isn't even close to finished, so why pretend that it is.
Can technology window show what improvements they unlock too?
This is shown in the special abilities panel, so I don't think it's necessary, I'll consider it though.
It seems like there is glitch when generating tech window for couple techs
I can't repeat the glitch, might have been a problem in v0.2.3.
Spoiler Advice: :
@raxo2222 : Please put all those large pictures in a spoiler when posting them. Most people gets anoyed having to scroll through them.
They used to show what processes, buildings, units and improvements they unlock. I think they also showed what went obsolete.
I think it was removed because the special ability panel got expanded to show it instead.
 
Last edited:
I think they may already be exposed to Python as I thought I showed prerequisite buildings and resources on the tech tree - maybe not I may have used some custom XML for that, I can't remember. Wrong mod!

In the tech screen I just used the canResearch function or variant. If the functions for the tech requiring a building or resource are made available then the Tech chooser screen should also be changed to show that information as well. Will need to think of a way of hilighting that these are not techs while placing them in the same area as the "and" techs.
 
The building requirement for tech is something from RoM/AND days. The resource thing is a mod from elsewhere., I don't think it is used in C2C - I was thinking of the wrong mod ie the one I am working on.

In C2C the resource requirement is handled by the building needing the resource being required for the tech. The function is not exposed to python but when it is the TechChooser screen should also be updated to use it.
 
I need these two functions to be exposed to python so that techs can list buildings in the requirement panel.

PrereqBuildingClass& CvTechInfo::getPrereqBuildingClass(int iIndex)
{
return m_aPrereqBuildingClass[iIndex];
}
PrereqBuildingClass& CvTechInfo::getPrereqOrBuildingClass(int iIndex)
{
return m_aPrereqOrBuildingClass[iIndex];
}

exposed to python as in:
python::class_<CvTechInfo, python::bases<CvInfoBase> >("CvTechInfo")
So I get what you need but I don't know how to do it. This data storage mechanism is very unusual for core civ IV programming. The PrereqBuildingClass& portion of this is usually int or bool and as it stands as a struct form, I have no idea what the correct syntax would be to report it to python, or even if it CAN be. This is why it was not exposed previously. @AIAndy might be able to give me enough guidance on that to be able to set it up correctly for you but there are currently no examples of this being done, so I'm swimming into waters where I'm not even sure it's really even water I'm swimming in, to try this. Unwise. My apologies.

If I did get it exposed to python, I believe you'd find it a little difficult to work with too as no examples exist of receiving and using this data storage type in python either. You'd probably need the functions above those too:

int CvTechInfo::getNumPrereqBuildingClasses() const

Then you'd setup a loop that calls to getNumPrereqBuildingClasses and then use the index derived from that loop to insert into the parameter for getPrereqBuildingClass to get the buildingclass index stored there in that slot.

This is not an array. It is a struct derived vector, and I don't know anyone has yet worked with such a tag on the python side. The first issue is cracking the code on how to report it to python at all. The second is then figuring out how to work with such a structure in python. None of this has ever been done.
 
Last edited:
Ah, Then I'll need new functions made that returns either the CvBuildingClassInfo, or the index that is unique to the building class and connected to its xml entry order.
It should be possible to have a function that looks at a tech and tells what building classes are listed in it as a requirement.
Spoiler Technical stuff :
similar to this which already exist for buildings:
int CvBuildingInfo::getPrereqAndTechs(int i) const
{
FAssertMsg(i < GC.getNUM_BUILDING_AND_TECH_PREREQS(), "Index out of bounds");
FAssertMsg(i > -1, "Index out of bounds");
return m_piPrereqAndTechs ? m_piPrereqAndTechs : -1;
}​


only made opposite like so in a way:
int CvTechInfo::getPrereqAndBuildingClass(int i) const
{
FAssertMsg(i < GC.getNUM_TECH_AND_BUILDING_PREREQS(), "Index out of bounds");
FAssertMsg(i > -1, "Index out of bounds");
return m_paiPrereqBuildingClass? m_paiPrereqBuildingClass : -1;
}​

Looking in CvInfos.cpp, I already see these functions, but they have been commented out...

You'd probably need the functions above those too:

int CvTechInfo::getNumPrereqBuildingClasses() const

Then you'd setup a loop that calls to getNumPrereqBuildingClasses and then use the index derived from that loop to insert into the parameter for getPrereqBuildingClass to get the buildingclass index stored there in that slot.
Those functions are completely useless, there is no way to identify what buildingclasses are required by knowing the number needed to unlock the tech.

Let's say that I in python have a CvTechInfo type object that contains this ↓ info, call it CvSomeTechInfo.
<TechInfo>
<Type>TECH_SOME_TECH</Type>
<PrereqBuildingClasses>
<PrereqBuildingClass>
<BuildingClassType>BUILDINGCLASS_X</BuildingClassType>
<iNumBuildingNeeded>1</iNumBuildingNeeded>​
</PrereqBuildingClass>
<PrereqBuildingClass>
<BuildingClassType>BUILDINGCLASS_Y</BuildingClassType>
<iNumBuildingNeeded>5</iNumBuildingNeeded>​
</PrereqBuildingClass>
<PrereqBuildingClass>
<BuildingClassType>BUILDINGCLASS_Z</BuildingClassType>
<iNumBuildingNeeded>2</iNumBuildingNeeded>​
</PrereqBuildingClass>​
</PrereqBuildingClasses>​
</TechInfo>

Then I use the CvTechInfo specific function:
iNumPrereqBuildingClasses = CvSomeTechInfo.getNumPrereqBuildingClasses()
What does it return, 1, 5, or 2? Or perhaps it returns 3 because there are 3 buildingclasses listed in its <PrereqBuildingClasses>.

From this number there is no way to identify what building class that is in the <BuildingClassType> tag.
 
Last edited:
This is a very hard data storage mechanism to explain. I'd have no idea how to draw info from it in python as it's unique even in c++ coding. I'll have to think out a way to store this information in a manner you can utilize it. The previous commented out tags were removed from use entirely to be replaced by this MUCH more efficient storage system but it is not friendly to python methods, as you are observing.

Generally speaking, the syntax to find the BuildingClass Index if you were calling it in C++ would be:
Code:
for (iI=0; iI < GC.getTechInfo(eTech).getNumPrereqBuildingClasses(); iI++)
{
          BuildingClassTypes eBuildingClass = (BuildingClassTypes)GC.getTechInfo(eTech).getBuildingClassTypes(iI).BuildingClassType;
          //you'd obviously want to use it now that you've obtained it...
}
To call for the iNumBuildingNeeded would probably be something like:
(BuildingClassTypes)GC.getTechInfo(eTech).getBuildingClassTypes(iI).iNumBuildingNeeded;

This example is NOT drawn from code but off the top of my head so it's not good for actual reference... just an example of how it works. It goes about things very differently than standard CivIV coding usually does. How I'm going to get you a way to call for it... I might be able to easily make a boolean that asks isPrereqBuildingClass(eBuildingClassIndex) and you can loop through building class indexes looking to find those that register as included buildingclasses. From that, you can identify the building classes to present to the pedia. This sort of boolean would be easy to report to python and should be workable for you but you'll have to invent the code as there probably aren't many examples.
 
Spoiler Technical stuff :
Generally speaking, the syntax to find the BuildingClass Index if you were calling it in C++ would be:
Code:
for (iI=0; iI < GC.getTechInfo(eTech).getNumPrereqBuildingClasses(); iI++)
{
          BuildingClassTypes eBuildingClass = (BuildingClassTypes)GC.getTechInfo(eTech).getBuildingClassTypes(iI).BuildingClassType;
          //you'd obviously want to use it now that you've obtained it...
}
That is exactly what I need, but you can't make a function for CvTechInfos that does this and returns eBuildingClass which is exposed to python?
All I need is a function that returns eBuildingClass like so:
loop ▬ i = 0
eBuildingClass = TheTechIWantToKnowStuffAbout.getPrereqAndBuildingClass(i) // if i = 0 I get the buildingclass index for the first required buildingclass, if i = 1 I get the buildingclass index for the second buildnigclass requirement, and so on.
if eBuildingclass != -1
do something sensible with the eBuildingClass before I fetch the next one.​
i += 1​
loop
Spoiler Same logic as used for finding bonus requirement for buildings: :
for i in range(nOr):
iBonus = CvBuildingInfo.getPrereqOrBonuses(i)
if i != 0:
screen.attachLabel(panelName, "", szOr)​
screen.attachImageButton(panelName, "", gc.getBonusInfo(iBonus).getButton(), enumGBS, enumWidBonus, iBonus, -1, False)​
To call for the iNumBuildingNeeded would probably be something like:
(BuildingClassTypes)GC.getTechInfo(eTech).getBuildingClassTypes(iI).iNumBuildingNeeded;
It might be nice to know how many is needed so I can slap in a "3x [Building Icon]" (if it requires 3 of the building) in the requirement panel.

I might be able to easily make a boolean that asks isPrereqBuildingClass(eBuildingClassIndex) and you can loop through building class indexes looking to find those that register as included buildingclasses.
Well I could use that, I have already utilized the same logic for setting up building and civic requirements for a building in the pedia:
Spoiler Python code :
for j in range(gc.getNumBuildingClassInfos()):
if CvBuildingInfo.isBuildingClassNeededInCity(j):
iBuilding = gc.getBuildingClassInfo(j).getDefaultBuildingIndex()
if iBuilding != -1:
aList1.append(iBuilding)​
elif CvBuildingInfo.isPrereqOrBuildingClass(j):
iBuilding = gc.getBuildingClassInfo(j).getDefaultBuildingIndex()
if iBuilding != -1:
aList2.append(iBuilding)
for j in range(gc.getNumCivicInfos()):
if CvBuildingInfo.isPrereqAndCivics(j):
iCivic = CivicTypes(j)
aList1.append(iCivic)​
elif CvBuildingInfo.isPrereqOrCivics(j):
iCivic = CivicTypes(j)
aList2.append(iCivic)​

P.S. To avoid confusion, it is not really the PrereqBuildingClass& storage I need, I need to extract simple data out of it.
I thought earlier that the PrereqBuildingClass& was the data type that was given out to X when this was done:
"X = gc.getBuildingClassInfo(eBuildingClass)"
 
Last edited:
Top Bottom