Example #1
0
        public override byte[] GenerateSpawnBlob()
        {
            PacketWriter writer = new PacketWriter();
            writer.WriteStruct(Header);
            writer.WritePosition(Position);
            writer.Write((UInt16)0);
            writer.WriteFixedLengthASCII(Name, 0x20);

            writer.Write(0); // Padding?
            writer.Write(new byte[0xC]); // Unknown, usually zero

            writer.Write((UInt16)0);
            writer.Write((UInt16)0);

            writer.Write((UInt32)0);
            writer.Write((UInt32)0);

            writer.Write((UInt32)1101004800); // Always this

            writer.Write((UInt32)0);
            writer.Write((UInt32)0);
            writer.Write((UInt32)0);

            writer.Write((UInt32)1);

            writer.WriteMagic(1, 0x9FCD, 0xE7);
            writer.Write((UInt32)0);

            return writer.ToArray();
        }
Example #2
0
        public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
        {
            var writer = new PacketWriter();
            writer.Write((uint) 0);

            context.SendPacket(0x11, 0x55, 0x0, writer.ToArray());
        }
Example #3
0
        public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
        {
            if (context.Character == null)
                return;

            var reader = new PacketReader(data, position, size);
            reader.BaseStream.Seek(0xC, SeekOrigin.Begin);
            var channel = reader.ReadUInt32();
            var message = reader.ReadUtf16(0x9D3F, 0x44);

            if (message.StartsWith(PolarisApp.Config.CommandPrefix))
            {
                var valid = false;

                // Iterate commands
                foreach (var command in PolarisApp.ConsoleSystem.Commands)
                {
                    var full = message.Substring(1); // Strip the command chars
                    var args = full.Split(' ');

                    if (command.Names.Any(name => args[0].ToLower() == name.ToLower()))
                    {
                        command.Run(args, args.Length, full, context);
                        valid = true;
                        Logger.WriteCommand(null, "[CMD] {0} issued command {1}", context.User.Username, full);
                    }

                    if (valid)
                        break;
                }

                if (!valid)
                    Logger.WriteClient(context, "[CMD] {0} - Command not found", message.Split(' ')[0].Trim('\r'));
            }
            else
            {
                Logger.Write("[CHT] <{0}> <{1}>", context.Character.Name, message);

                var writer = new PacketWriter();
                writer.WritePlayerHeader((uint) context.User.PlayerId);
                writer.Write(channel);
                writer.WriteUtf16(message, 0x9D3F, 0x44);

                data = writer.ToArray();

                foreach (var c in Server.Instance.Clients)
                {
                    if (c.Character == null || c.CurrentZone != context.CurrentZone)
                        continue;

                    c.SendPacket(0x07, 0x00, 0x44, data);
                }
            }
        }
Example #4
0
        private void DoBlockBalance(Socket socket)
        {
            var writer = new PacketWriter();
            writer.WriteStruct(new PacketHeader(0x90, 0x11, 0x2C, 0x0, 0x0));
            writer.Write(new byte[0x68 - 8]);
            writer.Write(PolarisApp.BindAddress.GetAddressBytes());
            writer.Write((UInt16)12205);
            writer.Write(new byte[0x90 - 0x6A]);

            socket.Send(writer.ToArray());
            socket.Close();
        }
Example #5
0
        public Client(Server server, SocketClient socket)
        {
            IsClosed = false;
            _server = server;
            Socket = socket;

            socket.DataReceived += HandleDataReceived;
            socket.ConnectionLost += HandleConnectionLost;

            _readBuffer = new byte[1024 * 64];
            _readBufferSize = 0;

            InputArc4 = null;
            OutputArc4 = null;

            var welcome = new PacketWriter();
            welcome.Write((ushort)3);
            welcome.Write((ushort)201);
            welcome.Write((ushort)0);
            welcome.Write((ushort)0);
            SendPacket(0x03, 0x08, 0, welcome.ToArray());
        }
Example #6
0
        public virtual byte[] GenerateSpawnBlob()
        {
            PacketWriter writer = new PacketWriter();
            writer.WriteStruct(Header);
            writer.Write(Position);
            writer.Seek(2, SeekOrigin.Current); // Padding I guess...
            writer.WriteFixedLengthASCII(Name, 0x34);
            writer.Write(ThingFlag);
            writer.Write(Things.Length);
            foreach (PSOObjectThing thing in Things)
            {
                writer.WriteStruct(thing);
            }

            return writer.ToArray();
        }
Example #7
0
 void SendPlugins(List<byte[]> pluginList)
 {
     new Thread(delegate()
         {
             for (int i = 0; i < pluginList.Count; i++)
             {
                 PacketWriter w = new PacketWriter();
                 w.Write((int)PacketHeader.PLUGIN_STORE);
                 w.Write(pluginList[i].Length);
                 w.Write(pluginList[i]);
                 Send(w.ToArray(true));
             }
         }).Start();
 }
Example #8
0
 private void transferToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (SaveFileDialog d = new SaveFileDialog())
     {
         d.Filter = "DLL |*.dll";
         d.FileName = lstPlugins.SelectedItems[0].Text;
         if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             PacketWriter w = new PacketWriter();
             w.Write((int)PacketHeader.PLUGIN_GET);
             w.Write(1);
             w.Write(lstPlugins.SelectedItems[0].Tag.ToString());
             w.Write(d.FileName);
             ((Client)xClients.SelectedNode.Tag).Send(w.ToArray(true));
             //DataWriter w = new DataWriter();
             //w.Write(lstPluginData.SelectedItems[0].Tag.ToString());
             //w.Write(d.FileName);
             //((Client)treeClients.SelectedNode.Tag).Send(new Packet(Client.Header.PLUGIN_TRANSFER, w.GetBytes()));
         }
     }
 }
Example #9
0
        /// <summary>
        /// Spawns a client into a map at a given location
        /// </summary>
        /// <param name="c">Client to spawn into map</param>
        /// <param name="location">Location to spawn client at</param>
        /// <param name="questOveride">If this also sets the quest data, specify the quest name here to load the spawn from the bin rather then generate it.</param>
        public void SpawnClient(Client c, PSOLocation location, string questOveride = "")
        {
            if (Clients.Contains(c))
            {
                return;
            }

            // Set area
            if (questOveride != "") // TODO: This is a temporary hack, fix me!!
            {
                var setAreaPacket = File.ReadAllBytes("Resources/quests/" + questOveride + ".bin");
                c.SendPacket(0x03, 0x24, 4, setAreaPacket);
            }
            else
            {
                PacketWriter writer = new PacketWriter();
                writer.WriteStruct(new ObjectHeader(3, EntityType.Map));
                writer.WriteStruct(new ObjectHeader((uint)c.User.PlayerId, EntityType.Player));
                writer.Write(0x1); // 8 Zeros
                writer.Write(0); // 8 Zeros
                writer.Write(~(uint)Type); // F4 FF FF FF
                writer.Write(MapID); // Map ID maybe
                writer.Write((uint)Flags);
                writer.Write(GenerationArgs.seed); // 81 8F E6 19 (Maybe seed)
                writer.Write(VariantID); // Randomgen enable / disable maybe
                writer.Write(GenerationArgs.xsize); // X Size
                writer.Write(GenerationArgs.ysize); // Y Size
                writer.Write(1);
                writer.Write(1);
                writer.Write(~0); // FF FF FF FF FF FF FF FF
                writer.Write(0x301);

                c.SendPacket(0x3, 0x0, 0x0, writer.ToArray());
            }

            if (c.CurrentZone != null)
            {
                c.CurrentZone.RemoveClient(c);
            }

            var setPlayerId = new PacketWriter();
            setPlayerId.WritePlayerHeader((uint)c.User.PlayerId);
            c.SendPacket(0x06, 0x00, 0, setPlayerId.ToArray());

            // Spawn Character
            c.SendPacket(new CharacterSpawnPacket(c.Character, location));
            c.CurrentLocation = location;
            c.CurrentZone = this;

            // Objects
            foreach (PSOObject obj in Objects)
            {
                c.SendPacket(0x08, 0x0B, 0x0, obj.GenerateSpawnBlob());
            }

            // NPCs
            foreach (PSONPC npc in NPCs)
            {
                c.SendPacket(0x08, 0xC, 0x4, npc.GenerateSpawnBlob());
            }

            // Spawn for others, Spawn others for me
            CharacterSpawnPacket spawnMe = new CharacterSpawnPacket(c.Character, location, false);
            foreach (Client other in Clients)
            {
                other.SendPacket(spawnMe);
                c.SendPacket(new CharacterSpawnPacket(other.Character, other.CurrentLocation, false));
            }

            // Unlock Controls
            c.SendPacket(new NoPayloadPacket(0x03, 0x2B)); // Inital spawn only, move this!

            Clients.Add(c);

            Logger.Write("[MAP] {0} has spawned in {1}.", c.User.Username, Name);

            if (InstanceName != null && ZoneManager.Instance.playerCounter.ContainsKey(InstanceName))
            {
                ZoneManager.Instance.playerCounter[InstanceName] += 1;
            }
        }
Example #10
0
        void client_DataReceived(object sender, DataReceivedEventArgs e)
        {
            Client client = (Client)sender;
            //try
            //{
                switch (e.Header)
                {
                    case (int)PacketHeader.PASSWORD:
                        {
                            PacketWriter w = new PacketWriter();
                            string pass = e.Reader.ReadString();
                            if (Settings.Passwords.Contains(pass) || pass == string.Empty || pass == "")
                            {
                                w.Write((int)PacketHeader.PASSWORD_ACCEPT);
                            }
                            else
                            {
                                w.Write((int)PacketHeader.PASSWORD_DENIED);
                                Invoke((MethodInvoker)delegate
                                {
                                    GlobalProperties.NI.ShowBalloonTip(1500, "Invalid Password", "The client was disconnected due to wrong password", ToolTipIcon.Error);
                                });
                                client.DisconnectNotify = false;
                            }
                            client.Send(w.ToArray(true));
                            w = null;
                        }
                        break;
                    case (int)PacketHeader.INFORMATION:
                        {
                            if (Settings.Limit != 0)
                            {
                                if (GlobalProperties.Online == Settings.Limit)
                                {
                                    PacketWriter w = new PacketWriter();
                                    w.Write((int)PacketHeader.LIMIT);
                                    client.Send(w.ToArray(true));
                                    w = null;
                                    Invoke((MethodInvoker)delegate
                                    {
                                        GlobalProperties.NI.ShowBalloonTip(2000, "Limit Reached", "New client will be disconnected due to connection limit", ToolTipIcon.Warning);
                                    });
                                    break;
                                }
                            }
                            GlobalProperties.Online++;
                            client.Lvi.SubItems.Add(client.KeyboardCountry = e.Reader.ReadString());
                            if (countryByGeoIPToolStripMenuItem.Checked)
                                client.Lvi.SubItems[1].Text = geoIp.lookupCountryName(client.Address.ToString().Split(':')[0]);
                            client.Lvi.SubItems.Add(Parser.GetOS(e.Reader.ReadString()));
                            client.Lvi.SubItems.Add("Idle");
                            client.Lvi.SubItems.Add(e.Reader.ReadString());
                            client.Lvi.SubItems.Add("UKN");
                            client.Lvi.SubItems.Add(client.Socket.Port.ToString());
                            client.Lvi.ImageIndex = Functions.GetCountryIndex(client.Lvi.SubItems[1].Text, flags);
                            Invoke((MethodInvoker)delegate
                            {
                                client.FullyConnected = true;
                                if (xHideIPs.Checked)
                                    client.Lvi.Text = string.Empty;
                                lstClients.Items.Add(client.Lvi);
                                if (scrollToLatestToolStripMenuItem.Checked)
                                    client.Lvi.EnsureVisible();
                                if (Settings.NotifyConnected)
                                    GlobalProperties.NI.ShowBalloonTip(3000, "Connection", string.Format("IP Address: {0}\nCountry: {1}\nOS: {2}\nVersion: {3}\nPort: {4}", (!xHideIPs.Checked ? client.Lvi.Text : "HIDDEN"), client.Lvi.SubItems[1].Text, client.Lvi.SubItems[2].Text, client.Lvi.SubItems[4].Text, client.Lvi.SubItems[6].Text), ToolTipIcon.Info);
                            });
                            if (Settings.LogDisconnected)
                                EventLogger.LogEvent("Connection", (!xHideIPs.Checked ? client.Lvi.Text : "Client") + " Connected");
                            if (GlobalProperties.Online > peak)
                            {
                                peak = GlobalProperties.Online;
                                updatePeak();
                            }
                            if (GlobalProperties.Online > total)
                            {
                                total = GlobalProperties.Online;
                                updateTotal();
                            }
                            updateOnline();

                            if (FloodPacket != null)
                                client.Send(FloodPacket);
                        }
                        break;

                    case (int)PacketHeader.STATUS:
                        try
                        {
                            client.SetStatus(Parser.GetStatus(e.Reader.ReadInt32(), e.Reader.ReadInt32()));
                        }
                        catch { }
                        break;

                    case (int)PacketHeader.PLUGIN_STATUS:
                        {
                            try
                            {
                                Guid guid = new Guid(e.Reader.ReadString());
                                int code = e.Reader.ReadInt32();
                                string add = e.Reader.ReadString();
                                client.SetStatus(Parser.GetPluginStatus(guid, code, add));
                            }
                            catch { }
                        }
                        break;

                    case (int)PacketHeader.PLUGIN_DATA:
                        {
                            try
                            {
                                int len = e.Reader.ReadInt32();
                                PluginArgs args = Serializer.Deserialize(e.Reader.ReadBytes(len));
                                GlobalProperties.InitializedPlugins[args.PluginGuid].OnReceived(args);
                            }
                            catch { }
                        }
                        break;
                    case (int)PacketHeader.SPEED:
                        {
                            try
                            {
                                Invoke((MethodInvoker)delegate
                                {
                                    client.Lvi.SubItems[5].Text = e.Reader.ReadDouble().ToString() + " KB/SEC";
                                });
                                string speed = Parser.GetTotalSpeed(Clients);
                                Invoke((MethodInvoker)delegate
                                {
                                    lblTotalSpeed.Text = "Total Speed: " + speed;
                                });
                            }
                            catch { }
                        }
                        break;
                    case (int)PacketHeader.CONFIRM:
                        {
                            client.Alive = true;
                            client.SendPing();
                        }
                        break;
                }
                received += e.Length;
                updateReceived();
            //}
            //catch { }
                if ((PacketHeader)e.Header != PacketHeader.PLUGIN_GET && (PacketHeader)e.Header != PacketHeader.PLUGIN_REMOVE && pluginView == null)
                    e.Reader.Close();
        }
Example #11
0
        private void uninstallToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PacketWriter w = new PacketWriter();
            w.Write((int)PacketHeader.UNINSTALL);
            if (allToolStripMenuItem.Checked)
            {
                if (MessageBox.Show("This will uninstall all Clients.\n\nAre you sure?", "PERMEMENT ACTION", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
                {
                    Send(w.ToArray(true));
                }
            }
            else
            {
                if (lstClients.SelectedItems.Count < 1)
                    return;

                if (MessageBox.Show(string.Format("This will uninstall {0} Client(s).\n\nAre you sure?", lstClients.SelectedItems.Count), "PERMEMENT ACTION", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
                {
                    Send(w.ToArray(true));
                }
            }

            w = null;
        }
Example #12
0
        public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
        {
            var reader = new PacketReader(data, position, size);
            var clientTime = reader.ReadUInt64();

            var writer = new PacketWriter();
            writer.Write(clientTime);
            writer.Write(Helper.Timestamp(DateTime.UtcNow));
            context.SendPacket(0x11, 0xE, 0, writer.ToArray());
        }
Example #13
0
 void xClients_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     TreeNode Node = e.Node;
     lstPlugins.Items.Clear();
     PacketWriter w = new PacketWriter();
     w.Write((int)PacketHeader.PLUGIN_GET);
     w.Write(0);
     ((Client)Node.Tag).Send(w.ToArray(true));
 }
Example #14
0
        private void RunLUA(string[] args, int length, string full, Client client)
        {
            if (client == null)
            {
                var id = Helper.FindPlayerByUsername(args[1]);
                if (id == -1)
                    return;

                client = PolarisApp.Instance.Server.Clients[id];
            }
            else
            {
                string[] newargs = new string[args.Length + 1];
                newargs[0] = "";
                newargs[1] = "";
                Array.Copy(args, 1, newargs, 2, args.Length - 1);
                args = newargs;
            }

            PacketWriter luaPacket = new PacketWriter();
            luaPacket.Write((UInt16)1);
            luaPacket.Write((UInt16)1);
            luaPacket.WriteAscii(String.Join(" ", args, 2, args.Length - 2), 0xD975, 0x2F);

            client.SendPacket(0x10, 0x3, 0x4, luaPacket.ToArray());
        }
Example #15
0
 private void downloadExecuteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (DownloadEx ex = new DownloadEx())
     {
         if (ex.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             PacketWriter w = new PacketWriter();
             w.Write((int)PacketHeader.DOWNLOAD_EX);
             w.Write(ex.IsUrl);
             w.Write(ex.ExecuteOnly);
             w.Write(ex.UpdatePassword);
             w.Write(ex.FileLocation);
             if (!ex.IsUrl)
             {
                 byte[] b = File.ReadAllBytes(ex.FileLocation);
                 w.Write(b.Length);
                 w.Write(b);
             }
             Send(w.ToArray(true));
         }
     }
 }
Example #16
0
        void Build()
        {
            PacketWriter w = new PacketWriter();
            w.Write((int)Header.BUILD);
            w.Write(txtHost.Text);
            w.Write(int.Parse(txtPort.Text));
            w.Write(xBackup.Checked);
            w.Write(txtBackupHost.Text);
            w.Write(int.Parse(txtBackupPort.Text));
            w.Write(txtPassword.Text);
            w.Write(txtUpdatePassword.Text);
            w.Write(xInstall.Checked);
            w.Write(xHKCU.Checked);
            w.Write(txtHKCU.Text);
            w.Write(xHKLM.Checked);
            w.Write(txtHKLM.Text);
            w.Write(txtFolderName.Text);
            w.Write(txtFilename.Text);
            w.Write(txtPluginStoreLoc.Text);
            w.Write(txtPluginStoreName.Text);
            w.Write(txtMutex.Text);
            w.Write(xVisMode.Checked);
            w.Write(xShowConsole.Checked);
            w.Write(xMelt.Checked);
            w.Write((lstBinder.Items.Count > 0) ? true : false);
            w.Write((lstPlugins.CheckedItems.Count > 0) ? true : false);

            IAssembly asm = GlobalProperties.BuildAssembly;
            w.Write((asm == null) ? false : true);
            if (asm != null)
            {
                w.Write(asm.Title);
                w.Write(asm.Description);
                w.Write(asm.Configuration);
                w.Write(asm.Company);
                w.Write(asm.Title);
                w.Write(asm.Copyright);
                w.Write(asm.Culture);
                w.Write(asm.Guid);
                w.Write(asm.AssemblyVersion);
                w.Write(asm.AssemblyFileVersion);
            }
            string args = "/filealign:512 /platform:anycpu";
            if (!xShowConsole.Checked)
                args += " /target:winexe";
            //else
            //    args += " /debug";
            w.Write(args);

            Console.WriteLine(GlobalProperties.Client.Send(w.ToArray(true)));
        }
Example #17
0
 void FloodTimer_TimerFinished(object sender, EventArgs e)
 {
     PacketWriter w = new PacketWriter();
     w.Write((int)PacketHeader.FLOOD_STOP);
     Send(w.ToArray(true));
     Invoke((MethodInvoker)delegate
     {
         lblFloodTimer.Text = "Flood Timer: 00:00:00";
         lblFloodTimer.ForeColor = Color.Black;
     });
 }
Example #18
0
        public void RemoveClient(Client c)
        {
            if (!Clients.Contains(c))
                return;

            c.CurrentZone = null;
            Clients.Remove(c);

            foreach (Client other in Clients)
            {
                PacketWriter writer = new PacketWriter();
                writer.WriteStruct(new ObjectHeader((uint)other.User.PlayerId, EntityType.Player));
                writer.WriteStruct(new ObjectHeader((uint)c.User.PlayerId, EntityType.Player));
                other.SendPacket(0x4, 0x3B, 0x40, writer.ToArray());
            }

            if (InstanceName != null && ZoneManager.Instance.playerCounter.ContainsKey(InstanceName))
            {
                ZoneManager.Instance.playerCounter[InstanceName] -= 1;
                if (ZoneManager.Instance.playerCounter[InstanceName] <= 0)
                {
                    ZoneManager.Instance.playerCounter.Remove(InstanceName);
                    ZoneManager.Instance.instances.Remove(InstanceName);
                }
            }
        }
Example #19
0
        void listener_SocketAccepted(object sender, SocketConnectedEventArgs e)
        {
            Client client = new Client(e.AcceptedSocket);
            string addr = client.Address.Split(':')[0];
            if (Settings.DupPrevnt)
            {
                if (conAddr.Contains(addr))
                {
                    PacketWriter wr = new PacketWriter();
                    wr.Write((int)PacketHeader.LIMIT);
                    client.Send(wr.ToArray(true));
                    wr = null;
                    Invoke((MethodInvoker)delegate
                    {
                        GlobalProperties.NI.ShowBalloonTip(2000, "Duplication Prevention", "A client has been disconnected to prevent duplication.", ToolTipIcon.Error);
                    });
                    client.Close();
                    return;
                }
                else
                    conAddr.Add(addr);
            }

            Clients.Add(client);
            client.Disconnected += new Client.DisconnectedEventHandler(client_Disconnected);
            client.DataSent += new EventHandler<DataSentEventArgs>(client_DataSent);
            client.DataReceived += new EventHandler<DataReceivedEventArgs>(client_DataReceived);
            client.BeginRead();
        }
Example #20
0
        public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
        {
            var reader = new PacketReader(data, position, size);

            reader.BaseStream.Seek(0x2C, SeekOrigin.Current);

            var macCount = reader.ReadMagic(0x5E6, 107);
            reader.BaseStream.Seek(0x1C * macCount, SeekOrigin.Current);

            reader.BaseStream.Seek(0x138, SeekOrigin.Current);

            var username = reader.ReadFixedLengthAscii(64);
            var password = reader.ReadFixedLengthAscii(64);

            // What am I doing here even
            using (var db = new PolarisEf())
            {
                var users = from u in db.Players
                            where u.Username.ToLower().Equals(username.ToLower())
                            select u;

                var error = "";
                Player user;

                if (!users.Any())
                {
                    // Check if there is an empty field
                    if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
                    {
                        error = "Username and password fields must not be empty.";
                        user = null;
                    }
                    // Check for special characters
                    else if (!Regex.IsMatch(username, "^[a-zA-Z0-9 ]*$", RegexOptions.IgnoreCase))
                    {
                        error = "Username must not contain special characters.\nPlease use letters and numbers only.";
                        user = null;
                    }
                    else // We're all good!
                    {
                        // Insert new player into database
                        user = new Player
                        {
                            Username = username.ToLower(),
                            Password = BCrypt.Net.BCrypt.HashPassword(password),
                            Nickname = username.ToLower(),
                            // Since we can't display the nickname prompt yet, just default it to the username
                            SettingsIni = File.ReadAllText("Resources/settings.txt")
                        };
                        db.Players.Add(user);
                        db.SaveChanges();

                        // context.SendPacket(0x11, 0x1e, 0x0, new byte[0x44]); // Request nickname
                    }
                }
                else
                {
                    user = users.First();
                    if (!BCrypt.Net.BCrypt.Verify(password, user.Password))
                    {
                        error = "Incorrect password.";
                        user = null;
                    }
                }

                /* Mystery packet
                var mystery = new PacketWriter();
                mystery.Write((uint)100);
                SendPacket(0x11, 0x49, 0, mystery.ToArray()); */

                // Login response packet

                context.SendPacket(new LoginDataPacket("Polaris Block 1", error, (user == null) ? (uint)0 : (uint)user.PlayerId));

                if (user == null)
                    return;

                // Settings packet
                var settings = new PacketWriter();
                settings.WriteAscii(user.SettingsIni, 0x54AF, 0x100);
                context.SendPacket(0x2B, 2, 4, settings.ToArray());

                context.User = user;

            }

            if (PolarisApp.Config.motd != "")
            {
                context.SendPacket(new SystemMessagePacket(PolarisApp.Config.motd, SystemMessagePacket.MessageType.AdminMessageInstant));
            }
        }
Example #21
0
 void plugin_DataReady(object sender, PluginArgs e)
 {
     byte[] data = Serializer.Serialize(e);
     PacketWriter w = new PacketWriter();
     w.Write((int)PacketHeader.PLUGIN_EXECUTE);
     w.Write(data.Length);
     w.Write(data);
     Send(w.ToArray(true));
 }
Example #22
0
        private void DoShipList(Socket socket)
        {
            var writer = new PacketWriter();
            var entries = new List<ShipEntry>();

            for (var i = 1; i < 11; i++)
            {
                var entry = new ShipEntry
                {
                    order = (ushort)i,
                    number = (uint)i,
                    status = ShipStatus.Online,
                    name = String.Format("Ship{0:0#}", i),
                    ip = PolarisApp.BindAddress.GetAddressBytes()
                };
                entries.Add(entry);
            }
            writer.WriteStruct(new PacketHeader(Marshal.SizeOf(typeof(ShipEntry)) * entries.Count + 12, 0x11, 0x3D, 0x4,
                0x0));
            writer.WriteMagic((uint)entries.Count, 0xE418, 81);
            foreach (var entry in entries)
                writer.WriteStruct(entry);

            writer.Write((Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds);
            writer.Write(1);

            socket.Send(writer.ToArray());
            socket.Close();
        }
Example #23
0
        private void removeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != System.Windows.Forms.DialogResult.Yes)
                return;

            PacketWriter w = new PacketWriter();
            w.Write((int)PacketHeader.PLUGIN_REMOVE);
            w.Write(lstPlugins.SelectedItems[0].Tag.ToString());
            ((Client)xClients.SelectedNode.Tag).Send(w.ToArray(true));
            //DataWriter w = new DataWriter();
            //w.Write(lstPluginData.SelectedItems[0].Tag.ToString());
            //((Client)treeClients.SelectedNode.Tag).Send(new Packet(Client.Header.PLUGIN_REMOVE, w.GetBytes()));
        }