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

Fix extinct species not having preview in auto-evo exporer #5701

Merged
merged 8 commits into from
Nov 26, 2024
18 changes: 16 additions & 2 deletions src/auto-evo/AutoEvoExploringTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,15 @@ public void AskExit()
}

public Species? GetActiveSpeciesData(uint speciesId)
{
return GetActiveSpeciesDataFromGeneration(generationDisplayed, speciesId);
}

public Species? GetActiveSpeciesDataFromGeneration(int generation, uint speciesId)
{
var gameWorld = world.GameProperties.GameWorld;

for (int i = generationDisplayed; i >= 0; --i)
for (int i = generation; i >= 0; --i)
{
gameWorld.GenerationHistory[i].AllSpeciesData
.TryGetValue(speciesId, out var speciesRecord);
Expand Down Expand Up @@ -891,7 +896,16 @@ private void UpdateSpeciesPreview(Species species)
private void EvolutionaryTreeNodeSelected(int generation, uint id)
{
HistoryListMenuIndexChanged(generation);
UpdateSpeciesPreview(world.SpeciesHistoryList[generation][id]);

var species = GetActiveSpeciesDataFromGeneration(generation, id);

if (species == null)
{
GD.PrintErr("Couldn't find active species data to show");
dligr marked this conversation as resolved.
Show resolved Hide resolved
return;
}

UpdateSpeciesPreview(species);
}

private void PatchListMenuIndexChanged(int index)
Expand Down