コード例 #1
0
ファイル: World.cs プロジェクト: dpisanu/xrunuo
        public static void Broadcast(int hue, bool ascii, string text)
        {
            Packet p;

            if (ascii)
            {
                p = new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text);
            }
            else
            {
                p = new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text);
            }

            p.Acquire();

            foreach (var client in GameServer.Instance.Clients)
            {
                if (client.Mobile != null)
                {
                    client.Send(p);
                    client.Flush();
                }
            }

            p.Release();
        }
コード例 #2
0
        public static void NonlocalOverheadMessage(this Item item, MessageType type, int hue, bool ascii, string text)
        {
            if (item == null || item.Map == null)
            {
                return;
            }

            Packet p;

            if (ascii)
            {
                p = new AsciiMessage(item.Serial, item.ItemID, type, hue, 3, item.Name, text);
            }
            else
            {
                p = new UnicodeMessage(item.Serial, item.ItemID, type, hue, 3, "ENU", item.Name, text);
            }

            p.Acquire();

            var eable = item.Map.GetClientsInRange(item.Location, item.GetMaxUpdateRange());

            foreach (var state in eable.Where(state => state.Mobile.CanSee(item)))
            {
                state.Send(p);
            }

            eable.Free();

            Packet.Release(p);
        }
コード例 #3
0
ファイル: World.cs プロジェクト: Pumpk1ns/outlands
        public static void Broadcast(int hue, bool ascii, string text)
        {
            Packet p;

            if (ascii)
            {
                p = new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text);
            }
            else
            {
                p = new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text);
            }

            List <NetState> list = NetState.Instances;

            p.Acquire();

            for (int i = 0; i < list.Count; ++i)
            {
                if (list[i].Mobile != null)
                {
                    list[i].Send(p);
                }
            }

            p.Release();

            NetState.FlushAll();
        }
コード例 #4
0
ファイル: Party.cs プロジェクト: BackupTheBerlios/sunuo-svn
        public void SendPrivateMessage(Mobile from, Mobile to, string text)
        {
            to.Send(new PartyTextMessage(false, from, text));

            for (int i = 0; i < m_Listeners.Count; ++i)
            {
                Mobile mob = (Mobile)m_Listeners[i];

                if (mob.Party != this)
                {
                    ((Mobile)m_Listeners[i]).SendMessage("[{0}]->[{1}]: {2}", from.Name, to.Name, text);
                }
            }

            Packet p = null;

            foreach (NetState ns in from.GetClientsInRange(8))
            {
                Mobile mob = ns.Mobile;

                if (mob != null && mob.AccessLevel >= AccessLevel.GameMaster && mob.AccessLevel > from.AccessLevel && mob.Party != this && !m_Listeners.Contains(mob))
                {
                    if (p == null)
                    {
                        p = new UnicodeMessage(from.Serial, from.Body, MessageType.Regular, from.SpeechHue, 3, from.Language, from.Name, String.Format("[Party]->[{0}]: {1}", to.Name, text));
                    }

                    ns.Send(p);
                }
            }
        }
コード例 #5
0
        public static void PublicOverheadMessage(Mobile m, MessageType type, int hue, string text)
        {
            if (m.Map != null)
            {
                Packet p = null;

                IPooledEnumerable eable = m.Map.GetClientsInRange(m.Location);

                foreach (NetState state in eable)
                {
                    if (state.Mobile != null && state.Mobile.CanSee(m) && state.Mobile.AccessLevel >= AccessLevel.GameMaster)
                    {
                        if (p == null)
                        {
                            p = new UnicodeMessage(m.Serial, m.Body, type, hue, 3, m.Language, m.Name, text);

                            p.Acquire();
                        }

                        state.Send(p);
                    }
                }

                Packet.Release(p);

                eable.Free();
            }
        }
コード例 #6
0
ファイル: World.cs プロジェクト: BackupTheBerlios/sunuo-svn
        public static void Broadcast(int hue, bool ascii, string text)
        {
            Packet p;

            if (ascii)
            {
                p = new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text);
            }
            else
            {
                p = new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text);
            }

            ArrayList list = NetState.Instances;

            for (int i = 0; i < list.Count; ++i)
            {
                if (((NetState)list[i]).Mobile != null)
                {
                    ((NetState)list[i]).Send(p);
                }
            }

            NetState.FlushAll();
        }
コード例 #7
0
        private static void Msg(CommandEventArgs e)
        {
            Mobile from = e.Mobile;

            Guild GuildC = from.Guild as Guild;

            if (GuildC == null)
            {
                from.SendMessage("You are not in a guild!");
            }
            else
            {
                foreach (NetState state in NetState.Instances)
                {
                    Mobile m = state.Mobile;
                    if (m != null && GuildC.IsMember(m))
                    {
                        m.SendMessage(0x2C, String.Format("Guild[{0}]: {1}", from.Name, e.ArgString));
                    }
                }
                Packet p = null;
                foreach (NetState ns in from.GetClientsInRange(8))
                {
                    Mobile mob = ns.Mobile;
                    if (mob != null && mob.AccessLevel >= AccessLevel.GameMaster && mob.AccessLevel > from.AccessLevel)
                    {
                        if (p == null)
                        {
                            p = new UnicodeMessage(from.Serial, from.Body, MessageType.Regular, from.SpeechHue, 3, from.Language, from.Name, String.Format("[Guild]: {0}", e.ArgString));
                        }
                        ns.Send(p);
                    }
                }
            }
        }
コード例 #8
0
        public void PublicLOSMessage(MessageType type, int hue, bool ascii, string text)
        {
            Packet  p        = null;
            Point3D worldLoc = GetWorldLocation();

            IPooledEnumerable eable = GetClientsInRange(GetMaxUpdateRange());

            foreach (NetState state in eable)
            {
                Mobile m = state.Mobile;

                if (m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m)) && this.Map.LineOfSight(this.Map.GetPoint(m, true), worldLoc))
                {
                    if (p == null)
                    {
                        if (ascii)
                        {
                            p = new AsciiMessage(Serial, ItemID, type, hue, 3, Name, text);
                        }
                        else
                        {
                            p = new UnicodeMessage(Serial, ItemID, type, hue, 3, "ENU", Name, text);
                        }
                        p.SetStatic();
                    }
                    state.Send(p);
                }
                Packet.Release(ref p);
            }
            eable.Free();
        }
コード例 #9
0
ファイル: World.cs プロジェクト: travismills82/TrueUO
        public static void Broadcast(int hue, bool ascii, AccessLevel access, string text)
        {
            WorldBroadcastEventArgs e = new WorldBroadcastEventArgs(hue, ascii, access, text);

            EventSink.InvokeWorldBroadcast(e);

            hue    = e.Hue;
            ascii  = e.Ascii;
            text   = e.Text;
            access = e.Access;

            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }

            Packet p;

            if (ascii)
            {
                p = new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text);
            }
            else
            {
                p = new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text);
            }

            List <NetState> list = NetState.Instances;

            p.Acquire();

            for (var index = 0; index < list.Count; index++)
            {
                NetState s = list[index];

                if (s.Mobile != null && s.Mobile.AccessLevel >= access)
                {
                    s.Send(p);
                }
            }

            p.Release();

            NetState.FlushAll();
        }
コード例 #10
0
        public void TestUnicodeMessage()
        {
            Serial serial      = (Serial)0x1024;
            var    graphic     = 0x100;
            var    messageType = MessageType.Label;
            var    hue         = 1024;
            var    font        = 3;
            var    lang        = "ENU";
            var    name        = "Stuff";
            var    text        = "Some Text";

            var expected = new UnicodeMessage(
                serial,
                graphic,
                messageType,
                hue,
                font,
                lang,
                name,
                text
                ).Compile();

            var ns = PacketTestUtilities.CreateTestNetState();

            ns.SendMessage(
                serial,
                graphic,
                messageType,
                hue,
                font,
                false,
                lang,
                name,
                text
                );

            var result = ns.SendPipe.Reader.TryRead();

            AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
        }
コード例 #11
0
ファイル: DetectionGarde.cs プロジェクト: jicomub/Temrael
        public override void DetecterAlentours()
        {
            IPooledEnumerable <Mobile> eable = mobile.GetMobilesInRange(DetectionRange);

            foreach (Mobile mob in eable)
            {
                ScriptMobile m = mob as ScriptMobile;
                if (m == null || m == mobile || !m.Hidden || !mobile.InLOS(m) || m.AccessLevel > AccessLevel.Player)
                {
                    continue;
                }

                m.Hidden = false;

                Packet p = null;

                IPooledEnumerable <NetState> neable = mobile.Map.GetClientsInRange(mobile.Location);

                foreach (NetState state in neable)
                {
                    if (state.Mobile.CanSee(this) && state.Mobile.InLOS(this))
                    {
                        string text = String.Format("Fais signe à {0} de déguerpir.", mob.GetNameUsedBy(state.Mobile));

                        p = new UnicodeMessage(mobile.Serial, mobile.Body, MessageType.Emote, 1209, 3,
                                               mobile.Language, mobile.Name, text);

                        p.Acquire();

                        state.Send(p);

                        Packet.Release(p);
                    }
                }
                neable.Free();
            }

            eable.Free();
        }
コード例 #12
0
        public void TestUnicodeMessage()
        {
            Serial serial      = 0x1;
            var    graphic     = 0x100;
            var    messageType = MessageType.Label;
            var    hue         = 1024;
            var    font        = 3;
            var    lang        = "ENU";
            var    name        = "Stuff";
            var    text        = "Some Text";

            var data = new UnicodeMessage(
                serial,
                graphic,
                messageType,
                hue,
                font,
                lang,
                name,
                text
                ).Compile();

            Span <byte> expectedData = stackalloc byte[50 + text.Length * 2];
            var         pos          = 0;

            expectedData.Write(ref pos, (byte)0xAE);                  // Packet ID
            expectedData.Write(ref pos, (ushort)expectedData.Length); // Length

            expectedData.Write(ref pos, serial);
            expectedData.Write(ref pos, (ushort)graphic);
            expectedData.Write(ref pos, (byte)messageType);
            expectedData.Write(ref pos, (ushort)hue);
            expectedData.Write(ref pos, (ushort)font);
            expectedData.WriteAsciiFixed(ref pos, lang, 4);
            expectedData.WriteAsciiFixed(ref pos, name, 30);
            expectedData.WriteBigUniNull(ref pos, text);

            AssertThat.Equal(data, expectedData);
        }
コード例 #13
0
        public static void Broadcast(int hue, bool ascii, string text)
        {
            Packet packet1;
            int    num1;

            if (ascii)
            {
                packet1 = new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text);
            }
            else
            {
                packet1 = new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text);
            }
            ArrayList list1 = NetState.Instances;

            for (num1 = 0; (num1 < list1.Count); ++num1)
            {
                if (((NetState)list1[num1]).Mobile != null)
                {
                    ((NetState)list1[num1]).Send(packet1);
                }
            }
        }