Tokata_RuNeLess
Chieftain
I wanna add a table to the game as Specialist_ResourceQuantity. So I edited CvInfos.cpp and CvCity.cpp.
While reading these code there comes a question. I cannot find out the difference between m_aiExtraSpecialistYield[(YieldTypes) eIndex] and m_aiBaseYieldRateFromSpecialists[(YieldTypes) eIndex]. It seems that they always return the same value, like this:
Is there anyone who can tell me the difference between them (and however the necessity of defining 2 variables)? Thanks a lot!
While reading these code there comes a question. I cannot find out the difference between m_aiExtraSpecialistYield[(YieldTypes) eIndex] and m_aiBaseYieldRateFromSpecialists[(YieldTypes) eIndex]. It seems that they always return the same value, like this:
Code:
/// Base yield rate from Specialists
int CvCity::GetBaseYieldRateFromSpecialists(YieldTypes eIndex) const
{
VALIDATE_OBJECT
CvAssertMsg(eIndex >= 0, "eIndex expected to be >= 0");
CvAssertMsg(eIndex < NUM_YIELD_TYPES, "eIndex expected to be < NUM_YIELD_TYPES");
return m_aiBaseYieldRateFromSpecialists[eIndex];
}
// --------------------------------------------------------------------------------
/// Base yield rate from Specialists
void CvCity::ChangeBaseYieldRateFromSpecialists(YieldTypes eIndex, int iChange)
{
VALIDATE_OBJECT
CvAssertMsg(eIndex >= 0, "eIndex expected to be >= 0");
CvAssertMsg(eIndex < NUM_YIELD_TYPES, "eIndex expected to be < NUM_YIELD_TYPES");
if(iChange != 0)
{
m_aiBaseYieldRateFromSpecialists.setAt(eIndex, m_aiBaseYieldRateFromSpecialists[eIndex] + iChange);
if(getTeam() == GC.getGame().getActiveTeam())
{
if(isCitySelected())
{
DLLUI->setDirty(CityScreen_DIRTY_BIT, true);
}
}
}
}
Code:
int CvCity::getExtraSpecialistYield(YieldTypes eIndex) const
{
VALIDATE_OBJECT
CvAssertMsg(eIndex >= 0, "eIndex expected to be >= 0");
CvAssertMsg(eIndex < NUM_YIELD_TYPES, "eIndex expected to be < NUM_YIELD_TYPES");
return m_aiExtraSpecialistYield[eIndex];
}
// --------------------------------------------------------------------------------
int CvCity::getExtraSpecialistYield(YieldTypes eIndex, SpecialistTypes eSpecialist) const
{
VALIDATE_OBJECT
CvAssertMsg(eIndex >= 0, "eIndex expected to be >= 0");
CvAssertMsg(eIndex < NUM_YIELD_TYPES, "eIndex expected to be < NUM_YIELD_TYPES");
CvAssertMsg(eSpecialist >= 0, "eSpecialist expected to be >= 0");
CvAssertMsg(eSpecialist < GC.getNumSpecialistInfos(), "GC.getNumSpecialistInfos expected to be >= 0");
if (eSpecialist == GC.getDEFAULT_SPECIALIST())
{
return 0;
}
int iYieldMultiplier = GET_PLAYER(getOwner()).getSpecialistExtraYield(eSpecialist, eIndex) +
GET_PLAYER(getOwner()).getSpecialistExtraYield(eIndex) +
GET_PLAYER(getOwner()).GetPlayerTraits()->GetSpecialistYieldChange(eSpecialist, eIndex);
#if defined(MOD_API_UNIFIED_YIELDS)
iYieldMultiplier += GET_PLAYER(getOwner()).getSpecialistYieldChange(eSpecialist, eIndex);
ReligionTypes eMajority = GetCityReligions()->GetReligiousMajority();
if(eMajority >= RELIGION_PANTHEON)
{
const CvReligion* pReligion = GC.getGame().GetGameReligions()->GetReligion(eMajority, getOwner());
if(pReligion)
{
iYieldMultiplier += pReligion->m_Beliefs.GetSpecialistYieldChange(eSpecialist, eIndex);
BeliefTypes eSecondaryPantheon = GetCityReligions()->GetSecondaryReligionPantheonBelief();
if (eSecondaryPantheon != NO_BELIEF)
{
iYieldMultiplier += GC.GetGameBeliefs()->GetEntry(eSecondaryPantheon)->GetSpecialistYieldChange(eSpecialist, eIndex);
}
}
}
#endif
int iExtraYield = GetCityCitizens()->GetSpecialistCount(eSpecialist) * iYieldMultiplier;
return iExtraYield;
}
// --------------------------------------------------------------------------------
void CvCity::updateExtraSpecialistYield(YieldTypes eYield)
{
VALIDATE_OBJECT
int iOldYield;
int iNewYield;
int iI;
CvAssertMsg(eYield >= 0, "eYield expected to be >= 0");
CvAssertMsg(eYield < NUM_YIELD_TYPES, "eYield expected to be < NUM_YIELD_TYPES");
iOldYield = getExtraSpecialistYield(eYield);
iNewYield = 0;
for(iI = 0; iI < GC.getNumSpecialistInfos(); iI++)
{
iNewYield += getExtraSpecialistYield(eYield, ((SpecialistTypes)iI));
}
if(iOldYield != iNewYield)
{
m_aiExtraSpecialistYield.setAt(eYield, iNewYield);
CvAssert(getExtraSpecialistYield(eYield) >= 0);
ChangeBaseYieldRateFromSpecialists(eYield, (iNewYield - iOldYield));
}
}
// --------------------------------------------------------------------------------
void CvCity::updateExtraSpecialistYield()
{
VALIDATE_OBJECT
int iI;
for(iI = 0; iI < NUM_YIELD_TYPES; iI++)
{
updateExtraSpecialistYield((YieldTypes)iI);
}
}
Is there anyone who can tell me the difference between them (and however the necessity of defining 2 variables)? Thanks a lot!