Civic Attitude Modifier

I don't see the problem right away, but then I didn't quite understand what is happening. Can you be much more specific about what you expect and what you get?

Here are some more tips.

Instead of comparing to an empty string, check if it's empty:

Code:
if (... && !paszCivicAttitudeReasons[iJ].empty())

Double-check that it's empty() by hovering over it after typing it in. If it returns bool, it's correct. If not, use "...size() != 0)".

You can use <string>.clear() to reset it to "" instead of assigning "" to it.

Code:
paszCivicAttitudeReasons[iJ].clear();
 
Okay, what is supposed to happen is that, given two players, I check both of their civics, compare them to see if the player has any civics that affect the target player's diplomacy, and store the reason, and attitude change from that in each of those arrays.

Then, in the second loop, I check for redundant reasons, so I don't get "We Hate Slaves" twice, and delete the redundant reason, and add the attitude hit together.

Then, in the third loop, that's where the text is supposed to actually appear, if there is any.
 
Okay, I think I know what i'm doing wrong here. I need to be using a 2d array. I'm trying to cram GC.getNumCivicOptionInfos() ^ 2 into GC.getNumCivicOptionInfos(). Because I have say, 5 possibilities why player 1 hates or likes player 2's first civic, and 5 more for the next one, and etc...

Right?
 
Thanks for the tips EF, I should really know all the functions for those classes. Is there a good place to look them all up?

Anyway, I got the code working, I was right about need a 2d array. For the curious, it's:
Spoiler :
Code:
		if (iPass == 0)
		{
			CivicTypes eTargetCivic;
			CivicTypes eCivic;
			int** ppaiCivicAttitudeChanges = new int*[GC.getNumCivicOptionInfos()];
			CvWString** ppaszCivicAttitudeReasons = new CvWString*[GC.getNumCivicOptionInfos()];
			for (int iJ = 0; iJ < GC.getNumCivicOptionInfos(); iJ++)
			{
				ppaiCivicAttitudeChanges[iJ] = new int[GC.getNumCivicOptionInfos()];
				ppaszCivicAttitudeReasons[iJ] = new CvWString[GC.getNumCivicOptionInfos()];
			}
			for (int iJ = 0; iJ < GC.getNumCivicOptionInfos(); iJ++)
			{
				eTargetCivic = GET_PLAYER(eTargetPlayer).getCivics((CivicOptionTypes)iJ);
				for (int iK = 0; iK < GC.getNumCivicOptionInfos(); iK++)
				{
					eCivic = GET_PLAYER(ePlayer).getCivics((CivicOptionTypes)iK);
					ppaiCivicAttitudeChanges[iJ][iK] = GC.getCivicInfo(eTargetCivic).getCivicAttitudeChange(eCivic);
					ppaszCivicAttitudeReasons[iJ][iK] = GC.getCivicInfo(eTargetCivic).getCivicAttitudeReason(eCivic);
				}
			}
			for (int iJ = 0; iJ < GC.getNumCivicOptionInfos(); iJ++)
			{
				for (int iK = 0; iK < GC.getNumCivicOptionInfos(); iK++)
				{
					for (int iL = iK + 1; iL < GC.getNumCivicOptionInfos(); iL++)
					{
						if (ppaszCivicAttitudeReasons[iJ][iK] == ppaszCivicAttitudeReasons[iJ][iL])
						{
							ppaiCivicAttitudeChanges[iJ][iK] += ppaiCivicAttitudeChanges[iJ][iL];
							ppaszCivicAttitudeReasons[iJ][iL].clear();
							ppaiCivicAttitudeChanges[iJ][iL] = 0;
						}
					}
				}
			}
			for (int iJ = 0; iJ < GC.getNumCivicOptionInfos(); iJ++)
			{
				for (int iK = 0; iK < GC.getNumCivicOptionInfos(); iK++)
				{
					if (ppaiCivicAttitudeChanges[iJ][iK] != 0 && !ppaszCivicAttitudeReasons[iJ][iK].empty())
					{
						szBuffer.append(NEWLINE);
						szTempBuffer.Format(SETCOLR L"%s" ENDCOLR, TEXT_COLOR((ppaiCivicAttitudeChanges[iJ][iK] > 0) ? "COLOR_POSITIVE_TEXT" : "COLOR_NEGATIVE_TEXT"), gDLL->getText(ppaszCivicAttitudeReasons[iJ][iK], ppaiCivicAttitudeChanges[iJ][iK]).GetCString());
						szBuffer.append(szTempBuffer);
					}
				}
			}
			for (int iJ = 0; iJ < GC.getNumCivicOptionInfos(); iJ++)
			{
				SAFE_DELETE_ARRAY(ppaiCivicAttitudeChanges[iJ]);
				SAFE_DELETE_ARRAY(ppaszCivicAttitudeReasons[iJ]);
			}
			SAFE_DELETE_ARRAY(ppaiCivicAttitudeChanges);
			SAFE_DELETE_ARRAY(ppaszCivicAttitudeReasons);
		}
 
Yes, you can see the API for lots of C++ libraries at cplusplus.com. For example, check out the string class. Note that CvString is a subclass of std::string while CvWString is a subclass of std::wstring.
 
Top Bottom