Hooks
static bool BeforeCvGame_updateScore(CvGame* self, bool bForce);static void AfterCvGame_updateScore(CvGame* self, bool bForce);static void ReplaceCvGame_updateScore(void (*original)(CvGame*, bool), CvGame* self, bool bForce);CivRegisterBefore<CivHooks::CvGame_updateScore>(host, &BeforeCvGame_updateScore);CivRegisterAfter<CivHooks::CvGame_updateScore>(host, &AfterCvGame_updateScore);CivRegisterReplace<CivHooks::CvGame_updateScore>(host, &ReplaceCvGame_updateScore);
Code
1688void CvGame::updateScore(bool bForce)1689{1690 if(!isScoreDirty() && !bForce)1691 return;16921693 setScoreDirty(false);16941695 bool abPlayerScored[MAX_CIV_PLAYERS];1696 bool abTeamScored[MAX_CIV_TEAMS];1697 int iScore;1698 int iBestScore;1699 PlayerTypes eBestPlayer;1700 TeamTypes eBestTeam;1701 int iI, iJ, iK;17021703 for(iI = 0; iI < MAX_CIV_PLAYERS; iI++)1704 {1705 abPlayerScored[iI] = false;1706 }17071708 for(iI = 0; iI < MAX_CIV_PLAYERS; iI++)1709 {1710 iBestScore = MIN_INT;1711 eBestPlayer = NO_PLAYER;17121713 for(iJ = 0; iJ < MAX_CIV_PLAYERS; iJ++)1714 {1715 if(!abPlayerScored[iJ])1716 {1717 iScore = GET_PLAYER((PlayerTypes)iJ).GetScore(false);17181719 if(iScore >= iBestScore)1720 {1721 iBestScore = iScore;1722 eBestPlayer = (PlayerTypes)iJ;1723 }1724 }1725 }17261727 abPlayerScored[eBestPlayer] = true;17281729 setRankPlayer(iI, eBestPlayer);1730 setPlayerRank(eBestPlayer, iI);1731 setPlayerScore(eBestPlayer, iBestScore);17321733 CvPlayerAI& player = GET_PLAYER(eBestPlayer);17341735 unsigned int uiDataSetIndex = player.getReplayDataSetIndex("REPLAYDATASET_SCORE");1736 player.setReplayDataValue(uiDataSetIndex, getGameTurn(), iBestScore);1737 }17381739 for(iI = 0; iI < MAX_CIV_TEAMS; iI++)1740 {1741 abTeamScored[iI] = false;1742 }17431744 for(iI = 0; iI < MAX_CIV_TEAMS; iI++)1745 {1746 iBestScore = MIN_INT;1747 eBestTeam = NO_TEAM;17481749 for(iJ = 0; iJ < MAX_CIV_TEAMS; iJ++)1750 {1751 if(!abTeamScored[iJ])1752 {1753 iScore = GET_TEAM((TeamTypes) iJ).GetScore();17541755 for(iK = 0; iK < MAX_CIV_PLAYERS; iK++)1756 {1757 if(GET_PLAYER((PlayerTypes)iK).getTeam() == iJ)1758 {1759 iScore += getPlayerScore((PlayerTypes)iK);1760 }1761 }17621763 if(iScore >= iBestScore)1764 {1765 iBestScore = iScore;1766 eBestTeam = (TeamTypes)iJ;1767 }1768 }1769 }17701771 abTeamScored[eBestTeam] = true;17721773 setRankTeam(iI, eBestTeam);1774 setTeamRank(eBestTeam, iI);1775 setTeamScore(eBestTeam, iBestScore);1776 }1777}