Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions C7/Text/c7-static-map-save-standalone.json
Original file line number Diff line number Diff line change
Expand Up @@ -71322,7 +71322,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "A Barbarian Chiefdom",
"cityNameIndex": 0,
"turnsUntilPriorityReevaluation": 0,
"luxuryRate": 0,
"scienceRate": 5,
Expand All @@ -71340,7 +71339,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "Netherlands",
"cityNameIndex": 0,
"tileKnowledge": [
{
"x": 57,
Expand Down Expand Up @@ -71417,7 +71415,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "America",
"cityNameIndex": 0,
"tileKnowledge": [
{
"x": 64,
Expand Down Expand Up @@ -71494,7 +71491,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "Aztecs",
"cityNameIndex": 0,
"tileKnowledge": [
{
"x": 59,
Expand Down Expand Up @@ -71567,7 +71563,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "Inca",
"cityNameIndex": 0,
"tileKnowledge": [
{
"x": 76,
Expand Down Expand Up @@ -71644,7 +71639,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "Persia",
"cityNameIndex": 0,
"tileKnowledge": [
{
"x": 30,
Expand Down Expand Up @@ -71725,7 +71719,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "Maya",
"cityNameIndex": 0,
"tileKnowledge": [
{
"x": 9,
Expand Down Expand Up @@ -71802,7 +71795,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "Iroquois",
"cityNameIndex": 0,
"tileKnowledge": [
{
"x": 46,
Expand Down
8 changes: 0 additions & 8 deletions C7/Text/c7-static-map-save.json
Original file line number Diff line number Diff line change
Expand Up @@ -73895,7 +73895,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "A Barbarian Chiefdom",
"cityNameIndex": 0,
"turnsUntilPriorityReevaluation": 0,
"luxuryRate": 0,
"scienceRate": 5,
Expand All @@ -73913,7 +73912,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "Netherlands",
"cityNameIndex": 0,
"tileKnowledge": [
{
"x": 57,
Expand Down Expand Up @@ -73990,7 +73988,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "America",
"cityNameIndex": 0,
"tileKnowledge": [
{
"x": 64,
Expand Down Expand Up @@ -74067,7 +74064,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "Aztecs",
"cityNameIndex": 0,
"tileKnowledge": [
{
"x": 59,
Expand Down Expand Up @@ -74140,7 +74136,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "Inca",
"cityNameIndex": 0,
"tileKnowledge": [
{
"x": 76,
Expand Down Expand Up @@ -74217,7 +74212,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "Persia",
"cityNameIndex": 0,
"tileKnowledge": [
{
"x": 30,
Expand Down Expand Up @@ -74298,7 +74292,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "Maya",
"cityNameIndex": 0,
"tileKnowledge": [
{
"x": 9,
Expand Down Expand Up @@ -74375,7 +74368,6 @@
"hasPlayedCurrentTurn": false,
"defeated": false,
"civilization": "Iroquois",
"cityNameIndex": 0,
"tileKnowledge": [
{
"x": 46,
Expand Down
5 changes: 1 addition & 4 deletions C7Engine/C7GameData/ImportCiv3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ private void ImportBicLeaders() {
save.Players.Add(MakeSavePlayerFromCiv(save.Civilizations[i],
isBarbarian: i == 0,
isHuman: false,
cityNameIndex: 0,
era: ""));

// Set a government for players not associated with LEAD.
Expand Down Expand Up @@ -465,7 +464,6 @@ private void ImportSavLeaders() {
SavePlayer player = MakeSavePlayerFromCiv(civ,
isBarbarian: i == 0,
isHuman: i == 1,
cityNameIndex: leader.FoundedCities,
era: theBiq.Eras[leader.Era].CivilopediaEntry);

// Record what the player is currently researching.
Expand Down Expand Up @@ -769,7 +767,7 @@ private void ImportSavLeaders() {
}
}

private SavePlayer MakeSavePlayerFromCiv(Civilization civ, bool isBarbarian, bool isHuman, int cityNameIndex, string era) {
private SavePlayer MakeSavePlayerFromCiv(Civilization civ, bool isBarbarian, bool isHuman, string era) {
return new SavePlayer {
id = ids.CreateID("player"),
colorIndex = civ.colorIndex,
Expand All @@ -779,7 +777,6 @@ private SavePlayer MakeSavePlayerFromCiv(Civilization civ, bool isBarbarian, boo
// Never let barbarians play before a real player.
hasPlayedCurrentTurn = isBarbarian,

cityNameIndex = cityNameIndex,
eraCivilopediaName = era,
};
}
Expand Down
34 changes: 22 additions & 12 deletions C7Engine/C7GameData/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class Player {
public bool defeated = false;

public Civilization civilization;
internal int cityNameIndex = 0;

public List<MapUnit> units = new List<MapUnit>();
public List<City> cities = new List<City>();
Expand Down Expand Up @@ -157,18 +156,29 @@ public void AddTechItemToResearchQueue(Tech tech) {
ResearchQueue.Enqueue(tech);
}

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"
private IEnumerable<string> CityNameGenerator() {
List<string> cityNames = civilization.cityNames;
int loopCounter = 0;

// Perpetual generator expression to yield all city names lazily
while (true) {
foreach (string city in cityNames) {
if (loopCounter == 0) yield return city;
else if (loopCounter == 1) yield return $"New {city}";
else {
if (loopCounter % 2 == 0) yield return $"{city} {(loopCounter / 2) + 1}";
else yield return $"New {city} {(loopCounter / 2) + 1}";
}
}
loopCounter++;
}
cityNameIndex++;
return name;
}

public string GetNextCityName() {
// Convert to hashset for faster lookups
HashSet<string> cityNameHashSet = cities.Select(city => city.name).ToHashSet();

return CityNameGenerator().First(x => !cityNameHashSet.Contains(x));
}

public Player() {
Expand Down
3 changes: 0 additions & 3 deletions C7Engine/C7GameData/Save/SavePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class SavePlayer {
public bool defeated = false;

public string civilization;
public int cityNameIndex = 0;

public List<TileLocation> tileKnowledge = new List<TileLocation>();

Expand Down Expand Up @@ -68,7 +67,6 @@ public Player ToPlayer(GameMap map, List<Civilization> civilizations, List<Gover
defeated = defeated,
colorIndex = colorIndex,
civilization = civilization is not null ? civilizations.Find(civ => civ.name == civilization) : null,
cityNameIndex = cityNameIndex,
knownTechs = knownTechs,
eraCivilopediaName = eraCivilopediaName,
luxuryRate = luxuryRate,
Expand Down Expand Up @@ -118,7 +116,6 @@ public SavePlayer(Player player) {
civilization = player.civilization?.name;
// TODO: this should be computed by looking at cities defined in the save
// so that adding cities in the save structure doesn't require updating this value
cityNameIndex = player.cityNameIndex;
tileKnowledge = player.tileKnowledge.AllKnownTiles().ConvertAll(tile => new TileLocation(tile));
turnsUntilPriorityReevaluation = player.turnsUntilPriorityReevaluation;
knownTechs = player.knownTechs;
Expand Down