Ejemplo n.º 1
0
        public TradeItem FindItem(string item)
        {
            TradeItem tradeItem = new TradeItem();
            tradeItem.Id = -1;
            int id = -1;

            if (!int.TryParse(item, out id))
                id = TradeItems.Where(i => i.Name == item).First().Id;

            UpdateGUI();

            try
            {
                lock (_lock)
                {
                    foreach (TradeItem titem in TradeItems)
                        if (titem.Id == id || titem.Name.ToLower().Trim() == item.ToLower().Trim())
                            return titem;
                    return null;

                }
            }
            catch (InvalidOperationException ex)
            {
                Helpers.Debug.Report(ex);
            }
            return null;
        }
Ejemplo n.º 2
0
        public void UpdateGUI()
        {
            try
            {
                bool foundTrade = false;
                PositionX = 0;
                PositionY = 0;
                int gp = Memory.ReadInt32(Addresses.Client.GUI);
                PositionX += Memory.ReadInt32(gp + 0x14);
                PositionY += Memory.ReadInt32(gp + 0x18);

                int pointerToPosition = Memory.ReadInt32(gp + 0x38);

                PositionX += Memory.ReadInt32(pointerToPosition + 0x14);
                PositionY += Memory.ReadInt32(pointerToPosition + 0x18);

                int basePointer = Memory.ReadInt32(pointerToPosition + 0x24);

                for (int window = 0; window < 20; window++)
                {
                    if (foundTrade)
                        return;

                    int windowId = Memory.ReadInt32(basePointer + 0x2C);

                    #region Reading info about trade window

                    if (windowId == 0xA)
                    {
                        foundTrade = true;

                        IsOpened = true;
                        PositionX += Memory.ReadInt32(basePointer + 0x14);
                        PositionY += Memory.ReadInt32(basePointer + 0x18);
                        Width = Memory.ReadInt32(basePointer + 0x1C);
                        Height = Memory.ReadInt32(basePointer + 0x20);
                        IsMinimized = (Memory.ReadInt32(basePointer + 0x64) == 1);

                        int pointerToListBox = Memory.ReadInt32(basePointer + 0x44);
                        ItemListPositionX = PositionX + Memory.ReadInt32(pointerToListBox + 0x14);
                        ItemListPositionY = PositionY + Memory.ReadInt32(pointerToListBox + 0x18);
                        ItemListWidth = PositionX + Memory.ReadInt32(basePointer + 0x1C);
                        ItemListHeight = PositionX + Memory.ReadInt32(basePointer + 0x20);

                        int pointerUnknown01 = Memory.ReadInt32(pointerToListBox + 0x34);
                        int pointerUnknown02 = Memory.ReadInt32(pointerUnknown01 + 0x24);
                        int pointerUnknown03 = Memory.ReadInt32(pointerUnknown02 + 0x24);

                        TypeItems = Memory.ReadInt32(pointerUnknown02 + 0x2C);
                        SelectedItem = Memory.ReadInt32(pointerUnknown02 + 0x54);

                        int pointerToBars = Memory.ReadInt32(pointerUnknown03 + 0x24);
                        HeightBar = Memory.ReadInt32(pointerToBars + 0x2C);
                        Valor = Memory.ReadInt32(pointerToBars + 0x30);
                        PositionBar = Memory.ReadInt32(pointerToBars + 0x34);
                        VisibleArea = Memory.ReadInt32(pointerToBars + 0x3C);

                        int pointerToTradeType = Memory.ReadInt32(pointerToListBox + 0x30);
                        TradeType = Memory.ReadInt32(pointerToTradeType + 0x34);

                        int pointerUnknown04 = Memory.ReadInt32(pointerToListBox + 0x38);
                        int pointerUnknown05 = Memory.ReadInt32(pointerUnknown04 + 0x34);
                        int pointerUnknown06 = Memory.ReadInt32(pointerUnknown05 + 0x24);

                        ItemsAmount = Memory.ReadInt32(pointerUnknown06 + 0x30);
                        HeightAmountBar = Memory.ReadInt32(pointerUnknown06 + 0x40);
                        ValorAmountBar = Memory.ReadInt32(pointerUnknown06 + 0x44);
                        MaxAmount = Memory.ReadInt32(pointerUnknown06 + 0x2C);

                        int pointerUnknown07 = Memory.ReadInt32(pointerToListBox + 0x38);
                        int pointerUnknown08 = Memory.ReadInt32(pointerUnknown07 + 0x10);
                        int pointerUnknown09 = Memory.ReadInt32(pointerUnknown08 + 0x38);

                        MaxItems = Memory.ReadInt32(pointerUnknown08 + 0x34);
                        PlayerMoney = Memory.ReadInt32(pointerUnknown08 + 0x3C);

                        TradeItems.Clear();

                        for (int j = 0; j < MaxItems; j++)
                        {
                            TradeItem tradeItem = new TradeItem();
                            tradeItem.Id = Memory.ReadInt32(pointerUnknown09 + j * 0x40);
                            tradeItem.Name = Memory.ReadString(pointerUnknown09 + 8 + j * 0x40);
                            tradeItem.Weight = Memory.ReadInt32(pointerUnknown09 + 0x2C + j * 0x40);
                            tradeItem.Buy = Memory.ReadInt32(pointerUnknown09 + 0x30 + j * 0x40);
                            tradeItem.Sell = Memory.ReadInt32(pointerUnknown09 + 0x34 + j * 0x40);
                            tradeItem.Qtd = Memory.ReadInt32(pointerUnknown09 + 0x38 + j * 0x40);
                            tradeItem.Index = Memory.ReadInt32(pointerUnknown09 + 0x3C + j * 0x40);
                            if (tradeItem.Index != 1)
                                TradeItems.Add(tradeItem);
                        }
                        break;
                    }

                    #endregion

                    basePointer = Memory.ReadInt32(basePointer + 0x10);
                }
            }
            catch (InvalidOperationException ex)
            {
                Helpers.Debug.Report(ex);
            }
        }