Skip to content

Commit

Permalink
Don't try to disable the same tech twice (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekolis committed Jun 16, 2022
1 parent 66ce6a7 commit d942939
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions FrEee.WinForms/Forms/GameSetupForm.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FrEee.Game.Enumerations;
using FrEee.Game.Enumerations;
using FrEee.Game.Objects.Space;
using FrEee.Game.Objects.Technology;
using FrEee.Game.Objects.Vehicles;
Expand Down Expand Up @@ -709,7 +709,13 @@ private void SaveChanges()
for (int i = 0; i < lstTechs.Items.Count; i++)
{
if (!lstTechs.GetItemChecked(i))
setup.ForbiddenTechnologyNames.Add(((Technology)lstTechs.Items[i]).Name);
{
var techName = ((Technology)lstTechs.Items[i]).Name;
if (!setup.ForbiddenTechnologyNames.Contains(techName))
{
setup.ForbiddenTechnologyNames.Add(techName);
}
}
}
setup.StartingResources = (int)spnStartResources.Value;
setup.ResourceStorage = (int)spnResourceStorage.Value;
Expand Down Expand Up @@ -828,4 +834,4 @@ private void btnGenerateSeed_Click(object sender, EventArgs e)
spnSeed.Value = DateTime.Now.Millisecond + 1000 * DateTime.Now.Second + 60000 * DateTime.Now.Minute;
}
}
}
}
2 changes: 1 addition & 1 deletion FrEee/Game/Setup/GameSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public void PopulateGalaxy(Galaxy gal, PRNG dice)
gal.CleanGameState();

// remove forbidden techs
foreach (var tname in ForbiddenTechnologyNames)
foreach (var tname in ForbiddenTechnologyNames.Distinct())
Mod.Current.Technologies.Single(t => t.Name == tname).Dispose();

// set omniscient view and all systems seen flags
Expand Down

0 comments on commit d942939

Please sign in to comment.