public static Highscore Load(Stream fs, System.Text.Decoder decoder)
{
const int length = 4;
byte[] data = new byte[length];
char[] chars;
string name;
fs.Read(data, 0, length);
var bytesCount = System.BitConverter.ToInt32(data, 0);
if (bytesCount > 0 && bytesCount < 100000)
{
data = new byte[bytesCount];
fs.Read(data, 0, bytesCount);
chars = new char[decoder.GetCharCount(data, 0, bytesCount)];
decoder.GetChars(data, 0, bytesCount, chars, 0, true);
name = new string(chars);
}
else
{
name = "highscore";
}
//
bytesCount = 9;
data = new byte[bytesCount];
fs.Read(data, 0, bytesCount);
return(new Highscore(System.BitConverter.ToInt32(data, 0), name, System.BitConverter.ToUInt32(data, 4), (GameEndingType)data[8]));
}