public override void SendInfoTo( NetState state, bool sendOplPacket )
        {
            Mobile mob = state.Mobile;

            if ( mob != null && mob.AccessLevel > AccessLevel.Player )
                state.Send(new SpecialWorldItemPacket(this,0x241a));//Display as stone to GMs
            else
                state.Send(new SpecialWorldItemPacket(this, 0x21A3));//Display as blocker to Players

            if ( sendOplPacket )
                state.Send( OPLPacket );
        }
Exemplo n.º 2
0
		public override void SendInfoTo( NetState state )
		{
			Mobile mob = state.Mobile;

			if ( mob != null && mob.AccessLevel >= AccessLevel.GameMaster )
				state.Send( new GMItemPacket( this ) );
			else
				state.Send( WorldPacket );

			if ( ObjectPropertyList.Enabled )
				state.Send( OPLPacket );
		}
        public void RejectNoEncryption(NetState ns)
        {
            // Log it on the console
            Console.WriteLine("Client: {0}: Unencrypted client detected, disconnected", ns);

            // Send the client the typical "Bad communication" packet and also a sysmessage stating the error
            ns.Send(new AsciiMessage(Server.Serial.MinusOne, -1, MessageType.Label, 0x35, 3, "System", "Unencrypted connections are not allowed on this server."));
            ns.Send(new AccountLoginRej(ALRReason.BadComm));

            // Disconnect the client
            ns.Dispose(true);
        }
Exemplo n.º 4
0
		public override void SendInfoTo( NetState state )
		{
			Mobile mob = state.Mobile;

			// Determines whether we sent the item's basic packet (<GM) or an indication
			// of the LoF blocker's existence (GM+)

			if ( mob != null && mob.AccessLevel >= AccessLevel.GameMaster )
				state.Send( new GMItemPacket( this ) );
			else
				state.Send( WorldPacket );

			if ( ObjectPropertyList.Enabled )
				state.Send( OPLPacket );
		}
Exemplo n.º 5
0
        private static void OnGuildTrack( NetState state, PacketReader pvSrc )
        {
            Mobile from = state.Mobile;
            Guild guild = from.Guild as Guild;

            if ( guild != null )
            {
                bool locations = pvSrc.ReadByte() != 0;

                Packets.GuildTrack packet = new Packets.GuildTrack( from, guild, locations );

                if ( packet.UnderlyingStream.Length > ( locations ? 9 : 5 ) )
                    state.Send( packet );
            }
            else
                state.Send( new Packets.GuildTrack() );
        }
Exemplo n.º 6
0
		public override void SendInfoTo( NetState state )
		{
			Mobile mob = state.Mobile;

            //Al: It seems that older clients display 0x21A3 as unused tile
            //      Since we modify the flags of 0x21A3 we have to use this itemid
            //      Hence we display this item as 0x21A4 (==normal blocker) to the
            //      UO client. This is extremely ugly :)

            if (mob != null && mob.AccessLevel >= AccessLevel.GameMaster)
                state.Send(new SpecialWorldItemPacket(this,0x241a));//Display as stone to GMs
            else
                state.Send(new SpecialWorldItemPacket(this, 0x21A4));//Display as blocker to Players

			if ( ObjectPropertyList.Enabled )
				state.Send( OPLPacket );
		}
Exemplo n.º 7
0
        private static void AccountSearch(NetState state, PacketReader pvSrc)
        {
            AcctSearchType type = (AcctSearchType)pvSrc.ReadByte();
            string term = pvSrc.ReadString();

            if (type == AcctSearchType.IP && !Utility.IsValidIP(term))
            {
                state.Send(new MessageBoxMessage("Invalid search term.\nThe IP sent was not valid.", "Invalid IP"));
                return;
            }
            else
            {
                term = term.ToUpper();
            }

            ArrayList list = new ArrayList();

            foreach (Account a in Accounts.GetAccounts())
            {
                if (!CanAccessAccount(state.Account, a))
                    continue;

                switch ( type )
                {
                    case AcctSearchType.Username:
                        {
                            if (a.Username.ToUpper().IndexOf(term) != -1)
                                list.Add(a);
                            break;
                        }
                    case AcctSearchType.IP:
                        {
                            for (int i = 0; i < a.LoginIPs.Length; i++)
                            {
                                if (Utility.IPMatch(term, a.LoginIPs[i]))
                                {
                                    list.Add(a);
                                    break;
                                }
                            }
                            break;
                        }
                }
            }

            if (list.Count > 0)
            {
                if (list.Count <= 25)
                    state.Send(AdminNetwork.Compress(new AccountSearchResults(list)));
                else
                    state.Send(new MessageBoxMessage("There were more than 25 matches to your search.\nNarrow the search parameters and try again.", "Too Many Results"));
            }
            else
            {
                state.Send(new MessageBoxMessage("There were no results to your search.\nPlease try again.", "No Matches"));
            }
        }
        private static void WorldBroadcast( NetState state, PacketReader pvSrc )
        {
            string message = pvSrc.ReadUTF8String();
            int hue = pvSrc.ReadInt16();
            bool ascii = pvSrc.ReadBoolean();

            World.Broadcast(hue, ascii, message);

            state.Send( new MessageBoxMessage( "Your message has been broadcasted.", "Message Broadcasted" ) );
        }
Exemplo n.º 9
0
		private static void statusServer_packetReceived( NetState state, PacketReader reader )
		{
			string status = BuildStatus();

			int currBufferSize = SendQueue.CoalesceBufferSize;
			SendQueue.CoalesceBufferSize = Math.Max( (status.Length + 2), currBufferSize );

			state.Send( new StatusInfo( status ) );

			SendQueue.CoalesceBufferSize = currBufferSize;
		}
Exemplo n.º 10
0
        public static void QueryPartyLocations(NetState state, PacketReader pvSrc)
        {
            Mobile from = state.Mobile;
            Party party = Party.Get(from);

            if (party != null)
            {
                AckPartyLocations ack = new AckPartyLocations(from, party);

                if (ack.UnderlyingStream.Length > 8)
                    state.Send(ack);
            }
        }
Exemplo n.º 11
0
        private static void OnPartyTrack( NetState state, PacketReader pvSrc )
        {
            Mobile from = state.Mobile;
            Party party = Party.Get( from );

            if ( party != null )
            {
                Packets.PartyTrack packet = new Packets.PartyTrack( from, party );

                if ( packet.UnderlyingStream.Length > 8 )
                    state.Send( packet );
            }
        }
Exemplo n.º 12
0
        private static void CustomRunebook(NetState state, PacketReader pvSrc)
        {
            int RuneBookSerial = pvSrc.ReadInt32();

            var runebook = World.FindItem(RuneBookSerial) as Runebook;

            if (runebook != null)
            {
                Packets.SallosRunebook packet = new Packets.SallosRunebook(runebook);

                if (packet.UnderlyingStream.Length > 7)
                    state.Send(packet);
            }
        }
Exemplo n.º 13
0
        public static void SendEndVendorBuy(this NetState ns, Serial vendor)
        {
            if (ns == null)
            {
                return;
            }

            var writer = new SpanWriter(stackalloc byte[8]);

            writer.Write((byte)0x3B); // Packet ID
            writer.Write((ushort)8);
            writer.Write(vendor);
            writer.Write((byte)0); // Buy count

            ns.Send(writer.Span);
        }
Exemplo n.º 14
0
        public static void SendScreenEffect(this NetState ns, ScreenEffectType type)
        {
            if (ns == null || !ns.GetSendBuffer(out var buffer))
            {
                return;
            }

            var writer = new CircularBufferWriter(buffer);

            writer.Write((byte)0x70); // Packet ID
            writer.Write((byte)0x4);
            writer.Clear(8);
            writer.Write((ushort)type);
            writer.Clear(16);

            ns.Send(ref buffer, writer.Position);
        }
Exemplo n.º 15
0
        public static void SendScreenEffect(this NetState ns, ScreenEffectType type)
        {
            if (ns == null)
            {
                return;
            }

            var writer = new SpanWriter(stackalloc byte[28]);

            writer.Write((byte)0x70); // Packet ID
            writer.Write((byte)0x4);
            writer.Clear(8);
            writer.Write((ushort)type);
            writer.Clear(16);

            ns.Send(writer.Span);
        }
Exemplo n.º 16
0
        public static void UOGQuery(NetState state, PacketReader pvSrc)
        {
            byte cmd = pvSrc.ReadByte();

            if (cmd != 0xFF)
            {
                return;
            }

            Console.WriteLine("Client {0} querying UOG status", state);

            string name = Core.Config.ServerName;

            if (name == null)
            {
                name = "SunUO Login";
            }

            int age     = 0;
            int clients = NetState.Instances.Count;
            int items   = 0;
            int chars   = 0;

            GameServerListConfig gsl = Core.Config.GameServerListConfig;

            if (gsl != null)
            {
                /* add values from game servers */
                foreach (GameServerConfig gs in gsl.GameServers)
                {
                    ServerStatus status = ServerQueryTimer.GetStatus(gs);
                    if (status != null)
                    {
                        age     += status.age;
                        clients += status.clients;
                        items   += status.items;
                        chars   += status.chars;
                    }
                }
            }

            string statStr = String.Format(", Name={0}, Age={1}, Clients={2}, Items={3}, Chars={4}, Mem={5}K", name, age, clients, items, chars, (int)(System.GC.GetTotalMemory(false) / 1024));

            state.Send(new UOGInfo(statStr));
            state.Dispose();
        }
Exemplo n.º 17
0
        public static void SendMessageLocalized(
            this NetState ns,
            Serial serial, int graphic, MessageType type, int hue, int font, int number, string name = "", string args = ""
            )
        {
            if (ns == null)
            {
                return;
            }

            Span <byte> buffer = stackalloc byte[GetMaxMessageLocalizedLength(args)];
            var         length = CreateMessageLocalized(
                buffer, serial, graphic, type, hue, font, number, name, args
                );

            ns.Send(buffer.Slice(0, length));
        }
Exemplo n.º 18
0
        public static void SendPrompt(this NetState ns, Prompt prompt)
        {
            if (ns == null || prompt == null)
            {
                return;
            }

            var writer = new SpanWriter(stackalloc byte[21]);

            writer.Write((byte)0xC2); // Packet ID
            writer.Write((ushort)21);
            writer.Write(prompt.Serial);
            writer.Write(prompt.Serial);
            writer.Clear(10);

            ns.Send(writer.Span);
        }
Exemplo n.º 19
0
        public override void OnResponse( NetState sender, RelayInfo info )
        {
            Mobile from = sender.Mobile;

            switch (info.ButtonID)
            {
                case 0:
                    {
                        break;
                    }
                case 1:
                    {
                        sender.Send(new LaunchBrowser(url));
                        break;
                    }
            }
        }
Exemplo n.º 20
0
        public static void SendTargetReq(this NetState ns, Target t)
        {
            if (ns == null || !ns.GetSendBuffer(out var buffer))
            {
                return;
            }

            var writer = new CircularBufferWriter(buffer);

            writer.Write((byte)0x6C); // Packet ID
            writer.Write(t.AllowGround);
            writer.Write(t.TargetID);
            writer.Write((byte)t.Flags);
            writer.Clear(12);

            ns.Send(ref buffer, writer.Position);
        }
Exemplo n.º 21
0
        /**
         * Packet: 0x8C
         * Length: 11 bytes
         *
         * Sends acknowledge play server
         */
        public static void SendPlayServerAck(this NetState ns, ServerInfo si, int authId)
        {
            if (ns == null || !ns.GetSendBuffer(out var buffer))
            {
                return;
            }

            var writer = new CircularBufferWriter(buffer);

            writer.Write((byte)0x8C); // Packet ID

            writer.WriteLE(si.RawAddress);
            writer.Write((short)si.Address.Port);
            writer.Write(authId);

            ns.Send(ref buffer, writer.Position);
        }
Exemplo n.º 22
0
        /**
         * Packet: 0x86
         * Length: Up to 424 bytes
         *
         * Sends updated character list
         */
        public static void SendCharacterListUpdate(this NetState ns, IAccount a)
        {
            if (ns == null || a == null || !ns.GetSendBuffer(out var buffer))
            {
                return;
            }

            var writer = new CircularBufferWriter(buffer);

            writer.Write((byte)0x86);           // Packet ID
            writer.Seek(2, SeekOrigin.Current); // Length

            var highSlot = -1;

            for (var i = a.Length - 1; i >= 0; i--)
            {
                if (a[i] != null)
                {
                    highSlot = i;
                    break;
                }
            }

            var count = Math.Max(Math.Max(highSlot + 1, a.Limit), 5);

            writer.Write((byte)count);

            for (int i = 0; i < count; i++)
            {
                var m = a[i];

                if (m == null)
                {
                    writer.Clear(60);
                }
                else
                {
                    var name = (m.RawName?.Trim()).DefaultIfNullOrEmpty("-no name-");
                    writer.WriteAscii(name, 30);
                    writer.Clear(30); // password
                }
            }

            writer.WritePacketLength();
            ns.Send(ref buffer, writer.Position);
        }
Exemplo n.º 23
0
        public static void SendTimeSyncResponse(this NetState ns)
        {
            if (ns == null || !ns.GetSendBuffer(out var buffer))
            {
                return;
            }

            var writer = new CircularBufferWriter(buffer);

            writer.Write((byte)0xF2);     // Packet ID

            writer.Write(Core.TickCount); // ??
            writer.Write(Core.TickCount); // ??
            writer.Write(Core.TickCount); // ??

            ns.Send(ref buffer, writer.Position);
        }
Exemplo n.º 24
0
        public static void SendBondedStatus(this NetState ns, Serial serial, bool bonded)
        {
            if (ns == null)
            {
                return;
            }

            var writer = new SpanWriter(stackalloc byte[11]);

            writer.Write((byte)0xBF);   // Packet ID
            writer.Write((ushort)11);   // Length
            writer.Write((ushort)0x19); // Subpacket ID
            writer.Write((byte)0);      // Command
            writer.Write(serial);
            writer.Write(bonded);

            ns.Send(writer.Span);
        }
        public static void SendUpdateSecureTrade(this NetState ns, Container cont, TradeFlag flag, int first, int second)
        {
            if (ns == null || !ns.GetSendBuffer(out var buffer))
            {
                return;
            }

            var writer = new CircularBufferWriter(buffer);

            writer.Write((byte)0x6F); // Packet ID
            writer.Write((ushort)16); // Length
            writer.Write((byte)flag);
            writer.Write(cont.Serial);
            writer.Write(first);
            writer.Write(second);

            ns.Send(ref buffer, writer.Position);
        }
Exemplo n.º 26
0
        public static void SendUpdateSecureTrade(this NetState ns, Container cont, TradeFlag flag, int first, int second)
        {
            if (ns == null)
            {
                return;
            }

            var writer = new SpanWriter(stackalloc byte[16]);

            writer.Write((byte)0x6F); // Packet ID
            writer.Write((ushort)16); // Length
            writer.Write((byte)flag);
            writer.Write(cont.Serial);
            writer.Write(first);
            writer.Write(second);

            ns.Send(writer.Span);
        }
Exemplo n.º 27
0
        public static void SendMapCommand(this NetState ns, MapItem map, int command, int x = 0, int y = 0, bool editable = false)
        {
            if (ns.CannotSendPackets())
            {
                return;
            }

            var writer = new SpanWriter(stackalloc byte[11]);

            writer.Write((byte)0x56); // Packet ID
            writer.Write(map.Serial);
            writer.Write((byte)command);
            writer.Write(editable);
            writer.Write((short)x);
            writer.Write((short)y);

            ns.Send(writer.Span);
        }
Exemplo n.º 28
0
        public static void SendCloseGump(this NetState ns, int typeId, int buttonId)
        {
            if (ns == null)
            {
                return;
            }

            var writer = new SpanWriter(stackalloc byte[13]);

            writer.Write((byte)0xBF); // Packet ID
            writer.Write((ushort)13);

            writer.Write((short)0x04);
            writer.Write(typeId);
            writer.Write(buttonId);

            ns.Send(writer.Span);
        }
Exemplo n.º 29
0
        public static void SendPrompt(this NetState ns, Prompt prompt)
        {
            if (ns == null || prompt == null || !ns.GetSendBuffer(out var buffer))
            {
                return;
            }

            var writer = new CircularBufferWriter(buffer);

            writer.Write((byte)0xC2); // Packet ID
            writer.Write((ushort)21);
            writer.Write(prompt.Serial);
            writer.Write(prompt.Serial);
            writer.Write((long)0);
            writer.Write((short)0);

            ns.Send(ref buffer, writer.Position);
        }
        public static void SendMessageLocalizedAffix(
            this NetState ns,
            Serial serial, int graphic, MessageType type, int hue, int font, int number, string name,
            AffixType affixType, string affix = "", string args = ""
            )
        {
            if (ns == null)
            {
                return;
            }

            Span <byte> buffer = stackalloc byte[GetMaxMessageLocalizedAffixLength(affix, args)].InitializePacket();
            var         length = CreateMessageLocalizedAffix(
                buffer, serial, graphic, type, hue, font, number, name, affixType, affix, args
                );

            ns.Send(buffer.SliceToLength(length));
        }
Exemplo n.º 31
0
        public static void SendHelpResponse(this NetState ns, Serial s, string text)
        {
            text = text?.Trim() ?? "";

            if (ns == null || text.Length == 0 || !ns.GetSendBuffer(out var buffer))
            {
                return;
            }

            var writer = new CircularBufferWriter(buffer);

            writer.Write((byte)0xB7);
            writer.Write((ushort)(9 + text.Length * 2));
            writer.Write(s);
            writer.WriteBigUniNull(text);

            ns.Send(ref buffer, writer.Position);
        }
Exemplo n.º 32
0
        public static void SendBondedStatus(this NetState ns, Serial serial, bool bonded)
        {
            if (ns == null || !ns.GetSendBuffer(out var buffer))
            {
                return;
            }

            var writer = new CircularBufferWriter(buffer);

            writer.Write((byte)0xBF);   // Packet ID
            writer.Write((ushort)11);   // Length
            writer.Write((ushort)0x19); // Subpacket ID
            writer.Write((byte)0);      // Command
            writer.Write(serial);
            writer.Write(bonded);

            ns.Send(ref buffer, writer.Position);
        }
Exemplo n.º 33
0
        public static void SendMovementRej(this NetState ns, int seq, Mobile m)
        {
            if (ns == null || !ns.GetSendBuffer(out var buffer))
            {
                return;
            }

            var writer = new CircularBufferWriter(buffer);

            writer.Write((byte)0x21); // Packet ID
            writer.Write((byte)seq);
            writer.Write((short)m.X);
            writer.Write((short)m.Y);
            writer.Write((byte)m.Direction);
            writer.Write((sbyte)m.Z);

            ns.Send(ref buffer, 8);
        }
Exemplo n.º 34
0
        private static void Mobile_Damaged(Mobile m, DamagedEventArgs args)
        {
            var amount = args.Amount;
            var from   = args.From;

            NetState ourState = m.NetState, theirState = from?.NetState;

            if (ourState == null)
            {
                var master = m.GetDamageMaster(from);

                if (master != null)
                {
                    ourState = master.NetState;
                }
            }

            if (theirState == null && from != null)
            {
                var master = from.GetDamageMaster(m);

                if (master != null)
                {
                    theirState = master.NetState;
                }
            }

            if (amount > 0 && (ourState != null || theirState != null))
            {
                var p = Packet.Acquire(new DamagePacket(m, amount));

                if (ourState != null)
                {
                    ourState.Send(p);
                }

                if (theirState != null && theirState != ourState)
                {
                    theirState.Send(p);
                }

                Packet.Release(p);
            }
        }
Exemplo n.º 35
0
        public static void SendOldSpellbookContent(this NetState ns, Serial book, int offset, ulong content)
        {
            if (ns == null || !ns.GetSendBuffer(out var buffer))
            {
                return;
            }

            var writer = new CircularBufferWriter(buffer);

            writer.Write((byte)0x3C);           // Packet ID
            writer.Seek(4, SeekOrigin.Current); // Length & written count

            var written = 0;

            ulong mask = 1;

            for (var i = 0; i < 64; ++i, mask <<= 1)
            {
                if ((content & mask) != 0)
                {
                    writer.Write(0x7FFFFFFF - i);
                    writer.Write((ushort)0);            // child ItemID
                    writer.Write((byte)0);              // ItemID offset
                    writer.Write((ushort)(i + offset)); // Amount
                    writer.Write(0);                    // X, Y
                    if (ns.ContainerGridLines)
                    {
                        writer.Write((byte)0); // Grid Location
                    }
                    writer.Write(book);
                    writer.Write((short)0); // Quest Hue

                    ++written;
                }
            }

            var length = writer.Position;

            writer.Seek(1, SeekOrigin.Begin);
            writer.Write((ushort)length);
            writer.Write((ushort)written);

            ns.Send(ref buffer, length);
        }
Exemplo n.º 36
0
        public static void SendCorpseEquip(this NetState ns, Mobile beholder, Corpse beheld)
        {
            if (ns.CannotSendPackets())
            {
                return;
            }

            var list = beheld.EquipItems;

            var maxLength = 8 + (list.Count + 2) * 5;
            var writer    = new SpanWriter(stackalloc byte[maxLength]);

            writer.Write((byte)0x89);
            writer.Seek(2, SeekOrigin.Current);
            writer.Write(beheld.Serial);

            for (var i = 0; i < list.Count; ++i)
            {
                var item = list[i];

                if (!item.Deleted && beholder.CanSee(item) && item.Parent == beheld)
                {
                    writer.Write((byte)(item.Layer + 1));
                    writer.Write(item.Serial);
                }
            }

            if (beheld.Hair?.ItemID > 0)
            {
                writer.Write((byte)(Layer.Hair + 1));
                writer.Write(HairInfo.FakeSerial(beheld.Owner.Serial) - 2);
            }

            if (beheld.FacialHair?.ItemID > 0)
            {
                writer.Write((byte)(Layer.FacialHair + 1));
                writer.Write(FacialHairInfo.FakeSerial(beheld.Owner.Serial) - 2);
            }

            writer.Write((byte)Layer.Invalid);

            writer.WritePacketLength();
            ns.Send(writer.Span);
        }
Exemplo n.º 37
0
        public static void SendDisplayBuyList(this NetState ns, Serial vendor)
        {
            if (ns == null || !ns.GetSendBuffer(out var buffer))
            {
                return;
            }

            var writer = new CircularBufferWriter(buffer);

            writer.Write((byte)0x24);  // Packet ID
            writer.Write(vendor);
            writer.Write((short)0x30); // Vendor Buy Window
            if (ns.HighSeas)
            {
                writer.Write((short)0x0);
            }

            ns.Send(ref buffer, writer.Position);
        }
Exemplo n.º 38
0
        public static void SendDisplayContainer(this NetState ns, Serial cont, int gumpId)
        {
            if (ns == null || !ns.GetSendBuffer(out var buffer))
            {
                return;
            }

            var writer = new CircularBufferWriter(buffer);

            writer.Write((byte)0x24); // Packet ID
            writer.Write(cont);
            writer.Write((ushort)gumpId);
            if (ns.HighSeas)
            {
                writer.Write((short)0x7D);
            }

            ns.Send(ref buffer, writer.Position);
        }
Exemplo n.º 39
0
        public static void SendServerPollInfo(this NetState ns)
        {
            if (ns == null)
            {
                return;
            }

            var writer = new SpanWriter(stackalloc byte[15]);

            writer.Write((byte)0xC0);               // Packet ID
            writer.Write((ushort)17);               // Length
            writer.Write(ConnectUOProtocolVersion); // Version
            writer.Write((byte)_serverType);
            writer.Write((int)(Core.TickCount / 1000));
            writer.Write(Accounts.Count);                // Shame if you modify this!
            writer.Write(TcpServer.Instances.Count - 1); // Shame if you modify this!

            ns.Send(writer.Span);
        }
Exemplo n.º 40
0
        public static void SendHelpResponse(this NetState ns, Serial s, string text)
        {
            text = text?.Trim() ?? "";

            if (ns == null || text.Length == 0)
            {
                return;
            }

            var length = 9 + text.Length * 2;
            var writer = new SpanWriter(stackalloc byte[length]);

            writer.Write((byte)0xB7);
            writer.Write((ushort)length);
            writer.Write(s);
            writer.WriteBigUniNull(text);

            ns.Send(writer.Span);
        }
Exemplo n.º 41
0
        public static void SendDisplayContainer(this NetState ns, Serial cont, int gumpId)
        {
            if (ns == null)
            {
                return;
            }

            var writer = new SpanWriter(stackalloc byte[ns.HighSeas ? 9 : 7]);

            writer.Write((byte)0x24); // Packet ID
            writer.Write(cont);
            writer.Write((ushort)gumpId);
            if (ns.HighSeas)
            {
                writer.Write((short)0x7D);
            }

            ns.Send(writer.Span);
        }
Exemplo n.º 42
0
        public static void SendDisplayBuyList(this NetState ns, Serial vendor)
        {
            if (ns == null)
            {
                return;
            }

            var writer = new SpanWriter(stackalloc byte[ns.HighSeas ? 9 : 7]);

            writer.Write((byte)0x24);  // Packet ID
            writer.Write(vendor);
            writer.Write((short)0x30); // Vendor Buy Window
            if (ns.HighSeas)
            {
                writer.Write((short)0x0);
            }

            ns.Send(writer.Span);
        }
        public static void SendCloseSecureTrade(this NetState ns, Container cont)
        {
            if (ns == null)
            {
                return;
            }

            var writer = new SpanWriter(stackalloc byte[17]);

            writer.Write((byte)0x6F); // Packet ID
            writer.Write((ushort)17); // Length
            writer.Write((byte)TradeFlag.Close);
            writer.Write(cont.Serial);
            writer.Write(0);
            writer.Write(0);
            writer.Write(false);

            ns.Send(writer.Span);
        }
Exemplo n.º 44
0
        public static void PrivateOverheadMessage(this Item item, MessageType type, int hue, int number, NetState state, string args = "")
        {
            if (item.Map != null && state != null)
            {
                Packet p = null;
                Point3D worldLoc = item.GetWorldLocation();

                Mobile m = state.Mobile;

                if (m != null && m.CanSee(item) && m.InRange(worldLoc, item.GetUpdateRange(m)))
                {
                    if (p == null)
                        p = Packet.Acquire(new MessageLocalized(item.Serial, item.ItemID, type, hue, 3, number, item.Name, args));

                    state.Send(p);
                }

                Packet.Release(p);
            }
        }
Exemplo n.º 45
0
        public static void Authenticate( NetState state, PacketReader pvSrc )
        {
            string user = pvSrc.ReadString( 30 );
            string pw = pvSrc.ReadString( 30 );

            Account a = Accounts.GetAccount( user );
            if ( a == null )
            {
                state.Send( new Login( LoginResponse.NoUser ) );
                log.Warn(String.Format("ADMIN: Invalid username '{0}' from {1}",
                                       user, state));
                DelayedDisconnect( state );
            }
            else if ( !a.HasAccess( state ) )
            {
                state.Send( new Login( LoginResponse.BadIP ) );
                log.Warn(String.Format("ADMIN: Access to '{0}' from {1} denied.",
                                       user, state));
                DelayedDisconnect( state );
            }
            else if ( !a.CheckPassword( pw ) )
            {
                state.Send( new Login( LoginResponse.BadPass ) );
                log.Warn(String.Format("ADMIN: Invalid password '{0}' for user '{1}' from {2}",
                                       pw, user, state));
                DelayedDisconnect( state );
            }
            else if ( a.AccessLevel != AccessLevel.Administrator || a.Banned )
            {
                log.Warn(String.Format("ADMIN: Account '{0}' does not have admin access. Connection Denied.",
                                       user));
                state.Send( new Login( LoginResponse.NoAccess ) );
                DelayedDisconnect( state );
            }
            else
            {
                log.Warn(String.Format("ADMIN: Access granted to '{0}' from {1}",
                                       user, state));
                state.Account = a;
                a.LogAccess( state );
                a.LastLogin = DateTime.Now;

                state.Send( new Login( LoginResponse.OK ) );
                state.Send( Compress( new ConsoleData( m_ConsoleData.ToString() ) ) );
                m_Auth.Add( state );
            }
        }
Exemplo n.º 46
0
        public static void LoginServerSeed(NetState state, PacketReader pvSrc)
        {
            int seed = pvSrc.ReadInt32(); // Seed

            int clientMaj = pvSrc.ReadInt32();
            int clientMin = pvSrc.ReadInt32();
            int clientRev = pvSrc.ReadInt32();
            int clientPat = pvSrc.ReadInt32();

            if ((seed == 0) && (clientMaj == 0) && (clientMin == 0) && (clientPat == 0) && (clientRev == 0))
            {
                state.SentFirstPacket = true;
                // This is UOExt. Cheers!
                state.Send(m_UOExtSupport);
                state.Flush();
                return;
            }

            // Enroute to old EF handler
            pvSrc.Seek(0, System.IO.SeekOrigin.Begin);
            m_OldEFHandler.OnReceive(state, pvSrc);

        }
Exemplo n.º 47
0
		//public override void SendInfoTo( NetState state )
		//{
			//base.SendInfoTo( state );
                public override void SendInfoTo( NetState state, bool sendOplPacket )
		{
			base.SendInfoTo( state, sendOplPacket );
			if ( ItemID == 0x2006 )
			{
				state.Send( new SleepingBodyContent( state.Mobile, this ) );
				state.Send( new SleepingBodyEquip( state.Mobile, this ) );
			}
		}
Exemplo n.º 48
0
		public static void GodModeRequest( NetState state, PacketReader pvSrc )
		{
			if ( VerifyGC( state ) )
			{
				state.Send( new GodModeReply( pvSrc.ReadBoolean() ) );
			}
		}
Exemplo n.º 49
0
		public static void UTripTime( NetState state, PacketReader pvSrc )
		{
			int unk1 = pvSrc.ReadByte();
			int unk2 = pvSrc.ReadInt32();

			state.Send( new UTripTimeResponse( unk1 ) );
		}
Exemplo n.º 50
0
		public static void MobileNameRequest( NetState state, PacketReader pvSrc )
		{
			Mobile m = World.FindMobile( pvSrc.ReadInt32() );

			if ( m != null && Utility.InUpdateRange( state.Mobile, m ) && state.Mobile.CanSee( m ) )
				state.Send( new MobileName( m ) );
		}
Exemplo n.º 51
0
		public static void VendorSellReply( NetState state, PacketReader pvSrc )
		{
			Serial serial = pvSrc.ReadInt32();
			Mobile vendor = World.FindMobile( serial );

			if ( vendor == null )
			{
				return;
			}
			else if ( vendor.Deleted || !Utility.RangeCheck( vendor.Location, state.Mobile.Location, 10 ) )
			{
				state.Send( new EndVendorSell( vendor ) );
				return;
			}

			int count = pvSrc.ReadUInt16();
			if ( count < 100 && pvSrc.Size == (1+2+4+2+(count*6)) )
			{
				List<SellItemResponse> sellList = new List<SellItemResponse>( count );

				for (int i=0;i<count;i++)
				{
					Item item = World.FindItem( pvSrc.ReadInt32() );
					int Amount = pvSrc.ReadInt16();

					if ( item != null && Amount > 0 )
						sellList.Add(  new SellItemResponse( item, Amount ) );
				}

				if ( sellList.Count > 0 )
				{
					IVendor v = vendor as IVendor;

					if ( v != null && v.OnSellItems( state.Mobile, sellList ) )
						state.Send( new EndVendorSell( vendor ) );
				}
			}
		}
Exemplo n.º 52
0
 public void SendDetailedInfoTo( NetState state )
 {
     if ( state != null )
     {
         lock ( this )
         {
             if ( m_PacketCache == null )
                 DesignStateDetailed.SendDetails( state, m_Foundation, this );
             else
                 state.Send( m_PacketCache );
         }
     }
 }
		private static void ServerInfoRequest( NetState state, PacketReader pvSrc )
		{
			state.Send( AdminNetwork.Compress( new ServerInfo() ) );
		}
		private static void RemoveAccount( NetState state, PacketReader pvSrc )
		{
			Account a = Accounts.GetAccount( pvSrc.ReadString() );

			if ( a == null )
			{
				state.Send( new MessageBoxMessage( "The account could not be found (and thus was not deleted).", "Account Not Found" ) );
			}
			else if ( a == state.Account )
			{
				state.Send( new MessageBoxMessage( "You may not delete your own account.", "Not Allowed" ) );
			}
			else
			{
				for (int i=0;i<a.Length;i++)
				{
					if ( a[i] != null )
						a[i].Delete();
				}

				Accounts.Table.Remove( a.Username );
				state.Send( new MessageBoxMessage( "The requested account (and all it's characters) has been deleted.", "Account Deleted" ) );
			}
		}
		private static void UpdateAccount( NetState state, PacketReader pvSrc )
		{
			string username = pvSrc.ReadString();
			string pass = pvSrc.ReadString();

			Account a = Accounts.GetAccount( username );

			if ( a == null )
				a = Accounts.AddAccount( username, pass );
			else if ( pass != "(hidden)" )
				a.SetPassword( pass );

			if ( a != state.Account )
			{
				a.AccessLevel = (AccessLevel)pvSrc.ReadByte();
				a.Banned = pvSrc.ReadBoolean();
			}
			else
			{
				pvSrc.ReadInt16();//skip both
				state.Send( new MessageBoxMessage( "Warning: When editing your own account, account status and accesslevel cannot be changed.", "Editing Own Account" ) );
			}

			ArrayList list = new ArrayList();
			ushort length = pvSrc.ReadUInt16();
			bool invalid = false;
			for (int i=0;i<length;i++)
			{
				string add = pvSrc.ReadString();
				if ( Utility.IsValidIP( add ) )
					list.Add( add );
				else
					invalid = true;
			}

			if ( list.Count > 0 )
				a.IPRestrictions = (string[])list.ToArray( typeof( string ) );
			else
				a.IPRestrictions = new string[0];

			if ( invalid )
				state.Send( new MessageBoxMessage( "Warning: one or more of the IP Restrictions you specified was not valid.", "Invalid IP Restriction" ) );
			state.Send( new MessageBoxMessage( "Account updated successfully.", "Account Updated" ) );
		}
Exemplo n.º 56
0
		public static void AccountLogin_ReplyAck( NetState state )
		{
			ServerListEventArgs e = new ServerListEventArgs( state, state.Account );

			EventSink.InvokeServerList( e );

			if ( e.Rejected )
			{
				state.Account = null;
				state.Send( new AccountLoginRej( ALRReason.BadComm ) );
				state.Dispose();
			}
			else
			{
				ServerInfo[] info = e.Servers.ToArray();

				state.ServerInfo = info;

				state.Send( new AccountLoginAck( info ) );
			}
		}
Exemplo n.º 57
0
		public void SendTo(NetState state)
		{
			state.Send(new DisplayHuePicker(this));
			state.AddHuePicker(this);
		}
Exemplo n.º 58
0
		public static void AccountLogin_ReplyRej( NetState state, ALRReason reason )
		{
			state.Send( new AccountLoginRej( reason ) );
			state.Dispose();
		}
Exemplo n.º 59
0
 public void SendGeneralInfoTo( NetState state )
 {
     if ( state != null )
         state.Send( new DesignStateGeneral( m_Foundation, this ) );
 }
Exemplo n.º 60
0
		public static void VendorBuyReply( NetState state, PacketReader pvSrc )
		{
			pvSrc.Seek( 1, SeekOrigin.Begin );

			int msgSize = pvSrc.ReadUInt16();
			Mobile vendor = World.FindMobile( pvSrc.ReadInt32() );
			byte flag = pvSrc.ReadByte();

			if ( vendor == null )
			{
				return;
			}
			else if ( vendor.Deleted || !Utility.RangeCheck( vendor.Location, state.Mobile.Location, 10 ) )
			{
				state.Send( new EndVendorBuy( vendor ) );
				return;
			}

			if ( flag == 0x02 )
			{
				msgSize -= 1+2+4+1;

				if ( (msgSize / 7) > 100 )
					return;

				List<BuyItemResponse> buyList = new List<BuyItemResponse>( msgSize / 7 );
				for ( ;msgSize>0;msgSize-=7)
				{
					byte layer = pvSrc.ReadByte();
					Serial serial = pvSrc.ReadInt32();
					int amount = pvSrc.ReadInt16();
				
					buyList.Add( new BuyItemResponse( serial, amount ) );
				}

				if ( buyList.Count > 0 )
				{
					IVendor v = vendor as IVendor;

					if ( v != null && v.OnBuyItems( state.Mobile, buyList ) )
						state.Send( new EndVendorBuy( vendor ) );
				}
			}
			else
			{
				state.Send( new EndVendorBuy( vendor ) );
			}
		}