public bool ComprobarArchivo(string RtuaPartidaGuardada) { bool correcto; StringBuilder TextCheck = new StringBuilder(); //Crear lector Lector = new BinaryReaderBigEndian(new FileStream(RtuaPartidaGuardada, FileMode.Open, FileAccess.Read)); //Comprobar el primer byte if (Lector.Read().ToString().Equals("4")) { Lector.BaseStream.Seek(unchecked ((int)0x12), SeekOrigin.Begin); for (int i = 0; i < 6; i++) { TextCheck.Append(Lector.ReadChar()); } if (TextCheck.ToString().Equals("SPHINX")) { correcto = true; } else { correcto = false; } } else { correcto = false; } return(correcto); }
public string [] LeerAnkhs(string RtuaPartidaGuardada) { string [] Ankhs = new string[2]; //Crear lector Lector = new BinaryReaderBigEndian(new FileStream(RtuaPartidaGuardada, FileMode.Open, FileAccess.Read)); //Numero de ankhs Lector.BaseStream.Seek(unchecked ((int)0x3610), SeekOrigin.Begin); Ankhs[0] = checked ((int)SwapBytes(Lector.ReadUInt32())).ToString(); //Número total de ankhs Lector.BaseStream.Seek(unchecked ((int)0x3614), SeekOrigin.Begin); Ankhs[1] = (checked ((int)SwapBytes(Lector.ReadUInt32())) / 3).ToString(); return(Ankhs); }
public List <Objectives> ObtenerObjectivesPartidaGuardada(int PosicionObjectives, string PrefijoObjectives, string RtuaPartidaGuardada) { //Crear lector. Lector = new BinaryReaderBigEndian(new FileStream(RtuaPartidaGuardada, FileMode.Open, FileAccess.Read)); //Crear Lista List <Objectives> ObjectivesEncontrados = new List <Objectives>(); //Variables importantes. int NumeroInventario, Contador = 0; uint DatosLeidos; //Ir a la sección donde están los objectives. Lector.BaseStream.Seek(unchecked ((int)PosicionObjectives), SeekOrigin.Begin); //Número de objectives que hay. NumeroInventario = checked ((int)SwapBytes(Lector.ReadUInt32())); //Buscar los objectives. while (Contador < NumeroInventario) { //Leer datos DatosLeidos = SwapBytes(Lector.ReadUInt32()); //Comprobar si lo que ha leido es un objective. if (DatosLeidos.ToString("X4").StartsWith(PrefijoObjectives)) { if (DatosLeidos.ToString("X4").Length == 8) { ObjectivesEncontrados.Add(new Objectives { ObjectiveNumHex = DatosLeidos.ToString("X4"), ValorObjective = int.Parse(SwapBytes(Lector.ReadUInt32()).ToString("X4"), System.Globalization.NumberStyles.HexNumber).ToString() }); Contador++; } } //Si son datos de relleno o se han hecho las 1700 iteraciones sale del bucle. if (DatosLeidos.ToString("X4").Equals("55555555") || Contador == 1700) { break; } } Lector.Close(); return(ObjectivesEncontrados); }