Civic Attitude Modifier

Recall that you just changed the name of that function. ;) It should be "getCivicAttitudeChange(...)"

Got a new one. Looks like it's working, but it must be ignoring the XML.

Civ4ScreenShot0071.jpg
 
A good way to test these types of things is to put in data that will be obvious. In the code that reads the modifier from the XML (readpass2() IIRC), overwrite the value with -100. This will make every civic have a -100 modifier for all other civics. It will test that the code that copies the values on down to reading them for AI_getAttitudeVal() works.
 
A good way to test these types of things is to put in data that will be obvious. In the code that reads the modifier from the XML (readpass2() IIRC), overwrite the value with -100. This will make every civic have a -100 modifier for all other civics. It will test that the code that copies the values on down to reading them for AI_getAttitudeVal() works.

I just changed

Code:
pXML->InitList(&m_piCivicAttitudeChanges, GC.getNumCivicInfos(), 0);

to

Code:
pXML->InitList(&m_piCivicAttitudeChanges, GC.getNumCivicInfos(), -100);

but In game, this had no effect whatsoever.

Anyways, as a side note, I noticed some commented out code, slightly above the readpass2, I am not sure if it's important or not.

Code:
    // create arrays to hold attitude changes and messages
    //pXML->InitList(&m_piCivicAttitudeChanges, GC.getNumCivicInfos(), 0);
    //pXML->InitList(&m_pszCivicAttitudeTextKeys, GC.getNumCivicInfos(), "");
 
Okay, that makes me suspect that the copying is not working. Can you please post the latest CvInfos.cpp?
 
I've added some debug alert messages to the readpass2() function. Give it a shot. You should see these messages:

  • Found CivicAttitudeChanges
  • Found first CivicAttitudeChange
  • Civic: <civic>
  • Modifier: <modifier>
 
I've added some debug alert messages to the readpass2() function. Give it a shot. You should see these messages:

  • Found CivicAttitudeChanges
  • Found first CivicAttitudeChange
  • Civic: <civic>
  • Modifier: <modifier>
I found CivicAttitudeChanges
Found First CivicAttitudeChange
Civic: CIVIC_DESPOTISM
Modifier: -100

However, in game, it doesn't actually seem to give an attitude change...
 
Perhaps it has to do with CvPlayerAI.cpp rather than CvInfos.cpp. Can we see CvPlayerAI.cpp?
 
No... I guess the error would be here:
Code:
int CvPlayerAI::AI_getCivicAttitudeChange(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)).getCivicAttitudeChange(GET_PLAYER(ePlayer).getCivics((CivicOptionTypes)iJ));
		}
	}
	
	return iAttitude;
}
But it makes sense, at least to me, so I'm not sure why it isn't working.
 
Have you verified that those -100 modifiers are making their way into the final CvCivicInfo objects? Try out that code snippet I had you type into the in-game console to verify that you can see the modifiers. It's possible that the copyNonDefaults() is failing or not getting called.
 
Have you verified that those -100 modifiers are making their way into the final CvCivicInfo objects? Try out that code snippet I had you type into the in-game console to verify that you can see the modifiers. It's possible that the copyNonDefaults() is failing or not getting called.

Okay, I will, but not until tomorrow. I need some sleep. It's midnight here...
 
Have you verified that those -100 modifiers are making their way into the final CvCivicInfo objects? Try out that code snippet I had you type into the in-game console to verify that you can see the modifiers. It's possible that the copyNonDefaults() is failing or not getting called.

Okay, I just ran the game, opened the console, and typed in those commands. I got 0, just like post above...:(
 
Okay, let's compile what we know:

  1. Reading from the XML into the initial array works
  2. The final CivicInfo objects don't get those values
The only thing that happens in-between is copying from one CivicInfo to another inside copyNonDefaultsReadPass2(). I see that it checks if the array exists before doing the copying, but the only code that initializes the array is readPass2().

At the end of read() there is a commented-out call to InitList() for the array. Uncomment it and see if that solves the problem. I really wish there was some documentation around these functions for WoC as I really don't want to read through a bunch of code I won't be using. :( </whine>
 
At the end of read() there is a commented-out call to InitList() for the array. Uncomment it and see if that solves the problem. I really wish there was some documentation around these functions for WoC as I really don't want to read through a bunch of code I won't be using. :( </whine>

Why don't we just drag Facihele, or one of the other WoC'ers over here, and have them tell us what we are doing wrong.

Anyways, I'm recompiling, Hopefully, that will help.
 
Try adding these debug messages.

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
	char szMessage[1024];

	if (m_piCivicAttitudeChanges)
	{
		for ( int i = 0; i < GC.getNumCivicInfos(); i++ )
		{
			if ( m_piCivicAttitudeChanges[i] == iDefault )
			{
				m_piCivicAttitudeChanges[i] = pClassInfo->getCivicAttitudeChange(i);
				if (m_piCivicAttitudeChanges[i] != 0)
				{
					sprintf(szMessage, "Civic: %d = %d", i, m_piCivicAttitudeChanges[i]);
					gDLL->MessageBox(szMessage, "copyNonDefaultsReadPass2");
				}
			}
		}
	}
	else
	{
		sprintf(szMessage, "Skipping");
		gDLL->MessageBox(szMessage, "copyNonDefaultsReadPass2");
	}
}

You should not see "Skipping". You should see a message for each non-zero modifier.
 
Back
Top Bottom