Merge pull request #12484 from pchote/installer-fixes

Fix asset installation on 32 bit windows and with original RA CDs.
This commit is contained in:
reaperrr
2016-12-28 16:53:15 +01:00
committed by GitHub
8 changed files with 53 additions and 16 deletions

View File

@@ -481,11 +481,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (Platform.CurrentPlatform != PlatformType.Windows)
return null;
var path = Microsoft.Win32.Registry.GetValue(source.RegistryKey, source.RegistryValue, null) as string;
if (path == null)
return null;
foreach (var prefix in source.RegistryPrefixes)
{
var path = Microsoft.Win32.Registry.GetValue(prefix + source.RegistryKey, source.RegistryValue, null) as string;
if (path == null)
continue;
return IsValidSourcePath(path, source) ? path : null;
return IsValidSourcePath(path, source) ? path : null;
}
return null;
}
if (source.Type == ModContent.SourceType.Disc)
@@ -500,15 +505,34 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
try
{
foreach (var kv in source.IDFiles)
foreach (var kv in source.IDFiles.Nodes)
{
var filePath = Path.Combine(path, kv.Key);
if (!File.Exists(filePath))
return false;
using (var fileStream = File.OpenRead(filePath))
if (CryptoUtil.SHA1Hash(fileStream) != kv.Value)
return false;
{
var offsetNode = kv.Value.Nodes.FirstOrDefault(n => n.Key == "Offset");
var lengthNode = kv.Value.Nodes.FirstOrDefault(n => n.Key == "Length");
if (offsetNode != null || lengthNode != null)
{
var offset = 0L;
if (offsetNode != null)
offset = FieldLoader.GetValue<long>("Offset", offsetNode.Value.Value);
var length = fileStream.Length - offset;
if (lengthNode != null)
length = FieldLoader.GetValue<long>("Length", lengthNode.Value.Value);
fileStream.Position = offset;
var data = fileStream.ReadBytes((int)length);
if (CryptoUtil.SHA1Hash(data) != kv.Value.Value)
return false;
}
else if (CryptoUtil.SHA1Hash(fileStream) != kv.Value.Value)
return false;
}
}
}
catch (Exception)