summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Controllers
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-10-17 19:53:40 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-10-17 19:53:40 -0400
commitd578345cfd53df8a91ae8e0e1346b711332a999a (patch)
treefa9a2e6c855a532dbd99910c7cdac1dc468010da /src/SMAPI.Web/Controllers
parentebe41180c41f544919c03fb3bf6029437a7d65a4 (diff)
parentf8c9a2929bb42ef7f71fa3a2d258c5566960aa69 (diff)
downloadSMAPI-d578345cfd53df8a91ae8e0e1346b711332a999a.tar.gz
SMAPI-d578345cfd53df8a91ae8e0e1346b711332a999a.tar.bz2
SMAPI-d578345cfd53df8a91ae8e0e1346b711332a999a.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.Web/Controllers')
-rw-r--r--src/SMAPI.Web/Controllers/ModsApiController.cs30
1 files changed, 9 insertions, 21 deletions
diff --git a/src/SMAPI.Web/Controllers/ModsApiController.cs b/src/SMAPI.Web/Controllers/ModsApiController.cs
index c6e9a713..dcddaf10 100644
--- a/src/SMAPI.Web/Controllers/ModsApiController.cs
+++ b/src/SMAPI.Web/Controllers/ModsApiController.cs
@@ -144,7 +144,7 @@ namespace StardewModdingAPI.Web.Controllers
}
// fetch data
- ModInfoModel data = await this.GetInfoForUpdateKeyAsync(updateKey, allowNonStandardVersions, wikiEntry?.MapRemoteVersions);
+ ModInfoModel data = await this.GetInfoForUpdateKeyAsync(updateKey, allowNonStandardVersions, wikiEntry?.Overrides?.ChangeRemoteVersions);
if (data.Status != RemoteModStatus.Ok)
{
errors.Add(data.Error ?? data.Status.ToString());
@@ -195,7 +195,7 @@ namespace StardewModdingAPI.Web.Controllers
}
// get recommended update (if any)
- ISemanticVersion installedVersion = this.ModSites.GetMappedVersion(search.InstalledVersion?.ToString(), wikiEntry?.MapLocalVersions, allowNonStandard: allowNonStandardVersions);
+ ISemanticVersion installedVersion = this.ModSites.GetMappedVersion(search.InstalledVersion?.ToString(), wikiEntry?.Overrides?.ChangeLocalVersions, allowNonStandard: allowNonStandardVersions);
if (apiVersion != null && installedVersion != null)
{
// get newer versions
@@ -255,8 +255,8 @@ namespace StardewModdingAPI.Web.Controllers
/// <summary>Get the mod info for an update key.</summary>
/// <param name="updateKey">The namespaced update key.</param>
/// <param name="allowNonStandardVersions">Whether to allow non-standard versions.</param>
- /// <param name="mapRemoteVersions">Maps remote versions to a semantic version for update checks.</param>
- private async Task<ModInfoModel> GetInfoForUpdateKeyAsync(UpdateKey updateKey, bool allowNonStandardVersions, IDictionary<string, string> mapRemoteVersions)
+ /// <param name="mapRemoteVersions">The changes to apply to remote versions for update checks.</param>
+ private async Task<ModInfoModel> GetInfoForUpdateKeyAsync(UpdateKey updateKey, bool allowNonStandardVersions, ChangeDescriptor mapRemoteVersions)
{
// get mod page
IModPage page;
@@ -290,15 +290,12 @@ namespace StardewModdingAPI.Web.Controllers
.Distinct()
.ToList();
- // apply remove overrides from wiki
+ // apply overrides from wiki
+ if (entry?.Overrides?.ChangeUpdateKeys?.HasChanges == true)
{
- var removeKeys = new HashSet<UpdateKey>(
- from key in entry?.ChangeUpdateKeys ?? new string[0]
- where key.StartsWith('-')
- select UpdateKey.Parse(key.Substring(1))
- );
- if (removeKeys.Any())
- updateKeys.RemoveAll(removeKeys.Contains);
+ List<string> newKeys = updateKeys.Select(p => p.ToString()).ToList();
+ entry.Overrides.ChangeUpdateKeys.Apply(newKeys);
+ updateKeys = newKeys.Select(UpdateKey.Parse).ToList();
}
// if the list has both an update key (like "Nexus:2400") and subkey (like "Nexus:2400@subkey") for the same page, the subkey takes priority
@@ -348,15 +345,6 @@ namespace StardewModdingAPI.Web.Controllers
if (entry.ChucklefishID.HasValue)
yield return UpdateKey.GetString(ModSiteKey.Chucklefish, entry.ChucklefishID.ToString());
}
-
- // overrides from wiki
- foreach (string key in entry?.ChangeUpdateKeys ?? Array.Empty<string>())
- {
- if (key.StartsWith('+'))
- yield return key.Substring(1);
- else if (!key.StartsWith("-"))
- yield return key;
- }
}
}
}