Skip to content

Commit

Permalink
Fixed archive loading and a crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
Parker147 committed Jul 23, 2014
1 parent b1373f7 commit 3d2d0a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions LegendsViewer/Controls/Map/MapControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ public MapPanel(Bitmap map, World world, DwarfTabControl dwarfTabControl, Object
}
if (battle.Coordinates.Y < ZoomBounds.Y) ZoomBounds.Y = battle.Coordinates.Y;
if (battle.Coordinates.X < ZoomBounds.X) ZoomBounds.X = battle.Coordinates.X;
if (battle.Coordinates.Y > ZoomBounds.Height) ZoomBounds.Height = battle.Site.Coordinates.Y;
if (battle.Coordinates.X > ZoomBounds.Width) ZoomBounds.Width = battle.Site.Coordinates.X;
if (battle.Coordinates.Y > ZoomBounds.Height) ZoomBounds.Height = battle.Coordinates.Y;
if (battle.Coordinates.X > ZoomBounds.Width) ZoomBounds.Width = battle.Coordinates.X;
}
}

Expand Down
35 changes: 18 additions & 17 deletions LegendsViewer/FileLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,8 @@ public void AttemptLoadFrom(string file)
{
XMLText.Text = file;
XMLState = FileState.Ready;
LocateOtherFiles(file);
}

LocateOtherFiles(file);
Load();
}

Expand Down Expand Up @@ -353,20 +352,22 @@ private void extract_DoWork(object sender, DoWorkEventArgs e)
if (extractor.ArchiveFileNames.Count(file => file.EndsWith(".bmp") || file.EndsWith(".png") || file.EndsWith(".jpg") || file.EndsWith(".jpeg")) == 0)
throw new Exception("No map image found.");

string xml = extractor.ArchiveFileNames.Where(file => file.EndsWith(".xml")).Single();
if (File.Exists(xml)) throw new Exception(xml + " already exists.");
extractor.ExtractFiles(System.IO.Directory.GetCurrentDirectory(), xml);
ExtractedFiles.Add(xml);
string outputDirectory = new FileInfo(extractor.FileName).Directory.FullName;

string xml = extractor.ArchiveFileNames.Single(file => file.EndsWith(".xml"));
if (File.Exists(Path.Combine(outputDirectory, xml))) throw new Exception(xml + " already exists.");
extractor.ExtractFiles(outputDirectory, xml);
ExtractedFiles.Add(Path.Combine(outputDirectory, xml));

string history = extractor.ArchiveFileNames.Where(file => file.EndsWith("-world_history.txt")).Single();
if (File.Exists(history)) throw new Exception(history + " already exists.");
extractor.ExtractFiles(System.IO.Directory.GetCurrentDirectory(), history);
ExtractedFiles.Add(history);
string history = extractor.ArchiveFileNames.Single(file => file.EndsWith("-world_history.txt"));
if (File.Exists(Path.Combine(outputDirectory, history))) throw new Exception(history + " already exists.");
extractor.ExtractFiles(outputDirectory, history);
ExtractedFiles.Add(Path.Combine(outputDirectory, history));

string sites = extractor.ArchiveFileNames.Where(file => file.EndsWith("-world_sites_and_pops.txt")).Single();
if (File.Exists(sites)) throw new Exception(sites + " already exists.");
extractor.ExtractFiles(System.IO.Directory.GetCurrentDirectory(), sites);
ExtractedFiles.Add(sites);
string sites = extractor.ArchiveFileNames.Single(file => file.EndsWith("-world_sites_and_pops.txt"));
if (File.Exists(Path.Combine(outputDirectory, sites))) throw new Exception(sites + " already exists.");
extractor.ExtractFiles(outputDirectory, sites);
ExtractedFiles.Add(Path.Combine(outputDirectory, sites));

string map = "";

Expand All @@ -382,9 +383,9 @@ private void extract_DoWork(object sender, DoWorkEventArgs e)
map = fileSelect.SelectedFile;
}

if (File.Exists(map)) throw new Exception(map + " already exists.");
extractor.ExtractFiles(Directory.GetCurrentDirectory(), map);
ExtractedFiles.Add(map);
if (File.Exists(Path.Combine(outputDirectory, map))) throw new Exception(map + " already exists.");
extractor.ExtractFiles(outputDirectory, map);
ExtractedFiles.Add(Path.Combine(outputDirectory, map));
}
}
private void extract_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
Expand Down

0 comments on commit 3d2d0a1

Please sign in to comment.