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

ImportCiv3.cs: Add support for loading cities in scenarios #491

Merged
merged 1 commit into from
Jan 20, 2025
Merged
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
26 changes: 26 additions & 0 deletions C7GameData/ImportCiv3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ private SaveGame importBiq(string biqPath, string defaultBiqPath) {
ImportSharedBiqData();
ImportBicLeaders();
ImportBicUnits();
ImportBicCities();

Dictionary<int, Resource> resourcesByIndex = ImportCiv3Resources();
SetMapDimensions(biq, save);
Expand Down Expand Up @@ -439,6 +440,31 @@ private void ImportSavCities() {
}
}

private void ImportBicCities() {
BiqData theBiq = biq.Unit is null ? defaultBiq : biq;

foreach (CITY city in theBiq.City) {
if (city.Owner < 0 || city.Owner >= save.Players.Count) {
continue;
}
SavePlayer player = save.Players[city.Owner];
SaveCity saveCity = new SaveCity{
id = ids.CreateID("city"),
owner = player.id,
location = new TileLocation(city.X, city.Y),
// TODO: try and get this from the unit prototype
producible = "Worker",
name = city.Name,
size = city.Size,
shieldsStored = 0,
foodStored = 0,
foodNeededToGrow = 20, // HACK: don't know where to find this
// residents = city.Ppod // TODO: load tiles worked from PPOD
};
save.Cities.Add(saveCity);
}
}

private void ImportUnitPrototypes() {
PRTO[] Prto = biq.Prto ?? defaultBiq.Prto;
foreach (PRTO prto in Prto) {
Expand Down