Ejemplo n.º 1
0
        private static void Initialize()
        {
            StartupPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (StartupPath == null)
            {
                throw new InvalidOperationException();
            }

            AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;

            PacketWaitEntries = new PacketWaitEntries();

            _incomingQueue = new ThreadQueue <Packet>(ProcessIncomingQueue);
            _outgoingQueue = new ThreadQueue <Packet>(ProcessOutgoingQueue);

            IncomingPacketHandlers.Initialize();
            OutgoingPacketHandlers.Initialize();

            IncomingPacketFilters.Initialize();
            OutgoingPacketFilters.Initialize();

            CommandsManager.Initialize();

            AssistantOptions.Load();
        }
Ejemplo n.º 2
0
        public void WontThrowExceptionDuplicateKey()
        {
            byte[] packet =
            {
                0xb1, 0x00, 0x83, 0x00, 0x1d, 0x78, 0xb9, 0x04, 0x5d, 0xd3, 0xaa, 0x00, 0x00, 0x00, 0x01, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0xb3, 0xd9, 0xd5, 0x89, 0x00,
                0x20, 0xc2, 0xb9, 0xb0, 0x99, 0x00, 0x00, 0x00, 0x18, 0x00, 0x46, 0x00, 0x69, 0x00, 0x73, 0x00,
                0x68, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x43, 0x00, 0x68, 0x00, 0x69, 0x00, 0x70, 0x00,
                0x73, 0x00, 0x20, 0xc7, 0x74, 0x00, 0x20, 0xb2, 0xf9, 0xc2, 0xe0, 0xc7, 0x44, 0x00, 0x20, 0xcd,
                0x08, 0xb3, 0x00, 0xd5, 0x69, 0xb2, 0xc8, 0xb2, 0xe4, 0x00, 0x00, 0x00, 0x0b, 0xc2, 0x18, 0xb7,
                0x7d, 0xc5, 0xec, 0xbd, 0x80, 0xb9, 0x7c, 0x00, 0x20, 0xd0, 0x74, 0xb9, 0xad, 0xd5, 0x58, 0xc1,
                0x38, 0xc6, 0x94, 0x00, 0x00, 0x00, 0x02, 0xc2, 0x18, 0xb7, 0x7d, 0x00, 0x00, 0x00, 0x02, 0xac,
                0x70, 0xc8, 0x08
            };

            PacketHandler handler = OutgoingPacketHandlers.GetHandler(packet[0]);

            try
            {
                handler.OnReceive(new PacketReader(packet, packet.Length, false));
            }
            catch (Exception)
            {
                Assert.Fail();
                throw;
            }
        }
Ejemplo n.º 3
0
        public void Initialize()
        {
            Engine.Items   = new ItemCollection(0);
            Engine.Mobiles = new MobileCollection(Engine.Items);
            Engine.Player  = new PlayerMobile(1);

            OutgoingPacketHandlers.Initialize();
        }
Ejemplo n.º 4
0
        internal static bool Initialize(MainWindow mainWindow)
        {
            if (File.Exists(Path.Combine(StartupPath, "Updater_New.exe")))
            {
                try
                {
                    File.Copy(Path.Combine(StartupPath, "Updater_New.exe"), Path.Combine(StartupPath, "Updater.exe"), true);
                }
                catch (Exception)
                {
                }
            }

            string[] renameFiles = Directory.GetFiles(StartupPath, "*.new", SearchOption.AllDirectories);
            foreach (string renameFile in renameFiles)
            {
                string path     = Path.GetDirectoryName(renameFile);
                string origFile = Path.Combine(path, Path.GetFileNameWithoutExtension(renameFile));
                try
                {
                    File.Delete(origFile);
                    File.Move(renameFile, origFile);
                }
                catch (Exception)
                {
                }
            }

            if (!MainWindow.CurrentOptions.IsValid())
            {
                return(false);
            }
            //try { Config.Register( "UOM hooks", Path.Combine( StartupPath, "UOMachine.exe" ), Path.Combine( StartupPath, "ClientHook.dll" ) ); }
            //catch (Exception ex)
            //{
            //    Utility.Log.LogMessage( ex );
            //    /* Ensure EasyHook files are in output directory if you get this error */
            //    System.Windows.MessageBox.Show( Strings.ErrorwithGACinstallation );
            //    return false;
            //}
            myMainWindow = mainWindow;
            InternalEventHandler.IncomingPacketHandler.Initialize();
            InternalEventHandler.OutgoingPacketHandler.Initialize();
            Network.Initialize();
            InternalEventHandler.IPCHandler.Initialize();
            mySkillNames = Skills.GetSkills(MainWindow.CurrentOptions.UOFolder);
            TileData.Initialize(MainWindow.CurrentOptions.UOFolder);
            Map.Initialize(MainWindow.CurrentOptions.UOFolder, MainWindow.CurrentOptions.CacheLevel);
            Art.Initialize(MainWindow.CurrentOptions.UOFolder);
            Cliloc.Initialize(MainWindow.CurrentOptions.UOFolder);
            NamespaceToAssembly.Initialize();
            IncomingPacketHandlers.Initialize();
            OutgoingPacketHandlers.Initialize();
            return(true);
        }
Ejemplo n.º 5
0
            private static void ServerInstance_OutgoingPacketEvent(int clientID, byte[] data)
            {
                int           clientIndex = GetClient(clientID);
                PacketHandler handler     = OutgoingPacketHandlers.GetHandler(data[0]);

                if (handler != null)
                {
                    handler.OnReceive(clientIndex, new PacketReader(data, data.Length, handler.Length != 0));
                }
                LowLevel.OnOutgoingPacket(clientIndex, data);
            }
Ejemplo n.º 6
0
        public void WillSetHolding()
        {
            byte[] packet = { 0x07, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };

            PacketHandler handler = OutgoingPacketHandlers.GetHandler(0x07);

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

            Assert.AreEqual(unchecked ((int)0xAABBCCDD), Engine.Player.Holding);
            Assert.AreEqual(0xEEFF, Engine.Player.HoldingAmount);
        }
Ejemplo n.º 7
0
        private static void ProcessOutgoingQueue(Packet packet)
        {
            PacketSentEvent?.Invoke(packet.GetPacket(), packet.GetLength());

            PacketHandler handler = OutgoingPacketHandlers.GetHandler(packet.GetPacketID());

            int length = _getPacketLength(packet.GetPacketID());

            handler?.OnReceive?.Invoke(new PacketReader(packet.GetPacket(), packet.GetLength(), length > 0));

            PacketWaitEntries.CheckWait(packet.GetPacket(), PacketDirection.Outgoing);
        }
Ejemplo n.º 8
0
        public void WontThrowExceptionVersionAlpha()
        {
            // 5.0.1j
            byte[] packet = { 0xbd, 0x00, 0x0a, 0x35, 0x2e, 0x30, 0x2e, 0x31, 0x6a, 0x00 };

            OutgoingPacketHandlers.Initialize();

            PacketHandler handler = OutgoingPacketHandlers.GetHandler(0xBD);

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

            Engine.ClientVersion = null;
        }
Ejemplo n.º 9
0
        private static void Initialize()
        {
            StartupPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (StartupPath == null)
            {
                throw new InvalidOperationException();
            }

            AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;

            PacketWaitEntries = new PacketWaitEntries();

            _incomingQueue = new ThreadQueue <Packet>(ProcessIncomingQueue);
            _outgoingQueue = new ThreadQueue <Packet>(ProcessOutgoingQueue);

            IncomingPacketHandlers.Initialize();
            OutgoingPacketHandlers.Initialize();

            OutgoingPacketFilters.Initialize();

            CommandsManager.Initialize();

            string langOverridePath = Path.Combine(StartupPath, "Data", "languageOverride.json");

            if (!File.Exists(langOverridePath))
            {
                return;
            }

            string fileText = File.ReadAllText(langOverridePath);

            JObject jsonObject = JObject.Parse(fileText);

            if (jsonObject?["Language"] == null)
            {
                return;
            }

            Language lang = (Language)jsonObject["Language"]?.ToObject <Language>();

            if (lang != Language.Default)
            {
                Options.SetLanguage(lang);
            }

            Options.LanguageOverride = lang;
        }
Ejemplo n.º 10
0
        public void WillChangeLastAliasOnTargetSent()
        {
            _player.LastTargetSerial = 0x02;

            AliasCommands.SetDefaultAliases();

            Assert.AreEqual(0x02, AliasCommands.GetAlias("last"));

            OutgoingPacketHandlers.Initialize();
            PacketHandler handler = OutgoingPacketHandlers.GetHandler(0x6C);

            byte[] packet =
            {
                0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xBB, 0xCC, 0xDD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
            };

            handler?.OnReceive(new PacketReader(packet, packet.Length, true));

            Assert.AreEqual(0xAABBCCDD, (uint)AliasCommands.GetAlias("last"));
        }
Ejemplo n.º 11
0
        public void Initialize()
        {
            _packetLengths = new int[byte.MaxValue];

            string json = File.ReadAllText(Path.Combine(Environment.CurrentDirectory,
                                                        "packetlengths.json"));

            JObject jsonObj = JObject.Parse(json);

            foreach (JProperty token in jsonObj["PacketLengths"].Children <JProperty>())
            {
                int key = int.Parse(token.Name);
                int val = token.Value.ToObject <int>();

                if (val == 0x8000)
                {
                    val = 0;
                }

                _packetLengths[key] = val;
            }

            _player = new PlayerMobile(0x01)
            {
                Equipment = new ItemCollection(0x01)
            };
            _backpack = new Item(0x40000002)
            {
                Container = new ItemCollection(0x40000002), Owner = 0x01
            };
            _player.SetLayer(Layer.Backpack, _backpack.Serial);

            Engine.Items.Add(_backpack);

            Engine.Player = _player;

            IncomingPacketHandlers.Initialize();
            OutgoingPacketHandlers.Initialize();

            Engine.InternalPacketSentEvent += OnInternalPacketSentEvent;
        }
Ejemplo n.º 12
0
        private static void ProcessOutgoingQueue(Packet packet)
        {
            try
            {
                PacketSentEvent?.Invoke(packet.GetPacket(), packet.GetLength());

                PacketHandler handler = OutgoingPacketHandlers.GetHandler(packet.GetPacketID());

                int length = _getPacketLength(packet.GetPacketID());

                handler?.OnReceive?.Invoke(new PacketReader(packet.GetPacket(), packet.GetLength(), length > 0));

                PacketWaitEntries.CheckWait(packet.GetPacket(), PacketDirection.Outgoing);
            }
            catch (Exception e)
            {
                e.ToExceptionless().SetProperty("Packet", packet.GetPacket())
                .SetProperty("Player", Player.ToString()).SetProperty("WorldItemCount", Items.Count())
                .SetProperty("WorldMobileCount", Mobiles.Count()).Submit();
            }
        }
Ejemplo n.º 13
0
        private void OnInternalPacketSentEvent(byte[] data, int length)
        {
            PacketHandler handler = OutgoingPacketHandlers.GetHandler(data[0]);

            handler?.OnReceive(new PacketReader(data, data.Length, _packetLengths[data[0]] != 0));

            if (data[0] == 0x08)
            {
                int serial          = (data[1] << 24) | (data[2] << 16) | (data[3] << 8) | data[4];
                int containerSerial = (data[11] << 24) | (data[12] << 16) | (data[13] << 8) | data[14];

                //container cont update

                PacketWriter pw = new PacketWriter(21);
                pw.Write((byte)0x25);
                pw.Write(serial);
                pw.Seek(10, SeekOrigin.Current);
                pw.Write(containerSerial);
                pw.Write((short)0);

                byte[] packet = pw.ToArray();

                handler = IncomingPacketHandlers.GetHandler(packet[0]);

                handler?.OnReceive(new PacketReader(packet, packet.Length, true));
            }

            if (data[0] == 0x13)
            {
                int   serial          = (data[1] << 24) | (data[2] << 16) | (data[3] << 8) | data[4];
                Layer layer           = (Layer)data[5];
                int   containerSerial = (data[6] << 24) | (data[7] << 16) | (data[8] << 8) | data[9];


                Mobile mobile = Engine.Mobiles.GetMobile(containerSerial);

                int itemInLayer = mobile?.GetLayer(layer) ?? 0;

                if (itemInLayer != 0)
                {
                    // item already in layer / liftrej
                    return;
                }

                // equip update

                PacketWriter pw = new PacketWriter(15);
                pw.Write((byte)0x2E);
                pw.Write(serial);
                pw.Write((short)0);
                pw.Write((byte)0);
                pw.Write((byte)layer);
                pw.Write(containerSerial);
                pw.Write((short)0);

                byte[] packet = pw.ToArray();

                handler = IncomingPacketHandlers.GetHandler(packet[0]);

                handler?.OnReceive(new PacketReader(packet, packet.Length, true));
            }
        }