Help Needed With Building That Gives Free Unit Class

Padjur

Prince
Joined
Nov 16, 2009
Messages
318
Background

I want to add an Office building for Corporations. These buildings are to be built in the normal way but will give you a CEO of the particular corporation to which the office is related. the plan is to add a tag OfficeCorporation, to the BuildingInfos.XML.

There is a tag, in CIV4CorporationInfo.xml, <FreeUnitClass> which is linked to the tag in
CIV4BuildingInfos.xml, <FoundsCorporation>, I want to change that to link it to the office, so that when an office is built you receive a free CEO. The unit while be set to Immobile but will establish the corporation in that city. In other words I want to change the method of in which to corporation is spread, from building a unit in a city which has the corporation to building a building in a city that does not, to spread it.


The Function
The Idea is that this function could be used to switch the free unit from the headquarters to the office. The headquarters is determined by foundscorporation, so I add OfficeCorporation and change Headquarters for Office in the function below?
Also what does GC.getGameINLINE mean? and are there parts of this function that I must keep, I just want the headquarters ability in giving free CEO's removed (all other functions of the headquarters are to remain the same.) Thanks for any help.



In CvCity.cpp
Code:
bool CvCity::isHeadquarters(CorporationTypes eIndex) const
{
	return (GC.getGameINLINE().getHeadquarters(eIndex) == this);
}

void CvCity::setHeadquarters(CorporationTypes eIndex)
{
	GC.getGameINLINE().setHeadquarters(eIndex, this, true);

	if (GC.getCorporationInfo(eIndex).getFreeUnitClass() != NO_UNITCLASS)
	{
		UnitTypes eFreeUnit = ((UnitTypes)(GC.getCivilizationInfo(getCivilizationType()).getCivilizationUnits(GC.getCorporationInfo(eIndex).getFreeUnitClass())));

		if (eFreeUnit != NO_UNIT)
		{
			GET_PLAYER(getOwnerINLINE()).initUnit(eFreeUnit, getX_INLINE(), getY_INLINE());
		}
	}
}

bool CvCity::isHeadquarters() const
{
	int iI;

	for (iI = 0; iI < GC.getNumCorporationInfos(); iI++)
	{
		if (isHeadquarters((CorporationTypes)iI))
		{
			return true;
		}
	}

	return false;
}
 
I can't help you with your main question because I'm not familiar with corporations, I never used them when playing the game. GC.getGameINLINE is a macro. If I understand things properly it is just a fast and easy way to get the current CvGame object.
 
Ok thanks for the info on GC.getGameINLINE General Tso.

So I've added my tag in the XML and to CvInfo's, compiled and tested (that's the easy bit), now I want it to do something :hmm:

This is my stab in the dark, (always the same with the SDK :rolleyes:) For the craic I'll add this and see what happens. I think its not going to work, If anybody can help with this it would be greatly appreaciated.
Code:
bool CvCity::isOfficeCorporation(CorporationTypes eIndex) const
{
	return (GC.getGameINLINE().getOfficeCorporation(eIndex) == this);
}


bool CvCity::isOfficeCorporation() const
{
	if (iChange > 0)
	{
		CorporationTypes eCorporation = (CorporationTypes)GC.getBuildingInfo(eBuilding).getOfficeCorporation();
		if (NO_CORPORATION != eCorporation && !GC.getGameINLINE().isCorporationFounded(eCorporation))
		{
			setOffice(eCorporation);
		}
	}
}


void CvCity::setOffice(CorporationTypes eIndex)
{
	GC.getGameINLINE().setOffice(eIndex, this, true);

	if (GC.getCorporationInfo(eIndex).getFreeUnitClass() != NO_UNITCLASS)
	{
		UnitTypes eFreeUnit = ((UnitTypes)(GC.getCivilizationInfo(getCivilizationType()).getCivilizationUnits(GC.getCorporationInfo(eIndex).getFreeUnitClass())));

		if (eFreeUnit != NO_UNIT)
		{
			GET_PLAYER(getOwnerINLINE()).initUnit(eFreeUnit, getX_INLINE(), getY_INLINE());
		}
	}
}


Edit OK Problem 'getOfficeCorporation' : is not a member of 'CvGameAI'|


:confused: What I wanted to do was point it to CvInfo's, where I added this but I don't know what I'm doing
Code:
int CvBuildingInfo::getOfficeCorporation() const		
{
	return m_iOfficeCorporation;
}
 
Top Bottom