From 76f3c0098a2d0e67675e8e5521776a2ee869d9f2 Mon Sep 17 00:00:00 2001 From: cadon Date: Mon, 18 Jul 2022 22:00:13 +0200 Subject: [PATCH] fix for species with no color information (fixes #1278) --- ARKBreedingStats/species/CreatureColored.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ARKBreedingStats/species/CreatureColored.cs b/ARKBreedingStats/species/CreatureColored.cs index 3bb3aec4..0866015b 100644 --- a/ARKBreedingStats/species/CreatureColored.cs +++ b/ARKBreedingStats/species/CreatureColored.cs @@ -35,7 +35,7 @@ internal static string SpeciesImageName(string speciesName, bool replacePolar = /// Returns the image file path to the image with the according colorization. /// private static string ColoredCreatureCacheFilePath(string speciesName, byte[] colorIds, bool listView = false) - => Path.Combine(_imgCacheFolderPath, speciesName.Substring(0, Math.Min(speciesName.Length, 5)) + "_" + Convert.ToBase64String(colorIds.Select(ci => (byte)ci).Concat(Encoding.UTF8.GetBytes(speciesName)).ToArray()).Replace('/', '-') + (listView ? "_lv" : string.Empty) + Extension); + => Path.Combine(_imgCacheFolderPath, speciesName.Substring(0, Math.Min(speciesName.Length, 5)) + "_" + Convert.ToBase64String(colorIds.Select(ci => ci).Concat(Encoding.UTF8.GetBytes(speciesName)).ToArray()).Replace('/', '-') + (listView ? "_lv" : string.Empty) + Extension); /// /// Checks if an according species image exists in the cache folder, if not it tries to creates one. Returns false if there's no image. @@ -79,7 +79,7 @@ public static Bitmap GetColoredCreature(byte[] colorIds, Species species, bool[] if (string.IsNullOrEmpty(species?.name)) onlyColors = true; else - speciesName = SpeciesImageName(species?.name); + speciesName = SpeciesImageName(species.name); if (onlyColors || string.IsNullOrEmpty(ImageFolder)) return DrawPieChart(colorIds, enabledColorRegions, size, pieSize); @@ -461,7 +461,7 @@ private static bool ApplyColorsUnsafe(byte[][] rgb, bool[] enabledColorRegions, public static string RegionColorInfo(Species species, byte[] colorIds) { - if (species == null || colorIds == null) return null; + if (species?.colors == null || colorIds == null) return null; var creatureRegionColors = new StringBuilder("Colors:"); var cs = species.colors;