Hooks
static bool BeforeCvMinorCivQuest_GetContestValueForPlayer(CvMinorCivQuest* self, PlayerTypes ePlayer, int& result);static void AfterCvMinorCivQuest_GetContestValueForPlayer(CvMinorCivQuest* self, PlayerTypes ePlayer, int& result);static int ReplaceCvMinorCivQuest_GetContestValueForPlayer(int (*original)(CvMinorCivQuest*, PlayerTypes), CvMinorCivQuest* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvMinorCivQuest_GetContestValueForPlayer>(host, &BeforeCvMinorCivQuest_GetContestValueForPlayer);CivRegisterAfter<CivHooks::CvMinorCivQuest_GetContestValueForPlayer>(host, &AfterCvMinorCivQuest_GetContestValueForPlayer);CivRegisterReplace<CivHooks::CvMinorCivQuest_GetContestValueForPlayer>(host, &ReplaceCvMinorCivQuest_GetContestValueForPlayer);
Code
296// Assumes that only one contest of a particular Type is active from this minor at any given time.297// Otherwise, the results across different spans of contest will be calculated together here.298int CvMinorCivQuest::GetContestValueForPlayer(PlayerTypes ePlayer)299{300 MinorCivQuestTypes eType = GetType();301 int iValue = -1;302 CvPlayer* pMinor = &GET_PLAYER(GetMinor());303 if(!pMinor)304 {305 CvAssertMsg(false, "Error when calculating contest standings - could not find minor civ! Please send Anton your save file and version.");306 return iValue;307 }308309 // Player must actually be in the contest to have a score!310 if(!pMinor->GetMinorCivAI()->IsActiveQuestForPlayer(ePlayer, eType))311 return iValue;312313#if defined(MOD_EVENTS_QUESTS)314 if (UseEvents() && !IsInternal()) {315 if (m_pQuestInfo->isContest()) {316 int iAcc = 0;317 if (GAMEEVENTINVOKE_VALUE(iAcc, GAMEEVENT_QuestContestValue, ePlayer, m_eMinor, m_eType) == GAMEEVENTRETURN_VALUE) {318 iValue = iAcc;319 }320 }321 } else {322#endif323 if(eType == MINOR_CIV_QUEST_CONTEST_CULTURE)324 {325 int iStartCulture = pMinor->GetMinorCivAI()->GetQuestData1(ePlayer, eType);326 int iEndCulture = GET_PLAYER(ePlayer).GetJONSCultureEverGenerated();327 iValue = iEndCulture - iStartCulture;328 }329 else if(eType == MINOR_CIV_QUEST_CONTEST_FAITH)330 {331 int iStartFaith = pMinor->GetMinorCivAI()->GetQuestData1(ePlayer, eType);332 int iEndFaith = GET_PLAYER(ePlayer).GetFaithEverGenerated();333 iValue = iEndFaith - iStartFaith;334 }335 else if(eType == MINOR_CIV_QUEST_CONTEST_TECHS)336 {337 int iStartTechs = pMinor->GetMinorCivAI()->GetQuestData1(ePlayer, eType);338 int iEndTechs = GET_TEAM(GET_PLAYER(ePlayer).getTeam()).GetTeamTechs()->GetNumTechsKnown();339 iValue = iEndTechs - iStartTechs;340 }341#if defined(MOD_EVENTS_QUESTS)342 }343#endif344345 return iValue;346}