public FileInfo(Reader reader, List <string> FileList, int cnt) { for (int y = 0; y < 16; y += 4) { md5Hash[y + 3] = reader.ReadByte(); md5Hash[y + 2] = reader.ReadByte(); md5Hash[y + 1] = reader.ReadByte(); md5Hash[y] = reader.ReadByte(); } MD5FileName = ConvertByteArrayToString(md5Hash); var md5 = MD5.Create(); FileName = (cnt + 1) + ".bin"; //Make a base name for (int i = 0; i < FileList.Count; i++) { // Mania Hashes all Strings at Lower Case string fp = FileList[i].ToLower(); bool match = true; for (int z = 0; z < 16; z++) { if (CalculateMD5Hash(fp)[z] != md5Hash[z]) { match = false; break; } } if (match) { FileName = FileList[i]; break; } } DataOffset = reader.ReadUInt32(); uint tmp = reader.ReadUInt32(); Encrypted = (tmp & 0x80000000) != 0; FileSize = (tmp & 0x7FFFFFFF); long tmp2 = reader.BaseStream.Position; reader.BaseStream.Position = DataOffset; Filedata = reader.ReadBytes(FileSize); // Decrypt File if Encrypted if (Encrypted) { Filedata = Decrypt(Filedata); } reader.BaseStream.Position = tmp2; Extension = GetExtensionFromData(); if (FileName == (cnt + 1) + ".bin") { switch (Extension) { case ExtensionTypes.GIF: FileName = "Sprite" + (cnt + 1) + ".gif"; break; case ExtensionTypes.R3D: FileName = "Model" + (cnt + 1) + ".bin"; break; case ExtensionTypes.OGG: FileName = "Music" + (cnt + 1) + ".ogg"; break; case ExtensionTypes.PNG: FileName = "Image" + (cnt + 1) + ".png"; break; case ExtensionTypes.WAV: FileName = "SoundEffect" + (cnt + 1) + ".wav"; break; case ExtensionTypes.UNKNOWN: FileName = "UnknownFileType" + (cnt + 1) + ".bin"; break; } } md5.Dispose(); }
public Object(Reader reader) { cur_id++; id = cur_id; //Attribute bits, 2 bytes, unsigned byte t1 = reader.ReadByte(); byte t2 = reader.ReadByte(); AttributeType = (ushort)((t2 << 8) + t1); // Object type, 1 byte, unsigned type = reader.ReadByte(); //Type // Object subtype, 1 byte, unsigned subtype = reader.ReadByte(); //SubType/PropertyValue //a position, made of 8 bytes, 4 for X, 4 for Y position = new Position(reader); for (int i = 0; i < attributes.Length; i++) { attributes[i] = uint.MaxValue; } if ((AttributeType & 0x1) != 0) { attributes[0] = reader.ReadUInt32(); } if ((AttributeType & 0x2) != 0) { attributes[1] = reader.ReadByte(); } if ((AttributeType & 0x4) != 0) { attributes[2] = reader.ReadUInt32(); } if ((AttributeType & 0x8) != 0) { attributes[3] = reader.ReadUInt32(); } if ((AttributeType & 0x10) != 0) { attributes[4] = reader.ReadByte(); } if ((AttributeType & 0x20) != 0) { attributes[5] = reader.ReadByte(); } if ((AttributeType & 0x40) != 0) { attributes[6] = reader.ReadByte(); } if ((AttributeType & 0x80) != 0) { attributes[7] = reader.ReadByte(); } if ((AttributeType & 0x100) != 0) { attributes[8] = reader.ReadUInt32(); } if ((AttributeType & 0x200) != 0) { attributes[9] = reader.ReadByte(); } if ((AttributeType & 0x400) != 0) { attributes[10] = reader.ReadByte(); } if ((AttributeType & 0x800) != 0) { attributes[11] = reader.ReadUInt32(); } if ((AttributeType & 0x1000) != 0) { attributes[12] = reader.ReadUInt32(); } if ((AttributeType & 0x2000) != 0) { attributes[13] = reader.ReadUInt32(); } else if ((AttributeType & 0x4000) != 0) { attributes[14] = reader.ReadUInt32(); } }