예제 #1
0
        /// <summary>
        /// Constructor for playback.
        /// </summary>
        /// <param name="fileName"></param>
        internal MouseRecording(string fileName)
        {
            this.FileName = fileName;
            this.Packets  = new List <Objects.Packet>();
            if (!File.Exists(fileName))
            {
                return;
            }
            using (Stream stream = Utils.TibiaCam.DecompressCamToStream(fileName))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    this._RecorderVersion = reader.ReadUInt16();
                    this.Interval         = reader.ReadUInt16();

                    WinApi.RECT r = new WinApi.RECT();
                    r.left               = 0;
                    r.top                = 0;
                    r.right              = reader.ReadUInt16();
                    r.bottom             = reader.ReadUInt16();
                    this.clientWindowOld = r;

                    WinApi.RECT r2 = new WinApi.RECT();
                    r2.left            = reader.ReadUInt16();
                    r2.top             = reader.ReadUInt16();
                    r2.right           = reader.ReadUInt16();
                    r2.bottom          = reader.ReadUInt16();
                    this.gameWindowOld = r2;

                    while (reader.BaseStream.Position < reader.BaseStream.Length)
                    {
                        Objects.Packet p  = new Objects.Packet();
                        DataType       dt = (DataType)reader.ReadByte();
                        p.AddByte((byte)dt);
                        switch (dt)
                        {
                        case DataType.ClientWindowChange:
                            p.AddUInt16(reader.ReadUInt16());     // width
                            p.AddUInt16(reader.ReadUInt16());     // height
                            break;

                        case DataType.GameWindowChange:
                            p.AddUInt16(reader.ReadUInt16());     // x
                            p.AddUInt16(reader.ReadUInt16());     // y
                            p.AddUInt16(reader.ReadUInt16());     // width
                            p.AddUInt16(reader.ReadUInt16());     // height
                            break;

                        case DataType.MouseXY:
                            p.AddByte(reader.ReadByte());     // mouse %x
                            p.AddByte(reader.ReadByte());     // mouse %y
                            break;
                        }
                        this.Packets.Add(p);
                    }
                }
            }
        }
예제 #2
0
파일: Combobot.cs 프로젝트: uvbs/bot-2016
 private void SendComboThread(object tcpclient)
 {
     try
     {
         TcpClient tc = (TcpClient)tcpclient;
         // wait for all threads to start
         this.SendComboResetEvent.WaitOne();
         Objects.Packet p = new Objects.Packet();
         p.AddByte((byte)PacketType.Combo);
         p.AddUInt32(this.Target);
         p.AddLength();
         p.Send(tc);
     }
     catch { }
 }
예제 #3
0
파일: Combobot.cs 프로젝트: uvbs/bot-2016
        /// <summary>
        /// Handles a connected client. Run this method on a seperate thread.
        /// </summary>
        /// <param name="combobotClientDescriptor">A CombobotClientDescriptor object.</param>
        private void HandleClient(object combobotClientDescriptor)
        {
            CombobotClientDescriptor descriptor = (CombobotClientDescriptor)combobotClientDescriptor;

            try
            {
                TcpClient     tc      = descriptor.TcpClient;
                NetworkStream nstream = tc.GetStream();
                while (this.IsRunning)
                {
                    Objects.Packet p = Objects.Packet.GetNextPacket(nstream);
                    if (p.Length == 0)
                    {
                        break;     // disconnected
                    }
                    p.GetUInt16(); // length, not needed
                    switch ((PacketType)p.GetByte())
                    {
                    case PacketType.Ping:
                        descriptor.SetRTT((ushort)descriptor.GetElapsedMilliseconds());
                        if (this.ClientPingReceived != null)
                        {
                            this.ClientPingReceived(descriptor);
                        }
                        break;

                    case PacketType.PlayerInfo:
                        descriptor.CharacterName = p.GetString();
                        break;
                    }
                }
            }
            catch { }
            finally
            {
                if (descriptor.TcpClient != null)
                {
                    descriptor.TcpClient.Close();
                }
                this.ConnectedClients.Remove(descriptor);
                if (this.ClientDisconnected != null)
                {
                    this.ClientDisconnected(descriptor);
                }
            }
        }
예제 #4
0
파일: Combobot.cs 프로젝트: uvbs/bot-2016
        /// <summary>
        /// Sends a player information request packet and a ping packet every 5 seconds to all connected clients.
        /// Run this method on a seperate thread.
        /// </summary>
        private void KeepAliveClients()
        {
            while (this.IsRunning)
            {
                Thread.Sleep(5000);

                // create a ping packet
                Objects.Packet p = new Objects.Packet();
                p.AddByte((byte)PacketType.Ping);
                p.AddLength();
                // create a player info request packet
                Objects.Packet playerInfo = new Objects.Packet();
                playerInfo.AddByte((byte)PacketType.PlayerInfo);
                playerInfo.AddLength();
                foreach (CombobotClientDescriptor descriptor in this.GetConnectedClients())
                {
                    playerInfo.Send(descriptor.TcpClient);
                    descriptor.StartTimer();
                    p.Send(descriptor.TcpClient);
                }
            }
        }
예제 #5
0
파일: Combobot.cs 프로젝트: uvbs/bot-2016
        private void HandleServer()
        {
            try
            {
                this.TcpClient   = new TcpClient(this.ServerIP, this.ServerPort);
                this.IsConnected = true;
                if (this.Connected != null)
                {
                    this.Connected();
                }
                Objects.Item   item;
                Objects.Packet p = new Objects.Packet();
                p.AddByte((byte)PacketType.PlayerInfo);
                p.AddString(this.Client.Player.Name);
                p.AddLength();
                p.Send(this.TcpClient);
                while (true)
                {
                    p = Objects.Packet.GetNextPacket(this.TcpClient.GetStream());
                    if (p.Length == 0)
                    {
                        break;     // disconnected
                    }
                    p.GetUInt16(); // length, not needed
                    switch ((PacketType)p.GetByte())
                    {
                    case PacketType.Combo:
                        if (!this.Client.Player.Connected)
                        {
                            continue;
                        }
                        uint             targetid = p.GetUInt32();
                        Objects.Creature c        = this.Client.BattleList.GetAny(targetid);
                        if (c == null || !this.Client.Player.Location.IsOnScreen(c.Location))
                        {
                            break;
                        }
                        switch (this.Action)
                        {
                        case ActionType.Say:
                            if (string.IsNullOrEmpty(this.ActionEx))
                            {
                                break;
                            }
                            this.Client.Packets.Say(this.ActionEx);
                            break;

                        case ActionType.CustomRune:
                            ushort runeid = 0;
                            if (!ushort.TryParse(this.ActionEx, out runeid))
                            {
                                break;
                            }
                            item = this.Client.Inventory.GetItem(runeid);
                            if (item != null)
                            {
                                item.UseOnCreature(c);
                            }
                            break;

                        case ActionType.SuddenDeath:
                            item = this.Client.Inventory.GetItem(this.Client.ItemList.Runes.SuddenDeath);
                            if (item != null)
                            {
                                item.UseOnCreature(c);
                            }
                            break;

                        case ActionType.HeavyMagicMissile:
                            item = this.Client.Inventory.GetItem(this.Client.ItemList.Runes.HeavyMagicMissile);
                            if (item != null)
                            {
                                item.UseOnCreature(c);
                            }
                            break;

                        case ActionType.Explosion:
                            item = this.Client.Inventory.GetItem(this.Client.ItemList.Runes.Explosion);
                            if (item != null)
                            {
                                item.UseOnCreature(c);
                            }
                            break;

                        case ActionType.Paralyze:
                            item = this.Client.Inventory.GetItem(this.Client.ItemList.Runes.Paralyze);
                            if (item != null)
                            {
                                item.UseOnCreature(c);
                            }
                            break;
                        }
                        break;

                    case PacketType.Ping:
                        p = new Objects.Packet();
                        p.AddByte((byte)PacketType.Ping);
                        p.AddLength();
                        p.Send(this.TcpClient);
                        break;

                    case PacketType.PlayerInfo:
                        p = new Objects.Packet();
                        p.AddByte((byte)PacketType.PlayerInfo);
                        p.AddString(this.Client.Player.Name);
                        p.AddLength();
                        p.Send(this.TcpClient);
                        break;
                    }
                }
            }
            catch { }
            finally
            {
                if (this.TcpClient != null)
                {
                    this.TcpClient.Close();
                }
                this.IsConnected = false;
                if (this.Disconnected != null)
                {
                    this.Disconnected();
                }
            }
        }
예제 #6
0
 private void ThreadRecord()
 {
     try
     {
         this.Packets = new List <Objects.Packet>();
         Objects.Packet meta = new Objects.Packet();
         meta.AddUInt16((ushort)Settings.CurrentVersion); // recorder version
         meta.AddUInt16(Settings.Tibiacam.Recorder.MouseInterval);
         WinApi.RECT clientRect = new WinApi.RECT();
         WinApi.GetClientRect(Client.Tibia.MainWindowHandle, out clientRect);
         this.clientWindowOld = clientRect;
         //meta.AddUInt16((ushort)clientRect.left);
         //meta.AddUInt16((ushort)clientRect.top);
         meta.AddUInt16((ushort)clientRect.right);
         meta.AddUInt16((ushort)clientRect.bottom);
         WinApi.RECT r = Client.Misc.GameWindow;
         this.gameWindowOld = r;
         meta.AddUInt16((ushort)r.left);
         meta.AddUInt16((ushort)r.top);
         meta.AddUInt16((ushort)r.right);
         meta.AddUInt16((ushort)r.bottom);
         this.Packets.Add(meta);
         this.Interval = Settings.Tibiacam.Recorder.MouseInterval;
         while (isRecording)
         {
             Objects.Packet p;
             WinApi.RECT    newClientRect = new WinApi.RECT();
             WinApi.GetClientRect(Client.Tibia.MainWindowHandle, out newClientRect);
             if (newClientRect.right != this.clientWindowOld.right ||
                 newClientRect.bottom != this.clientWindowOld.bottom)
             {
                 p = new Objects.Packet();
                 this.clientWindowOld = newClientRect;
                 p.AddByte((byte)DataType.ClientWindowChange);
                 p.AddUInt16((ushort)newClientRect.right);
                 p.AddUInt16((ushort)newClientRect.bottom);
                 this.Packets.Add(p);
                 continue;
             }
             WinApi.RECT newRect = Client.Misc.GameWindow;
             if (this.gameWindowOld.left != newRect.left ||
                 this.gameWindowOld.bottom != newRect.bottom)
             {
                 p = new Objects.Packet();
                 this.gameWindowOld = newRect;
                 p.AddByte((byte)DataType.GameWindowChange);
                 p.AddUInt16((ushort)newRect.left);
                 p.AddUInt16((ushort)newRect.top);
                 p.AddUInt16((ushort)newRect.right);
                 p.AddUInt16((ushort)newRect.bottom);
                 this.Packets.Add(p);
                 continue;
             }
             p = new Objects.Packet();
             System.Drawing.Point mousePercentage = this.CalculateMousePercentage();
             p.AddByte((byte)DataType.MouseXY);
             if (WinApi.GetForegroundWindow() == Client.Tibia.MainWindowHandle)
             {
                 p.AddByte((byte)mousePercentage.X);
                 p.AddByte((byte)mousePercentage.Y);
             }
             else
             {
                 p.AddByte(0);
                 p.AddByte(0);
             }
             this.Packets.Add(p);
             Thread.Sleep(this.Interval);
         }
     }
     catch (Exception ex) { MessageBox.Show("Mouse recording error:\n" + ex.Message + "\n" + ex.StackTrace); }
     isRecording = false;
 }
예제 #7
0
        /// <summary>
        /// Constructor for playback.
        /// </summary>
        /// <param name="fileName">Relative or absolute path (including file name).</param>
        /// <param name="readMetaData">If true, will read data like Tibia version, recorder version and duration.</param>
        /// <param name="readPackets">If true, will buffer all packets to memory.</param>
        /// <param name="readMouseMovements">If true, will try to read a mouse movement file (*.kcammouse) with the same file name as the recording.</param>
        internal Recording(string fileName, bool readMetaData, bool readPackets, bool readMouseMovements)
        {
            this.Type = RecordingType.Playback;
            if (File.Exists(fileName))
            {
                this.Packets = new List <Recording.Packet>();

                if (fileName.EndsWith(".kcam"))
                {
                    Recorder = Enums.Recorder.TibianicTools;
                }
                else if (fileName.EndsWith(".tmv"))
                {
                    Recorder = Enums.Recorder.TibiaMovie;
                }
                else if (fileName.EndsWith(".cam"))
                {
                    Recorder = Enums.Recorder.IryontCam;
                }
                else
                {
                    return;
                }
                FileName = fileName; RecorderVersion = "?"; TibiaVersion = "?"; Duration = 0;
                //if (fileName.Contains("\\")) { FileNameShort = fileName.Substring(fileName.LastIndexOf('\\') + 1); }
                //else { FileNameShort = fileName; }
                if (readMetaData || readPackets || readMouseMovements)
                {
                    switch (this.Recorder)
                    {
                    case Enums.Recorder.IryontCam:
                        try
                        {
                            using (FileStream fstream = File.OpenRead(this.FileName))
                            {
                                using (BinaryReader reader = new BinaryReader(fstream))
                                {
                                    if (readPackets)
                                    {
                                        uint tickFirst = 0;
                                        // add first packet
                                        tickFirst = (uint)reader.ReadUInt64();
                                        ushort len  = reader.ReadUInt16();
                                        byte[] data = new byte[len + 2];
                                        Array.Copy(BitConverter.GetBytes(len), data, 2);
                                        byte[] packet = reader.ReadBytes(len);
                                        Array.Copy(packet, 0, data, 2, packet.Length);
                                        this.Packets.Add(new Recording.Packet(0, data));
                                        while (reader.BaseStream.Position < reader.BaseStream.Length)
                                        {
                                            uint tick = (uint)reader.ReadUInt64() - tickFirst;
                                            len  = reader.ReadUInt16();
                                            data = new byte[len + 2];
                                            Array.Copy(BitConverter.GetBytes(len), data, 2);
                                            packet = reader.ReadBytes(len);
                                            Array.Copy(packet, 0, data, 2, packet.Length);
                                            this.Packets.Add(new Recording.Packet(tick, data));
                                        }
                                        Recording.Packet lastPacket = this.Packets[this.Packets.Count - 1];
                                        this.Duration = lastPacket.Time;
                                    }
                                }
                            }
                        }
                        catch { this.isCorrupt = true; }
                        break;

                    case Enums.Recorder.TibiaMovie:
                        /*using (FileStream stream = File.OpenRead(fileName))
                         * {
                         *  if (readMetaData)
                         *  {
                         *      byte[] metaData = new byte[8];
                         *      stream.Read(metaData, 0, 8);
                         *      metaData = Utils.TibiaCam.Zlib.Decompress(metaData);
                         *      RecorderVersion = BitConverter.ToUInt16(metaData, 0).ToString();
                         *      TibiaVersion = BitConverter.ToUInt16(metaData, 2).ToString();
                         *      Duration = BitConverter.ToUInt32(metaData, 4);
                         *  }
                         *  if (readPackets)
                         *  {
                         *      byte[] buffer = new byte[stream.Length - 8];
                         *      if (!readMetaData) stream.Position += 8;
                         *      stream.Read(buffer, 0, buffer.Length);
                         *      Utils.TibiaCam.Zlib.Decompress(buffer);
                         *      Packets = Utils.TibiaCam.Zlib.BytesToPacket(Utils.TibiaCam.Zlib.Decompress(buffer));
                         *  }
                         *  stream.Close();
                         * }*/
                        break;

                    case Enums.Recorder.TibianicTools:
                        if (readMouseMovements)
                        {
                            string mouseFileName = fileName + "mouse";
                            if (File.Exists(mouseFileName))
                            {
                                try { this.MouseRecording = new MouseRecording(mouseFileName); }
                                catch { this.MouseRecording = null; }
                            }
                        }
                        try
                        {
                            Stream stream    = Utils.TibiaCam.DecompressCamToStream(fileName);
                            int    firstByte = stream.ReadByte();
                            stream.Position = 0;
                            if (firstByte == (int)'T')     // true for 1.2 and older
                            {
                                isOld = true;
                                List <string> strings = new List <string>();
                                StreamReader  reader  = new StreamReader(stream);
                                TibiaVersion    = reader.ReadLine().Replace("TibiaVersion=", "");
                                RecorderVersion = reader.ReadLine().Replace("TibiaCamVersion=", "");
                                Duration        = (uint)double.Parse(reader.ReadLine().Replace("TotalRunningTime=", ""));
                                if (readPackets)
                                {
                                    while (true)
                                    {
                                        string line = reader.ReadLine();
                                        if (line == null || line.Length == 0)
                                        {
                                            break;
                                        }
                                        strings.Add(line);
                                    }
                                    stream.Close();
                                    stream.Dispose();
                                    List <Recording.Packet> packets = new List <Recording.Packet>();
                                    foreach (string line in strings)
                                    {
                                        string temp  = line;
                                        uint   sleep = uint.Parse(temp.Substring(0, temp.IndexOf(':')));
                                        temp = temp.Remove(0, temp.IndexOf(':') + 1);
                                        string[]       split  = temp.Split(' ');
                                        Objects.Packet packet = new Objects.Packet();
                                        for (int j = 0; j < split.Length; j++)
                                        {
                                            packet.AddByte(byte.Parse(split[j], System.Globalization.NumberStyles.AllowHexSpecifier));
                                        }
                                        packet.GetPosition = 0;
                                        packets.Add(new Recording.Packet(sleep, packet.ToBytes()));
                                    }
                                    Packets = packets;
                                }
                            }
                            else
                            {
                                isOld = false;
                                BinaryReader reader   = new BinaryReader(stream);
                                byte[]       metadata = new byte[8]; // 2 bytes TibiaVersion, 2 bytes CamVersion, 4 bytes RunningLength(ms)
                                reader.Read(metadata, 0, 8);         // fill metadata
                                if (readMetaData)
                                {
                                    TibiaVersion    = metadata[0] + "." + metadata[1];
                                    RecorderVersion = metadata[2] + "." + metadata[3];
                                    Duration        = BitConverter.ToUInt32(metadata, 4);
                                }
                                if (readPackets)
                                {
                                    List <Recording.Packet> packets = new List <Recording.Packet>();
                                    while (reader.BaseStream.Position < reader.BaseStream.Length)
                                    {
                                        uint sleep = reader.ReadUInt32();
                                        uint len   = reader.ReadUInt32();   // should be changed to UInt16 in future versions as packets never exceed 65k bytes
                                        // merge split packets
                                        ushort packetLen = reader.ReadUInt16();
                                        if (packetLen > len - 2)
                                        {
                                            Objects.Packet p = new Objects.Packet();
                                            reader.BaseStream.Position += 4;
                                            p.AddUInt16(packetLen);
                                            p.AddBytes(reader.ReadBytes((int)len - 2));
                                            uint totalBytesRead = len - 2;
                                            while (totalBytesRead < packetLen)
                                            {
                                                reader.ReadUInt32();     // sleep, not needed
                                                len = reader.ReadUInt32();
                                                p.AddBytes(reader.ReadBytes((int)len));
                                                totalBytesRead += len;
                                            }
                                            packets.Add(new Recording.Packet(sleep, p.ToBytes()));
                                        }
                                        else
                                        {
                                            reader.BaseStream.Position -= 2;
                                            packets.Add(new Recording.Packet(sleep, reader.ReadBytes((int)len)));
                                        }
                                    }
                                    Packets = packets;
                                    // if duration is 0, get duration from last packet
                                    if (this.Duration == 0)
                                    {
                                        Recording.Packet p = this.Packets[this.Packets.Count - 1];
                                        this.Duration = p.Time;
                                    }
                                }
                                reader.Close();
                                stream.Close();
                                stream.Dispose();
                                if (readMouseMovements)
                                {
                                    string name = fileName.Substring(0, fileName.LastIndexOf('.'));
                                    name += ".kcammouse";
                                    if (File.Exists(name))
                                    {
                                        MouseRecording = new MouseRecording(name);
                                    }
                                    else
                                    {
                                        MouseRecording = null;
                                    }
                                }
                            }
                        }
                        catch { isCorrupt = true; }
                        break;
                    }
                }
            }
        }
예제 #8
0
        private void PlaybackSendMouse()
        {
            try
            {
                Recording rec = this.CurrentRecording;
                if (rec == null)
                {
                    return;
                }
                MouseRecording mouseRec = null;
                if (this.CurrentRecording.MouseRecording != null)
                {
                    mouseRec = this.CurrentRecording.MouseRecording;
                }
                else
                {
                    return;
                }

                mouseRec.CurrentIndex = 0;
                while (this.IsRunning && this.TcpClientLocal.Connected)
                {
                    if (this.threadPlaybackSend == null || !this.threadPlaybackSend.IsAlive)
                    {
                        return;
                    }
                    while (this.PlaybackSpeed <= 0)
                    {
                        Thread.Sleep(200); continue;
                    }
                    //int currentTime = mouseRec.Seek(this.CurrentRecording.TimePassed);
                    //int mouseTime = i * mouseRec.Interval;

                    Objects.Packet p = mouseRec.Packets[mouseRec.CurrentIndex];
                    p.GetPosition = 0;
                    MouseRecording.DataType dt = (MouseRecording.DataType)p.GetByte();
                    switch (dt)
                    {
                    case MouseRecording.DataType.ClientWindowChange:
                        break;

                    case MouseRecording.DataType.GameWindowChange:
                        break;

                    case MouseRecording.DataType.MouseXY:
                        int percentX = p.GetByte(), percentY = p.GetByte();
                        if (percentX == 0 && percentY == 0)
                        {
                            break;
                        }
                        if (WinApi.GetForegroundWindow() != Client.Tibia.MainWindowHandle)
                        {
                            break;
                        }
                        System.Drawing.Point point = mouseRec.CalculateScreenMouseXY(new System.Drawing.Point(percentX, percentY));
                        System.Windows.Forms.Cursor.Position = point;
                        break;
                    }
                    p.GetPosition = 0;
                    mouseRec.CurrentIndex++;
                    Thread.Sleep((int)(mouseRec.Interval / this.PlaybackSpeed));
                }
            }
            catch { }
        }
예제 #9
0
        private void PlaybackRecv()
        {
            try
            {
                NetworkStream nstream = TcpClientLocal.GetStream();
                int           connection = 0;
                bool          doLoop = true, obtainedXteaKey = false;

                while (doLoop)
                {
                    Objects.Packet p = Objects.Packet.GetNextPacket(nstream);
                    if (p.Length == 0)
                    {
                        break;
                    }

                    if (!obtainedXteaKey)
                    {
                        if (Client.TibiaVersion >= 770)
                        {
                            this.XteaKey = new uint[4];
                            for (int i = 0; i < 4; i++)
                            {
                                this.XteaKey[i] = Memory.ReadUInt(Addresses.Client.XTEAKey + i * 4);
                            }
                        }
                        obtainedXteaKey = true;
                    }

                    connection = Memory.ReadByte(Addresses.Client.Connection);
                    switch ((Enums.Connection)connection)
                    {
                    case Enums.Connection.WaitingForCharacterList:
                        if (this.AutoPlayback)
                        {
                            p = new Objects.Packet();
                            p.AddByte(0x64);
                            p.AddByte(1);
                            p.AddString("TibiaCam");
                            p.AddString(CurrentRecording.TibiaVersion);
                            p.AddBytes(IPAddress.Loopback.GetAddressBytes());
                            p.AddUInt16(this.ListenerPort);
                            p.AddUInt16(0);     // premium days
                            p.AddLength();
                            if (Client.TibiaVersion >= 770)
                            {
                                p.XteaEncrypt(this.XteaKey); p.AddLength();
                            }
                            p.Send(this.TcpClientLocal);
                            doLoop = false;
                            break;
                        }

                        List <string> files = new List <string>();
                        foreach (string kcam in System.IO.Directory.GetFiles(System.Windows.Forms.Application.StartupPath + "\\", "*.kcam"))
                        {
                            files.Add(kcam);
                        }
                        foreach (string iryontcam in System.IO.Directory.GetFiles(System.Windows.Forms.Application.StartupPath + "\\", "*.cam"))
                        {
                            files.Add(iryontcam);
                        }
                        if (Settings.Tibiacam.Playback.SupportTibiaMovies)
                        {
                            foreach (string tmv in System.IO.Directory.GetFiles(System.Windows.Forms.Application.StartupPath + "\\", "*.tmv"))
                            {
                                files.Add(tmv);
                            }
                        }
                        files.Sort();
                        string warning = string.Empty;
                        int    count   = files.Count;
                        if (files.Count > 255)
                        {
                            warning = "\n\nWarning! There are " + files.Count + " recordings.\nOnly the first 255 recordings are listed."; count = 255;
                        }
                        p = new Objects.Packet();
                        p.AddByte(0x14);     // motd type
                        // motd id is 0-255, which is followed by a newline (\n)
                        p.AddString((byte)new Random().Next(255) + "\nThank you for using Tibianic Tools.\nhttp://code.google.com/p/tibianic-tools/\nhttp://tibianic.org/" + warning);
                        p.AddByte(0x64);     // character list type
                        List <Recording> recordings = new List <Recording>();
                        for (int i = 0; i < count; i++)
                        {
                            Recording r = new Recording(files[i], Settings.Tibiacam.Playback.ReadMetaData, false, false);
                            if (!r.isCorrupt)
                            {
                                recordings.Add(r);
                            }
                        }
                        p.AddByte((byte)count);     // amount of characters
                        foreach (Recording r in recordings)
                        {
                            p.AddString(r.FileNameShort);                     // character name
                            p.AddString(r.TibiaVersion);                      // server name
                            p.AddBytes(IPAddress.Loopback.GetAddressBytes()); // server ipv4 (in this case: 127.0.0.1)
                            p.AddUInt16(this.ListenerPort);                   // server port
                        }
                        p.AddUInt16((ushort)count);                           // premium days
                        p.AddLength();
                        if (Client.TibiaVersion >= 770)
                        {
                            p.XteaEncrypt(this.XteaKey); p.AddLength();
                        }
                        p.Send(TcpClientLocal);
                        doLoop = false;
                        break;

                    case Enums.Connection.ConnectingGameServer:
                        if (this.AutoPlayback)
                        {
                            this.threadPlaybackSend = new Thread(new ThreadStart(PlaybackSend));
                            this.threadPlaybackSend.Start();
                            break;
                        }
                        CharacterList.Player player = CharacterList.GetPlayers()[Memory.ReadByte(Addresses.Charlist.SelectedIndex)];
                        if (!System.IO.File.Exists(player.Name))
                        {
                            System.Windows.Forms.MessageBox.Show(player.Name + "\ndoes not exist", "Error"); doLoop = false; break;
                        }
                        Recording rec = new Recording(player.Name, true, true, Settings.Tibiacam.Playback.doPlayMouse);
                        if (rec.isCorrupt || !rec.ContainsData())
                        {
                            System.Windows.Forms.MessageBox.Show(player.Name + "\nappears to be corrupt or it doesn't contain any data", "Error"); doLoop = false; break;
                        }
                        this.CurrentRecording = rec;
                        while (this.threadPlaybackSend != null && this.threadPlaybackSend.IsAlive)
                        {
                            this.threadPlaybackSend.Abort(); Thread.Sleep(100);
                        }
                        while (this.threadPlaybackSendMouse != null && this.threadPlaybackSendMouse.IsAlive)
                        {
                            this.threadPlaybackSendMouse.Abort(); Thread.Sleep(100);
                        }
                        this.threadPlaybackSend = new Thread(new ThreadStart(PlaybackSend));
                        this.threadPlaybackSend.Start();
                        break;

                    case Enums.Connection.Online:
                        ushort len = p.GetUInt16();
                        if (Client.TibiaVersion >= 770)
                        {
                            p = p.XteaDecrypt(this.XteaKey, 2);
                            if (p == null)
                            {
                                break;
                            }
                            p.GetPosition = 2;
                        }
                        byte type = p.GetByte();
                        switch (type)
                        {
                        case 0x14:         // logout
                            while (this.threadPlaybackSend != null && this.threadPlaybackSend.IsAlive)
                            {
                                this.threadPlaybackSend.Abort(); Thread.Sleep(100);
                            }
                            this.TcpClientLocal.Close();
                            return;

                        case 0x96:         // player speech
                            byte speechType = p.GetByte();
                            if (speechType < 1 || speechType > 3)
                            {
                                break;
                            }
                            string   msg      = p.GetString().ToLower();
                            string[] msgSplit = msg.Split(' ');
                            p = new Objects.Packet();
                            switch (msgSplit[0])
                            {
                            case "info":
                                p.AddByte(0xb4);
                                p.AddByte(22);
                                p.AddString("Tibia version: " + this.CurrentRecording.TibiaVersion + "\nRecorder version: " + this.CurrentRecording.RecorderVersion + "\n# of packets: " + this.CurrentRecording.Packets.Count);
                                p.AddLength();
                                if (Client.TibiaVersion >= 770)
                                {
                                    p.XteaEncrypt(this.XteaKey, p.GetPosition); p.AddLength();
                                }
                                p.Send(this.TcpClientLocal);
                                break;

                            case "goto":
                                TimeSpan ts;
                                if (!TimeSpan.TryParse(msgSplit[1], out ts))
                                {
                                    break;
                                }
                                this.FastForward(ts);
                                break;

                            case "pause":
                                this.PlaybackSpeed = 0;
                                break;

                            case "resume":
                                this.PlaybackSpeed = 1;
                                break;
                            }
                            break;
                        }
                        break;
                    }
                }
                if (TcpClientLocal != null)
                {
                    TcpClientLocal.Close();
                }
            }
            catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message + "\n" + ex.StackTrace); if (TcpClientLocal != null)
                                   {
                                       TcpClientLocal.Close();
                                   }
            }
        }
예제 #10
0
        private void PlaybackSend()
        {
            try
            {
                Recording.Packet p;
                this.CurrentPacket = 0;
                this.DoFastForward = false;
                uint timeOld = 0, timeNew = 0;
                bool hasShownInfo = false;
                this.CurrentRecording.TimePassed = 0;
                if (this.CurrentRecording.MouseRecording != null)
                {
                    while (this.threadPlaybackSendMouse != null && this.threadPlaybackSendMouse.IsAlive)
                    {
                        this.threadPlaybackSendMouse.Abort(); Thread.Sleep(100);
                    }
                    this.threadPlaybackSendMouse = new Thread(new ThreadStart(this.PlaybackSendMouse));
                    threadPlaybackSendMouse.Start();
                }

                try
                {
                    while (this.CurrentPacket < this.CurrentRecording.Packets.Count)
                    {
                        if (!this.TcpClientLocal.Connected)
                        {
                            return;
                        }

                        if (this.DoFastForward)
                        {
                            if (TimeSpan.FromMilliseconds(this.CurrentRecording.TimePassed) > this.FastForwardTo)
                            {
                                this.CurrentPacket = 0; this.CurrentRecording.TimePassed = 0;
                            }
                            while (this.CurrentPacket < this.CurrentRecording.Packets.Count &&
                                   this.CurrentRecording.TimePassed < this.FastForwardTo.TotalMilliseconds)
                            {
                                p = this.CurrentRecording.Packets[this.CurrentPacket].Clone();
                                this.CurrentRecording.TimePassed = p.Time;
                                //if (this.CurrentRecording.Recorder == Enums.Recorder.TibianicTools) p.GetPosition += 4;
                                //else if (this.CurrentRecording.Recorder == Enums.Recorder.TibiaMovie) p.GetPosition += 2;
                                if (Client.TibiaVersion >= 770)
                                {
                                    p = p.XteaEncrypt(this.XteaKey, 0);
                                }
                                p.Send(this.TcpClientLocal);
                                this.CurrentPacket++;
                            }
                            this.DoFastForward = false;
                            hasShownInfo       = false;
                        }
                        else if (this.PlaybackSpeed <= 0)
                        {
                            Thread.Sleep(200); continue;
                        }

                        if (/*Client.TibiaVersion == 740 && */ !hasShownInfo && this.CurrentPacket > 3 && Client.Player.Connected)
                        {
                            Thread.Sleep(100);
                            Objects.Packet packet = new Objects.Packet();
                            packet.AddByte(0xb4); // text message
                            packet.AddByte(16);   // orange color
                            packet.AddString("Welcome to a Tibianic Tools recording!\nKeyboard hotkeys:\nArrow keys - change playback speed\nBackspace - rewind 1 minute");
                            packet.AddByte(0xb4);
                            packet.AddByte(16);
                            packet.AddString("Text commands:\ninfo - show recording information\ngoto hh:mm:ss - rewinds/fast forwards to given time\npause - pauses playback\nresume - resumes playback");
                            packet.AddLength();
                            if (Client.TibiaVersion >= 770)
                            {
                                packet.XteaEncrypt(this.XteaKey, packet.GetPosition); packet.AddLength();
                            }
                            packet.Send(this.TcpClientLocal);

                            hasShownInfo = true;
                            Thread.Sleep(20);
                        }

                        p = this.CurrentRecording.Packets[this.CurrentPacket].Clone();
                        this.CurrentRecording.TimePassed = p.Time;
                        timeNew = this.CurrentRecording.TimePassed;
                        int sleep = (int)((timeNew - timeOld) / this.PlaybackSpeed);
                        //if (this.CurrentRecording.Recorder == Enums.Recorder.TibianicTools) p.GetPosition += 4; // length, not needed
                        //else if (this.CurrentRecording.Recorder == Enums.Recorder.TibiaMovie) p.GetPosition += 2; // -||-
                        // try-catch because Thread.Interrupt() will throw an exception
                        try { if (sleep > 0)
                              {
                                  Thread.Sleep(sleep);
                              }
                        }
                        catch { }
                        if (!this.TcpClientLocal.Connected)
                        {
                            return;
                        }
                        if (Client.TibiaVersion >= 770)
                        {
                            p = p.XteaEncrypt(this.XteaKey, 0);
                        }
                        p.Send(this.TcpClientLocal);
                        if (this.CurrentRecording.MouseRecording != null)
                        {
                            MouseRecording mouseRec = this.CurrentRecording.MouseRecording;
                            //int currentTime = mouseRec.Seek(this.CurrentRecording.TimePassed);
                            int mouseTime = mouseRec.CurrentIndex * mouseRec.Interval;
                            int timeMarginMax = mouseTime + 200, timeMarginMin = mouseTime - 200;
                            if (timeNew >= timeMarginMax || timeNew <= timeMarginMin)
                            {
                                this.CurrentRecording.MouseRecording.CurrentIndex = this.CurrentRecording.MouseRecording.Seek(timeNew);
                            }
                        }
                        timeOld = timeNew;
                        this.CurrentPacket++;
                    }
                }
                catch { }
                Thread.Sleep(3000);
                this.PlaybackSpeed = 1;
                WinApi.SetWindowText(Client.Tibia.MainWindowHandle, "Tibia");
                if (TcpClientLocal != null)
                {
                    TcpClientLocal.Close();
                }
                if (this.DoKillAfterPlayback && !Client.Tibia.HasExited)
                {
                    Client.Tibia.Kill();
                }
                else
                {
                    this.AutoPlayback = false;
                }
            }
            catch (Exception ex) { /*System.Windows.Forms.MessageBox.Show(ex.Message + "\n" + ex.StackTrace);*/ }
        }
예제 #11
0
        private void HandleTcpServer()
        {
            try
            {
                if (TcpClientServer == null)
                {
                    return;
                }
                NetworkStream nstream = TcpClientServer.GetStream();
                int           connection = 0;
                bool          changeCharacterList = false, sentAnimatedTextPacket = false;
                while (true)
                {
                    Objects.Packet p = Objects.Packet.GetNextPacket(nstream);
                    if (p.Length == 0)
                    {
                        break;
                    }

                    if (connection != 8)
                    {
                        connection = Memory.ReadByte(Addresses.Client.Connection);
                    }
                    if (connection == 3)
                    {
                        changeCharacterList = true;
                        Memory.WriteByte(Addresses.Charlist.NumberOfCharacters, 0);
                    }
                    else if (connection > 5 && this.IsRunning)
                    {
                        if (connection == 8 && !sentAnimatedTextPacket)
                        {
                            Objects.Packet animPacket = new Objects.Packet();
                            animPacket.AddByte((byte)Addresses.Enums.IncomingPacketTypes.AnimatedText);
                            animPacket.AddUInt16(Client.Player.X);
                            animPacket.AddUInt16(Client.Player.Y);
                            animPacket.AddByte(Client.Player.Z);
                            animPacket.AddByte(181);
                            animPacket.AddString("Recording!");
                            animPacket.AddLength();
                            if (Client.TibiaVersion >= 770)
                            {
                                animPacket.XteaEncrypt(this.XteaKey); animPacket.AddLength();
                            }
                            animPacket.Send(TcpClientLocal);
                            sentAnimatedTextPacket = true;
                        }
                        if (!this.RecordingStopwatch.IsRunning)
                        {
                            this.RecordingStopwatch.Start();
                        }
                        if (this.CurrentRecording.MouseRecording != null && !this.CurrentRecording.MouseRecording.IsRecording)
                        {
                            this.CurrentRecording.MouseRecording.StartRecording();
                        }
                        Objects.Packet temp = new Objects.Packet();
                        //temp.AddUInt32((uint)this.RecordingStopwatch.ElapsedMilliseconds);
                        if (Client.TibiaVersion >= 770)
                        {
                            Objects.Packet decryptedPacket = p.XteaDecrypt(this.XteaKey, 2);
                            //temp.AddUInt32((uint)decryptedPacket.Length);
                            temp.AddBytes(decryptedPacket.ToBytes());
                        }
                        else
                        {
                            //temp.AddUInt32((uint)p.Length);
                            temp.AddBytes(p.ToBytes());
                        }
                        this.CurrentRecording.Packets.Add(new Recording.Packet((uint)this.RecordingStopwatch.ElapsedMilliseconds, temp.ToBytes()));
                        this.CurrentRecording.TimePassed = (uint)this.RecordingStopwatch.ElapsedMilliseconds;
                    }
                    p.Send(this.TcpClientLocal);
                }

                if (changeCharacterList)
                {
                    changeCharacterList = false;
                    for (int i = 0; i < 100; i++)
                    {
                        if (Memory.ReadInt(Addresses.Client.DialogOpen) > 0 &&
                            Memory.ReadByte(Addresses.Charlist.NumberOfCharacters) > 0)
                        {
                            this.CachedCharacterList = CharacterList.GetPlayers();
                            Client.Charlist.WriteIP("127.0.0.1", this.ListenerPort);
                            break;
                        }
                        else if (Memory.ReadInt(Addresses.Client.DialogOpen) > 0 &&
                                 Client.Misc.DialogTitle == "Enter Game")
                        {
                            break;
                        }
                        Thread.Sleep(100);
                    }
                }

                if (this.TcpClientLocal != null)
                {
                    this.TcpClientLocal.Close();
                }
                if (this.TcpClientServer != null)
                {
                    this.TcpClientServer.Close();
                }
            }
            catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message + "\n" + ex.StackTrace); }
        }
예제 #12
0
        /// <summary>
        /// Handles the local Tibia client connection. Should be run on its own thread.
        /// </summary>
        private void HandleTcpLocal()
        {
            try
            {
                if (TcpClientLocal == null)
                {
                    return;
                }
                NetworkStream nstream         = TcpClientLocal.GetStream();
                int           connection      = 0;
                bool          obtainedXteaKey = false;

                while (true)
                {
                    Objects.Packet p = Objects.Packet.GetNextPacket(nstream);
                    if (p.Length == 0)
                    {
                        break;
                    }

                    if (!obtainedXteaKey)
                    {
                        if (Client.TibiaVersion >= 770)
                        {
                            this.XteaKey = new uint[4];
                            for (int i = 0; i < 4; i++)
                            {
                                this.XteaKey[i] = Memory.ReadUInt(Addresses.Client.XTEAKey + i * 4);
                            }
                        }
                        obtainedXteaKey = true;
                    }

                    if (connection != 8)
                    {
                        connection = Memory.ReadByte(Addresses.Client.Connection);
                        if (connection == 6) // connecting to gameserver
                        {
                            try
                            {
                                byte index = Memory.ReadByte(Addresses.Charlist.SelectedIndex);
                                if (index < 0 || index >= this.CachedCharacterList.Count)
                                {
                                    break;                                                       // invalid index
                                }
                                CharacterList.Player player = this.CachedCharacterList[index];
                                TcpClientServer = new TcpClient(player.IP, player.Port);
                                Thread t = new Thread(new ThreadStart(HandleTcpServer));
                                t.Start();
                                Thread.Sleep(20); // give thread time to start
                            }
                            catch { break; }
                        }
                        else if (connection > 0 && connection < 6) // connecting to login server, not sure exactly what value it should be
                        {
                            try
                            {
                                this.TcpClientServer = new TcpClient(this.ServerInfo.IP, this.ServerInfo.Port);
                                Thread t = new Thread(new ThreadStart(HandleTcpServer));
                                t.Start();
                                Thread.Sleep(20); // give thread time to start
                            }
                            catch { break; } // couldn't connect to server
                        }
                    }
                    p.Send(this.TcpClientServer);

                    try
                    {
                        if (Client.TibiaVersion >= 770)
                        {
                            p = p.XteaDecrypt(this.XteaKey, 2);
                        }
                        ushort len        = p.GetUInt16();
                        byte   packetType = p.GetByte();
                        if (!Settings.Tibiacam.Recorder.Filters.OutgoingPrivateMessages && packetType == 0x96 && Client.TibiaVersion == 740)
                        {
                            if (p.GetByte() != 0x04)
                            {
                                continue;
                            }
                            Objects.Packet pm = new Objects.Packet();
                            pm.AddByte((byte)Addresses.Enums.IncomingPacketTypes.CreatureSpeech);
                            string recipient = p.GetString();
                            pm.AddString(recipient);
                            pm.AddByte(0x04);
                            string msg = p.GetString();
                            pm.AddString("» " + msg);
                            pm.AddLength();
                            //Objects.Packet temp = new Objects.Packet();
                            //temp.AddUInt32((uint)this.RecordingStopwatch.ElapsedMilliseconds);
                            //temp.AddUInt32((uint)pm.Length);
                            //temp.AddBytes(pm.ToBytes());
                            CurrentRecording.Packets.Add(new Recording.Packet((uint)this.RecordingStopwatch.ElapsedMilliseconds, pm.ToBytes()));
                        }
                    }
                    catch { }
                }
                if (this.TcpClientLocal != null)
                {
                    this.TcpClientLocal.Close();
                }
                if (this.TcpClientServer != null)
                {
                    this.TcpClientServer.Close();
                }
            }
            catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message + "\n" + ex.StackTrace); }
        }
예제 #13
0
파일: Cavebot.cs 프로젝트: KyLuaa/bot
        /// <summary>
        /// Loads data (waypoints, loot, targets, settings) from a file.
        /// </summary>
        /// <param name="file">The file to load.</param>
        /// <returns>Returns true if file is found and is valid, false if not.</returns>
        public bool Load(FileInfo file)
        {
            if (!file.Exists) return false;

            if (file.Extension.ToLower() == ".cs")
            {
                Objects.Script script = new Objects.Script(this.Client, file);
                this.Clear();
                script.Run();
                return true;
            }
            else
            {
                Objects.Packet p = new Objects.Packet();
                using (FileStream fstream = file.OpenRead())
                {
                    byte[] buffer = new byte[fstream.Length];
                    fstream.Read(buffer, 0, buffer.Length);
                    p = new Objects.Packet(buffer);
                }
                // read metadata
                ushort version = p.GetUInt16();
                if (this.Load(version, p)) return true;
                this.RemoveAllWaypoints();
                this.RemoveAllLoot();
                this.RemoveAllTargets();
                this.CurrentSettings.LoadDefaults();
                return false;
            }
        }
예제 #14
0
파일: Client.cs 프로젝트: uvbs/bot-2016
        /// <summary>
        /// Will attempt to load object properties.
        /// </summary>
        /// <exception cref="Exception"></exception>
        private void LoadObjectProperties()
        {
            byte   itemIdOffset = 100;
            string localDatFile = "ObjectProperties" + this.TibiaVersion + ".dat";
            string datPath      = this.TibiaProcess.MainModule.FileName;

            datPath = datPath.Substring(0, datPath.LastIndexOf(Path.DirectorySeparatorChar) + 1) + "Tibia.dat";

            if (!File.Exists(datPath))
            {
                throw new Exception("Could not load object properties since Tibia.dat could not be found in the client's directory." +
                                    "\nWithout object properties, modules like cavebot will not function properly.");
            }

            using (BinaryReader readerDatFile = new BinaryReader(File.OpenRead(datPath)))
            {
                bool queryServer = false, queryClient = false;
                System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
                byte[] datHash = md5.ComputeHash(readerDatFile.BaseStream);
                readerDatFile.BaseStream.Position = 4; // first 4 bytes is file signature

                if (File.Exists(localDatFile))
                {
                    using (BinaryReader readerLocalFile = new BinaryReader(File.OpenRead(localDatFile)))
                    {
                        if (datHash.DataEquals(readerLocalFile.ReadBytes(datHash.Length)))
                        {
                            ushort count = readerLocalFile.ReadUInt16();
                            this.ObjectProperties = new Objects.ObjectProperties[count];
                            for (ushort i = 0; i < count; i++)
                            {
                                try
                                {
                                    Objects.ObjectProperties objProperty = new Objects.ObjectProperties((ushort)(i + itemIdOffset));
                                    objProperty.Flags        = readerLocalFile.ReadUInt32();
                                    this.ObjectProperties[i] = objProperty;
                                    if (this.ObjectPropertyRead != null)
                                    {
                                        this.ObjectPropertyRead(i, count);
                                    }
                                }
                                catch
                                {
                                    queryServer = true;
                                    break;
                                }
                            }
                            if (!queryClient && !queryServer)
                            {
                                if (this.ObjectPropertiesFinishedReading != null)
                                {
                                    this.ObjectPropertiesFinishedReading(count);
                                }
                                return;
                            }
                        }
                        else
                        {
                            queryServer = true;
                        }
                    }
                }
                else
                {
                    queryServer = true;
                }

                if (queryServer)
                {
                    try
                    {
                        TcpClient      tc = new TcpClient(this.ObjectPropertiesServerIP, this.ObjectPropertiesServerPort);
                        Objects.Packet p  = new Objects.Packet();
                        p.AddBytes(datHash);
                        p.AddLength();
                        p.Send(tc);

                        p = Objects.Packet.GetNextPacket(tc.GetStream());
                        if (p.Length == 0)
                        {
                            queryClient = true;
                        }
                        else
                        {
                            p.GetUInt16();
                            byte[] hash  = p.GetBytes(datHash.Length);
                            ushort count = p.GetUInt16();
                            byte[] data  = p.GetBytes(count * 4);
                            tc.Close();
                            this.ObjectProperties = new Objects.ObjectProperties[count];
                            for (ushort i = 0; i < count; i++)
                            {
                                var objProps = new Objects.ObjectProperties((ushort)(itemIdOffset + i));
                                objProps.Flags           = BitConverter.ToUInt32(data, i * 4);
                                this.ObjectProperties[i] = objProps;
                                if (this.ObjectPropertyRead != null)
                                {
                                    this.ObjectPropertyRead(i, count);
                                }
                            }
                            if (this.ObjectPropertiesFinishedReading != null)
                            {
                                this.ObjectPropertiesFinishedReading(count);
                            }
                            this.SaveObjectProperties(datHash);
                            return;
                        }
                    }
                    catch
                    {
                        queryClient = true;
                    }
                }

                if (queryClient)
                {
                    try
                    {
                        ushort itemCount = (ushort)(readerDatFile.ReadUInt16() - itemIdOffset);
                        this.ObjectProperties = new Objects.ObjectProperties[itemCount];
                        for (int i = 0; i < itemCount; i++)
                        {
                            Objects.ObjectProperties objProperties = new ObjectProperties((ushort)(i + itemIdOffset));
                            switch (this.TibiaVersion)
                            {
                            case 772:
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.HasAutomapColor))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.HasAutomapColor);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.HasHelpLens))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.HasHelpLens);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsBlocking))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsBlocking);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsContainer))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsContainer);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsFloorChange))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsFloorChange);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsFluidContainer))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsFluidContainer);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsGround))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsGround);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsHangable))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsHangable);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsImmobile))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsImmobile);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsAlwaysTopUse))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsAlwaysTopUse);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsMissileBlocking))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsMissileBlocking);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsPathBlocking))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsPathBlocking);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsPickupable))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsPickupable);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsSplash))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsSplash);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsStackable))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsStackable);
                                }
                                //if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsTopOrder1)) objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsTopOrder1);
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsTopOrder2))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsTopUseIfOnly);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsTopOrder3))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsWalkThrough);
                                }
                                if (this.Packets.GetObjectProperty((ushort)(i + itemIdOffset), (byte)Enums.ObjectProperties772.IsUsable))
                                {
                                    objProperties.AddFlag(Enums.ObjectPropertiesFlags.IsUsable);
                                }
                                break;
                            }
                            this.ObjectProperties[i] = objProperties;
                            if (this.ObjectPropertyRead != null)
                            {
                                this.ObjectPropertyRead(i + 1, itemCount);
                            }
                        }
                        if (this.ObjectPropertiesFinishedReading != null)
                        {
                            this.ObjectPropertiesFinishedReading(itemCount);
                        }
                        this.SaveObjectProperties(datHash);
                    }
                    catch (Exception ex)
                    {
                        if (this.ObjectPropertiesFailed != null)
                        {
                            this.ObjectPropertiesFailed(ex);
                        }
                    }
                }
            }
        }