internal void Load(SaveFileReader reader) { reader.ReadVersion(2); GameType = reader.ReadEnum <SaveGameType>(); MapPath = reader.ReadAsciiString(); Timestamp = reader.ReadDateTime(); DisplayName = reader.ReadUnicodeString(); MapFileName = reader.ReadAsciiString(); Side = reader.ReadAsciiString(); MissionIndex = reader.ReadUInt32(); }
internal static void Load(SaveFileReader reader, Game game) { reader.ReadVersion(2); var mapPath1 = reader.ReadAsciiString(); var mapPath2 = reader.ReadAsciiString(); var gameType = reader.ReadEnum <GameType>(); var mapSize = reader.BeginSegment(); // TODO: Delete this temporary map when ending the game. var mapPathInSaveFolder = Path.Combine( game.ContentManager.UserDataFileSystem.RootDirectory, mapPath1); var saveFolder = Path.GetDirectoryName(mapPathInSaveFolder); if (!Directory.Exists(saveFolder)) { Directory.CreateDirectory(saveFolder); } using (var mapOutputStream = File.OpenWrite(mapPathInSaveFolder)) { reader.ReadBytesIntoStream(mapOutputStream, (int)mapSize); } reader.EndSegment(); var unknown2 = reader.ReadUInt32(); // 586 var unknown3 = reader.ReadUInt32(); // 3220 if (gameType == GameType.Skirmish) { game.SkirmishManager = new LocalSkirmishManager(game); game.SkirmishManager.Settings.Load(reader); game.SkirmishManager.Settings.MapName = mapPath1; game.SkirmishManager.HandleStartButtonClickAsync().Wait(); game.SkirmishManager.StartGame(); } else { game.StartSinglePlayerGame(mapPath1); } }