cpp question : Who exactly is "GC"?

kipkuhmi

Warlord
Joined
Aug 8, 2007
Messages
131
Hi everybody,

I'm currently trying to set up the new leader trait "informed", which would double the Espionage Points for your faction.

In CvPlayer.cpp I have inserted a few lines (bold in the text segment below). Building the CvGameCoreDLL.dll and running the game I do more or less get what I want, only the points are now always doubled - regardless what faction I play.

Now my question is: who exactly is "GC", as in "GC.getTraitInfo((TraitTypes)iI).getEspModifier()"? - Is he a self reference to the active player or is he ANY player? Or somebody else?

Thanks for any help.



Code:
void CvPlayer::doEspionagePoints()
{
	if (getCommerceRate(COMMERCE_ESPIONAGE) > 0)
	{
	    int iI;

		GET_TEAM(getTeam()).changeEspionagePointsEver(getCommerceRate(COMMERCE_ESPIONAGE));

		int iSpending = 0;

		// Divide up Espionage between Teams
		for (int iLoop = 0; iLoop < MAX_CIV_TEAMS; iLoop++)
		{
			if (getTeam() != iLoop)
			{
				if (GET_TEAM((TeamTypes)iLoop).isAlive())
				{
					if (GET_TEAM(getTeam()).isHasMet((TeamTypes)iLoop))
					{
						iSpending = getEspionageSpending((TeamTypes)iLoop);
                        [B]for (iI = 0; iI < GC.getNumTraitInfos(); iI++)                           // new segment
		                {                                                                                //
                         	if (GC.getTraitInfo((TraitTypes)iI).getEspModifier() == 100)   //
			                {                                                                        // 
                                iSpending *= 2;                                                            //
                            }[/B]                                                                               // end of segment
                        }

						if (iSpending > 0)
						{
							GET_TEAM(getTeam()).changeEspionagePointsAgainstTeam((TeamTypes)iLoop, iSpending);
						}
					}
				}
			}
		}
	}
}
 
GC is the 'Global Context' object, all of the methods in GC are used to handle raw game data. For example you will never see: GC.setMyInformation(toThis) but you will see things like GC.getInformation(index). You use GC methods to performs checks against rules, convert strings to index values so you can match tests against things like a trait name (since the index can vary depending on the number of traits in your XML files).

Does that make any sense?
 
Wow, that was a quick answer. And I guess I'm starting to get the picture ... most importantly, I think I do now understand what's wrong with my "if" condition:

I thought, that "GC.getNumTraitInfos()" was the number of leadertraits for one single person (so it would normally return the value "2"). Now it appears to me that it rather describes the general amount of all the different traits present in the game.
Subsequently, the loop runs down ALL the different traits with EspModifier = 0 until it bumps into the one with EspModifier = 100 ("EspModifier" being my newly introduced variable for the "informed" leader trait). As this will always happen sooner or later, the "if" condition is always fulfilled and hence useless.

What I originally wanted was a way to check the given player's two leader traits for a EspModifier = 100. Well, I will have to do a little more homework to find out how to do that. :)

Oh, and if I understood you correctly, GC is a Civ creation, not a genuine c++ class, right? - In any case, thanks for your quick help!
 
Top Bottom