Python Performance and Interface Overhaul (PPIO)

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?
I probably can. The problem is, there isn't always just one building class. So it's easier for python to query a bool function which is basically asking, is THIS building class included? So a tag like isBuildingClassPrereq(eBuildingClassIndex) would work but getPrereqBuildingClass would not because there's not just one answer.

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.
You should. I'll set you up with a function for that as well.
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:
Yeah, I figured there were some examples of that kind of logic. We'll have to do that.
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)"
I understand what you need but got wholely lost in the python syntax you gave as an example there. lol
 
I probably can. The problem is, there isn't always just one building class.
That's why the function would take an integer argument that indicates which of the building classes we want the eBuildingClass index for.
If the tech has two buildingclass requirement:
CvTechInfo.function( 0 ) would return the eBuildinClass for the first buildingclass requirement listed for the tech that CvTechInfo points to.
CvTechInfo.function( 1 ) would return the eBuildingClass for the second buyildingclass requirment listed.
CvTechInfo.function( 2 ) would return -1
Spoiler Technical stuff :
So it's easier for python to query a bool function which is basically asking, is THIS building class included? So a tag like isBuildingClassPrereq(eBuildingClassIndex) would work but getPrereqBuildingClass would not because there's not just one answer.
That would require the python to loop through all the building classes in the game asking the tech "IsRequiredBuilding(eLoopBuildingClass)" for every one of them.
Is this smart if the dll can fetch the valid ones directly?
Wouldn't the dll be faster than python even if it had to loop through all the building classes as well?

I would really prefer that you make a function that is comparable to this one, that already exist for finding tech requirments for buildings:
Code:
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[i] : -1;
}
Spoiler Maybe somethig like this :
Code:
int  CvTechInfo::NameOfFunction(int iIndex, int eTech)
{
         return GC.getTechInfo(eTech).getPrereqBuildingClass(iIndex).eBuildingClass
}


// Or perhaps it would make more sense as a global context function

int  CyGlobalContext::getTechPrereqBuildingClass(int iIndex, int eTech)
{
         return GC.getTechInfo(eTech).getPrereqBuildingClass(iIndex).eBuildingClass
}


// or even better, it returns what I really need:

CvBuildingClassInfo*  CyGlobalContext::getTechPrereqBuildingClassInfo(int iIndex, int eTech)
{
         return (i>=0 && i<GC.getNumBuildingClassInfos()) ? &GC.getBuildingClassInfo((BuildingClassTypes)(GC.getTechInfo(eTech).getPrereqBuildingClass(iIndex).eBuildingClass) : NULL;
}
 
Last edited:
Rather than struggling to figure out how to arrange that sort of thing, the bool is MUCH easier. (because I can envision how to whereas the others I cannot. Those appear on the surface to me to require a new declaration of a variable which would have a memory impact on the game as a whole.
 
Ok, you do know best, I'm happy as long as it becomes possible for the pedia to display what buildings a tech require. ^^

Spoiler Edit :
Rather than struggling to figure out how to arrange that sort of thing, the bool is MUCH easier. (because I can envision how to whereas the others I cannot. Those appear on the surface to me to require a new declaration of a variable which would have a memory impact on the game as a whole.
I'm curious about why there would need to be a new variable for what I suggested.
What would it represent/store?
 
Last edited:
Assuming that there is also a boolean test first that says if the tech requires a building or not. If the tech does then the code will have to loop through all buildings to see if it is needed.

If there isn't a boolean indicating that a tech requires a building then you will have to loop through every building for each tech.

edit this is a good example of why your data model in the processing area should be different to the storage data model. Basically you would have a new file Tech_Building that only contained two ids, the tech id and the building class id. It would be created at XML loading and would have its methods exposed to Python.

Although there was a suggestion recently to do away with Building Classes in C2C since it does not have UBs in the same way that vanilla has and it would release memory for other things.
 
Last edited:
I'm curious about why there would need to be a new variable for what I suggested.
Part of this is that you're asking for me to delve into a region of knowledge I'm not incredibly comfortable with on a theoretical level - I tend more to parrot this stuff so when there's an example, great, when not... ugh.

I was thinking on this and I think I've figured out a way to let it run the way you're looking for it to.
 
Ok, so you'll have to loop by calling for the tech's getNumPrereqBuildingClasses(). I'm not sure how you'd set it up in python exactly but it looks, again, like this in C++:

for (iI=0; iI < GC.getTechInfo(eTech).getNumPrereqBuildingClasses(); iI++)
{

I'm exposing getNumPrereqBuildingClasses so you can define the loop count and use it to call to the following new functions:
int getPrereqBuildingClassType(int iIndex);
int getPrereqBuildingClassMinimumRequired(int iIndex);

so continuing syntax use in the DLL as an example:

Code:
int iRequired = 0;
for (iI=0; iI < GC.getTechInfo(eTech).getNumPrereqBuildingClasses(); iI++)
{
          if (GC.getTechInfo(eTech).getPrereqBuildingClassType(iI) != -1)
          {
                    BuildingClassTypes eBuildingClass = (BuildingClassType)GC.getTechInfo(eTech).getPrereqBuildingClassType(iI);
                    iRequired = GC.getTechInfo(eTech).getPrereqBuildingClassMinimumRequired(iI);
                    //Then do whatever you're going to do with it.
          }
}
Hopefully you're code bi-lingual enough to sort that out. From previous comments, I think you are.

aka when the tech's getNum index number is handed off to the parameter of getPrereqBuildingClassType, you will get a return of the buildingclass index # in that slot. And when you hand it off to the parameter of getPrereqBuildingClassMinimumRequired, you'll get the minimum amount of those buildings that must be built to enable the tech.

This works the same with these tags as well:
int getNumPrereqOrBuildingClasses() const;
int getPrereqOrBuildingClassType(int iIndex);
int getPrereqOrBuildingClassMinimumRequired(int iIndex);

The new tags are purely for reporting to python for you to convert to a simpler method. It was surprisingly easy to do this - I was just overthinking things and letting my lack of comfort in this area confound my mind until I thought on it in the background for a while. I've been stuck on xml and spreadsheeting for so long that I'm starting to get a little rusty minded on coding already.

This should be on the SVN in an hour or so once compiling is complete.
 
I really have to say, thanks a lot for this mod. I've found I actually use the sevopedia a whole lot more then I used to now that it doesn't take eighty years to load every time I want to check something out. I really noticed it when I forgot to re-add it after updating the version and had to immediately quit and re-add it so I could use it. 10/10 mod, would recommend.
 
Ok, so you'll have to loop by calling for the tech's getNumPrereqBuildingClasses(). I'm not sure how you'd set it up in python exactly but it looks, again, like this in C++:

for (iI=0; iI < GC.getTechInfo(eTech).getNumPrereqBuildingClasses(); iI++)
{

I'm exposing getNumPrereqBuildingClasses so you can define the loop count and use it to call to the following new functions:
int getPrereqBuildingClassType(int iIndex);
int getPrereqBuildingClassMinimumRequired(int iIndex);
While this is an appropriate way to do that (and it is done the same way at several other places in the code), it is actually possible to expose the vector of struct directly as a Python container (which in turn allows some nicer Python code).
For that you expose the struct and then the vector with the vector_indexing_suite.
See here:
https://stackoverflow.com/questions/43107005/exposing-stdvectorstruct-with-boost-python
http://www.boost.org/doc/libs/1_32_0/libs/python/doc/v2/indexing.html
 
While this is an appropriate way to do that (and it is done the same way at several other places in the code), it is actually possible to expose the vector of struct directly as a Python container (which in turn allows some nicer Python code).
For that you expose the struct and then the vector with the vector_indexing_suite.
See here:
https://stackoverflow.com/questions/43107005/exposing-stdvectorstruct-with-boost-python
http://www.boost.org/doc/libs/1_32_0/libs/python/doc/v2/indexing.html
Good to know. I'll have to research that further.

Glad to hear it worked for you Toffer! :D
 
Here's another one that could be nice to have exposed to python:

bool CvPromotionLineInfo::isBuildUp() const
{
return m_bBuildUp;​
}

I can make a build up sub category by looking at the description name, all build up names start with "Build up".
But that function makes it a bit more flexible in case we wan't to change naming conventions for those types of promos.
 
Is it possible to sort buildings (all types)/units/civics/promotions/improvements chronologically?
If they would require 2 or more techs, then tech with highest X number should be selected, in case of same X, then Y coordination would be selected.
You could create new category named "Chronology", where techs, buildings, units, civics, promotions and improvements are sorted by technology position in tree.

That would be bit indirect unlike with techs - first you would need to scan tech requirements in these "unlockables", then pick farthest tech in tree and finally place it in proper position.
 
Last edited:
First of all, I have more important aspects to focus on improving in the pedia. It's a bit about what I'm motivated to work on as well.
Additionally, there is little need for such lists, and the required code would spaghettify a lot of the pedia code reducing its readability and performance unnecessarily.

I might look into it when I feel the pedia modmod is closer to finished.
 
First of all, I have more important aspects to focus on improving in the pedia. It's a bit about what I'm motivated to work on as well.
Additionally, there is little need for such lists, and the required code would spaghettify a lot of the pedia code reducing its readability and performance unnecessarily.

I might look into it when I feel the pedia modmod is closer to finished.
Thank you for what you have accomplished! Good Stuff! :thumbsup::hatsoff:
 
Back
Top Bottom