Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong number for "Required population" in the city demands window #844

xmnovotny opened this issue Jun 10, 2021 · 1 comment


Copy link

Describe the bug
In the industrial type city, there is incorect display of required population for increase demands limit.

Steps to reproduce
Look to the numbers of industrial city while it grows, especially for larger cities.

Build version,


every time

In the code, there is wrong calcuation of required popuation, because it ignores City.ExtraDemand value.

Below is my quick fix using Harmony, which seems to work:

[HarmonyPatch(typeof(CityWindowDemandsTabHeader), "Invalidate")]
private static void CityWindowDemandsTabHeader_Invalidate_pof(CityWindowDemandsTabHeader __instance, City ____city, Text ____nextPopulationText)
    if (____city.Type == CityType.Industrial)
        int demandLimit = ____city.DemandLimit;
        int newPopulation = ____city.GetPopulation(demandLimit - ____city.ExtraDemandLimit + 1);
        if (newPopulation <= 0)
            newPopulation = Mathf.Max(newPopulation, ____city.Population);
        if (____city.Status != CityStatus.Megapolis)
            int newStatusPopulation = ____city.GetPopulation(____city.Status + 1);
            if (newStatusPopulation < newPopulation)
                int newPopulation2 = ____city.GetPopulation(demandLimit - ____city.ExtraDemandLimit);
                newPopulation = Mathf.Min(Mathf.Max(newPopulation2, newStatusPopulation));
        ____nextPopulationText.text = StringHelper.Nicify(newPopulation);
Copy link

The latest build on the beta branch should include the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants