private void RaiseOnGameSaved(AowGameType type, string fileName) { if (OnGameSaved != null) { OnGameSaved(this, new AowGameSavedEventArgs(type, fileName)); } }
private void RaiseOnGameSaved(AowGameType type, string fileName, string gameTitle, string mapTitle, string turnNo) { if (OnGameSaved != null) { OnGameSaved(this, new AowGameSavedEventArgs(type, fileName, gameTitle, mapTitle, turnNo)); } }
public void DeleteGame(AowGameType theGameType, string fileName) { if (!theGameType.Equals(AowGameType.Unknown)) { AowGame theGame = GetGameByType(theGameType); if (theGame != null && theGame.IsInstalled) { DirectoryInfo[] theFolders = new DirectoryInfo[] { theGame.EmailIn, theGame.EmailOut, theGame.Save }; string searchPattern = GetSearchPattern(fileName); foreach (DirectoryInfo folder in theFolders) { FileInfo[] matchingFiles = GetAllGameFiles(fileName, folder, searchPattern); if (matchingFiles.Length > 0) { foreach (FileInfo file in matchingFiles) { if (File.Exists(file.FullName)) { File.Delete(file.FullName); } } } } } } else { //If it's an unknown game just delete ClearCheckEmailFolder(fileName); } }
private void ParseProperties() { try { ParseAowMajorVersion(); switch (_fileType) { case ASGFileType.Aow1: ParseAow1(); break; case ASGFileType.Aow2Sm: ParseAow2(aowmap_signature); break; case ASGFileType.AowMpe: ParseAow2(mpe_signature); break; } } catch (Exception ex) { Trace.TraceError(ex.ToString()); Trace.Flush(); _fileType = ASGFileType.Unknown; _gameType = AowGameType.Unknown; } }
public AowGameSavedEventArgs(AowGameType type, string fileName, string gameTitle, string mapTitle, string turnNo) { _theGameType = type; _fileName = fileName; _gameTitle = gameTitle; _mapTitle = mapTitle; _turnNo = turnNo; }
public Activity(ActivityState status, AowGameType type, string fileName, string mapTitle, string turnNo) { _status = status; _type = type; _fileName = fileName; _mapTitle = mapTitle; _turnNo = turnNo; _dateTicks = DateTime.Now.Ticks.ToString(); }
public bool IsInstalled(AowGameType theGameType) { bool returnVal = false; AowGame theGame = GetGameByType(theGameType); if (theGame != null) { returnVal = theGame.IsInstalled; } return(returnVal); }
public void ArchiveEndedGame(AowGameType theGameType, string fileName, string endedFolderName) { if (!theGameType.Equals(AowGameType.Unknown)) { AowGame theGame = GetGameByType(theGameType); if (theGame != null && theGame.IsInstalled) { DirectoryInfo[] theFolders = new DirectoryInfo[] { theGame.EmailIn, theGame.EmailOut, theGame.Save }; string searchPattern = GetSearchPattern(fileName); foreach (DirectoryInfo folder in theFolders) { FileInfo[] matchingFiles = GetAllGameFiles(fileName, folder, searchPattern); if (matchingFiles.Length > 0) { string endedFolderPath = Path.Combine(folder.FullName, endedFolderName); if (!Directory.Exists(endedFolderPath)) { Directory.CreateDirectory(endedFolderPath); } DirectoryInfo theEndedFolder = new DirectoryInfo(endedFolderPath); foreach (FileInfo file in matchingFiles) { string newFileName = Path.Combine(theEndedFolder.FullName, file.Name); try { if (File.Exists(newFileName)) { File.Delete(newFileName); } //This is in a Try Catch incase it tries to move a non virtualized file in virtualization mode (UAC on) File.Move(file.FullName, newFileName); } catch { } } } } } } else { //If it's an unknown game just delete ClearCheckEmailFolder(fileName); } }
public int GetUnSentActivitiesCountByGameType(AowGameType theType) { int returnVal = 0; List <Activity> unSentMatches = _activities.FindAll(item => item.GameType.Equals(theType) && item.Status.Equals(ActivityState.Received)); if (unSentMatches != null & unSentMatches.Count > 0) { returnVal = unSentMatches.Count; } return(returnVal); }
private void ParseAow1() { _gameType = AowGameType.Aow1; using (BinaryReader input = new BinaryReader(_theAttachment.GetMemoryStream())) { if (_fetch_compressed_data) { if (CheckSignature(input, compressed_part_signature)) { DataCompressor compressed_data = new DataCompressor(input, true); compressed_data.Compressed = false; // decompression happens here using (BinaryReader main_input = new BinaryReader(new MemoryStream(compressed_data.Data))) { if (CheckSignature(main_input, aow1map_signature)) { int possible_class_id = main_input.ReadInt32(); main_input.BaseStream.Position += 3; // skip field list of root offsetmap, moving straight to the contents OffsetMap map_om = new OffsetMap(main_input.BaseStream); _mapTitle = map_om.ReadShortPascalString(0x19); _turnNumber = map_om.ReadInt32(0x13); OffsetMap section_15 = map_om.GetSubFieldOffsetMap(0x15); OffsetMap s_15_1 = section_15.GetSubFieldOffsetMap(0x01); OffsetMap s_15_1_1 = s_15_1.GetSubFieldOffsetMap(0x01, true); OffsetMap s_15_1_1_36 = s_15_1_1.GetSubFieldOffsetMap(0x36); OffsetMap s_15_1_1_36_15 = s_15_1_1_36.GetSubFieldOffsetMap(0x15); _gameTitle = s_15_1_1_36_15.ReadShortPascalString(0x14); } else { _isValid = false; } } } else { _isValid = false; } } } }
public AowGame(AowGameType theGameType) { _gameType = theGameType; switch (_gameType) { case AowGameType.Aow1: _exeFile = Aow1ExeName; _gameName = _displayName = Aow1GameName; break; case AowGameType.Aow2: _exeFile = Aow2ExeName; _gameName = _displayName = Aow2GameName; break; case AowGameType.AowSm: _exeFile = AowSmExeName; _gameName = _displayName = AowSmGameName; break; case AowGameType.AowMpe: //This is a patch for Shadow Magic with a different game exe; it uses the same registry locations as SM _exeFile = AowMpeExeName; _gameName = AowSmGameName; _displayName = AowMpeGameName; break; } _rootRegKey = RegistryHelper.GetDeepestKey(Registry.CurrentUser, string.Format(AowRegPathTemplate, _gameName), false); if (_rootRegKey != null) { DetectGame(); } }
public AowGameSavedEventArgs(AowGameType type, string fileName) : this(type, fileName, null, null, null) { }
public AowGame GetGameByType(AowGameType theGameType) { return(_games.Find(game => game.GameType.Equals(theGameType))); }
private void ParseAow2(byte[] signature) { using (BinaryReader input = new BinaryReader(_theAttachment.GetMemoryStream())) { if (CheckSignature(input, signature)) { int header_length = input.ReadInt32() - 7; // хз почему, но это так _modId = input.ReadInt32(); if (CheckSignature(input, magic_11_bytes)) { long compressed_part_start = input.BaseStream.Position + header_length; OffsetMap header_om = new OffsetMap(input.BaseStream, input.BaseStream.Position, header_length); _mapTitle = header_om.ReadShortPascalString(0x20); _turnNumber = header_om.ReadInt32(0x21); byte playersCount = header_om.ReadByte(0x1e); // compressed info if (_fetch_compressed_data) { input.BaseStream.Position = compressed_part_start; if (CheckSignature(input, compressed_part_signature)) { DataCompressor compressed_data = new DataCompressor(input, true); compressed_data.Compressed = false; // decompression happens here using (BinaryReader main_input = new BinaryReader(new MemoryStream(compressed_data.Data))) { // digging up the game title if (CheckSignature(main_input, decompressed_data_signature)) { OffsetMap map_om = new OffsetMap(main_input.BaseStream); OffsetMap player_list_wrapper_om = map_om.GetSubFieldOffsetMap(0x1a); OffsetMap player_list_om = player_list_wrapper_om.GetSubFieldOffsetMap(0x01); OffsetMap player_1_om = player_list_om.GetSubFieldOffsetMap(0x01, true); OffsetMap player_1_pbem_settings_wrapper = player_1_om.GetSubFieldOffsetMap(0x36); OffsetMap player_1_pbem_settings = player_1_pbem_settings_wrapper.GetSubFieldOffsetMap(0x15); _gameTitle = player_1_pbem_settings.ReadShortPascalString(0x14); // WT or SM? OffsetMap race_list_wrapper_om = map_om.GetSubFieldOffsetMap(0x1b); OffsetMap race_list_om = race_list_wrapper_om.GetSubFieldOffsetMap(0x01); int race_count = race_list_om.Fields.Count; switch (race_count) { case 15: _gameType = _fileType == ASGFileType.AowMpe ? AowGameType.AowMpe : AowGameType.AowSm; break; case 12: _gameType = AowGameType.Aow2; break; default: _gameType = AowGameType.Unknown; break; } } else { _isValid = false; } } } else { _isValid = false; } } } } } }