示例#1
0
 /// <summary>
 /// BPS of the mp3 file
 /// </summary>
 //public byte BPS { get { return bps; } set { bps = value; } }
 /// <summary>
 /// Creates a WzSoundProperty with the specified name
 /// </summary>
 /// <param name="name">The name of the property</param>
 /// <param name="reader">The wz reader</param>
 /// <param name="parseNow">Indicating whether to parse the property now</param>
 public WzSoundProperty(string name, WzBinaryReader reader, bool parseNow)
 {
     this.name = name;
     wzReader = reader;
     reader.BaseStream.Position++;
     offs = reader.BaseStream.Position;
     //note - soundDataLen does NOT include the length of the header.
     int soundDataLen = reader.ReadCompressedInt();
     len_ms = reader.ReadCompressedInt();
     header = reader.ReadBytes(soundHeaderMask.Length);
     ParseHeader();
     if (parseNow)
         mp3bytes = reader.ReadBytes(soundDataLen);
     else
         reader.BaseStream.Position += soundDataLen;
 }
示例#2
0
		internal void ParseSound(WzBinaryReader reader)
		{
			reader.BaseStream.Position++;
			int soundDataLen = reader.ReadCompressedInt();
			reader.ReadCompressedInt();
			mp3bytes = reader.ReadBytes(soundDataLen);
		}
示例#3
0
		internal void ParseMainWzDirectory()
		{
			if (this.path == null)
			{
				Console.WriteLine("[Error] Path is null");
				return;
			}

			WzBinaryReader reader = new WzBinaryReader(File.Open(this.path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), WzIv);

			this.Header = new WzHeader();
			this.Header.Ident = reader.ReadString(4);
			this.Header.FSize = reader.ReadUInt64();
			this.Header.FStart = reader.ReadUInt32();
			this.Header.Copyright = reader.ReadNullTerminatedString();
			reader.ReadBytes((int)(Header.FStart - reader.BaseStream.Position));
			reader.Header = this.Header;
			this.version = reader.ReadInt16();
			if (fileVersion == -1)
			{
				for (int j = 0; j < short.MaxValue; j++)
				{
					this.fileVersion = (short)j;
					this.versionHash = GetVersionHash(version, fileVersion);
					if (this.versionHash != 0)
					{
						reader.Hash = this.versionHash;
						long position = reader.BaseStream.Position;
						WzDirectory testDirectory = null;
						try
						{
							testDirectory = new WzDirectory(reader, this.name, this.versionHash, this.WzIv);
							testDirectory.ParseDirectory();
						}
						catch
						{
							reader.BaseStream.Position = position;
							continue;
						}
						WzImage testImage = testDirectory.GetChildImages()[0];

						try
						{
							reader.BaseStream.Position = testImage.Offset;
							byte checkByte = reader.ReadByte();
							reader.BaseStream.Position = position;
							testDirectory.Dispose();
							switch (checkByte)
							{
								case 0x73:
								case 0x1b:
									{
										WzDirectory directory = new WzDirectory(reader, this.name, this.versionHash, this.WzIv);
										directory.ParseDirectory();
										this.wzDir = directory;
										return;
									}
							}
							reader.BaseStream.Position = position;
						}
						catch
						{
							reader.BaseStream.Position = position;
						}
					}
				}
				throw new Exception("Error with game version hash : The specified game version is incorrect and WzLib was unable to determine the version itself");
			}
			else
			{
				this.versionHash = GetVersionHash(version, fileVersion);
				reader.Hash = this.versionHash;
				WzDirectory directory = new WzDirectory(reader, this.name, this.versionHash, this.WzIv);
				directory.ParseDirectory();
				this.wzDir = directory;
			}
		}
示例#4
0
		internal WzPngProperty(WzBinaryReader reader)
		{
			// Read compressed bytes
			width = reader.ReadCompressedInt();
			height = reader.ReadCompressedInt();
			format = reader.ReadCompressedInt();
			format2 = reader.ReadByte();
			reader.BaseStream.Position += 4;
			int len = reader.ReadInt32() - 1;
			reader.BaseStream.Position += 1;

			if (len > 0)
				compressedBytes = reader.ReadBytes(len);
		}