Prototype icon indicating copy to clipboard operation
Prototype copied to clipboard

Next City Name Cycles When Build City Dialog Opened but City Not Built

Open pcen opened this issue 2 years ago • 2 comments

Repro:

  1. open build city dialog: default city name is cities[n]
  2. close build city dialog instead of building city
  3. open build city dialog: default city name is cities[n + 1]

The cause is that Player.GetNextCityName always increments cityNameIndex:

in C7GameData/Player.cs

public string GetNextCityName() {
    string name = civilization.cityNames[cityNameIndex % civilization.cityNames.Count];
    int bonusLoops = cityNameIndex / civilization.cityNames.Count;
    if (bonusLoops % 2 == 1) {
	name = "New " + name;
    }
    int suffix = (bonusLoops / 2) + 1;
    if (suffix > 1) {
	name = name + " " + suffix; //e.g. for bonusLoops = 2, we'll have "Athens 2"
    }
    cityNameIndex++;
    return name;
}

Instead, behaviour should increment cityNameIndex when a city is built. MsgCityBuilt is implement in #407 so once merged we can fix this behaviour easily

pcen avatar Sep 18 '23 00:09 pcen

Technically this is faithful to Civ3 but I agree on fixing it :)

WildWeazel avatar Sep 18 '23 03:09 WildWeazel

lol good to know, I guess this should be categorised as an enhancement 😆

pcen avatar Sep 18 '23 04:09 pcen