some mostly useless code reformatting in client.common
This commit is contained in:
parent
255eb5adbf
commit
993845fe72
|
@ -6,6 +6,16 @@ using ICSharpCode.SharpZipLib.Zip;
|
||||||
|
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
|
public enum BinaryStateLump
|
||||||
|
{
|
||||||
|
Versiontag,
|
||||||
|
Corestate,
|
||||||
|
Framebuffer,
|
||||||
|
Input,
|
||||||
|
CorestateText,
|
||||||
|
Movieheader
|
||||||
|
}
|
||||||
|
|
||||||
public class BinaryStateFileNames
|
public class BinaryStateFileNames
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -36,22 +46,19 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum BinaryStateLump
|
|
||||||
{
|
|
||||||
Versiontag,
|
|
||||||
Corestate,
|
|
||||||
Framebuffer,
|
|
||||||
Input,
|
|
||||||
CorestateText,
|
|
||||||
Movieheader
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// more accurately should be called ZipStateLoader, as it supports both text and binary core data
|
/// more accurately should be called ZipStateLoader, as it supports both text and binary core data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class BinaryStateLoader : IDisposable
|
public class BinaryStateLoader : IDisposable
|
||||||
{
|
{
|
||||||
|
private ZipFile _zip;
|
||||||
|
private Version _ver;
|
||||||
private bool _isDisposed;
|
private bool _isDisposed;
|
||||||
|
|
||||||
|
private BinaryStateLoader()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
@ -71,13 +78,6 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ZipFile _zip;
|
|
||||||
private Version _ver;
|
|
||||||
|
|
||||||
private BinaryStateLoader()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ReadVersion(Stream s)
|
private void ReadVersion(Stream s)
|
||||||
{
|
{
|
||||||
// the "BizState 1.0" tag contains an integer in it describing the sub version.
|
// the "BizState 1.0" tag contains an integer in it describing the sub version.
|
||||||
|
@ -139,8 +139,8 @@ namespace BizHawk.Client.Common
|
||||||
/// <returns>true if callback was called and stream was loaded</returns>
|
/// <returns>true if callback was called and stream was loaded</returns>
|
||||||
public bool GetLump(BinaryStateLump lump, bool abort, Action<Stream> callback)
|
public bool GetLump(BinaryStateLump lump, bool abort, Action<Stream> callback)
|
||||||
{
|
{
|
||||||
string Name = BinaryStateFileNames.Get(lump);
|
var name = BinaryStateFileNames.Get(lump);
|
||||||
var e = _zip.GetEntry(Name);
|
var e = _zip.GetEntry(name);
|
||||||
if (e != null)
|
if (e != null)
|
||||||
{
|
{
|
||||||
using (var zs = _zip.GetInputStream(e))
|
using (var zs = _zip.GetInputStream(e))
|
||||||
|
@ -150,14 +150,13 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (abort)
|
|
||||||
|
if (abort)
|
||||||
{
|
{
|
||||||
throw new Exception("Essential zip section not found: " + Name);
|
throw new Exception("Essential zip section not found: " + name);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GetLump(BinaryStateLump lump, bool abort, Action<BinaryReader> callback)
|
public bool GetLump(BinaryStateLump lump, bool abort, Action<BinaryReader> callback)
|
||||||
|
@ -198,28 +197,12 @@ namespace BizHawk.Client.Common
|
||||||
throw new Exception("Couldn't find Binary or Text savestate");
|
throw new Exception("Couldn't find Binary or Text savestate");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public bool GetFrameBuffer(Action<Stream> callback)
|
|
||||||
{
|
|
||||||
return GetFileByName(BinaryStateFileNames.Framebuffer, false, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void GetInputLogRequired(Action<Stream> callback)
|
|
||||||
{
|
|
||||||
GetFileByName(BinaryStateFileNames.Input, true, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void GetMovieHeaderRequired(Action<Stream> callback)
|
|
||||||
{
|
|
||||||
GetFileByName(BinaryStateFileNames.Movieheader, true, callback);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BinaryStateSaver : IDisposable
|
public class BinaryStateSaver : IDisposable
|
||||||
{
|
{
|
||||||
private readonly ZipOutputStream zip;
|
private readonly ZipOutputStream _zip;
|
||||||
|
private bool _isDisposed;
|
||||||
|
|
||||||
private static void WriteVersion(Stream s)
|
private static void WriteVersion(Stream s)
|
||||||
{
|
{
|
||||||
|
@ -234,23 +217,23 @@ namespace BizHawk.Client.Common
|
||||||
/// <param name="s">not closed when finished!</param>
|
/// <param name="s">not closed when finished!</param>
|
||||||
public BinaryStateSaver(Stream s)
|
public BinaryStateSaver(Stream s)
|
||||||
{
|
{
|
||||||
zip = new ZipOutputStream(s)
|
_zip = new ZipOutputStream(s)
|
||||||
{
|
{
|
||||||
IsStreamOwner = false,
|
IsStreamOwner = false,
|
||||||
UseZip64 = UseZip64.Off
|
UseZip64 = UseZip64.Off
|
||||||
};
|
};
|
||||||
zip.SetLevel(0);
|
_zip.SetLevel(0);
|
||||||
|
|
||||||
PutLump(BinaryStateLump.Versiontag, WriteVersion);
|
PutLump(BinaryStateLump.Versiontag, WriteVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PutLump(BinaryStateLump lump, Action<Stream> callback)
|
public void PutLump(BinaryStateLump lump, Action<Stream> callback)
|
||||||
{
|
{
|
||||||
string Name = BinaryStateFileNames.Get(lump);
|
var name = BinaryStateFileNames.Get(lump);
|
||||||
var e = new ZipEntry(Name) {CompressionMethod = CompressionMethod.Stored};
|
var e = new ZipEntry(name) {CompressionMethod = CompressionMethod.Stored};
|
||||||
zip.PutNextEntry(e);
|
_zip.PutNextEntry(e);
|
||||||
callback(zip);
|
callback(_zip);
|
||||||
zip.CloseEntry();
|
_zip.CloseEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PutLump(BinaryStateLump lump, Action<BinaryWriter> callback)
|
public void PutLump(BinaryStateLump lump, Action<BinaryWriter> callback)
|
||||||
|
@ -273,35 +256,6 @@ namespace BizHawk.Client.Common
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public void PutCoreStateBinary(Action<Stream> callback)
|
|
||||||
{
|
|
||||||
PutFileByName(BinaryStateFileNames.Corestate, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PutCoreStateText(Action<Stream> callback)
|
|
||||||
{
|
|
||||||
PutFileByName(BinaryStateFileNames.CorestateText, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PutFrameBuffer(Action<Stream> callback)
|
|
||||||
{
|
|
||||||
PutFileByName(BinaryStateFileNames.Framebuffer, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PutInputLog(Action<Stream> callback)
|
|
||||||
{
|
|
||||||
PutFileByName(BinaryStateFileNames.Input, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PutMovieHeader(Action<Stream> callback)
|
|
||||||
{
|
|
||||||
PutFileByName(BinaryStateFileNames.Movieheader, callback);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
private bool _isDisposed;
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
@ -316,7 +270,7 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
zip.Close();
|
_zip.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,10 @@
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
public class MovieHeader : Dictionary<string, string>, IMovieHeader
|
public class MovieHeader : Dictionary<string, string>, IMovieHeader
|
||||||
{
|
{
|
||||||
public List<string> Comments { get; private set; }
|
|
||||||
public Dictionary<string, string> BoardProperties { get; private set; }
|
|
||||||
public SubtitleList Subtitles { get; private set; }
|
|
||||||
|
|
||||||
public MovieHeader()
|
public MovieHeader()
|
||||||
{
|
{
|
||||||
Comments = new List<string>();
|
Comments = new List<string>();
|
||||||
|
@ -20,17 +13,100 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
this[HeaderKeys.EMULATIONVERSION] = VersionInfo.GetEmuVersion();
|
this[HeaderKeys.EMULATIONVERSION] = VersionInfo.GetEmuVersion();
|
||||||
this[HeaderKeys.MOVIEVERSION] = HeaderKeys.MovieVersion1;
|
this[HeaderKeys.MOVIEVERSION] = HeaderKeys.MovieVersion1;
|
||||||
this[HeaderKeys.PLATFORM] = Global.Emulator != null ? Global.Emulator.SystemId : String.Empty;
|
this[HeaderKeys.PLATFORM] = Global.Emulator != null ? Global.Emulator.SystemId : string.Empty;
|
||||||
this[HeaderKeys.GAMENAME] = String.Empty;
|
this[HeaderKeys.GAMENAME] = string.Empty;
|
||||||
this[HeaderKeys.AUTHOR] = String.Empty;
|
this[HeaderKeys.AUTHOR] = string.Empty;
|
||||||
this[HeaderKeys.RERECORDS] = "0";
|
this[HeaderKeys.RERECORDS] = "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<string> Comments { get; private set; }
|
||||||
|
public Dictionary<string, string> BoardProperties { get; private set; }
|
||||||
|
public SubtitleList Subtitles { get; private set; }
|
||||||
|
|
||||||
|
public ulong Rerecords
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!ContainsKey(HeaderKeys.RERECORDS))
|
||||||
|
{
|
||||||
|
this[HeaderKeys.RERECORDS] = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
return ulong.Parse(this[HeaderKeys.RERECORDS]);
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this[HeaderKeys.RERECORDS] = value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool StartsFromSavestate
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ContainsKey(HeaderKeys.STARTSFROMSAVESTATE))
|
||||||
|
{
|
||||||
|
return bool.Parse(this[HeaderKeys.STARTSFROMSAVESTATE]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
Add(HeaderKeys.STARTSFROMSAVESTATE, "True");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Remove(HeaderKeys.STARTSFROMSAVESTATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GameName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ContainsKey(HeaderKeys.GAMENAME))
|
||||||
|
{
|
||||||
|
return this[HeaderKeys.GAMENAME];
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this[HeaderKeys.GAMENAME] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SystemID
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ContainsKey(HeaderKeys.PLATFORM))
|
||||||
|
{
|
||||||
|
return this[HeaderKeys.PLATFORM];
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this[HeaderKeys.PLATFORM] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public new string this[string key]
|
public new string this[string key]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return this.ContainsKey(key) ? base[key] : String.Empty;
|
return this.ContainsKey(key) ? base[key] : string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
|
@ -84,94 +160,9 @@ namespace BizHawk.Client.Common
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ulong Rerecords
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (!ContainsKey(HeaderKeys.RERECORDS))
|
|
||||||
{
|
|
||||||
this[HeaderKeys.RERECORDS] = "0";
|
|
||||||
}
|
|
||||||
|
|
||||||
return ulong.Parse(this[HeaderKeys.RERECORDS]);
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this[HeaderKeys.RERECORDS] = value.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool StartsFromSavestate
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (ContainsKey(HeaderKeys.STARTSFROMSAVESTATE))
|
|
||||||
{
|
|
||||||
return bool.Parse(this[HeaderKeys.STARTSFROMSAVESTATE]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value)
|
|
||||||
{
|
|
||||||
Add(HeaderKeys.STARTSFROMSAVESTATE, "True");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Remove(HeaderKeys.STARTSFROMSAVESTATE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GameName
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (ContainsKey(HeaderKeys.GAMENAME))
|
|
||||||
{
|
|
||||||
return this[HeaderKeys.GAMENAME];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return String.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this[HeaderKeys.GAMENAME] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string SystemID
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (ContainsKey(HeaderKeys.PLATFORM))
|
|
||||||
{
|
|
||||||
return this[HeaderKeys.PLATFORM];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return String.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this[HeaderKeys.PLATFORM] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ParseLineFromFile(string line)
|
public bool ParseLineFromFile(string line)
|
||||||
{
|
{
|
||||||
if (!String.IsNullOrWhiteSpace(line))
|
if (!string.IsNullOrWhiteSpace(line))
|
||||||
{
|
{
|
||||||
var splitLine = line.Split(new[] { ' ' }, 2);
|
var splitLine = line.Split(new[] { ' ' }, 2);
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,15 @@
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
public class PlatformFrameRates
|
public class PlatformFrameRates
|
||||||
{
|
{
|
||||||
public double this[string systemId, bool pal]
|
// these are political numbers, designed to be in accord with tasvideos.org tradition. theyre not necessarily mathematical factualities (although they may be in some cases)
|
||||||
{
|
// it would be nice if we could turn this into a rational expression natively, and also, to write some comments about the derivation and ideal valees (since this seems to be where theyre all collected)
|
||||||
get
|
// are we collecting them anywhere else? for avi-writing code perhaps?
|
||||||
|
private static readonly Dictionary<string, double> _rates = new Dictionary<string, double>
|
||||||
{
|
{
|
||||||
var key = systemId + (pal ? "_PAL" : String.Empty);
|
{ "NES", 60.098813897440515532 }, // discussion here: http://forums.nesdev.com/viewtopic.php?t=492 ; a rational expression would be (19687500 / 11) / ((341*262-0.529780.5)/3) -> (118125000 / 1965513) -> 60.098813897440515529533511098629 (so our chosen number is very close)
|
||||||
if (_rates.ContainsKey(key))
|
|
||||||
{
|
|
||||||
return _rates[key];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 60.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//these are political numbers, designed to be in accord with tasvideos.org tradition. theyre not necessarily mathematical factualities (although they may be in some cases)
|
|
||||||
//it would be nice if we could turn this into a rational expression natively, and also, to write some comments about the derivation and ideal valees (since this seems to be where theyre all collected)
|
|
||||||
//are we collecting them anywhere else? for avi-writing code perhaps?
|
|
||||||
private static Dictionary<string, double> _rates = new Dictionary<string, double>
|
|
||||||
{
|
|
||||||
{ "NES", 60.098813897440515532 }, //discussion here: http://forums.nesdev.com/viewtopic.php?t=492 ; a rational expression would be (19687500 / 11) / ((341*262-0.529780.5)/3) -> (118125000 / 1965513) -> 60.098813897440515529533511098629 (so our chosen number is very close)
|
|
||||||
{ "NES_PAL", 50.006977968268290849 },
|
{ "NES_PAL", 50.006977968268290849 },
|
||||||
{ "FDS", 60.098813897440515532 },
|
{ "FDS", 60.098813897440515532 },
|
||||||
{ "FDS_PAL", 50.006977968268290849 },
|
{ "FDS_PAL", 50.006977968268290849 },
|
||||||
|
@ -53,5 +36,19 @@ namespace BizHawk.Client.Common
|
||||||
{ "A78", 59.9227510135505 },
|
{ "A78", 59.9227510135505 },
|
||||||
{ "Coleco", 59.9227510135505 }
|
{ "Coleco", 59.9227510135505 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public double this[string systemId, bool pal]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var key = systemId + (pal ? "_PAL" : string.Empty);
|
||||||
|
if (_rates.ContainsKey(key))
|
||||||
|
{
|
||||||
|
return _rates[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 60.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,12 @@
|
||||||
using System;
|
using System.Text;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
public class Subtitle
|
public class Subtitle
|
||||||
{
|
{
|
||||||
public string Message { get; set; }
|
|
||||||
public int Frame { get; set; }
|
|
||||||
public int X { get; set; }
|
|
||||||
public int Y { get; set; }
|
|
||||||
public int Duration { get; set; }
|
|
||||||
public uint Color { get; set; }
|
|
||||||
|
|
||||||
public Subtitle()
|
public Subtitle()
|
||||||
{
|
{
|
||||||
Message = String.Empty;
|
Message = string.Empty;
|
||||||
X = 0;
|
X = 0;
|
||||||
Y = 0;
|
Y = 0;
|
||||||
Duration = 120;
|
Duration = 120;
|
||||||
|
@ -32,6 +24,13 @@ namespace BizHawk.Client.Common
|
||||||
Color = s.Color;
|
Color = s.Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Message { get; set; }
|
||||||
|
public int Frame { get; set; }
|
||||||
|
public int X { get; set; }
|
||||||
|
public int Y { get; set; }
|
||||||
|
public int Duration { get; set; }
|
||||||
|
public uint Color { get; set; }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder("subtitle ");
|
var sb = new StringBuilder("subtitle ");
|
||||||
|
@ -40,7 +39,7 @@ namespace BizHawk.Client.Common
|
||||||
.Append(X).Append(" ")
|
.Append(X).Append(" ")
|
||||||
.Append(Y).Append(" ")
|
.Append(Y).Append(" ")
|
||||||
.Append(Duration).Append(" ")
|
.Append(Duration).Append(" ")
|
||||||
.Append(String.Format("{0:X8}", Color)).Append(" ")
|
.Append(string.Format("{0:X8}", Color)).Append(" ")
|
||||||
.Append(Message);
|
.Append(Message);
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -22,14 +21,14 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
public bool AddFromString(string subtitleStr)
|
public bool AddFromString(string subtitleStr)
|
||||||
{
|
{
|
||||||
if (!String.IsNullOrWhiteSpace(subtitleStr))
|
if (!string.IsNullOrWhiteSpace(subtitleStr))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var subparts = subtitleStr.Split(' ');
|
var subparts = subtitleStr.Split(' ');
|
||||||
|
|
||||||
// Unfortunately I made the file format space delminated so this hack is necessary to get the message
|
// Unfortunately I made the file format space delminated so this hack is necessary to get the message
|
||||||
var message = String.Empty;
|
var message = string.Empty;
|
||||||
for (var i = 6; i < subparts.Length; i++)
|
for (var i = 6; i < subparts.Length; i++)
|
||||||
{
|
{
|
||||||
message += subparts[i] + ' ';
|
message += subparts[i] + ' ';
|
||||||
|
@ -52,10 +51,8 @@ namespace BizHawk.Client.Common
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,11 +5,6 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
public class Rewinder
|
public class Rewinder
|
||||||
{
|
{
|
||||||
public Rewinder()
|
|
||||||
{
|
|
||||||
RewindActive = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private StreamBlobDatabase _rewindBuffer;
|
private StreamBlobDatabase _rewindBuffer;
|
||||||
private RewindThreader _rewindThread;
|
private RewindThreader _rewindThread;
|
||||||
private byte[] _lastState;
|
private byte[] _lastState;
|
||||||
|
@ -19,6 +14,11 @@ namespace BizHawk.Client.Common
|
||||||
private byte[] _rewindFellationBuf;
|
private byte[] _rewindFellationBuf;
|
||||||
private byte[] _tempBuf = new byte[0];
|
private byte[] _tempBuf = new byte[0];
|
||||||
|
|
||||||
|
public Rewinder()
|
||||||
|
{
|
||||||
|
RewindActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
public Action<string> MessageCallback { get; set; }
|
public Action<string> MessageCallback { get; set; }
|
||||||
public bool RewindActive { get; set; }
|
public bool RewindActive { get; set; }
|
||||||
|
|
||||||
|
@ -220,11 +220,9 @@ namespace BizHawk.Client.Common
|
||||||
// otherwise, allocate it
|
// otherwise, allocate it
|
||||||
return new byte[size];
|
return new byte[size];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
_rewindFellationBuf = inbuf;
|
||||||
_rewindFellationBuf = inbuf;
|
return null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CaptureRewindStateNonDelta(byte[] currentState)
|
private void CaptureRewindStateNonDelta(byte[] currentState)
|
||||||
|
@ -251,7 +249,7 @@ namespace BizHawk.Client.Common
|
||||||
var inChangeSequence = false;
|
var inChangeSequence = false;
|
||||||
|
|
||||||
// try to set up the buffer in advance so we dont ever have exceptions in here
|
// try to set up the buffer in advance so we dont ever have exceptions in here
|
||||||
//zeromus says: this sets off red flags for me. vecna got an exception that might be related to this inflating to 2x the input size. we should add an emergency check, or analyze how much it could inflate by (perhaps 3x would be adequate in every case?)
|
// zeromus says: this sets off red flags for me. vecna got an exception that might be related to this inflating to 2x the input size. we should add an emergency check, or analyze how much it could inflate by (perhaps 3x would be adequate in every case?)
|
||||||
if (_tempBuf.Length < currentState.Length)
|
if (_tempBuf.Length < currentState.Length)
|
||||||
{
|
{
|
||||||
_tempBuf = new byte[currentState.Length * 2];
|
_tempBuf = new byte[currentState.Length * 2];
|
||||||
|
|
Loading…
Reference in New Issue