Skip to content

Commit

Permalink
AvailableModule: Documentation and spacing fixes only.
Browse files Browse the repository at this point in the history
  • Loading branch information
pjf committed Oct 20, 2015
1 parent 6ca197c commit a71194a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Core/Registry/AvailableModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,32 +77,39 @@ public CkanModule Latest(KSPVersion ksp_version = null, RelationshipDescriptor r
CkanModule module;
log.DebugFormat("Our dictionary has {0} keys", module_version.Keys.Count);
log.DebugFormat("Choosing between {0} available versions", available_versions.Count);

// Uh oh, nothing available. Maybe this existed once, but not any longer.
if (available_versions.Count == 0)
{
return null;
}

// No restrictions? Great, we can just pick the first one!
if (ksp_version == null && relationship == null)
{
module = module_version[available_versions.First()];

log.DebugFormat("No KSP version restriction, {0} is most recent", module);
return module;
}

// If there's no relationship to satisfy, we can just pick the first that is
// compatible with our version of KSP.
if (relationship == null)
{
// Time to check if there's anything that we can satisfy.
// Time to check if there's anything that we can satisfy.
var version =
available_versions.FirstOrDefault(v => module_version[v].IsCompatibleKSP(ksp_version));
if (version != null)
return module_version[version];

log.DebugFormat("No version of {0} is compatible with KSP {1}",
module_version[available_versions[0]].identifier, ksp_version);
log.DebugFormat("No version of {0} is compatible with KSP {1}",
module_version[available_versions[0]].identifier, ksp_version);

return null;
}
return null;
}

// If we're here, then we have a relationship to satisfy, so things get more complex.
if (ksp_version == null)
{
var version = available_versions.FirstOrDefault(relationship.version_within_bounds);
Expand Down

0 comments on commit a71194a

Please sign in to comment.