Inheritance: IDisposable
コード例 #1
0
ファイル: CommHeaders.cs プロジェクト: pkt30/OscarLib
 /// <summary>
 /// Initializes a new SNACHeader from a bytestream
 /// </summary>
 /// <param name="byteStream"></param>
 internal SNACHeader(ByteStream byteStream)
 {
     FamilyServiceID = byteStream.ReadUshort();
     FamilySubtypeID = byteStream.ReadUshort();
     Flags = byteStream.ReadUshort();
     requestID = byteStream.ReadUint();
 }
コード例 #2
0
ファイル: LEV.cs プロジェクト: joeriedel/DarkForcesUnity
 public LEV(string name, byte[] data, object createArgs)
     : base(name, Type.LEV)
 {
     using (MemoryStream backing = new MemoryStream(data, false))
     using (ByteStream stream = new ByteStream(backing)) {
         ParseLevel(new Tokenizer(name, Tokenizer.ECommentStyle.LEV, stream));
     }
 }
コード例 #3
0
ファイル: GMD.cs プロジェクト: joeriedel/DarkForcesUnity
 public GMD(string name, byte[] data, object createArgs)
     : base(name, Type.GMD)
 {
     using (MemoryStream backing = new MemoryStream(data, false))
     using (ByteStream stream = new ByteStream(backing)) {
         ExtractMIDI(stream);
     }
 }
コード例 #4
0
 public override object ReadObject(ByteStream _TargetStream)
 {
     ushort len = (ushort)Converter.Converters[typeof(ushort)].ReadObject(_TargetStream);
     string[] strings = new string[len];
     for (int i = 0; i < len; i++)
     {
         strings[i] = (string)Converter.Read(_TargetStream);
     }
     return strings;
 }
コード例 #5
0
 public override void WriteObject(object _Object, ByteStream _TargetStream)
 {
     string[] strings = (string[])_Object;
     Converter.Converters[typeof(ushort)].WriteObject(strings.Length, _TargetStream);
     foreach (string s in strings)
     {
         Converter.Write(s, _TargetStream);
     }
     foreach (char c in (string)_Object) _TargetStream.Write((byte)c);
 }
コード例 #6
0
ファイル: FME.cs プロジェクト: joeriedel/DarkForcesUnity
    public FME(string name, byte[] data, object createArgs)
        : base(name, Type.FME)
    {
        BM.CreateArgs args = createArgs as BM.CreateArgs;
        if (args == null) {
            throw new System.ArgumentException("FME requires BM.CreateArgs.");
        }

        using (MemoryStream backing = new MemoryStream(data, false))
        using (ByteStream stream = new ByteStream(backing)) {
            _frame = ReadHeader1(stream, args, out _header);
        }
    }
コード例 #7
0
ファイル: BM.cs プロジェクト: joeriedel/DarkForcesUnity
    public BM(string name, byte[] data, object createArgs)
        : base(name, Type.BM)
    {
        CreateArgs args = createArgs as CreateArgs;
        if (args == null) {
            throw new System.ArgumentException("BM requires BM.CreateArgs.");
        }

        using (MemoryStream backing = new MemoryStream(data, false))
        using (ByteStream stream = new ByteStream(backing)) {
            ParseBitmap(stream, args);
        }
    }
コード例 #8
0
ファイル: MyBot.cs プロジェクト: Yonom/ByteChannel
 public void On(JoinCompleteEvent e)
 {
     this._byteChannel = new ByteChannel<Player>(new CoinChannel());
     var bp = new ByteProtocol<Player>(this._byteChannel);
     var up = new UserProtocol<Player>(bp.RegisterProtocol("ByetUserStreams.Demo"), p => (uint)p.UserId);
     var stream = new ByteStream(up.GetUserChannel(this.Players.OwnPlayer, this.Players.OwnPlayer));
     {
         var writer = new StreamWriter(stream) {AutoFlush = true};
         writer.Write("Hello world!\n");
         var reader = new StreamReader(stream);
         ThreadPool.QueueUserWorkItem(o =>
         {
             while (true)
             {
                 Console.Write((char) reader.Read());
             }
         });
     }
 }
コード例 #9
0
ファイル: TsProgram.cs プロジェクト: heksesang/bmff
        void ProgramMapTableReceived(object sender, TsStreamEventArgs eventArgs)
        {
            var e = eventArgs as TsStreamEventArgs<TsTable>;
            if (e == null) return;

            lock (_syncObject)
            {
                var pmt = e.DecodedUnit.TableIdentifier == TableIdentifier.ProgramMap ? (ProgramMapTable) e.DecodedUnit : null;
                if (pmt == null) return;

                Debug.WriteLine("Program Map Received");
                Debug.WriteLine("Program Number: " + pmt.ProgramNumber + " Program Clock Reference PID: " +
                                pmt.ProgramClockReferencePid);

                Info = pmt.ProgramInfo;
                foreach (var pm in pmt.Rows)
                {
                    Debug.WriteLine("******** " + pm.StreamType + " on PID " + pm.PacketIdentifier);
#if DEBUG
                    foreach (var descriptor in pm.StreamInfo)
                        Debug.WriteLine("\tHas " + descriptor.Tag + " descriptor.");
#endif
                    var stream =
                        (from s in Streams where s.PacketIdentifier == pm.PacketIdentifier select s).FirstOrDefault();
                    if (stream == null)
                    {
                        try
                        {
                            stream = (TsStream) Activator.CreateInstance(TsStream.StreamTypes[pm.StreamType]);
                            stream.PacketIdentifier = pm.PacketIdentifier;
                        }
                        catch (Exception)
                        {
                            stream = new ByteStream() {PacketIdentifier = pm.PacketIdentifier};
                        }
                        Streams.Add(stream);
                        OnStreamAdded(stream);
                    }
                    stream.Type = pm.StreamType;
                    stream.Info = pm.StreamInfo;
                }
            }
        }
コード例 #10
0
ファイル: TransferService.cs プロジェクト: SiteView/ECC8.13
            private void OnSocket5Processed(Socket5 sender, bool result)
            {
                List<string> keys = new List<string>();
                foreach (KeyValuePair<string, ByteStream> byteStream in this.proxyList)
                {
                    if (byteStream.Value.Initiator != null && byteStream.Value.Target != null)
                    {
                        if (!byteStream.Value.Initiator.Connected || !byteStream.Value.Target.Connected)
                        {
                            keys.Add(byteStream.Key);
                        }
                    }
                }

                foreach (string key in keys)
                {
                    this.proxyList.Remove(key);
                }

                keys.Clear();

                if (result)
                {
                    if (!this.proxyList.ContainsKey(sender.BindAddress))
                    {
                        ByteStream byteStream = new ByteStream();
                        byteStream.Target = sender.SocketConnection;
                        this.proxyList.Add(sender.BindAddress, byteStream);
                    }
                    else
                    {
                        ByteStream byteStream = this.proxyList[sender.BindAddress];
                        byteStream.Initiator = sender.SocketConnection;
                        this.proxyList[sender.BindAddress] = byteStream;
                    }
                }
                else
                {
                    sender.OnSocket5Processed -= new Socket5Handler(OnSocket5Processed);
                    sender.Stop();

                }
            }
コード例 #11
0
ファイル: GMD.cs プロジェクト: joeriedel/DarkForcesUnity
    void ExtractMIDI(ByteStream stream)
    {
        if (stream.ReadString(4) != "MIDI") {
            throw new InvalidDataException("Not a GMD file!");
        }
        stream.Skip(4);

        string type;
        while ((type = GetChunkType(stream)) != null) {
            if (type == "MThd") {
                long size = stream.Length - stream.Position;
                _midiData = stream.Read((int)size);
                return;
            }

            if (!SkipChunk(stream)) {
                break;
            }
        }

        throw new InvalidDataException("Could not locate midi track header!");
    }
コード例 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AskForAllianceRankingListMessage"/> class.
 /// </summary>
 /// <param name="Stream">The stream.</param>
 public AskForAllianceRankingListMessage(ByteStream Stream) : base(Stream)
 {
     // AskForAllianceRankingListMessage.
 }
コード例 #13
0
 public override void write(ByteStream queue)
 {
     queue.WriteByte(GetShiftedTypeId(TYPE_ID));
     queue.WriteByte(OriginalInvokeId);
     ErrorValue.write(queue);
 }
コード例 #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Report_User_Message"/> class.
 /// </summary>
 /// <param name="Device">The device.</param>
 /// <param name="Reader">The reader.</param>
 public Report_User_Message(Device Device, ByteStream ByteStream) : base(Device, ByteStream)
 {
     // Report_User_Message.
 }
コード例 #15
0
 public override void WriteObject(object _Object, ByteStream _TargetStream)
 {
     string obj = (string)_Object;
     Converter.Converters[typeof(ushort)].WriteObject((ushort)obj.Length, _TargetStream);
     foreach (char c in (string)_Object) _TargetStream.Write((byte)c);
 }
コード例 #16
0
ファイル: ChatRoomInfo.cs プロジェクト: pkt30/OscarLib
        /// <summary>
        /// Processes a message received from a chat room -- SNAC(0E,06)
        /// </summary>
        /// <param name="dp">A <see cref="DataPacket"/> object containing SNAC(0E,06)</param>
        internal void ProcessIncomingMessage(DataPacket dp)
        {
            UserInfo sender = new UserInfo();
            byte[] message;
            Encoding encoding = Encoding.ASCII;
            string language = "";

            byte[] cookie = dp.Data.ReadByteArray(8);
            ushort channel = dp.Data.ReadUshort();
            using (TlvBlock outerTlvs = new TlvBlock(dp.Data.ReadByteArrayToEnd()))
            {
                using (ByteStream userStream = new ByteStream(outerTlvs.ReadByteArray(0x0003)))
                {
                    sender = userStream.ReadUserInfo();
                }

                using (TlvBlock innerTlvs = new TlvBlock(outerTlvs.ReadByteArray(0x0005)))
                {
                    message = innerTlvs.ReadByteArray(0x0001);
                    encoding = Marshal.AolMimeToEncoding(innerTlvs.ReadString(0x0002, Encoding.ASCII));
                    language = innerTlvs.ReadString(0x0003, Encoding.ASCII);
                }
            }

            if (MessageReceived != null)
            {
                IM msg = new IM(sender);
                msg.Message = Encoding.Unicode.GetString(Encoding.Convert(encoding, Encoding.Unicode, message));
                msg.Cookie = Cookie.GetReceivedCookie(cookie);
                MessageReceived(this, new MessageReceivedEventArgs(msg));
            }
        }
コード例 #17
0
 /// <summary>
 /// Decodes this instance.
 /// </summary>
 public override void Decode(ByteStream Stream)
 {
     this.AchievementData = Stream.DecodeData <AchievementData>();
     base.Decode(Stream);
 }
コード例 #18
0
 public LifeSafetyOperation(ByteStream queue) : base(queue)
 {
 }
コード例 #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MatchmakeInfoMessage"/> class.
 /// </summary>
 /// <param name="EstimedTime">The estimated time.</param>
 public MatchmakeInfoMessage(ByteStream Stream) : base(Stream)
 {
     // MatchmakeInfoMessage.
 }
コード例 #20
0
 public override void Server_ReceiveMessage(int connectionId, ByteStream msgData, LLServer server)
 {
     // Not required
 }
コード例 #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AllianceOnlineStatusUpdatedMessage"/> class.
 /// </summary>
 /// <param name="Stream">The stream.</param>
 public AllianceOnlineStatusUpdatedMessage(ByteStream Stream) : base(Stream)
 {
     // AllianceOnlineStatusUpdatedMessage.
 }
コード例 #22
0
 public abstract void Encode(ByteStream stream);
コード例 #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AvatarStreamMessage"/> class.
 /// </summary>
 /// <param name="Stream">The stream.</param>
 public AvatarStreamMessage(ByteStream Stream) : base(Stream)
 {
     // AvatarStreamMessage.
 }
コード例 #24
0
 /// <summary>	
 /// <p><strong>Applies to: </strong>desktop apps | Metro style apps</p><p> Creates a media source from a byte stream. This method is synchronous. </p>	
 /// </summary>	
 /// <param name="stream"><dd> <p> Pointer to the byte stream's <strong><see cref="SharpDX.MediaFoundation.IByteStream"/></strong> interface. </p> </dd></param>	
 /// <param name="url"><dd> <p> Null-terminated string that contains the URL of the byte stream. The URL is optional and can be <strong><c>null</c></strong>. See Remarks for more information. </p> </dd></param>	
 /// <param name="flags"><dd> <p> Bitwise <strong>OR</strong> of flags. See <strong>Source Resolver Flags</strong>. </p> </dd></param>	
 /// <param name="propertyStore"><dd> <p> Pointer to the <strong><see cref="SharpDX.ComObject"/></strong> interface of a property store. The method passes the property store to the byte-stream handler. The byte-stream handler can use the property store to configure the media source. This parameter can be <strong><c>null</c></strong>. For more information, see Configuring a Media Source. </p> </dd></param>	
 /// <param name="objectType"><dd> <p> Receives a member of the <strong><see cref="SharpDX.MediaFoundation.ObjectType"/></strong> enumeration, specifying the type of object that was created. </p> </dd></param>	
 /// <returns>a reference to the media source's <strong><see cref="SharpDX.ComObject"/></strong> interface. The caller must release the interface.</returns>	
 /// <remarks>	
 /// <p>The <em>dwFlags</em> parameter must contain the <strong><see cref="SharpDX.MediaFoundation.SourceResolverFlags.MediaSource"/></strong> flag and should not contain the <strong><see cref="SharpDX.MediaFoundation.SourceResolverFlags.ByteStream"/></strong> flag.</p><p>The source resolver attempts to find one or more byte-stream handlers for the byte stream, based on the file name extension of the URL, or the MIME type of the byte stream (or both). The URL is specified in the optional <em>pwszURL</em> parameter, and the MIME type may be specified in the <strong><see cref="SharpDX.MediaFoundation.ByteStreamAttributeKeys.ContentType"/></strong> attribute on the byte stream. Byte-stream handlers are registered by file name extension or MIME type, or both, as described in Scheme Handlers and Byte-Stream Handlers. The caller should specify at least one of these values (both if possible):</p><ul> <li> Specify the URL in the <em>pwszURL</em> parameter. </li> <li> Specify the MIME type by setting the <strong><see cref="SharpDX.MediaFoundation.ByteStreamAttributeKeys.ContentType"/></strong> attribute on the byte stream. (This attribute might be set already when you create the byte stream, depending on how the byte stream was created.) </li> </ul><p><strong>Note</strong>??This method cannot be called remotely.</p>	
 /// </remarks>	
 /// <msdn-id>ms704671</msdn-id>	
 /// <unmanaged>HRESULT IMFSourceResolver::CreateObjectFromByteStream([In] IMFByteStream* pByteStream,[In] const wchar_t* pwszURL,[In] unsigned int dwFlags,[In] IPropertyStore* pProps,[Out] MF_OBJECT_TYPE* pObjectType,[Out] IUnknown** ppObject)</unmanaged>	
 /// <unmanaged-short>IMFSourceResolver::CreateObjectFromByteStream</unmanaged-short>	
 public SharpDX.ComObject CreateObjectFromStream(ByteStream stream,
     string url,
     SourceResolverFlags flags,
     ComObject propertyStore,
     out SharpDX.MediaFoundation.ObjectType objectType)
 {
     ComObject result;
     CreateObjectFromByteStream_(stream.NativePointer,
         url,
         (int)(flags | SourceResolverFlags.MediaSource),
         propertyStore,
         out objectType,
         out result);
     return result;
 }
コード例 #25
0
 public override void WriteObject(object _Object, ByteStream _TargetStream)
 {
     _TargetStream.Write(BitConverter.GetBytes((int)_Object));
 }
コード例 #26
0
 public void SetBytestream(IRandomAccessStream streamHandle)
 {
     byteStream = new ByteStream(streamHandle);
     mediaEngineEx.SetSourceFromByteStream(byteStream, Url);
 }
コード例 #27
0
ファイル: ChatRoomInfo.cs プロジェクト: pkt30/OscarLib
        /// <summary>
        /// Send a message to this chatroom using a specific character set and language
        /// </summary>
        /// <param name="message">The message to send</param>
        /// <param name="charset">The character set in which to encode the message</param>
        /// <param name="language">The two-letter code of the language of the message</param>
        private void SendMessage(string message, Encoding charset, string language)
        {
            if (!Connection.Connected)
            {
                // TODO:  The semantics here aren't right
                throw new NotLoggedInException();
            }

            SNACHeader sh = new SNACHeader();
            sh.FamilyServiceID = 0x000E;
            sh.FamilySubtypeID = (ushort) ChatService.MessageFromClient;

            byte[] cookie = new byte[8];
            Random r = new Random();
            r.NextBytes(cookie);

            ByteStream stream = new ByteStream();
            stream.WriteByteArray(cookie);
            stream.WriteUshort(0x0003);

            TlvBlock tlvs = new TlvBlock();
            using (TlvBlock messageBlock = new TlvBlock())
            {
                Encoding messageEncoding = UtilityMethods.FindBestOscarEncoding(message);

                messageBlock.WriteString(CHATMESSAGE_MESSAGE, message, messageEncoding);
                messageBlock.WriteString(CHATMESSAGE_CHARSET,
                    UtilityMethods.OscarEncodingToString(messageEncoding), Encoding.ASCII);
                messageBlock.WriteString(CHATMESSAGE_LANGUAGE, language, Encoding.ASCII);
                messageBlock.WriteString(CHATMESSAGE_CONTENTTYPE, "text/x-aolrtf", Encoding.ASCII);
                messageBlock.WriteString(CHATMESSAGE_ENCODING, "binary", Encoding.ASCII);

                tlvs.WriteByteArray(0x0005, messageBlock.GetBytes());
            }
            tlvs.WriteEmpty(0x0001);

            stream.WriteTlvBlock(tlvs);

            DataPacket dp = Marshal.BuildDataPacket(Connection.ParentSession, sh, stream);
            dp.ParentConnection = Connection;
            SNACFunctions.BuildFLAP(dp);
        }
コード例 #28
0
 public virtual void ExploreSpawnAppearance(StreamWriter outputStream, ByteStream buffer, PacketDirection direction)
 {
     throw new NotImplementedException();
 }
コード例 #29
0
 public override void write(ByteStream queue)
 {
     write(queue, ObjectIdentifier, 0);
     writeOptional(queue, ListOfResults, 1);
 }
コード例 #30
0
ファイル: BM.cs プロジェクト: joeriedel/DarkForcesUnity
    private void ParseBitmap(ByteStream stream, CreateArgs createArgs)
    {
        if ((stream.ReadString(3) != "BM ") || (stream.ReadByte() != 0x1e)){
            throw new InvalidDataException("Not a BM file.");
        }

        Header header = ReadHeader(stream, EHeaderType.FileHeader);
        DebugCheck.Assert(stream.Position == 32);

        if ((header.W == 1) && (header.H != 1)) {
            // multiple bitmaps in this file.
            _fps = stream.ReadByte();
            stream.Skip(1);

            long baseOfs = stream.Position;

            int[] offsets = new int[header.IY];
            for (int i = 0; i < offsets.Length; ++i) {
                offsets[i] = stream.ReadLittleInt32();
            }

            for (int i = 0; i < offsets.Length; ++i) {
                stream.SeekSet(offsets[i] + baseOfs);
                Header subHeader = ReadHeader(stream, EHeaderType.SubHeader);
                Frame frame = ReadColumns(stream, subHeader, null, createArgs);
                _frames.Add(frame);
            }
        } else {
            int[] columnOffsets = null;

            if (header.Compressed != 0) {
                // read column offsets.
                stream.SeekSet(header.DataSize);
                columnOffsets = new int[header.W];

                for (int i = 0; i < columnOffsets.Length; ++i) {
                    columnOffsets[i] = stream.ReadLittleInt32() + 32;
                }
            }

            Frame frame = ReadColumns(stream, header, columnOffsets, createArgs);
            _frames.Add(frame);
        }
    }
コード例 #31
0
ファイル: BinaryPV.cs プロジェクト: MatyRi/BACnetNetduino
 public BinaryPV(ByteStream queue) : base(queue)
 {
 }
コード例 #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogicCollectShipRewardCommand"/> class.
 /// </summary>
 public LogicCollectShipRewardCommand(Connection connection, ByteStream stream) : base(connection, stream)
 {
     // LogicCollectShipRewardCommand.
 }
コード例 #33
0
 internal Error(ByteStream queue)
 {
     queue.ReadByte(); // Ignore the first byte. No news there.
     OriginalInvokeId = queue.ReadByte();
     ErrorValue       = BaseError.createBaseError(queue);
 }
コード例 #34
0
ファイル: Message.cs プロジェクト: marinehero/microserver
            public byte[] ToArray()
            {
                ByteStream result = new ByteStream(Size);

                result
                    .Append(domain.ToArray())
                    .Append(Marshalling.Struct.GetBytes(new Tail { Type = Type, Class = Class }));

                return result.ToArray();
            }
コード例 #35
0
 public override void WriteObject(object _Object, ByteStream _TargetStream)
 {
     _TargetStream.Write((byte)_Object);
 }
コード例 #36
0
 /// <summary>	
 /// <p><strong>Applies to: </strong>desktop apps | Metro style apps</p><p> Creates a media source from a byte stream. This method is synchronous. </p>	
 /// </summary>	
 /// <param name="stream"><dd> <p> Pointer to the byte stream's <strong><see cref="SharpDX.MediaFoundation.IByteStream"/></strong> interface. </p> </dd></param>	
 /// <param name="url"><dd> <p> Null-terminated string that contains the URL of the byte stream. The URL is optional and can be <strong><c>null</c></strong>. See Remarks for more information. </p> </dd></param>	
 /// <param name="flags"><dd> <p> Bitwise <strong>OR</strong> of flags. See <strong>Source Resolver Flags</strong>. </p> </dd></param>	
 /// <returns>a reference to the media source's <strong><see cref="SharpDX.ComObject"/></strong> interface. The caller must release the interface.</returns>	
 /// <remarks>	
 /// <p>The <em>dwFlags</em> parameter must contain the <strong><see cref="SharpDX.MediaFoundation.SourceResolverFlags.MediaSource"/></strong> flag and should not contain the <strong><see cref="SharpDX.MediaFoundation.SourceResolverFlags.ByteStream"/></strong> flag.</p><p>The source resolver attempts to find one or more byte-stream handlers for the byte stream, based on the file name extension of the URL, or the MIME type of the byte stream (or both). The URL is specified in the optional <em>pwszURL</em> parameter, and the MIME type may be specified in the <strong><see cref="SharpDX.MediaFoundation.ByteStreamAttributeKeys.ContentType"/></strong> attribute on the byte stream. Byte-stream handlers are registered by file name extension or MIME type, or both, as described in Scheme Handlers and Byte-Stream Handlers. The caller should specify at least one of these values (both if possible):</p><ul> <li> Specify the URL in the <em>pwszURL</em> parameter. </li> <li> Specify the MIME type by setting the <strong><see cref="SharpDX.MediaFoundation.ByteStreamAttributeKeys.ContentType"/></strong> attribute on the byte stream. (This attribute might be set already when you create the byte stream, depending on how the byte stream was created.) </li> </ul><p><strong>Note</strong>??This method cannot be called remotely.</p>	
 /// </remarks>	
 /// <msdn-id>ms704671</msdn-id>	
 /// <unmanaged>HRESULT IMFSourceResolver::CreateObjectFromByteStream([In] IMFByteStream* pByteStream,[In] const wchar_t* pwszURL,[In] unsigned int dwFlags,[In] IPropertyStore* pProps,[Out] MF_OBJECT_TYPE* pObjectType,[Out] IUnknown** ppObject)</unmanaged>	
 /// <unmanaged-short>IMFSourceResolver::CreateObjectFromByteStream</unmanaged-short>	
 public SharpDX.ComObject CreateObjectFromStream(ByteStream stream,
     string url,
     SourceResolverFlags flags)
 {
     ObjectType objectType;
     return CreateObjectFromStream(stream, url, flags, null, out objectType);
 }
コード例 #37
0
 public virtual void ExploreZonePlayerToBind(StreamWriter outputStream, ByteStream buffer, PacketDirection direction)
 {
     throw new NotImplementedException();
 }
コード例 #38
0
ファイル: LockStatus.cs プロジェクト: MatyRi/BACnetNetduino
 public LockStatus(ByteStream queue) : base(queue)
 {
 }
コード例 #39
0
ファイル: BM.cs プロジェクト: joeriedel/DarkForcesUnity
 private static void DecodeColumn(ByteStream stream, byte[] columnOut, int compressed)
 {
     if (compressed == 0) {
         // uncompressed.
         for (int y = 0; y < columnOut.Length; ++y) {
             columnOut[y] = (byte)stream.ReadByte();
         }
     } else if (compressed == 1) {
         // rle1
         for (int y = 0; y < columnOut.Length; ) {
             int code = stream.ReadByte();
             if (code > 128) {
                 byte color = (byte)stream.ReadByte();
                 int repeat = code & 0x7f;
                 while (repeat-- > 0) {
                     columnOut[y++] = color;
                 }
             } else {
                 while (code-- > 0) {
                     columnOut[y++] = (byte)stream.ReadByte();
                 }
             }
         }
     } else if (compressed == 2) {
         // rle2 (transparent coding)
         for (int y = 0; y < columnOut.Length; ) {
             int code = stream.ReadByte();
             if (code > 128) {
                 int skip = code & 0x7f;
                 while (skip-- > 0) {
                     columnOut[y++] = 0;
                 }
             } else {
                 while (code-- > 0) {
                     columnOut[y++] = (byte)stream.ReadByte();
                 }
             }
         }
     }
 }
コード例 #40
0
 public virtual void ExploreRequestClientZoneChange(StreamWriter outputStream, ByteStream buffer, PacketDirection direction)
 {
     throw new NotImplementedException();
 }
コード例 #41
0
ファイル: BM.cs プロジェクト: joeriedel/DarkForcesUnity
    private Header ReadHeader(ByteStream stream, EHeaderType headerType)
    {
        Header header = new Header();

        if (headerType == EHeaderType.FileHeader) {
            header.W = stream.ReadLittleShort16();
            header.H = stream.ReadLittleShort16();
            stream.Skip(2);
            header.IY = stream.ReadLittleShort16();
            header.Transparent = stream.ReadByte();
            stream.Skip(1);
            header.Compressed = stream.ReadLittleShort16();
            header.DataSize = stream.ReadLittleInt32();
            stream.Skip(12);
        } else {
            header.W = stream.ReadLittleShort16();
            header.H = stream.ReadLittleShort16();
            stream.Skip(20);
            header.Transparent = stream.ReadByte();
            stream.Skip(3);
        }

        return header;
    }
コード例 #42
0
 public virtual void ExploreSubItem(StreamWriter outputStream, ref ByteStream buffer)
 {
     throw new NotImplementedException();
 }
コード例 #43
0
ファイル: BM.cs プロジェクト: joeriedel/DarkForcesUnity
    public static Frame ReadColumns(ByteStream stream, Header header, int[] columnOffsets, CreateArgs createArgs)
    {
        try {
            Texture2D texture = new Texture2D(header.W, header.H, createArgs.TextureFormat, createArgs.bMipmap, false);

            texture.anisoLevel = createArgs.AnisoLevel;
            texture.filterMode = createArgs.FilterMode;
            texture.wrapMode = createArgs.WrapMode;

            Color32[] pixels = new Color32[header.W*header.H];
            byte[] column = new byte[header.H];
            bool bIsTransparent = (header.Transparent & 0x8) != 0;

            for (int x = 0; x < header.W; ++x) {
                if (columnOffsets != null) {
                    stream.SeekSet(columnOffsets[x]);
                }

                DecodeColumn(stream, column, header.Compressed);

                if (createArgs.TextureFormat == TextureFormat.Alpha8) {
                    int pixelOfs = x;

                    for (int y = 0; y < header.H; ++y, pixelOfs += header.W) {
                        byte color = column[y];
                        pixels[pixelOfs] = new Color32(color, color, color, color);
                    }

                } else {
                    int pixelOfs = x;

                    for (int y = 0; y < header.H; ++y, pixelOfs += header.W) {
                        byte color = column[y];

                        if (bIsTransparent && (color == 0)) {
                            pixels[pixelOfs] = PAL.Transparent;
                        } else {
                            pixels[pixelOfs] = createArgs.Pal.Colors[color];
                        }
                    }
                }
            }

            texture.SetPixels32(pixels);
            texture.Apply();

            return new Frame(texture, bIsTransparent);
        } catch (UnityException e) {
            throw e;
        }
    }
コード例 #44
0
 public virtual void DecodeItemPacket(StreamWriter outputStream, ByteStream buffer, PacketDirection direction)
 {
     throw new NotImplementedException();
 }
コード例 #45
0
 public virtual void ExploreOpenNewTasksWindow(StreamWriter outputStream, ByteStream buffer, PacketDirection direction)
 {
     throw new NotImplementedException();
 }
コード例 #46
0
 public virtual void ExploreMercenaryPurchaseWindow(StreamWriter outputStream, ByteStream buffer, PacketDirection direction)
 {
     throw new NotImplementedException();
 }
コード例 #47
0
 /// <summary>	
 /// <p><strong>Applies to: </strong>desktop apps | Metro style apps</p><p> Creates a media source from a byte stream. This method is synchronous. </p>	
 /// </summary>	
 /// <param name="stream"><dd> <p> Pointer to the byte stream's <strong><see cref="SharpDX.MediaFoundation.IByteStream"/></strong> interface. </p> </dd></param>	
 /// <param name="url"><dd> <p> Null-terminated string that contains the URL of the byte stream. The URL is optional and can be <strong><c>null</c></strong>. See Remarks for more information. </p> </dd></param>	
 /// <param name="flags"><dd> <p> Bitwise <strong>OR</strong> of flags. See <strong>Source Resolver Flags</strong>. </p> </dd></param>	
 /// <param name="objectType"><dd> <p> Receives a member of the <strong><see cref="SharpDX.MediaFoundation.ObjectType"/></strong> enumeration, specifying the type of object that was created. </p> </dd></param>	
 /// <returns>a reference to the media source's <strong><see cref="SharpDX.ComObject"/></strong> interface. The caller must release the interface.</returns>	
 /// <remarks>	
 /// <p>The <em>dwFlags</em> parameter must contain the <strong><see cref="SharpDX.MediaFoundation.SourceResolverFlags.MediaSource"/></strong> flag and should not contain the <strong><see cref="SharpDX.MediaFoundation.SourceResolverFlags.ByteStream"/></strong> flag.</p><p>The source resolver attempts to find one or more byte-stream handlers for the byte stream, based on the file name extension of the URL, or the MIME type of the byte stream (or both). The URL is specified in the optional <em>pwszURL</em> parameter, and the MIME type may be specified in the <strong><see cref="SharpDX.MediaFoundation.ByteStreamAttributeKeys.ContentType"/></strong> attribute on the byte stream. Byte-stream handlers are registered by file name extension or MIME type, or both, as described in Scheme Handlers and Byte-Stream Handlers. The caller should specify at least one of these values (both if possible):</p><ul> <li> Specify the URL in the <em>pwszURL</em> parameter. </li> <li> Specify the MIME type by setting the <strong><see cref="SharpDX.MediaFoundation.ByteStreamAttributeKeys.ContentType"/></strong> attribute on the byte stream. (This attribute might be set already when you create the byte stream, depending on how the byte stream was created.) </li> </ul><p><strong>Note</strong>??This method cannot be called remotely.</p>	
 /// </remarks>	
 /// <msdn-id>ms704671</msdn-id>	
 /// <unmanaged>HRESULT IMFSourceResolver::CreateObjectFromByteStream([In] IMFByteStream* pByteStream,[In] const wchar_t* pwszURL,[In] unsigned int dwFlags,[In] IPropertyStore* pProps,[Out] MF_OBJECT_TYPE* pObjectType,[Out] IUnknown** ppObject)</unmanaged>	
 /// <unmanaged-short>IMFSourceResolver::CreateObjectFromByteStream</unmanaged-short>	
 public SharpDX.ComObject CreateObjectFromStream(ByteStream stream,
     string url,
     SourceResolverFlags flags,
     out SharpDX.MediaFoundation.ObjectType objectType)
 {
     return CreateObjectFromStream(stream, url, flags, null, out objectType);
 }
コード例 #48
0
 public virtual void ExploreCastSpell(StreamWriter outputStream, ByteStream buffer, PacketDirection direction)
 {
     throw new NotImplementedException();
 }
コード例 #49
0
 public override object ReadObject(ByteStream _TargetStream)
 {
     return BitConverter.ToInt32(_TargetStream.Read(4), 0);
 }
コード例 #50
0
 public virtual void ExploreMercenaryDataResponse(StreamWriter outputStream, ByteStream buffer, PacketDirection direction)
 {
     throw new NotImplementedException();
 }
コード例 #51
0
ファイル: ChatRoomInfo.cs プロジェクト: pkt30/OscarLib
        /// <summary>
        /// Creates a new <see cref="ChatRoom"/> from a received <see cref="ByteStream"/>
        /// </summary>
        public ChatRoom(ByteStream stream)
        {
            exchangeNumber = stream.ReadUshort();
            fullName = stream.ReadString(stream.ReadByte(), Encoding.ASCII);
            instance = stream.ReadUshort();

            // A small chat room info block will only contain the bare essentials:
            // exchange number, chat room name, and instance number.
            // The chat room class really wants a display name, so parse one here.
            if (stream.HasMoreData)
            {
                detailLevel = stream.ReadByte();
                unknownCode = stream.ReadUshort(); // No idea what this is

                using (TlvBlock block = new TlvBlock(stream.ReadByteArrayToEnd()))
                {
                    flags = block.ReadUshort(CHATROOM_FLAGS);
                    if (block.HasTlv(CHATROOM_CREATION_TIME))
                    {
                        creationTime = block.ReadDateTime(CHATROOM_CREATION_TIME);
                    }
                    maxMessageLength = block.ReadUshort(CHATROOM_MESSAGE_LENGTH);
                    maxOccupants = block.ReadUshort(CHATROOM_MAX_OCCUPANTS);
                    displayName = block.ReadString(CHATROOM_DISPLAYNAME, Encoding.ASCII);
                    creationPermissions = block.ReadByte(CHATROOM_PERMISSIONS);

                    string charset = block.ReadString(CHATROOM_CHARSET1, Encoding.ASCII);
                    if (!String.IsNullOrEmpty(charset))
                    {
                        charSet1 = Encoding.GetEncoding(charset);
                    }
                    language1 = block.ReadString(CHATROOM_LANGUAGE1, Encoding.ASCII);

                    charset = block.ReadString(CHATROOM_CHARSET2, Encoding.ASCII);
                    if (!String.IsNullOrEmpty(charset))
                    {
                        charSet2 = Encoding.GetEncoding(charset);
                    }
                    language2 = block.ReadString(CHATROOM_LANGUAGE2, Encoding.ASCII);

                    contentType = block.ReadString(CHATROOM_CONTENTTYPE, Encoding.ASCII);
                }
            }

            // Make sure there's a display name to show
            if (String.IsNullOrEmpty(displayName))
            {
                Match match = AolUriParser.Match(fullName);
                if (match.Success)
                {
                    //displayName = UtilityMethods.DeHexUri(match.Groups["roomname"].Value);
                    int lastDashBeforeName = fullName.IndexOf('-', 16);
                    displayName = fullName.Substring(lastDashBeforeName + 1);
                }
                else
                {
                    displayName = fullName;
                }
            }
        }
コード例 #52
0
 /// <summary>
 ///     Decodes this instnace.
 /// </summary>
 public override void Decode(ByteStream stream)
 {
     base.Decode(stream);
 }
コード例 #53
0
ファイル: ChatRoomInfo.cs プロジェクト: pkt30/OscarLib
        /// <summary>
        /// Writes the ChatRoomInfo's parameters to a byte stream for transmission
        /// </summary>
        internal void WriteToByteStream(ByteStream stream)
        {
            // Write the basic info header
            stream.WriteUshort(exchangeNumber);
            stream.WriteByte((byte) "create".Length);
            stream.WriteString("create", Encoding.ASCII);
            stream.WriteUshort(instance);

            // Write details
            stream.WriteByte(0x01); // Detail level
            stream.WriteUshort(0x0003); // An unknown code, AIM 5.9 sets this to 0x0003
            using (TlvBlock tlvs = new TlvBlock())
            {
                tlvs.WriteString(CHATROOM_CHARSET1, UtilityMethods.OscarEncodingToString(charSet1), Encoding.ASCII);
                tlvs.WriteString(CHATROOM_DISPLAYNAME, displayName, Encoding.ASCII);
                tlvs.WriteString(CHATROOM_LANGUAGE1, language1, Encoding.ASCII);

                // Everything else is optional
                if (contentType != "text/x-aolrtf")
                {
                    tlvs.WriteString(CHATROOM_CONTENTTYPE, contentType, Encoding.ASCII);
                }

                if (Flags != 0xFFFF)
                {
                    tlvs.WriteUshort(CHATROOM_FLAGS, Flags);
                }
                if (MaxMessageLength != 0xFFFF)
                {
                    tlvs.WriteUshort(CHATROOM_MESSAGE_LENGTH, MaxMessageLength);
                }
                if (MaxOccupants != 0xFFFF)
                {
                    tlvs.WriteUshort(CHATROOM_MAX_OCCUPANTS, MaxOccupants);
                }
                if (CreationPermissions != 0xFF)
                {
                    tlvs.WriteByte(CHATROOM_PERMISSIONS, CreationPermissions);
                }
                if (charSet2 != null)
                {
                    tlvs.WriteString(CHATROOM_CHARSET2, charSet2.WebName, Encoding.ASCII);
                }
                if (!String.IsNullOrEmpty(language2))
                {
                    tlvs.WriteString(CHATROOM_LANGUAGE2, language2, Encoding.ASCII);
                }

                //stream.WriteUshort((ushort) tlvs.GetByteCount());
                stream.WriteTlvBlock(tlvs);
            }
        }
コード例 #54
0
        override public List <ZoneEntryStruct> GetSpawns()
        {
            List <ZoneEntryStruct> ZoneSpawns = new List <ZoneEntryStruct>();

            List <byte[]> SpawnPackets = GetPacketsOfType("OP_ZoneEntry", PacketDirection.ServerToClient);

            foreach (byte[] SpawnPacket in SpawnPackets)
            {
                ZoneEntryStruct NewSpawn = new ZoneEntryStruct();

                ByteStream Buffer = new ByteStream(SpawnPacket);

                NewSpawn.SpawnName = Buffer.ReadString(true);

                NewSpawn.SpawnName = Utils.MakeCleanName(NewSpawn.SpawnName);

                NewSpawn.SpawnID = Buffer.ReadUInt32();

                NewSpawn.Level = Buffer.ReadByte();

                float UnkSize = Buffer.ReadSingle();

                NewSpawn.IsNPC = Buffer.ReadByte();

                UInt32 Bitfield = Buffer.ReadUInt32();

                NewSpawn.Showname             = (Bitfield >> 28) & 1;
                NewSpawn.TargetableWithHotkey = (Bitfield >> 27) & 1;
                NewSpawn.Targetable           = (Bitfield >> 26) & 1;

                NewSpawn.ShowHelm = (Bitfield >> 24) & 1;
                NewSpawn.Gender   = (Bitfield >> 20) & 3;

                NewSpawn.Padding5  = (Bitfield >> 4) & 1;
                NewSpawn.Padding7  = (Bitfield >> 6) & 2047;
                NewSpawn.Padding26 = (Bitfield >> 25) & 1;

                Byte OtherData = Buffer.ReadByte();

                Buffer.SkipBytes(8);    // Skip 8 unknown bytes

                NewSpawn.DestructableString1 = "";
                NewSpawn.DestructableString2 = "";
                NewSpawn.DestructableString3 = "";

                if ((NewSpawn.IsNPC > 0) && ((OtherData & 3) > 0))
                {
                    // Destructable Objects. Not handled yet
                    //
                    //SQLOut(String.Format("-- OBJECT FOUND SpawnID {0}", SpawnID.ToString("x")));

                    NewSpawn.DestructableString1 = Buffer.ReadString(false);

                    NewSpawn.DestructableString2 = Buffer.ReadString(false);

                    NewSpawn.DestructableString3 = Buffer.ReadString(false);

                    NewSpawn.DestructableUnk1 = Buffer.ReadUInt32();

                    NewSpawn.DestructableUnk2 = Buffer.ReadUInt32();

                    NewSpawn.DestructableID1 = Buffer.ReadUInt32();

                    NewSpawn.DestructableID2 = Buffer.ReadUInt32();

                    NewSpawn.DestructableID3 = Buffer.ReadUInt32();

                    NewSpawn.DestructableID4 = Buffer.ReadUInt32();

                    NewSpawn.DestructableUnk3 = Buffer.ReadUInt32();

                    NewSpawn.DestructableUnk4 = Buffer.ReadUInt32();

                    NewSpawn.DestructableUnk5 = Buffer.ReadUInt32();

                    NewSpawn.DestructableUnk6 = Buffer.ReadUInt32();

                    NewSpawn.DestructableUnk7 = Buffer.ReadUInt32();

                    NewSpawn.DestructableUnk8 = Buffer.ReadUInt32();

                    NewSpawn.DestructableUnk9 = Buffer.ReadUInt32();

                    NewSpawn.DestructableByte = Buffer.ReadByte();

                    //SQLOut(String.Format("-- DES: {0,8:x} {1,8:x} {2,8:d} {3,8:d} {4,8:d} {5,8:d} {6,8:x} {7,8:x} {8,8:x} {9,8:x} {10,8:x} {11,8:x} {12,8:x} {13,2:x} {14} {15} {16}",
                    //          DestructableUnk1, DestructableUnk2, DestructableID1, DestructableID2, DestructableID3, DestructableID4,
                    //          DestructableUnk3, DestructableUnk4, DestructableUnk5, DestructableUnk6, DestructableUnk7, DestructableUnk8,
                    //          DestructableUnk9, DestructableByte, DestructableString1, DestructableString2, DestructableString3));
                }

                NewSpawn.Size = Buffer.ReadSingle();

                NewSpawn.Face = Buffer.ReadByte();

                NewSpawn.WalkSpeed = Buffer.ReadSingle();

                NewSpawn.RunSpeed = Buffer.ReadSingle();

                NewSpawn.Race = Buffer.ReadUInt32();

                NewSpawn.PropCount = Buffer.ReadByte();

                NewSpawn.BodyType = 0;

                if (NewSpawn.PropCount >= 1)
                {
                    NewSpawn.BodyType = Buffer.ReadUInt32();

                    for (int j = 1; j < NewSpawn.PropCount; ++j)
                    {
                        Buffer.SkipBytes(4);
                    }
                }

                Buffer.SkipBytes(1);   // Skip HP %

                NewSpawn.HairColor  = Buffer.ReadByte();
                NewSpawn.BeardColor = Buffer.ReadByte();
                NewSpawn.EyeColor1  = Buffer.ReadByte();
                NewSpawn.EyeColor2  = Buffer.ReadByte();
                NewSpawn.HairStyle  = Buffer.ReadByte();
                NewSpawn.Beard      = Buffer.ReadByte();

                NewSpawn.DrakkinHeritage = Buffer.ReadUInt32();

                NewSpawn.DrakkinTattoo = Buffer.ReadUInt32();

                NewSpawn.DrakkinDetails = Buffer.ReadUInt32();

                Buffer.SkipBytes(1);   // Skip Holding

                NewSpawn.Deity = Buffer.ReadUInt32();

                Buffer.SkipBytes(8);    // Skip GuildID and GuildRank

                NewSpawn.Class = Buffer.ReadByte();

                Buffer.SkipBytes(4);     // Skip PVP, Standstate, Light, Flymode

                NewSpawn.EquipChest2 = Buffer.ReadByte();

                bool UseWorn = (NewSpawn.EquipChest2 == 255);

                Buffer.SkipBytes(2);    // 2 Unknown bytes;

                NewSpawn.Helm = Buffer.ReadByte();

                NewSpawn.LastName = Buffer.ReadString(true);

                Buffer.SkipBytes(5);    // AATitle + unknown byte

                NewSpawn.PetOwnerID = Buffer.ReadUInt32();

                Buffer.SkipBytes(26);   // Unknown byte + 6 unknown uint32

                UInt32 Position1 = Buffer.ReadUInt32();

                UInt32 Position2 = Buffer.ReadUInt32();

                UInt32 Position3 = Buffer.ReadUInt32();

                UInt32 Position4 = Buffer.ReadUInt32();

                UInt32 Position5 = Buffer.ReadUInt32();

                NewSpawn.YPos = Utils.EQ19ToFloat((Int32)(Position3 & 0x7FFFF));

                NewSpawn.Heading = Utils.EQ19ToFloat((Int32)(Position4 & 0xFFF));

                NewSpawn.XPos = Utils.EQ19ToFloat((Int32)(Position4 >> 12) & 0x7FFFF);

                NewSpawn.ZPos = Utils.EQ19ToFloat((Int32)(Position5 & 0x7FFFF));

                NewSpawn.MeleeTexture1 = 0;
                NewSpawn.MeleeTexture2 = 0;

                if (NPCType.IsPlayableRace(NewSpawn.Race))
                {
                    for (int ColourSlot = 0; ColourSlot < 9; ++ColourSlot)
                    {
                        NewSpawn.SlotColour[ColourSlot] = Buffer.ReadUInt32();
                    }

                    for (int i = 0; i < 9; ++i)
                    {
                        NewSpawn.Equipment[i] = Buffer.ReadUInt32();

                        UInt32 Equip2 = Buffer.ReadUInt32();

                        UInt32 Equip1 = Buffer.ReadUInt32();

                        UInt32 Equip0 = Buffer.ReadUInt32();
                    }

                    if (NewSpawn.Equipment[Constants.MATERIAL_CHEST] > 0)
                    {
                        NewSpawn.EquipChest2 = (byte)NewSpawn.Equipment[Constants.MATERIAL_CHEST];
                    }

                    NewSpawn.ArmorTintRed = (byte)((NewSpawn.SlotColour[Constants.MATERIAL_CHEST] >> 16) & 0xff);

                    NewSpawn.ArmorTintGreen = (byte)((NewSpawn.SlotColour[Constants.MATERIAL_CHEST] >> 8) & 0xff);

                    NewSpawn.ArmorTintBlue = (byte)(NewSpawn.SlotColour[Constants.MATERIAL_CHEST] & 0xff);

                    if (NewSpawn.Equipment[Constants.MATERIAL_PRIMARY] > 0)
                    {
                        NewSpawn.MeleeTexture1 = NewSpawn.Equipment[Constants.MATERIAL_PRIMARY];
                    }

                    if (NewSpawn.Equipment[Constants.MATERIAL_SECONDARY] > 0)
                    {
                        NewSpawn.MeleeTexture2 = NewSpawn.Equipment[Constants.MATERIAL_SECONDARY];
                    }

                    if (UseWorn)
                    {
                        NewSpawn.Helm = (byte)NewSpawn.Equipment[Constants.MATERIAL_HEAD];
                    }
                    else
                    {
                        NewSpawn.Helm = 0;
                    }
                }
                else
                {
                    // Non playable race

                    Buffer.SkipBytes(16);

                    NewSpawn.MeleeTexture1 = Buffer.ReadUInt32();
                    Buffer.SkipBytes(12);
                    NewSpawn.MeleeTexture2 = Buffer.ReadUInt32();
                    Buffer.SkipBytes(12);
                }

                if (NewSpawn.EquipChest2 == 255)
                {
                    NewSpawn.EquipChest2 = 0;
                }

                if (NewSpawn.Helm == 255)
                {
                    NewSpawn.Helm = 0;
                }

                if ((OtherData & 4) > 0)
                {
                    NewSpawn.Title = Buffer.ReadString(false);
                }

                if ((OtherData & 8) > 0)
                {
                    NewSpawn.Suffix = Buffer.ReadString(false);
                }

                // unknowns
                Buffer.SkipBytes(8);

                NewSpawn.IsMercenary = Buffer.ReadByte();

                ZoneSpawns.Add(NewSpawn);
            }

            return(ZoneSpawns);
        }
コード例 #55
0
 public override object ReadObject(ByteStream _TargetStream)
 {
     ushort len = (ushort)Converter.Converters[typeof(ushort)].ReadObject(_TargetStream);
     return System.Text.Encoding.ASCII.GetString(_TargetStream.Read(len));
 }
コード例 #56
0
        public void ExploreZoneEntry(StreamWriter OutputStream, ByteStream Buffer, PacketDirection Direction)
        {
            if (Direction != PacketDirection.ServerToClient)
            {
                return;
            }

            string SpawnName = Buffer.ReadString(true);

            UInt32 SpawnID = Buffer.ReadUInt32();

            byte Level = Buffer.ReadByte();

            float UnkSize = Buffer.ReadSingle();

            byte IsNPC = Buffer.ReadByte();

            UInt32 Bitfield = Buffer.ReadUInt32();

            /*
             * NewSpawn.Showname = (Bitfield >> 28) & 1;
             * NewSpawn.TargetableWithHotkey = (Bitfield >> 27) & 1;
             * NewSpawn.Targetable = (Bitfield >> 26) & 1;
             *
             * NewSpawn.ShowHelm = (Bitfield >> 24) & 1;
             * NewSpawn.Gender = (Bitfield >> 20) & 3;
             *
             * NewSpawn.Padding5 = (Bitfield >> 4) & 1;
             * NewSpawn.Padding7 = (Bitfield >> 6) & 2047;
             * NewSpawn.Padding26 = (Bitfield >> 25) & 1;
             */
            Byte OtherData = Buffer.ReadByte();

            Buffer.SkipBytes(8);    // Skip 8 unknown bytes

            //NewSpawn.DestructableString1 = "";
            //NewSpawn.DestructableString2 = "";
            //NewSpawn.DestructableString3 = "";

            if ((IsNPC > 0) && ((OtherData & 3) > 0))
            {
                // Destructable Objects. Not handled yet
                //
                //SQLOut(String.Format("-- OBJECT FOUND SpawnID {0}", SpawnID.ToString("x")));

                Buffer.ReadString(false);

                Buffer.ReadString(false);

                Buffer.ReadString(false);

                Buffer.ReadUInt32();

                Buffer.ReadUInt32();

                Buffer.ReadUInt32();

                Buffer.ReadUInt32();

                Buffer.ReadUInt32();

                Buffer.ReadUInt32();

                Buffer.ReadUInt32();

                Buffer.ReadUInt32();

                Buffer.ReadUInt32();

                Buffer.ReadUInt32();

                Buffer.ReadUInt32();

                Buffer.ReadUInt32();

                Buffer.ReadUInt32();

                Buffer.ReadByte();
            }
            OutputStream.WriteLine("Size starts at offset {0}", Buffer.GetPosition());

            float Size = Buffer.ReadSingle();

            byte Face = Buffer.ReadByte();

            float WalkSpeed = Buffer.ReadSingle();

            float RunSpeed = Buffer.ReadSingle();

            UInt32 Race = Buffer.ReadUInt32();

            byte PropCount = Buffer.ReadByte();

            UInt32 BodyType = 0;

            if (PropCount >= 1)
            {
                BodyType = Buffer.ReadUInt32();

                for (int j = 1; j < PropCount; ++j)
                {
                    Buffer.SkipBytes(4);
                }
            }

            Buffer.SkipBytes(1);   // Skip HP %

            byte HairColor  = Buffer.ReadByte();
            byte BeardColor = Buffer.ReadByte();
            byte EyeColor1  = Buffer.ReadByte();
            byte EyeColor2  = Buffer.ReadByte();
            byte HairStyle  = Buffer.ReadByte();
            byte Beard      = Buffer.ReadByte();

            UInt32 DrakkinHeritage = Buffer.ReadUInt32();

            UInt32 DrakkinTattoo = Buffer.ReadUInt32();

            UInt32 DrakkinDetails = Buffer.ReadUInt32();

            Buffer.SkipBytes(1);   // Skip Holding

            UInt32 Deity = Buffer.ReadUInt32();

            Buffer.SkipBytes(8);    // Skip GuildID and GuildRank

            byte Class = Buffer.ReadByte();

            Buffer.SkipBytes(4);     // Skip PVP, Standstate, Light, Flymode

            byte EquipChest2 = Buffer.ReadByte();

            bool UseWorn = (EquipChest2 == 255);

            Buffer.SkipBytes(2);    // 2 Unknown bytes;

            byte Helm = Buffer.ReadByte();

            string LastName = Buffer.ReadString(true);

            Buffer.SkipBytes(5);    // AATitle + unknown byte

            UInt32 PetOwnerID = Buffer.ReadUInt32();

            Buffer.SkipBytes(26);   // Unknown byte + 6 unknown uint32

            OutputStream.WriteLine("Position starts at offset {0}", Buffer.GetPosition());

            UInt32 Position1 = Buffer.ReadUInt32();

            UInt32 Position2 = Buffer.ReadUInt32();

            UInt32 Position3 = Buffer.ReadUInt32();

            UInt32 Position4 = Buffer.ReadUInt32();

            UInt32 Position5 = Buffer.ReadUInt32();

            float YPos = Utils.EQ19ToFloat((Int32)(Position3 & 0x7FFFF));

            float Heading = Utils.EQ19ToFloat((Int32)(Position4 & 0xFFF));

            float XPos = Utils.EQ19ToFloat((Int32)(Position4 >> 12) & 0x7FFFF);

            float ZPos = Utils.EQ19ToFloat((Int32)(Position5 & 0x7FFFF));

            OutputStream.WriteLine("(X,Y,Z) = {0}, {1}, {2}, Heading = {3}", XPos, YPos, ZPos, Heading);

            if (NPCType.IsPlayableRace(Race))
            {
                for (int ColourSlot = 0; ColourSlot < 9; ++ColourSlot)
                {
                    OutputStream.WriteLine("Color {0} is {1}", ColourSlot, Buffer.ReadUInt32());
                }
            }

            OutputStream.WriteLine("");
        }
コード例 #57
0
ファイル: FME.cs プロジェクト: joeriedel/DarkForcesUnity
    public static BM.Frame ReadHeader2(ByteStream stream, BM.CreateArgs createArgs)
    {
        int headerStart = (int)stream.Position;

        BM.Header header = new BM.Header();
        header.W = stream.ReadLittleInt32();
        header.H = stream.ReadLittleInt32();
        header.Compressed = stream.ReadLittleInt32();
        header.DataSize = stream.ReadLittleInt32();
        header.Transparent = 0x8;

        stream.Skip(8);

        int[] columnOffsets = null;

        if (header.Compressed != 0) {
            header.Compressed = 2;

            columnOffsets = new int[header.W];

            for (int i = 0; i < columnOffsets.Length; ++i) {
                columnOffsets[i] = stream.ReadLittleInt32() + headerStart;
            }
        }

        return BM.ReadColumns(stream, header, columnOffsets, createArgs);
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="Ask_For_Playing_Gamecenter_Friends_Message"/> class.
 /// </summary>
 /// <param name="Device">The device.</param>
 public Ask_For_Playing_Gamecenter_Friends_Message(Device Device, ByteStream ByteStream) : base(Device, ByteStream)
 {
     // Ask_For_Playing_Gamecenter_Friends_Message.
 }
コード例 #59
0
ファイル: FME.cs プロジェクト: joeriedel/DarkForcesUnity
    public static BM.Frame ReadHeader1(ByteStream stream, BM.CreateArgs createArgs, out FMEHeader header)
    {
        header = new FMEHeader();
        header.Shift = new Vector2();
        header.Shift.x = (float)stream.ReadLittleInt32();
        header.Shift.y = (float)stream.ReadLittleInt32();
        header.Flipped = stream.ReadLittleInt32() != 0;

        int header2Ofs = stream.ReadLittleInt32();
        stream.Skip(16 + (header2Ofs-32));

        return ReadHeader2(stream, createArgs);
    }
コード例 #60
0
 void ITransportCallback <TMsg> .Write(ByteStream destination, ref TMsg msg)
 {
     Serializer.Serialize(destination, ref msg);
 }