public void Serialize(Stream output) { output.WriteStringASCII("WSG"); output.WriteValueU32(2, this.LittleEndian); SaveStream saveStream = new SaveStream(output, this.LittleEndian); this.PlayerData.Serialize(saveStream); }
public void Serialize(Stream output) { output.WriteString(Signature, Encoding.ASCII); output.WriteValueU32(2, this.Endian); SaveStream saveStream = new SaveStream(output, this.Endian); this.PlayerData.Serialize(saveStream); }
public void Deserialize(Stream input) { if (input.ReadStringASCII(3) != "WSG") // WSG is probably WillowSaveGame { throw new FormatException("not a Borderlands save file"); } UInt32 version = input.ReadValueU32(); if (version != 2 && version.Swap() != 2) { throw new FormatException("unsupported Borderlands save file version (" + version.ToString() + ")"); } this.LittleEndian = version == 2; SaveStream saveStream = new SaveStream(input, this.LittleEndian); this.PlayerData = new Save.Player(); this.PlayerData.Deserialize(saveStream); }
public void Deserialize(Stream input) { if (input.ReadString(Signature.Length, Encoding.ASCII) != Signature) { throw new FormatException("not a save"); } var version = input.ReadValueU32(); if (version != 2 && version.Swap() != 2) { throw new FormatException("unsupported save version " + version.ToString(CultureInfo.InvariantCulture)); } var endian = version == 2 ? Endian.Little : Endian.Big; var saveStream = new SaveStream(input, endian); var playerData = new Player(); playerData.Deserialize(saveStream); this._Endian = endian; this._PlayerData = playerData; }