Code
1713void CvCity::doTurn()1714{1715 AI_PERF_FORMAT("City-AI-perf.csv", ("CvCity::doTurn, Turn %03d, %s, %s,", GC.getGame().getElapsedGameTurns(), GetPlayer()->getCivilizationShortDescription(), getName().c_str()) );17161717 VALIDATE_OBJECT1718 CvPlot* pLoopPlot;1719 int iI;17201721 if(getDamage() > 0)1722 {1723 CvAssertMsg(m_iDamage <= GetMaxHitPoints(), "Somehow a city has more damage than hit points. Please show this to a gameplay programmer immediately.");17241725 int iHitsHealed = GC.getCITY_HIT_POINTS_HEALED_PER_TURN();1726 if(isCapital() && !GET_PLAYER(getOwner()).isMinorCiv())1727 {1728 iHitsHealed++;1729 }1730 int iBuildingDefense = m_pCityBuildings->GetBuildingDefense();1731 iBuildingDefense *= (100 + m_pCityBuildings->GetBuildingDefenseMod());1732 iBuildingDefense /= 100;1733 iHitsHealed += iBuildingDefense / 500;1734 changeDamage(-iHitsHealed);1735 }1736 if(getDamage() < 0)1737 {1738 setDamage(0);1739 }17401741 setDrafted(false);1742 setMadeAttack(false);1743 GetCityBuildings()->SetSoldBuildingThisTurn(false);17441745 DoUpdateFeatureSurrounded();17461747 GetCityStrategyAI()->DoTurn();17481749 GetCityCitizens()->DoTurn();17501751 AI_doTurn();17521753 bool bRazed = DoRazingTurn();17541755 if(!bRazed)1756 {1757 DoResistanceTurn();17581759 bool bAllowNoProduction = !doCheckProduction();17601761 doGrowth();17621763 DoUpdateIndustrialRouteToCapital();17641765 doProduction(bAllowNoProduction);17661767 doDecay();17681769 doMeltdown();17701771 {1772 AI_PERF_FORMAT_NESTED("City-AI-perf.csv", ("doImprovement, Turn %03d, %s, %s", GC.getGame().getElapsedGameTurns(), GetPlayer()->getCivilizationShortDescription(), getName().c_str()) );1773#if defined(MOD_GLOBAL_CITY_WORKING)1774 for(iI = 0; iI < GetNumWorkablePlots(); iI++)1775#else1776 for(iI = 0; iI < NUM_CITY_PLOTS; iI++)1777#endif1778 {1779 pLoopPlot = GetCityCitizens()->GetCityPlotFromIndex(iI);17801781 if(pLoopPlot != NULL)1782 {1783 if(pLoopPlot->getWorkingCity() == this)1784 {1785 if(pLoopPlot->isBeingWorked())1786 {1787 pLoopPlot->doImprovement();1788 }1789 }1790 }1791 }1792 }17931794 // Following function also looks at WLTKD stuff1795 DoTestResourceDemanded();17961797 // Culture accumulation1798 if(getJONSCulturePerTurn() > 0)1799 {1800 ChangeJONSCultureStored(getJONSCulturePerTurn());1801 }18021803 // Enough Culture to acquire a new Plot?1804 if(GetJONSCultureStored() >= GetJONSCultureThreshold())1805 {1806 DoJONSCultureLevelIncrease();1807 }18081809 // Resource Demanded Counter1810 if(GetResourceDemandedCountdown() > 0)1811 {1812 ChangeResourceDemandedCountdown(-1);18131814 if(GetResourceDemandedCountdown() == 0)1815 {1816 // Pick a Resource to demand1817 DoPickResourceDemanded();1818 }1819 }18201821 updateStrengthValue();18221823 DoNearbyEnemy();18241825#if !defined(NO_ACHIEVEMENTS)1826 //Check for Achievements1827 if(isHuman() && !GC.getGame().isGameMultiPlayer() && GET_PLAYER(GC.getGame().getActivePlayer()).isLocalPlayer())1828 {1829 if(getJONSCulturePerTurn()>=100)1830 {1831 gDLL->UnlockAchievement(ACHIEVEMENT_CITY_100CULTURE);1832 }1833 if(getYieldRate(YIELD_GOLD, false)>=100)1834 {1835 gDLL->UnlockAchievement(ACHIEVEMENT_CITY_100GOLD);1836 }1837 if(getYieldRate(YIELD_SCIENCE, false)>=100)1838 {1839 gDLL->UnlockAchievement(ACHIEVEMENT_CITY_100SCIENCE);1840 }1841 }1842#endif18431844 // sending notifications on when routes are connected to the capital1845 if(!isCapital())1846 {1847 CvNotifications* pNotifications = GET_PLAYER(m_eOwner).GetNotifications();1848 if(pNotifications)1849 {1850 CvCity* pPlayerCapital = GET_PLAYER(m_eOwner).getCapitalCity();1851 CvAssertMsg(pPlayerCapital, "No capital city?");18521853 if(m_bRouteToCapitalConnectedLastTurn != m_bRouteToCapitalConnectedThisTurn && pPlayerCapital)1854 {1855 Localization::String strMessage;1856 Localization::String strSummary;18571858 if(m_bRouteToCapitalConnectedThisTurn) // connected this turn1859 {1860 strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_TRADE_ROUTE_ESTABLISHED");1861 strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_TRADE_ROUTE_ESTABLISHED");1862 strMessage << getNameKey();1863 strMessage << pPlayerCapital->getNameKey();1864 pNotifications->Add(NOTIFICATION_TRADE_ROUTE, strMessage.toUTF8(), strSummary.toUTF8(), -1, -1, -1);1865 }1866 else // lost connection this turn1867 {1868 strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_TRADE_ROUTE_BROKEN");1869 strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_TRADE_ROUTE_BROKEN");1870 strMessage << getNameKey();1871 strMessage << pPlayerCapital->getNameKey();1872 pNotifications->Add(NOTIFICATION_TRADE_ROUTE_BROKEN, strMessage.toUTF8(), strSummary.toUTF8(), -1, -1, -1);1873 }1874 }1875 }18761877 m_bRouteToCapitalConnectedLastTurn = m_bRouteToCapitalConnectedThisTurn;1878 }18791880 // XXX1881#ifdef _DEBUG1882 {1883 CvPlot* pPlot;1884 int iCount;18851886 for(iI = 0; iI < NUM_YIELD_TYPES; iI++)1887 {1888 CvAssert(getBaseYieldRate((YieldTypes)iI) >= 0);1889 CvAssert(getYieldRate((YieldTypes)iI, false) >= 0);18901891 iCount = 0;18921893#if defined(MOD_GLOBAL_CITY_WORKING)1894 for(int iJ = 0; iJ < GetNumWorkablePlots(); iJ++)1895#else1896 for(int iJ = 0; iJ < NUM_CITY_PLOTS; iJ++)1897#endif1898 {1899 pPlot = GetCityCitizens()->GetCityPlotFromIndex(iJ);19001901 if(pPlot != NULL)1902 {1903 if(GetCityCitizens()->IsWorkingPlot(pPlot))1904 {1905 iCount += pPlot->getYield((YieldTypes)iI);1906 }1907 }1908 }19091910 for(int iJ = 0; iJ < GC.getNumSpecialistInfos(); iJ++)1911 {1912 iCount += (GET_PLAYER(getOwner()).specialistYield(((SpecialistTypes)iJ), ((YieldTypes)iI)) * (GetCityCitizens()->GetSpecialistCount((SpecialistTypes)iJ)));1913 }19141915 for(int iJ = 0; iJ < GC.getNumBuildingInfos(); iJ++)1916 {1917 const BuildingTypes eBuilding = static_cast<BuildingTypes>(iJ);1918 CvBuildingEntry* pkBuildingInfo = GC.getBuildingInfo(eBuilding);1919 if(pkBuildingInfo)1920 {1921 iCount += m_pCityBuildings->GetNumActiveBuilding(eBuilding) * (pkBuildingInfo->GetYieldChange(iI) + m_pCityBuildings->GetBuildingYieldChange((BuildingClassTypes)pkBuildingInfo->GetBuildingClassType(), (YieldTypes)iI));1922 }1923 }19241925 // Science from Population1926 if((YieldTypes) iI == YIELD_SCIENCE)1927 {1928 iCount += getPopulation() * GC.getSCIENCE_PER_POPULATION();1929 }19301931 CvAssert(iCount == getBaseYieldRate((YieldTypes)iI));1932 }1933 }1934#endif1935 // XXX1936 }1937}