less ../../../
git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1355 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -17,9 +17,12 @@ namespace OpenRa.FileFormats
|
||||
|
||||
public static Stream Open(string filename)
|
||||
{
|
||||
foreach (IFolder folder in mountedFolders)
|
||||
try { return folder.GetContent(filename); }
|
||||
catch { }
|
||||
foreach( IFolder folder in mountedFolders )
|
||||
{
|
||||
Stream s = folder.GetContent(filename);
|
||||
if( s != null )
|
||||
return s;
|
||||
}
|
||||
|
||||
throw new FileNotFoundException("File not found", filename);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace OpenRa.FileFormats
|
||||
public Stream GetContent(string filename)
|
||||
{
|
||||
try { return File.OpenRead(path + filename); }
|
||||
catch { throw new FileNotFoundException("File not found", filename); }
|
||||
catch { return null; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRa.FileFormats
|
||||
public Package(string filename)
|
||||
{
|
||||
this.filename = filename;
|
||||
using (Stream s = File.OpenRead(filename))
|
||||
using (Stream s = FileSystem.Open(filename))
|
||||
{
|
||||
BinaryReader reader = new BinaryReader(s);
|
||||
uint signature = reader.ReadUInt32();
|
||||
@@ -124,7 +124,7 @@ namespace OpenRa.FileFormats
|
||||
foreach( PackageEntry e in index )
|
||||
if (e.Hash == hash)
|
||||
{
|
||||
using (Stream s = File.OpenRead(filename))
|
||||
using (Stream s = FileSystem.Open(filename))
|
||||
{
|
||||
s.Seek( dataStart + e.Offset, SeekOrigin.Begin );
|
||||
byte[] data = new byte[ e.Length ];
|
||||
@@ -133,20 +133,13 @@ namespace OpenRa.FileFormats
|
||||
}
|
||||
}
|
||||
|
||||
throw new FileNotFoundException();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Stream GetContent(string filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetContent(PackageEntry.HashFilename(filename));
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
throw new FileNotFoundException("File not found", filename, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRa.FileFormats
|
||||
Walkability walkability = new Walkability();
|
||||
|
||||
char tileSetChar = char.ToUpperInvariant( suffix[ 1 ] );
|
||||
StreamReader tileIdFile = File.OpenText( "../../../tileSet.til" );
|
||||
StreamReader tileIdFile = new StreamReader( FileSystem.Open( "tileSet.til" ) );
|
||||
|
||||
while( true )
|
||||
{
|
||||
|
||||
@@ -8,14 +8,12 @@ namespace OpenRa.FileFormats
|
||||
{
|
||||
public class Walkability
|
||||
{
|
||||
const string src = "../../../templates.ini";
|
||||
|
||||
Dictionary<string, Dictionary<int, int>> walkability =
|
||||
new Dictionary<string, Dictionary<int, int>>();
|
||||
|
||||
public Walkability()
|
||||
{
|
||||
IniFile file = new IniFile(File.OpenRead(src));
|
||||
IniFile file = new IniFile( FileSystem.Open( "templates.ini" ) );
|
||||
Regex pattern = new Regex(@"tiletype(\d+)");
|
||||
|
||||
foreach (IniSection section in file.Sections)
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenRa.Game
|
||||
players.Add( i, new Player( i, string.Format( "Multi{0}", i ), OpenRa.TechTree.Race.Soviet ) );
|
||||
|
||||
map = new Map(new IniFile(FileSystem.Open(mapName)));
|
||||
FileSystem.Mount(new Package("../../../" + map.Theater + ".mix"));
|
||||
FileSystem.Mount(new Package(map.Theater + ".mix"));
|
||||
|
||||
viewport = new Viewport(clientSize, map.Size, renderer);
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace OpenRa.Game
|
||||
public MainWindow(Settings settings)
|
||||
{
|
||||
FileSystem.Mount(new Folder("../../../"));
|
||||
FileSystem.Mount(new Package("../../../conquer.mix"));
|
||||
FileSystem.Mount(new Package("../../../hires.mix"));
|
||||
FileSystem.Mount(new Package("conquer.mix"));
|
||||
FileSystem.Mount(new Package("hires.mix"));
|
||||
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
BackColor = Color.Black;
|
||||
|
||||
@@ -22,7 +22,6 @@ namespace OpenRa.Game
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
File.WriteAllText( "error.log", e.ToString() );
|
||||
Log.Write( "{0}", e.ToString() );
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRa.TechTree
|
||||
IEnumerable<Tuple<string, string, bool>> Lines(string filename, bool param)
|
||||
{
|
||||
Regex pattern = new Regex(@"^(\w+),([\w ]+)$");
|
||||
foreach (string s in File.ReadAllLines(filename))
|
||||
foreach (string s in File.ReadAllLines("../../../" + filename))
|
||||
{
|
||||
Match m = pattern.Match(s);
|
||||
if (m == null || !m.Success)
|
||||
@@ -54,10 +54,10 @@ namespace OpenRa.TechTree
|
||||
|
||||
void LoadRules()
|
||||
{
|
||||
IniFile rulesFile = new IniFile(File.OpenRead("../../../rules.ini"));
|
||||
IniFile rulesFile = new IniFile(FileSystem.Open("rules.ini"));
|
||||
IEnumerable<Tuple<string, string, bool>> definitions = Concat(
|
||||
Lines("../../../buildings.txt", true),
|
||||
Lines("../../../units.txt", false));
|
||||
Lines("buildings.txt", true),
|
||||
Lines("units.txt", false));
|
||||
|
||||
foreach (Tuple<string, string, bool> p in definitions)
|
||||
objects.Add(p.a, new Item(p.a, p.b, rulesFile.GetSection(p.a), p.c));
|
||||
|
||||
Reference in New Issue
Block a user