Python Performance and Interface Overhaul (PPIO)

No. In Divine Prophets and Limited Religions this can differ from whether the tech has been researched. The only call that works in ALL situations correctly is if the tech has been researched by any team.
Ok, didn't think about how divine prophets could influence it, makes sense. So just to be sure:
If someone invent a religion with "divine prophets" as an active GO, the religion tech will still be marked as a tech that can found a religion?
That gc.getGame().isTechCanFoundReligion(i) will return TRUE even if someone has invented it with "divine prophets" GO active?
 
You changed what button is cached as a UI element under the name "ReligionButton" + str(j)

The code I showed above is the code that determines if it should use the cached
"ReligionButton" + str(j)
or the cached
"ResearchButton" + str(i)
UI element for a religion tech.
Current coding:
Code:
    # *********************************************************************************
    # RESEARCH BUTTONS
    # *********************************************************************************

    i = 0
    for i in range( gc.getNumTechInfos() ):
      szName = "ResearchButton" + str(i)
      screen.setImageButton( szName, gc.getTechInfo(i).getButton(), 0, 0, 32, 32, WidgetTypes.WIDGET_RESEARCH, i, -1 )
      screen.hide( szName )

    i = 0
    for i in range(gc.getNumReligionInfos()):
      szName = "ReligionButton" + str(i)
      if ( gc.getGame().countKnownTechNumTeams( gc.getReligionInfo(i).getTechPrereq() ) > 0 ):
        szButton = gc.getReligionInfo(i).getGenericTechButton()
      else:
        szButton = gc.getReligionInfo(i).getTechButton()
      screen.setImageButton( szName, szButton, 0, 0, 32, 32, WidgetTypes.WIDGET_RESEARCH, gc.getReligionInfo(i).getTechPrereq(), -1 )
      screen.hide( szName )
So the change was to which button reference should be used. If a team has discovered the research tech:
Code:
 if ( gc.getGame().countKnownTechNumTeams( gc.getReligionInfo(i).getTechPrereq() ) > 0 ):
Then the button should be
Code:
gc.getReligionInfo(i).getGenericTechButton()
Otherwise, the button should be:
Code:
szButton = gc.getReligionInfo(i).getTechButton()
This is correct. I did this backwards in the dll and am committing a correction to this now. The tech tree should also use this kind of switch logic rather than calling to gc.getTechInfo(i).getButton() for religious techs only, and this is something DH said he'd address but if your overhaul includes that file then it's going to be necessary to include this change there too.
 
Ok, didn't think about how divine prophets could influence it, makes sense. So just to be sure:
If someone invent a religion with "divine prophets" as an active GO, the religion tech will still be marked as a tech that can found a religion?
That gc.getGame().isTechCanFoundReligion(i) will return TRUE even if someone has invented it with "divine prophets" GO active?
Until the prophet is used to found the religion somewhere, the religion can be discovered by a team and the actual religion itself not be founded yet. I want players to see that the tech has been researched, regardless of whether the religion is in play or not. In DP, if you get the tech after someone else gets it, the free prophet is already gone, and that's the main thing unless you are actually trying to get the religion founded and maybe you have an extra prophet on hand or soon coming and the player that got to the tech used that free prophet for something else.

Generally speaking, isTechCanFoundReligion is I think a bad call in general because even if the tech has been researched it will still be true for that religion because I think it only checks if the tech is a religious tech at all. If it does check that the religion has been founded, that's not good when you are on Choose Religions at all, where the tech is completely unmarried from whether the religion is founded or not.
 
Until the prophet is used to found the religion somewhere, the religion can be discovered by a team and the actual religion itself not be founded yet. I want players to see that the tech has been researched, regardless of whether the religion is in play or not. In DP, if you get the tech after someone else gets it, the free prophet is already gone, and that's the main thing unless you are actually trying to get the religion founded and maybe you have an extra prophet on hand or soon coming and the player that got to the tech used that free prophet for something else.
Yeah, I tested in game and divine prophet GO made it so that all religion techs had praying hands regardless of being invented by anyone or not.
Fixed that by changing the code to this:
Code:
artPath = ""
if CyPlayer.canFoundReligion() and GAME.isTechCanFoundReligion(i) and not GAME.countKnownTechNumTeams(i):
    for j in range(iReligionInfos):
        CvReligionInfo = GC.getReligionInfo(j)
        if CvReligionInfo.getTechPrereq() == i:
            artPath = CvReligionInfo.getTechButton()
            break
if not artPath:
    artPath = GC.getTechInfo(i).getButton()
Generally speaking, isTechCanFoundReligion is I think a bad call in general because even if the tech has been researched it will still be true for that religion because I think it only checks if the tech is a religious tech at all. If it does check that the religion has been founded, that's not good when you are on Choose Religions at all, where the tech is completely unmarried from whether the religion is founded or not.
If inventing the tech allows you to found a religion it doesn't matter what religion you found; the isTechCanFoundReligion is set to false for the tech that made you found a non-specific religion. With divine prophets the tech doesn't automatically found a religion and it is then also never marked as a tech that cannot found a religion.
So the change was to which button reference should be used. If a team has discovered the research tech:
Code:
 if ( gc.getGame().countKnownTechNumTeams( gc.getReligionInfo(i).getTechPrereq() ) > 0 ):
Then the button should be
Code:
gc.getReligionInfo(i).getGenericTechButton()
You don't seem to understand, if the religious tech has been invented by anyone on a non-divine prophet game, the "ResearchButton" + str(i) will be used for the religion tech button. Not the "ReligionButton" + str(i).
This is defined in this core C2C code that actually decides what cached button to use:
Code:
  def updateResearchButtons( self ):

    screen = CyGInterfaceScreen( "MainInterface", CvScreenEnums.MAIN_INTERFACE )

    for i in range( gc.getNumTechInfos() ):
      szName = "ResearchButton" + str(i)
      screen.hide( szName )

    # Find out our resolution
    xResolution = screen.getXResolution()
    yResolution = screen.getYResolution()

    #screen.hide( "InterfaceOrnamentLeftLow" )
    #screen.hide( "InterfaceOrnamentRightLow" )

    for i in range(gc.getNumReligionInfos()):
      szName = "ReligionButton" + str(i)
      screen.hide( szName )

    i = 0
    if ( CyInterface().shouldShowResearchButtons() and CyInterface().getShowInterface() == InterfaceVisibility.INTERFACE_SHOW ):
      iCount = 0


#RevolutionDCM limited religions
      pPlayer = gc.getActivePlayer()
      for i in range( gc.getNumTechInfos() ):
        if (pPlayer.canResearch(i, False)):
          if (iCount < 20):
            szName = "ResearchButton" + str(i)

            if(pPlayer.canFoundReligion() and gc.getGame().isTechCanFoundReligion(i)):
              for j in range( gc.getNumReligionInfos() ):
                if (gc.getReligionInfo(j).getTechPrereq() == i):
                  if( not gc.getGame().isReligionSlotTaken(j) ):
                    szName = "ReligionButton" + str(j)
                    break
#RevolutionDCM end

            screen.show( szName )
            self.setResearchButtonPosition(szName, iCount)

          iCount = iCount + 1

    return 0
In C2C right now, "gc.getTechInfo(i).getButton()" is the function that is used for religious techs if the tech has been invented and a religion was automatically founded by it.
Thus "gc.getReligionInfo(i).getGenericTechButton()" will, as it currently is, never be used.
 
Last edited:
Another note: This code does not run every turn of the game...
Code:
    # *********************************************************************************
    # RESEARCH BUTTONS
    # *********************************************************************************

    i = 0
    for i in range( gc.getNumTechInfos() ):
      szName = "ResearchButton" + str(i)
      screen.setImageButton( szName, gc.getTechInfo(i).getButton(), 0, 0, 32, 32, WidgetTypes.WIDGET_RESEARCH, i, -1 )
      screen.hide( szName )

    i = 0
    for i in range(gc.getNumReligionInfos()):
      szName = "ReligionButton" + str(i)
      if ( gc.getGame().countKnownTechNumTeams( gc.getReligionInfo(i).getTechPrereq() ) > 0 ):
        szButton = gc.getReligionInfo(i).getGenericTechButton()
      else:
        szButton = gc.getReligionInfo(i).getTechButton()
      screen.setImageButton( szName, szButton, 0, 0, 32, 32, WidgetTypes.WIDGET_RESEARCH, gc.getReligionInfo(i).getTechPrereq(), -1 )
      screen.hide( szName )
It is processed every time you start/load a game, alt-tab out and into the game, and when exiting the Pedia, perhaps also in some other occasions as well.
 
not GAME.countKnownTechNumTeams(i)
This call is an integer, not a boolean. I suppose you might be able to get away with calling an int like a bool in python and I can understand the logic in it if you can. DLL doesn't like that sort of thing when compiling.
With divine prophets the tech doesn't automatically found a religion and it is then also never marked as a tech that cannot found a religion.
Exactly why and GAME.isTechCanFoundReligion(i) is unnecessary to call. I can see the point in adding CyPlayer.canFoundReligion() though, which filters properly for not being able to found a religion due to limited religions.

You don't seem to understand, if the religious tech has been invented by anyone on a non-divine prophet game, the "ResearchButton" + str(i) will be used for the religion tech button. Not the "ReligionButton" + str(i).
OH... I get it now. On review then, whether Research or Religion button is used is important to audit through the code. Generally speaking, it looks like only the religion reference should ever be in use here. So yeah, the core should probably be adjusted on that too.

It looks like it should just always use the ReligiousButton and never use the tech button. Then the filter works properly.

Sorry... due to hasty code reading and the similarity in spelling between religion and research I was blinded to seeing the difference between the two variables.
 
Last edited:
Another note: This code does not run every turn of the game...
Code:
    # *********************************************************************************
    # RESEARCH BUTTONS
    # *********************************************************************************

    i = 0
    for i in range( gc.getNumTechInfos() ):
      szName = "ResearchButton" + str(i)
      screen.setImageButton( szName, gc.getTechInfo(i).getButton(), 0, 0, 32, 32, WidgetTypes.WIDGET_RESEARCH, i, -1 )
      screen.hide( szName )

    i = 0
    for i in range(gc.getNumReligionInfos()):
      szName = "ReligionButton" + str(i)
      if ( gc.getGame().countKnownTechNumTeams( gc.getReligionInfo(i).getTechPrereq() ) > 0 ):
        szButton = gc.getReligionInfo(i).getGenericTechButton()
      else:
        szButton = gc.getReligionInfo(i).getTechButton()
      screen.setImageButton( szName, szButton, 0, 0, 32, 32, WidgetTypes.WIDGET_RESEARCH, gc.getReligionInfo(i).getTechPrereq(), -1 )
      screen.hide( szName )
It is processed every time you start/load a game, alt-tab out and into the game, and when exiting the Pedia, perhaps also in some other occasions as well.
I suppose that means it needs to be reprocessed when any player researches a tech (could further be filtered for religious tech.)
 
This call is an integer, not a boolean. I suppose you might be able to get away with calling an int like a bool in python and I can understand the logic in it if you can. DLL doesn't like that sort of thing when compiling.
Yeah, python handles booleans the same as anythin else.
"if not" would return "True" for all of these elements [False, None, Null, 0, "", [], (), {}] and "False" for anything else.
Exactly why and GAME.isTechCanFoundReligion(i) is unnecessary to call. I can see the point in adding CyPlayer.canFoundReligion() though, which filters properly for not being able to found a religion due to limited religions.
I disagree, the GAME.isTechCanFoundReligion(i) filters out all non-religious techs that's not been invented by anyone so that they don't have to run through this piece of code:
Code:
              for j in range( gc.getNumReligionInfos() ):
                if (gc.getReligionInfo(j).getTechPrereq() == i):
                  if( not gc.getGame().isReligionSlotTaken(j) ):
                    szName = "ReligionButton" + str(j)
                    break
It looks like it should just always use the ReligiousButton and never use the tech button.

Generally speaking, it looks like only the religion reference should ever be in use here. So yeah, the core should probably be adjusted on that too.
I think it's strange to not ever use the tech button for religious techs in the tech-bar selection-area, but maybe you got a point I'm not seeing clearly atm.
I suppose that means it needs to be reprocessed when any player researches a tech (could further be filtered for religious tech.)
Then there would be little point in doing the caching if it must be done almost every turn.
 
Last edited:
I disagree, the GAME.isTechCanFoundReligion(i) filters out all non-religious techs that's not been invented by anyone so that they don't have to run through this piece of code:
Ok, so long as isTechCanFoundReligion doesn't care whether the religion has been founded somewhere in the game or not. I think that's what we were both saying earlier. Using this as a speed filter I can see the purpose. Every little bit counts right?
I think it's strange to not ever use the tech button for religious techs in the tech-bar selection-area, but maybe you got a point I'm not seeing clearly atm.
It is a little, but if its used somewhere else it should be that I'm not seeing or if there becomes a valid reason for it to find inclusion somewhere (which the button definition generally has) like perhaps on the tech splash popup screen, and we want that button to look like, say, the normal religious icon or something within a border, while on most all other references you want the praying hands on an alpha channeled religious icon (no button border) and when the religious tech is taken, instead display a greyscale alpha channeled religious icon without the praying hands at all (to REALLY highlight that the religious tech has already been captured) then it's good to have a way to vary all 3 buttons. Some of this is just planning ahead for the possibility of variations that aren't going to immediately exist.

Then there would be little point in doing the caching if it must be done almost every turn.
True, but if the cache is cleared only when religious techs are researched by any player, this should still be significant enough cause to continue having some caching and we could remove the clearing on some other factors that may be taking place unnecessarily. This is again higher end python complexity I don't want to get into myself so if you don't want to either, we could just remove all caching. Shouldn't be a noticeable difference. But again, with this mod, its the little things building up on us that cause significant slowdowns.

On that note, can I ask you to take care of the core coding changes that need to take place here or are you only able to work on your modmod's side of it with the way you're setup? From what I understand, you've established a way to fairly easily work with either codeset, right?
 
On that note, can I ask you to take care of the core coding changes that need to take place here or are you only able to work on your modmod's side of it with the way you're setup? From what I understand, you've established a way to fairly easily work with either codeset, right?
Sure, I understand what it is you want here now and will make sure it works on core C2C as well as in the modmod.
 
Sure, I understand what it is you want here now and will make sure it works on core C2C as well as in the modmod.
Thanks bro!
 
v0.5.9.2.2
I was wondering, could you put the religions in the city view inside a box like on the opposite end, like with the maintenance and the sliders?
  • ↑ Did that ↑
  • Adjusted the buttons used for religious techs, in the list that appears at the tech bar area when selecting a tech, based on the above discussion with TB.
v0.5.9.2.2.1 - Hotfix
9849
  • Helped TB out with a python conundrum.
  • When making the above religious tech button adjustments for core C2C I noticed some problems with it that is now fixed here as well.
@AllWhoCares: Should I make the tech selection buttons bigger?
Spoiler Like this :
8800_20180121235645_1.jpg
From 32x32 to 48x48
 
Last edited:
Theoretical question (not suggestion): Is it possible to make standalone pedia?
And why it is very hard to make?

Your pedia is so quick, that you can quickly launch game, enter pedia in main menu and see what where is.
 
Theoretical question (not suggestion): Is it possible to make standalone pedia?
And why it is very hard to make?
Do you mean a pedia that can be launched from desktop without starting the BtS game engine at all?
It's theoretically possible but it would be a gigantic project because the current pedia rely on the dll and BtS game engine to do a lot of the work, like interpreting the content of the XML files and generating the GUI elements.
 
Last edited:
So I guessed that would be hard :p

Is it possible to implement building requirement chain - basically something like tech tree, but for buildings themselves?
There is already building replacement chain in pedia.

This is replacement chain - there is nice Housing replacement chain - first one is Homeless.
Spoiler :
CzkYU9V.jpg



Requirement chain would function like that:
It goes trough all buildings, picks ones, that have building requirements, and try to make chains out of them like above replacement chain.
Here Library would be first - it doesn't have any building requirements, then would be university and so other buildings.
Spoiler :
1j6URBs.jpg
 
Last edited:
Is it possible to implement building requirement chain - basically something like tech tree, but for buildings themselves?
There is already building replacement chain in pedia.
Yes, it's doable, not a small task though.
I'll place the suggestion at the bottom of my priority list, so don't expect it anytime soon. ^^
 
The code that makes the chains is almost general enough that you can pass simple information to it and it will produce the tree. However the code itself is complex.

The request for requirement buildings would end up with something as messy as the unit tree.
 
I love this UI overhaul and hope that once V38 comes out this will be updated quickly enough so I can use this as well. However one thing that I would like to ask is if you can add building resources to the "map resources" tab instead of just map resources. As "bugs" "grass" and such are pretty useful to know
 
However one thing that I would like to ask is if you can add building resources to the "map resources" tab instead of just map resources. As "bugs" "grass" and such are pretty useful to know
Why don't you want "bugs" and "grass" to be in the building resource tab? Are you saying that the building resource tab does not contain "bugs" and "grass"?
 
Back
Top Bottom