C7-Game / Prototype

An early-stage, open-source 4X strategy game
https://c7-game.github.io/
MIT License
32 stars 9 forks source link

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

Open pcen opened 10 months ago

pcen commented 10 months ago

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

WildWeazel commented 10 months ago

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

pcen commented 10 months ago

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