Fixed exception in client when settings.json managed to refer to a non-existent or corrupt .zip

This commit is contained in:
William Moorehouse 2015-06-17 09:17:26 -04:00
parent f15744b7a2
commit a7d394ef19
2 changed files with 8 additions and 8 deletions

View File

@ -84,21 +84,21 @@ namespace TrueCraft.Client.Rendering
public void AddTexturePack(TexturePack texturePack) public void AddTexturePack(TexturePack texturePack)
{ {
if (texturePack == null) if (texturePack == null)
throw new ArgumentException(); return;
var archive = new ZipFile(Path.Combine(TexturePack.TexturePackPath, texturePack.Name)); // Make sure to 'silence' errors loading custom texture packs;
foreach (var entry in archive.Entries) // they're unimportant as we can just use default textures.
try
{ {
// Make sure to 'silence' errors loading custom texture packs; var archive = new ZipFile(Path.Combine(TexturePack.TexturePackPath, texturePack.Name));
// they're unimportant as we can just use default textures. foreach (var entry in archive.Entries)
try
{ {
var key = entry.FileName; var key = entry.FileName;
using (var stream = entry.OpenReader()) using (var stream = entry.OpenReader())
AddTexture(key, Texture2D.FromStream(Device, stream)); AddTexture(key, Texture2D.FromStream(Device, stream));
} }
catch { }
} }
catch { return; }
} }
/// <summary> /// <summary>

View File

@ -43,7 +43,7 @@ namespace TrueCraft.Core
/// <param name="path"></param> /// <param name="path"></param>
public static TexturePack FromArchive(string path) public static TexturePack FromArchive(string path)
{ {
if (string.IsNullOrEmpty(path) || !File.Exists(path)) if (string.IsNullOrEmpty(path))
throw new ArgumentException(); throw new ArgumentException();
string description = Unknown.Description; string description = Unknown.Description;