Ejemplo n.º 1
0
        public void ClilocTest70200()
        {
            string path = @"D:\Clients\7.0.20.0";

            Cliloc.Initialize(path);
            string cliloc = Cliloc.GetProperty(1061638);

            Assert.AreEqual(cliloc, "A House Sign");
            string clilocParam = Cliloc.GetLocalString(1062028, new string[] { "This structure is slightly worn." });

            Assert.AreEqual(clilocParam, "Condition: This structure is slightly worn.");
        }
Ejemplo n.º 2
0
        internal static unsafe void InitializePlugin(PluginHeader *plugin)
        {
            _onConnected             = OnConnected;
            _onDisconnected          = OnDisconnected;
            _onReceive               = OnPacketReceive;
            _onSend                  = OnPacketSend;
            _onPlayerPositionChanged = OnPlayerPositionChanged;
            _onClientClosing         = OnClientClosing;
            _onHotkeyPressed         = OnHotkeyPressed;
            _onMouse                 = OnMouse;
            WindowHandle             = plugin->HWND;

            plugin->OnConnected             = Marshal.GetFunctionPointerForDelegate(_onConnected);
            plugin->OnDisconnected          = Marshal.GetFunctionPointerForDelegate(_onDisconnected);
            plugin->OnRecv                  = Marshal.GetFunctionPointerForDelegate(_onReceive);
            plugin->OnSend                  = Marshal.GetFunctionPointerForDelegate(_onSend);
            plugin->OnPlayerPositionChanged = Marshal.GetFunctionPointerForDelegate(_onPlayerPositionChanged);
            plugin->OnClientClosing         = Marshal.GetFunctionPointerForDelegate(_onClientClosing);
            plugin->OnHotkeyPressed         = Marshal.GetFunctionPointerForDelegate(_onHotkeyPressed);
            plugin->OnMouse                 = Marshal.GetFunctionPointerForDelegate(_onMouse);

            _getPacketLength = Marshal.GetDelegateForFunctionPointer <OnGetPacketLength>(plugin->GetPacketLength);
            _getUOFilePath   = Marshal.GetDelegateForFunctionPointer <OnGetUOFilePath>(plugin->GetUOFilePath);
            _sendToClient    = Marshal.GetDelegateForFunctionPointer <OnPacketSendRecv>(plugin->Recv);
            _sendToServer    = Marshal.GetDelegateForFunctionPointer <OnPacketSendRecv>(plugin->Send);
            _requestMove     = Marshal.GetDelegateForFunctionPointer <RequestMove>(plugin->RequestMove);
            _setTitle        = Marshal.GetDelegateForFunctionPointer <OnSetTitle>(plugin->SetTitle);

            ClientPath    = _getUOFilePath();
            ClientVersion = new Version((byte)(plugin->ClientVersion >> 24), (byte)(plugin->ClientVersion >> 16),
                                        (byte)(plugin->ClientVersion >> 8), (byte)plugin->ClientVersion);

            if (!Path.IsPathRooted(ClientPath))
            {
                ClientPath = Path.GetFullPath(ClientPath);
            }

            Art.Initialize(ClientPath);
            Hues.Initialize(ClientPath);
            Cliloc.Initialize(ClientPath);
            Skills.Initialize(ClientPath);
            Speech.Initialize(ClientPath);
            TileData.Initialize(ClientPath);
            Statics.Initialize(ClientPath);
            MapInfo.Initialize(ClientPath);

            ClassicAssembly = AppDomain.CurrentDomain.GetAssemblies()
                              .FirstOrDefault(a => a.FullName.StartsWith("ClassicUO,"));

            InitializeExtensions();
        }
Ejemplo n.º 3
0
        public void WillParseAuctionSafeGump()
        {
            const string localPath = @"C:\Users\johns\Desktop\KvG Client 2.0";

            if (!Directory.Exists(localPath))
            {
                Debug.WriteLine("Not running test, requires Cliloc.enu");
                return;
            }

            Cliloc.Initialize(localPath);

            const string layout =
                "{ resizepic 0 0 9300 400 600 }{ xmfhtmltok 10 10 400 18 0 0 22660 1114513 @Heritage Raffle@ }{ xmfhtmltok 0 70 198 18 0 0 22660 1114514 @Can Buy Unlimited Tickets:@ }{ htmlgump 202 70 200 18 0 0 0 }{ xmfhtmltok 0 100 198 18 0 0 22660 1114514 @Currency Type:@ }{ htmlgump 202 100 200 18 1 0 0 }{ xmfhtmltok 0 130 198 18 0 0 22660 1114514 @Ticket Price:@ }{ htmlgump 202 130 200 18 2 0 0 }{ xmfhtmltok 0 160 198 18 0 0 22660 1114514 @Tickets Bought:@ }{ htmlgump 202 160 200 18 3 0 0 }{ xmfhtmltok 0 190 200 18 0 0 22660 1114514 @Odds of Winning:@ }{ htmlgump 202 190 200 18 4 0 0 }{ xmfhtmltok 0 220 198 18 0 0 22660 1114514 @Raffled Item:@ }{ xmfhtmltok 202 220 200 20 0 0 16 1114779 @The Lucky Sovereign Steed@ }{ tilepichue 90 314 8413 1152 }{ itemproperty 1074292781 }{ xmfhtmltok 200 243 200 18 0 0 22660 1154645 @Raffled Item Description:@ }{ htmlgump 202 263 197 140 5 1 1 }{ xmfhtmltok 0 450 198 18 0 0 22660 1114514 @Raffle Ticket Amount@ }{ resizepic 202 450 9350 193 22 }{ textentry 204 450 192 20 0 0 6 }{ button 168 480 4005 4007 1 0 1 }{ htmlgump 202 480 198 18 7 0 0 }{ xmfhtmltok 0 530 198 18 0 0 22660 1114514 @Raffle Ends:@ }{ htmlgump 202 530 198 18 8 0 0 }{ button 360 570 4020 4022 1 0 0 }{ xmfhtmltok 250 570 100 20 0 0 0 1114514 @#1060675@ }";

            Gump gump = GumpParser.Parse(0x01, 0x01, 1, 1, layout,
                                         new[] { "unknown", "unknown", "unknown", "unknown", "unknown", "unknown", "", "", "" });
        }
        public void WillGetPropertyValue()
        {
            const string localPath = @"C:\Users\johns\Desktop\KvG Client 2.0";

            if (!Directory.Exists(localPath))
            {
                Debug.WriteLine("Not running test, requires Cliloc.enu");
                return;
            }

            Cliloc.Initialize(localPath);

            byte[] packet =
            {
                0xD6, 0x00, 0x43, 0x00, 0x01, 0x40, 0xC5, 0xF6, 0x09, 0x00, 0x00, 0x02, 0xA0, 0x3B, 0xCF, 0x00,
                0x0F, 0x9E, 0xD5, 0x00, 0x00, 0x00, 0x10, 0x5E, 0x95, 0x00, 0x04, 0x37, 0x00, 0x34, 0x00, 0x00,
                0x10, 0x5C, 0x71, 0x00, 0x1A, 0x34, 0x00, 0x39, 0x00, 0x09, 0x00, 0x31, 0x00, 0x32, 0x00, 0x35,
                0x00, 0x09, 0x00, 0x37, 0x00, 0x31, 0x00, 0x09, 0x00, 0x35, 0x00, 0x35, 0x00, 0x30, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            Item item = new Item(0x40c5f609);

            Engine.Items.Add(item);

            IncomingPacketHandlers.Initialize();

            PacketHandler handler = IncomingPacketHandlers.GetHandler(0xD6);

            handler.OnReceive(new PacketReader(packet, packet.Length, false));

            Assert.IsNotNull(item.Properties);

            int value = PropertiesCommands.PropertyValue <int>(item.Serial, "Contents");

            Assert.AreEqual(49, value);

            value = PropertiesCommands.PropertyValue <int>(item.Serial, "Contents", 2);

            Assert.AreEqual(71, value);

            Engine.Items.Clear();
        }
Ejemplo n.º 5
0
        public void WillParseXmfHtmlTokCliloc()
        {
            const string localPath = @"C:\Users\johns\Desktop\KvG Client 2.0";

            if (!Directory.Exists(localPath))
            {
                Debug.WriteLine("Not running test, requires Cliloc.enu");
                return;
            }

            Cliloc.Initialize(localPath);

            const string layout = "{ xmfhtmltok 250 570 100 20 0 0 0 1114514 @#1060675@ }";

            Gump gump = GumpParser.Parse(0x01, 0x01, 1, 1, layout, new string[] { });

            GumpElement ge = gump.GetElementByXY(250, 570);

            Assert.AreEqual("<DIV ALIGN=RIGHT>CLOSE</DIV>", ge.Text);
        }
Ejemplo n.º 6
0
        public void WillParseXmfHtmlTokString()
        {
            const string localPath = @"C:\Users\johns\Desktop\KvG Client 2.0";

            if (!Directory.Exists(localPath))
            {
                Debug.WriteLine("Not running test, requires Cliloc.enu");
                return;
            }

            Cliloc.Initialize(localPath);

            const string layout = "{ xmfhtmltok 10 10 400 18 0 0 22660 1114513 @Heritage Raffle@ }";

            Gump gump = GumpParser.Parse(0x01, 0x01, 1, 1, layout, new string[] { });

            GumpElement ge = gump.GetElementByXY(10, 10);

            Assert.AreEqual("<DIV ALIGN=CENTER>Heritage Raffle</DIV>", ge.Text);
        }
Ejemplo n.º 7
0
        internal static unsafe void InitializePlugin(PluginHeader *plugin)
        {
            _onConnected             = OnConnected;
            _onDisconnected          = OnDisconnected;
            _onReceive               = OnPacketReceive;
            _onSend                  = OnPacketSend;
            _onPlayerPositionChanged = OnPlayerPositionChanged;
            _onClientClosing         = OnClientClosing;
            _onHotkeyPressed         = OnHotkeyPressed;
            _onMouse                 = OnMouse;
            _hWnd = plugin->HWND;

            plugin->OnConnected             = Marshal.GetFunctionPointerForDelegate(_onConnected);
            plugin->OnDisconnected          = Marshal.GetFunctionPointerForDelegate(_onDisconnected);
            plugin->OnRecv                  = Marshal.GetFunctionPointerForDelegate(_onReceive);
            plugin->OnSend                  = Marshal.GetFunctionPointerForDelegate(_onSend);
            plugin->OnPlayerPositionChanged = Marshal.GetFunctionPointerForDelegate(_onPlayerPositionChanged);
            plugin->OnClientClosing         = Marshal.GetFunctionPointerForDelegate(_onClientClosing);
            plugin->OnHotkeyPressed         = Marshal.GetFunctionPointerForDelegate(_onHotkeyPressed);
            plugin->OnMouse                 = Marshal.GetFunctionPointerForDelegate(_onMouse);

            _getPacketLength = Marshal.GetDelegateForFunctionPointer <OnGetPacketLength>(plugin->GetPacketLength);
            _getUOFilePath   = Marshal.GetDelegateForFunctionPointer <OnGetUOFilePath>(plugin->GetUOFilePath);
            _sendToClient    = Marshal.GetDelegateForFunctionPointer <OnPacketSendRecv>(plugin->Recv);
            _sendToServer    = Marshal.GetDelegateForFunctionPointer <OnPacketSendRecv>(plugin->Send);
            _requestMove     = Marshal.GetDelegateForFunctionPointer <RequestMove>(plugin->RequestMove);

            ClientPath = _getUOFilePath();

            if (!Path.IsPathRooted(ClientPath))
            {
                ClientPath = Path.GetFullPath(ClientPath);
            }

            Art.Initialize(ClientPath);
            Hues.Initialize(ClientPath);
            Cliloc.Initialize(ClientPath);
            Skills.Initialize(ClientPath);
            Speech.Initialize(ClientPath);
            TileData.Initialize(ClientPath);
        }
Ejemplo n.º 8
0
        public void WillRehueMatchingItemProperties()
        {
            const string localPath = @"C:\Users\johns\Desktop\KvG Client 2.0";

            if (!Directory.Exists(localPath))
            {
                Debug.WriteLine("Not running test, requires Cliloc.enu");
                return;
            }

            Cliloc.Initialize(localPath);

            Item corpse = new Item(0x40000000)
            {
                ID = 0x2006
            };

            Engine.Items.Add(corpse);

            IncomingPacketHandlers.Initialize();
            AutolootViewModel vm = new AutolootViewModel {
                Enabled = true
            };

            AutolootEntry lootEntry = new AutolootEntry
            {
                Rehue       = true,
                Autoloot    = false,
                Constraints = new ObservableCollection <AutolootConstraintEntry>(),
                ID          = 0x108a
            };

            AutolootConstraintEntry constraintEntry = new AutolootConstraintEntry
            {
                Property = vm.Constraints.FirstOrDefault(c => c.Name == "Faster Casting"),
                Operator = AutolootOperator.GreaterThan,
                Value    = 1
            };

            lootEntry.Constraints.Add(constraintEntry);

            vm.Items.Add(lootEntry);

            Engine.PacketWaitEntries = new PacketWaitEntries();

            AutoResetEvent are = new AutoResetEvent(false);

            void OnPacketReceivedEvent(byte[] data, int length)
            {
                if (data[0] == 0x25)
                {
                    are.Set();
                }
                else
                {
                    Assert.Fail();
                }
            }

            Engine.InternalPacketReceivedEvent += OnPacketReceivedEvent;

            Engine.PacketWaitEntries.WaitEntryAddedEvent += entry =>
            {
                byte[] containerContentsPacket =
                {
                    0x3C, 0x00, 0x19, 0x00, 0x01, 0x43, 0x13, 0xFC, 0x5E, 0x10, 0x8A, 0x00, 0x00, 0x01, 0x00, 0x13,
                    0x00, 0x82, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00
                };

                PacketHandler handler = IncomingPacketHandlers.GetHandler(0x3C);

                handler.OnReceive(new PacketReader(containerContentsPacket, containerContentsPacket.Length, false));
                entry.Packet = containerContentsPacket;
                entry.Lock.Set();

                byte[] propertiesPacket =
                {
                    0xD6, 0x00, 0x53, 0x00, 0x01, 0x43, 0x13, 0xFC, 0x5E, 0x00, 0x00, 0x01, 0x6E, 0x08, 0xB4, 0x00,
                    0x0F, 0xA0, 0xEA, 0x00, 0x00, 0x00, 0x10, 0x5E, 0x94, 0x00, 0x02, 0x31, 0x00, 0x00, 0x10, 0x2E,
                    0x64, 0x00, 0x14, 0x23, 0x00, 0x31, 0x00, 0x30, 0x00, 0x34, 0x00, 0x34, 0x00, 0x30, 0x00, 0x38,
                    0x00, 0x35, 0x00, 0x09, 0x00, 0x39, 0x00, 0x00, 0x10, 0x2E, 0x3C, 0x00, 0x02, 0x32, 0x00, 0x00,
                    0x10, 0x2E, 0x3D, 0x00, 0x02, 0x31, 0x00, 0x00, 0x10, 0x2E, 0x83, 0x00, 0x02, 0x34, 0x00, 0x00,
                    0x00, 0x00, 0x00
                };

                handler = IncomingPacketHandlers.GetHandler(0xD6);

                handler.OnReceive(new PacketReader(propertiesPacket, propertiesPacket.Length, false));
            };

            vm.OnCorpseEvent(corpse.Serial);

            bool result = are.WaitOne(5000);

            Assert.IsTrue(result);

            Engine.Items.Clear();
            Engine.PacketWaitEntries = null;

            Engine.InternalPacketReceivedEvent -= OnPacketReceivedEvent;
        }