CvPlayer::GetCultureYieldFromPreviousTurns(int, int)
- Defined in
- CvPlayer.cpp, line 10785
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_GetCultureYieldFromPreviousTurns
Hooks
static bool BeforeCvPlayer_GetCultureYieldFromPreviousTurns(CvPlayer* self, int iGameTurn, int iNumPreviousTurnsToCount, int& result);static void AfterCvPlayer_GetCultureYieldFromPreviousTurns(CvPlayer* self, int iGameTurn, int iNumPreviousTurnsToCount, int& result);static int ReplaceCvPlayer_GetCultureYieldFromPreviousTurns(int (*original)(CvPlayer*, int, int), CvPlayer* self, int iGameTurn, int iNumPreviousTurnsToCount);CivRegisterBefore<CivHooks::CvPlayer_GetCultureYieldFromPreviousTurns>(host, &BeforeCvPlayer_GetCultureYieldFromPreviousTurns);CivRegisterAfter<CivHooks::CvPlayer_GetCultureYieldFromPreviousTurns>(host, &AfterCvPlayer_GetCultureYieldFromPreviousTurns);CivRegisterReplace<CivHooks::CvPlayer_GetCultureYieldFromPreviousTurns>(host, &ReplaceCvPlayer_GetCultureYieldFromPreviousTurns);
Code
10783/// What is the sum of culture yield from the previous N turns?10784/// NOTE: This uses the data tracked in recording a replay, so if replays are disabled in the future then this must change!10785int CvPlayer::GetCultureYieldFromPreviousTurns(int iGameTurn, int iNumPreviousTurnsToCount)10786{10787 // Culture per turn yield is tracked in replay data, so use that10788 int iSum = 0;10789 for (int iI = 0; iI < iNumPreviousTurnsToCount; iI++)10790 {10791 int iTurn = iGameTurn - iI;10792 if (iTurn < 0)10793 {10794 break;10795 }1079610797 int iTurnCulture = getReplayDataValue(getReplayDataSetIndex("REPLAYDATASET_CULTUREPERTURN"), iTurn);10798 if (iTurnCulture >= 0)10799 {10800 iSum += iTurnCulture;10801 }10802 else if (iTurnCulture == -1) // No data for this turn (ex. late era start)10803 {10804 iSum += (3 * GetTotalJONSCulturePerTurn());10805 }10806 }1080710808 return iSum;10809}