CaptainMidnight
Warlord
- Joined
- Apr 16, 2006
- Messages
- 141
I've been trying to get some new tags to work. The tags enable civics to grant specific specialist types commerce bonuses. For example, under Free Market Merchant specialist are granted +1 and
The XML looks like this in CivicInfos.xml:
I have done all the work for infos.cpp and player.cpp. The affected specialist display the change correctly when in the civic. I haven't made any changes to cvcity.cpp yet so the extra commerce is not used by the city and am unsure how to proceed. Any help would be marvelous!
This is the main things i did in the (excluding the ppaaiSpecialistCivicExtraCommerce stuff) cvplayer.cpp :
and also here:
and finally this piece
My question is how do I get this information in player.cpp to be read and used by the city. I figured this piece of code in cvcity.cpp might be significant:
But everything I've tried hasn't worked. Any suggestions?
The XML looks like this in CivicInfos.xml:
Code:
<SpecialistCommerceChanges>
<SpecialistCommerceChange>
<SpecialistType>SPECIALIST_MERCHANT</SpecialistType>
<CommerceChanges>
<iCommerce>1</iCommerce>
<iCommerce>1</iCommerce>
<iCommerce>1</iCommerce>
<iCommerce>1</iCommerce>
</CommerceChanges>
</SpecialistCommerceChange>
</SpecialistCommerceChanges>
I have done all the work for infos.cpp and player.cpp. The affected specialist display the change correctly when in the civic. I haven't made any changes to cvcity.cpp yet so the extra commerce is not used by the city and am unsure how to proceed. Any help would be marvelous!
This is the main things i did in the (excluding the ppaaiSpecialistCivicExtraCommerce stuff) cvplayer.cpp :
Code:
[B]// CMEDIT Civic Specialist Commerce Changes 19/08/2011[/B]
int CvPlayer::getSpecialistCivicExtraCommerce(SpecialistTypes eIndex1, CommerceTypes eIndex) const
{
FAssertMsg(eIndex1 >= 0, "eIndex1 expected to be >= 0");
FAssertMsg(eIndex1 < GC.getNumSpecialistInfos(), "eIndex1 expected to be < GC.getNumSpecialistInfos()");
FAssertMsg(eIndex >= 0, "eIndex expected to be >= 0");
FAssertMsg(eIndex < NUM_COMMERCE_TYPES, "eIndex expected to be < NUM_COMMERCE__TYPES");
return m_ppaaiSpecialistCivicExtraCommerce [eIndex1][eIndex];
}
void CvPlayer::changeSpecialistCivicExtraCommerce(SpecialistTypes eIndex1, CommerceTypes eIndex, int iChange)
{
FAssertMsg(eIndex1 >= 0, "eIndex1 expected to be >= 0");
FAssertMsg(eIndex1 < GC.getNumSpecialistInfos(), "eIndex1 expected to be < GC.getNumSpecialistInfos()");
FAssertMsg(eIndex >= 0, "eIndex expected to be >= 0");
FAssertMsg(eIndex < NUM_COMMERCE_TYPES, "eIndex expected to be < NUM_COMMERCE_TYPES");
if (iChange != 0)
{
m_ppaaiSpecialistCivicExtraCommerce[eIndex1][eIndex] = (m_ppaaiSpecialistCivicExtraCommerce[eIndex1][eIndex] + iChange);
FAssert(m_ppaaiSpecialistCivicExtraCommerce(eIndex1, eIndex) >= 0);
updateCommerce(eIndex);
AI_makeAssignWorkDirty();
}
}
[B]//CMEdit End[/B]
and also here:
Code:
changeSpecialistExtraCommerce(((CommerceTypes)iI), (GC.getCivicInfo(eCivic).getSpecialistExtraCommerce(iI) * iChange));
}
[B]// CMEDIT Civic Specialist Commerce Changes 17/08/2011[/B]
for (iI = 0; iI < GC.getNumSpecialistInfos(); iI++)
{
for (iJ = 0; iJ < NUM_COMMERCE_TYPES; iJ++)
{
changeSpecialistCivicExtraCommerce(((SpecialistTypes)iI), ((CommerceTypes)iJ), (GC.getCivicInfo(eCivic).getSpecialistCommerceChange(iI, iJ) * iChange));
}
}
[B] // CMEDIT end[/B]
for (iI = 0; iI < GC.getNumBuildingClassInfos(); iI++)
and finally this piece
Code:
int CvPlayer::specialistCommerce(SpecialistTypes eSpecialist, CommerceTypes eCommerce) const
{
[B]// CMEDIT Civic Specialist Commerce Changes 19/08/2011[/B]
// return (GC.getSpecialistInfo(eSpecialist).getCommerceChange(eCommerce) + getSpecialistExtraCommerce(eCommerce));
return (GC.getSpecialistInfo(eSpecialist).getCommerceChange(eCommerce) + getSpecialistExtraCommerce(eCommerce) + getSpecialistCivicExtraCommerce (eSpecialist, eCommerce));
[B]// CMEDIT End[/B]
}
My question is how do I get this information in player.cpp to be read and used by the city. I figured this piece of code in cvcity.cpp might be significant:
Code:
int CvCity::getBaseCommerceRateTimes100(CommerceTypes eIndex) const
{
int iBaseCommerceRate;
iBaseCommerceRate = getCommerceFromPercent(eIndex, getYieldRate(YIELD_COMMERCE) * 100);
iBaseCommerceRate += 100 * ((getSpecialistPopulation() + getNumGreatPeople()) * GET_PLAYER(getOwnerINLINE()).getSpecialistExtraCommerce(eIndex));
iBaseCommerceRate += 100 * (getBuildingCommerce(eIndex) + getSpecialistCommerce(eIndex) + getReligionCommerce(eIndex) + getCorporationCommerce(eIndex) + GET_PLAYER(getOwnerINLINE()).getFreeCityCommerce(eIndex));
But everything I've tried hasn't worked. Any suggestions?