Code cleanup.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Cryville.Common.Network;
|
||||
using Cryville.Common.Unity;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -31,10 +32,10 @@ namespace Cryville.Crtr.Network {
|
||||
Dialog.Show(null, "Failed to check for update.");
|
||||
return;
|
||||
}
|
||||
var availableVersions = (from v in _versions where v.platforms.ContainsKey(PlatformConfig.Name) select v).ToArray();
|
||||
var availableVersions = _versions.Where(v => v.platforms.ContainsKey(PlatformConfig.Name)).ToArray();
|
||||
var versionIndex = new Dictionary<string, int>(availableVersions.Length);
|
||||
for (int i = 0; i < availableVersions.Length; i++) versionIndex.Add(availableVersions[i].name, i);
|
||||
var currentVersion = (from v in availableVersions where v.name == _currentVersion select v).SingleOrDefault();
|
||||
var currentVersion = availableVersions.Where(v => v.name == _currentVersion).SingleOrDefault();
|
||||
var latestVersion = availableVersions.Last();
|
||||
if (currentVersion == null) {
|
||||
Dialog.Show(null, string.Format("You are playing an unknown version of Cosmo Resona: {0}\nThe latest version is: {1}", _currentVersion, latestVersion.name));
|
||||
@@ -69,7 +70,17 @@ namespace Cryville.Crtr.Network {
|
||||
}
|
||||
}
|
||||
if (matchedUpstream != null) {
|
||||
if (matchedUpstream.external) {
|
||||
totalDiffSize = 0;
|
||||
Dialog.ShowAndWait("An error occurred while checking for update.\nPlease report this to the developers.");
|
||||
Logger.Log("main", 4, "Network", "Diff package is external, which is not expected");
|
||||
break;
|
||||
}
|
||||
totalDiffSize += matchedUpstream.size;
|
||||
if (totalDiffSize >= fullPackage.size) {
|
||||
totalDiffSize = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
totalDiffSize = 0;
|
||||
@@ -86,6 +97,7 @@ namespace Cryville.Crtr.Network {
|
||||
Dialog.ShowAndWait(string.Format("A new version is available: {0}\nDo you want to update?", latestVersion.name), "Yes", "No");
|
||||
}
|
||||
}
|
||||
Logger.Log("main", 0, "Network", "Update checker exited");
|
||||
}
|
||||
class VersionInfo {
|
||||
[JsonRequired]
|
||||
|
Reference in New Issue
Block a user