CvCityCitizens::DoDemoteWorstForcedWorkingPlot()
- Defined in
- CvCityCitizens.cpp, line 1907
- Class
- CvCityCitizens
- Hook name
CivHooks::CvCityCitizens_DoDemoteWorstForcedWorkingPlot
Hooks
static bool BeforeCvCityCitizens_DoDemoteWorstForcedWorkingPlot(CvCityCitizens* self);static void AfterCvCityCitizens_DoDemoteWorstForcedWorkingPlot(CvCityCitizens* self);static void ReplaceCvCityCitizens_DoDemoteWorstForcedWorkingPlot(void (*original)(CvCityCitizens*), CvCityCitizens* self);CivRegisterBefore<CivHooks::CvCityCitizens_DoDemoteWorstForcedWorkingPlot>(host, &BeforeCvCityCitizens_DoDemoteWorstForcedWorkingPlot);CivRegisterAfter<CivHooks::CvCityCitizens_DoDemoteWorstForcedWorkingPlot>(host, &AfterCvCityCitizens_DoDemoteWorstForcedWorkingPlot);CivRegisterReplace<CivHooks::CvCityCitizens_DoDemoteWorstForcedWorkingPlot>(host, &ReplaceCvCityCitizens_DoDemoteWorstForcedWorkingPlot);
Code
1906/// Remove the Forced status from the worst ForcedWorking plot1907void CvCityCitizens::DoDemoteWorstForcedWorkingPlot()1908{1909 int iValue;19101911 int iBestPlotValue = -1;1912 int iBestPlotID = -1;19131914 CvPlot* pLoopPlot;19151916 // Look at all workable Plots1917#if defined(MOD_GLOBAL_CITY_WORKING)1918 for(int iPlotLoop = 0; iPlotLoop < GetCity()->GetNumWorkablePlots(); iPlotLoop++)1919#else1920 for(int iPlotLoop = 0; iPlotLoop < NUM_CITY_PLOTS; iPlotLoop++)1921#endif1922 {1923 if(iPlotLoop != CITY_HOME_PLOT)1924 {1925 pLoopPlot = GetCityPlotFromIndex(iPlotLoop);19261927 if(pLoopPlot != NULL)1928 {1929 if(IsForcedWorkingPlot(pLoopPlot))1930 {1931 iValue = GetPlotValue(pLoopPlot, false);19321933 // First, or worst yet?1934 if(iBestPlotValue == -1 || iValue < iBestPlotValue)1935 {1936 iBestPlotValue = iValue;1937 iBestPlotID = iPlotLoop;1938 }1939 }1940 }1941 }1942 }19431944 if(iBestPlotID > -1)1945 {1946 pLoopPlot = GetCityPlotFromIndex(iBestPlotID);1947 SetForcedWorkingPlot(pLoopPlot, false);1948 }1949}