Modmodding Q&A Thread

CvCity& is a pointer, Google C++ pointer if you want to know more about that. In practice, you can dereference the pointer to get access to the functions of its objects:
Code:
pCity->getTeam()
And from there you can get the CvTeam object:
Code:
GET_TEAM(pCity->getTeam())
I'm not sure if CvCity actually has the getTeam() function, otherwise you can go via CvPlayer:
Code:
GET_TEAM(GET_PLAYER(pCity->getOwner()).getTeam())

To figure things like this out, it's generally a good idea to search for the construct you are stuck with in the source and look up how it's handled there. In most cases you will find an instructive example.
 
CvCity& is a pointer, Google C++ pointer if you want to know more about that. In practice, you can dereference the pointer to get access to the functions of its objects:
Code:
pCity->getTeam()
And from there you can get the CvTeam object:
Code:
GET_TEAM(pCity->getTeam())
I'm not sure if CvCity actually has the getTeam() function, otherwise you can go via CvPlayer:
Code:
GET_TEAM(GET_PLAYER(pCity->getOwner()).getTeam())

To figure things like this out, it's generally a good idea to search for the construct you are stuck with in the source and look up how it's handled there. In most cases you will find an instructive example.
Yeah, I did google it, but I was under the impression I was supposed to do city->GET_TEAM(getTeam()), but that didn't work so I was confused.
 
Just open CvCity to see what its members are.
 
And I'm getting the error that convinced me not to use -> on city

GET_TEAM(city->getTeam() results in an error on city saying "expression must have pointer type"
 
Well is city a pointer or not? Can you quote the entire method?
 
Sorry for the trouble, should have posted all of it in the beginning, here it is

Code:
void CvGameTextMgr::setFoodHelp(CvWStringBuffer &szBuffer, CvCity& city)
{
Spoiler Code that probably isn't relevant to the issue at hand :
Code:
FAssertMsg(NO_PLAYER != city.getOwnerINLINE(), "City must have an owner");
 
    CvYieldInfo& info = GC.getYieldInfo(YIELD_FOOD);
    bool bNeedSubtotal = false;
    int iBaseRate = 0;
    int i;

    // Worked Tiles
    int iTileFood = 0;
    for (i = 0; i < NUM_CITY_PLOTS; i++)
    {
        if (city.isWorkingPlot(i))
        {
            CvPlot* pPlot = city.getCityIndexPlot(i);

            if (pPlot != NULL)
            {
                iTileFood += pPlot->getYield(YIELD_FOOD);
            }
        }
    }
    if (iTileFood != 0)
    {
        szBuffer.append(gDLL->getText("TXT_KEY_MISC_HELP_WORKED_TILES_YIELD", iTileFood, info.getChar()));
        iBaseRate += iTileFood;
    }

    // Trade
    int iTradeFood = city.getTradeYield(YIELD_FOOD);
    if (iTradeFood != 0)
    {
        szBuffer.append(NEWLINE);
        szBuffer.append(gDLL->getText("TXT_KEY_MISC_HELP_SPECIALIST_COMMERCE", iTradeFood, info.getChar(), L"TXT_KEY_HEADING_TRADEROUTE_LIST"));
        iBaseRate += iTradeFood;
        bNeedSubtotal = true;
    }

    // Specialists
    int iSpecialistFood = 0;
    for (i = 0; i < GC.getNumSpecialistInfos(); i++)
    {
        iSpecialistFood += GET_PLAYER(city.getOwnerINLINE()).specialistYield((SpecialistTypes)i, YIELD_FOOD) * (city.getSpecialistCount((SpecialistTypes)i) + city.getFreeSpecialistCount((SpecialistTypes)i));
    }
    if (iSpecialistFood != 0)
    {
        szBuffer.append(NEWLINE);
        szBuffer.append(gDLL->getText("TXT_KEY_MISC_HELP_SPECIALIST_COMMERCE", iSpecialistFood, info.getChar(), L"TXT_KEY_CONCEPT_SPECIALISTS"));
        iBaseRate += iSpecialistFood;
        bNeedSubtotal = true;
    }

    // Corporations
    int iCorporationFood = city.getCorporationYield(YIELD_FOOD);
    if (iCorporationFood != 0)
    {
        szBuffer.append(NEWLINE);
        szBuffer.append(gDLL->getText("TXT_KEY_MISC_HELP_CORPORATION_COMMERCE", iCorporationFood, info.getChar()));
        iBaseRate += iCorporationFood;
        bNeedSubtotal = true;
    }
 
    // Buildings
    int iBuildingFood = 0;
    for (i = 0; i < GC.getNumBuildingInfos(); i++)
    {
        int iCount = city.getNumActiveBuilding((BuildingTypes)i);
        if (iCount > 0)
        {
            CvBuildingInfo& kBuilding = GC.getBuildingInfo((BuildingTypes)i);
            iBuildingFood += iCount * (kBuilding.getYieldChange(YIELD_FOOD) + city.getBuildingYieldChange((BuildingClassTypes)kBuilding.getBuildingClassType(), YIELD_FOOD));
        }
    }
    if (iBuildingFood != 0)
    {
        szBuffer.append(NEWLINE);
        szBuffer.append(gDLL->getText("TXT_KEY_MISC_HELP_BUILDING_COMMERCE", iBuildingFood, info.getChar()));
        iBaseRate += iBuildingFood;
        bNeedSubtotal = true;
    }
Code:
    // Harappan UP: Sanitation (positive health contributes to city growth)
    int iHealthFood = 0;
    if (city.getOwnerINLINE() == HARAPPA)
    {
        int Techs = 0;

        for  (int iI = 0; iI < GC.getNumTechInfos(); iI++) {
            if (GET_TEAM(city->getTeam()).isHasTech((TechTypes)iI)) {
                Techs++;
                if (Techs >= 30) break;
            }
        }
 
Oh sorry, I just noticed I misread your initial post. CvCity& is a reference, not a pointer. Which in practice mostly means that you address its members with a . instead of ->.
 
Oh sorry, I just noticed I misread your initial post. CvCity& is a reference, not a pointer. Which in practice mostly means that you address its members with a . instead of ->.
Yep, it worked. My issue was the city. was before GET_TEAM in my attempts when it should have been before getTeam()

GET_TEAM(city.getTeam()).isHasTech((TechTypes)iI)

Thank you so much for going through all this trouble.
 
Leoreth ... I have a mod-mod of KMod called MMod [found here: https://sourceforge.net/projects/mmod/files/ ]

I am wanting to implement 4 new things to my mod, and would like your assistance and / or guidance. While recently playing RFC Dawn of Civilization, I found that I really, truly liked the civics in your game. I particularly liked the "inquisitor" unit and how it plays essentially along with theocracy. I'd like to replace vanilla BTS civics with your civics, while also adding the "inquisitor" unit. Have you found that the AI, itself, understands how and when to use this unit? Aside from that, do you have any guidance for replacing the current civics with the civics in RFC Dawn of Civilization as well as utilizing the inquisitor unit?

At one time [back in mid-2015], I taught myself how to create new civilizations and new leaders, but have since completely forgotten the process. Would you be willing to point me to a direction to help me re-learn this process?
 
Last edited:
The civics part and the inquisitor are completely separate.

Keep in mind that I have added a lot of extra civic XML tags to implement the new civics. The best way to replicate that is therefore to start where CvCivicInfos reads the XML and then follow the call chains where these entries are referenced in the code.

The inquisitor has its own AI that identifies a city to remove religions from, move to this city and then pick the religion to remove based on the state religion. I don't remember if it was in Python or C++ though, search for either inquisitor or persecutor to find the related code.

Do you mean adding new civilizations and new leaders in general or to DoC?
 
Adding new civs and leaders in general ... as I was going to add them to my own mod-mod while also attempting to add the civics and inquisitor unit since Ive enjoyed them so much in RFC DoC
 
There are generic guides on that topic in the tutorials subforum.
 
How would I go about making founding cities (where possible) a priority over claiming them in Congresses.py? I've already managed to play around with the file in question a bit, but I'm a bit clueless on that particular matter.
 
The priority is the iValue variable in selectClaims(), the AI will always choose the city with the highest value.
 
Is there any code that activates when a tech is discovered? I'd like to place some code that activated upon discovering Automation.

EDIT: I think I found it, setHasTech
 
Yes, alternatively you can use onTechAcquired in Python.
 
The priority is the iValue variable in selectClaims(), the AI will always choose the city with the highest value.
Yeah, thanks, figured it out now and it's working for the AI, I don't know how to make the option to settle cities via congress available to the human player - gives me No Request every time.
 
You can find all the criteria in lines 1072-84.
 
I added early game Piracy units but the AI doesn't seem to be using them. Anyone have any ideas why? The Asset level for each is 1, and the Power level is 1 above their corresponding military boat (War Galley - Pirate, Heavy Galley - Corsair)
 
Have you assigned the corresponding unit AI?
 
Top Bottom