Skip to content

Commit

Permalink
Merge #2558 Avoid null ksp_version in Netkan
Browse files Browse the repository at this point in the history
  • Loading branch information
politas committed Oct 31, 2018
2 parents 5b54850 + 1ffdab2 commit 609d7d6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ All notable changes to this project will be documented in this file.
- [GUI] Fix crash at startup on Windows risen in #2536 (#2557 by: HebaruSan; reviewed: Olympic1)
- [Core] Allow game version of "any" with a vref (#2553 by: HebaruSan; reviewed: Olympic1)
- [Core] Fix null ref exception when repo has empty ckan file (#2549 by: HebaruSan; reviewed: Olympic1)
- [Multiple] Avoid null ksp_version in Netkan (#2558 by: HebaruSan; reviewed: politas)

## v1.25.3 (Woomera)

Expand Down
13 changes: 13 additions & 0 deletions Core/Versioning/KspVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ public bool IsAny
get { return !IsMajorDefined && !IsMinorDefined && !IsPatchDefined && !IsBuildDefined; }
}

/// <summary>
/// Check whether a version is null or Any.
/// We group them here because they mean the same thing.
/// </summary>
/// <param name="v">The version to check</param>
/// <returns>
/// True if null or Any, false otherwise
/// </returns>
public static bool IsNullOrAny(KspVersion v)
{
return v == null || v.IsAny;
}

/// <summary>
/// Initialize a new instance of the <see cref="KspVersion"/> class with all components unspecified.
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions Netkan/Transformers/AvcTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,16 @@ public static void ApplyVersions(JObject json, AvcVersion avc)
var kspMins = new List<KspVersion>();
var kspMaxes = new List<KspVersion>();

if (existingKspMin != null)
if (!KspVersion.IsNullOrAny(existingKspMin))
kspMins.Add(existingKspMin);

if (avcKspMin != null)
if (!KspVersion.IsNullOrAny(avcKspMin))
kspMins.Add(avcKspMin);

if (existingKspMax != null)
if (!KspVersion.IsNullOrAny(existingKspMax))
kspMaxes.Add(existingKspMax);

if (avcKspMax != null)
if (!KspVersion.IsNullOrAny(avcKspMax))
kspMaxes.Add(avcKspMax);

var kspMin = kspMins.Any() ? kspMins.Min() : null;
Expand Down

0 comments on commit 609d7d6

Please sign in to comment.