Civic Attitude Modifier

However, now, When I updated CyInfoInterface1.cpp, I get compiler errors:

Did you change the name of the CvCivicInfo::getCivicAttitudeChanges() function to CvCivicInfo::getCivicAttitudeChange()? [notice the lack of -s]

Oh, and Opera, I compiled a new DLL before I noticed those CyInfoInterface changes, and it compiled fine and the game loaded, but I have no way to test if the codes working, since it hasn't been exposed to python, and there is no code for the foreign diplo screens yet...

Good news! Add a -100 civic attitude modifier for a pair of early-game civics and see if anyone is furious with anyone else.
 
[plain][/plain] tags? Wow, that's tricky. I didn't even know those existed.

There's a lot of good stuff in the BB Code which you can find in the link in the box in the bottom-left corner of the posting page labeled Posting Rules.
 
Did you change the name of the CvCivicInfo::getCivicAttitudeChanges() function to CvCivicInfo::getCivicAttitudeChange()? [notice the lack of -s]

Nope:
Here's a snipped of the code in CvInfos, it hasn't been changed at all.

Code:
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"[B]CivicAttitudeChanges[/B]"))

Good news! Add a -100 civic attitude modifier for a pair of early-game civics and see if anyone is furious with anyone else.

*Runs off to change XML and start game*
 
Hmm...

Maybe I didn't code the XML right, but I'm not seeing any difference. My XML schema has been updated, (and gives no errors when loading, so I'm assuming that works), but the XML itself seems to be ignored. Take a looks:

Code:
		<CivicInfo>
			<CivicOptionType>CIVICOPTION_GOVERNMENT</CivicOptionType>
			<Type>CIVIC_CHIEFDOM</Type>
			...
			<CivicAttitudeChanges>
				<CivicAttitudeChange>
					<CivicType>CIVIC_DESPOTISM</CivicType>
					<iAttitudeChange>-100</iAttitudeChange>
					<Description>%D1: Whip it!</Description>
				</CivicAttitudeChange>
			</CivicAttitudeChanges>
			...
		</CivicInfo>
I immediately went into the worldbuilder, gave myself the tech for Despotism, and switched. (Oh, btw, Chiefdom is a starting civic, so the rest of the AI still were using it.) Then I placed a unit right next to an AI, so we could have contact. He was just cautious, like usual...
 
I was talking about the C++ function, not the XML element name. Search CvInfos.h for

Code:
getCivicAttitudeChanges

The function should match this signature:

Code:
int CvCivicInfo::getCivicAttitudeChanges(int i);

Did you modify the AI attitude calculation functions to consider the civics effects? I forget how far you got.
 
I was talking about the C++ function, not the XML element name. Search CvInfos.h for

Code:
getCivicAttitudeChanges
The function should match this signature:

Code:
int CvCivicInfo::getCivicAttitudeChanges(int i);

It does.
From the header file:
Code:
/*************************************************************************************************/
/** Afforess  Attitude Modifier Start         08/17/09                                               */
/**                                                                                              */
/**                                                                                              */
/*************************************************************************************************/
    int getCivicAttitudeChanges(int i) const;
    int* getCivicAttitudeChanges() const;
/*************************************************************************************************/
/** Afforess  Attitude Modifier End                                                                 */
/*************************************************************************************************/


Did you modify the AI attitude calculation functions to consider the civics effects? I forget how far you got.

I just check CvPlayerAi, and it has this function, which I don't remember writing, but must have at one point....
Code:
/*************************************************************************************************/
/** Afforess  Attitude Modifier           Start          08/18/09                                    */
/**                                                                                              */
/**                                                                                              */
/*************************************************************************************************/
int CvPlayerAI::AI_getCivicAttitudeChanges(PlayerTypes ePlayer) const
{
    int iAttitude = 0;
    
    // add modifier for every combination of civics between the two players
    for (int iI = 0; iI < GC.getNumCivicOptionInfos(); iI++)
    {
        for (int iJ = 0; iJ < GC.getNumCivicOptionInfos(); iJ++)
        {
            iAttitude += GC.getCivicInfo(getCivics((CivicOptionTypes)iI)).getCivicAttitudeChanges(GET_PLAYER(ePlayer).getCivics((CivicOptionTypes)iJ));
        }
    }
    
    return iAttitude;
}
/*************************************************************************************************/
/** Afforess  Attitude Modifier                                END                                   */
/*************************************************************************************************/

That's really the only other code I have, so if you're asking If I've taught the AI how to use it, the answer is no.
 
CvPlayerAI::AI_getAttitude() should add in the result of a call to AI_getCivicAttitudeChanges() before returning the actual attitude. It may be a different function, perhaps AI_getAttitudeVal()--whatever function sums up all the attitude modifiers.

Regarding the compile error, I think it's caused by the fact that it's finding the wrong function. Here is where function overloading can bite you in the ass. When you specify

Code:
&CvCivicInfo::getCivicAttitudeChanges

to get the address of the function, the compiler doesn't know which function you want: the one without any parameters or the one that takes a single int. There's probably a way to tell the compiler which, but it's far easier to just change the name of the single-value accessor (as I recommended originally :p) by removing the "-s":

Code:
int CvCivicInfo::getCivicAttitudeChange(int i) const;

You'll need to change AI_getCivicAttitudeChanges() and CyInterface1.cpp to use the new name.
 
Ah, yes. It's in AI_getAttitudeVal(ePlayer). Pretty easy to see how you should set it up ;)
 
For the first part, like this?
Code:
...
	iAttitude += AI_getOpenBordersAttitude(ePlayer);
	iAttitude += AI_getDefensivePactAttitude(ePlayer);
	iAttitude += AI_getRivalDefensivePactAttitude(ePlayer);
	iAttitude += AI_getRivalVassalAttitude(ePlayer);
	iAttitude += AI_getShareWarAttitude(ePlayer);
	iAttitude += AI_getFavoriteCivicAttitude(ePlayer);
	iAttitude += AI_getTradeAttitude(ePlayer);
	iAttitude += AI_getRivalTradeAttitude(ePlayer);
	[B]iAttitude += AI_getCivicAttitudeChange(ePlayer);[/B]//Afforess
...

And I'll make those pluralization changes...
 
Oh, and does anything need to be changed in the
Code:
bool CvCivicInfo::readPass2(CvXMLLoadUtility* pXML)

because I changed the pluralization?
 
Well, no. Just change all "changes" to "change" in every bit of code you added. Apart from that, there's no thing to modify.
 
Just to be clear, you should only remove the -s from one of the functions--the one that takes an int. You should be left with these two function declarations:

Code:
int getCivicAttitudeChange(int i) const;
int* getCivicAttitudeChanges() const;

I don't think any of the XML-reading code calls those functions, so that should be it.
 
Ah, damn, I thought you meant he should change all the -s things. Sorry :blush:
 
No worries. The point was to give the functions different names to help the compiler figure out which function we wanted to expose in CyInterface1.cpp.
 
Just to be clear, you should only remove the -s from one of the functions--the one that takes an int. You should be left with these two function declarations:

Code:
int getCivicAttitudeChange(int i) const;
int* getCivicAttitudeChanges() const;
I don't think any of the XML-reading code calls those functions, so that should be it.

So this function should look like this?

Code:
int CvCivicInfo::getCivicAttitudeChange(int i) const
{
    FAssertMsg(i < GC.getNumCivicInfos(), "Index out of bounds");
    FAssertMsg(i > -1, "Index out of bounds");
    return m_piCivicAttitudeChanges ? m_piCivicAttitudeChanges[i] : 0;
}
 
I'm obvoiusly not changing something right, because I'm getting a compiler error, on the red highlighted text.

Code:
void CvCivicInfo::copyNonDefaultsReadPass2(CvCivicInfo* pClassInfo) //Afforess
{
	bool bDefault = false;
	int iDefault = 0;
	int iTextDefault = -1;  //all integers which are TEXT_KEYS in the xml are -1 by default

	if (m_piCivicAttitudeChanges)
	{
		for ( int i = 0; i < GC.getNumCivicInfos(); i++ )
		{
			if ( m_piCivicAttitudeChanges[i] == iDefault )
			{
				[COLOR="Red"]m_piCivicAttitudeChanges[i] = pClassInfo->getCivicAttitudeChanges(i);[/COLOR]
			}
		}
	}
}

The error is:

CvInfos.cpp(8670) : error C2660: 'CvCivicInfo::getCivicAttitudeChanges' : function does not take 1 arguments
 
Oh right, it has to copy from one CvCivicInfo to another. I forgot about that part. Here you need to use the non-s function name because you are requesting a single value:

Code:
m_piCivicAttitudeChanges[i] = pClassInfo->[B]getCivicAttitudeChange[/B](i);
 
Oh right, it has to copy from one CvCivicInfo to another. I forgot about that part. Here you need to use the non-s function name because you are requesting a single value:

Code:
m_piCivicAttitudeChanges[i] = pClassInfo->[B]getCivicAttitudeChange[/B](i);

Thanks, I've gotten it to compile now. However, I tried the python console commands, with no success.

Civ4ScreenShot0070.jpg
 
Recall that you just changed the name of that function. ;) It should be "getCivicAttitudeChange(...)"
 
Back
Top Bottom