Example #1
0
        private void Handle(mesg_spacket msg)
        {
            lMessage.Debug(msg.ToString());

            if (!msg.Flags.HasFlag(MessageFlags.MVALID))
            {
                l.Warn("UNEXPECTED: Got message without MVALID bit set");
                return;
            }

            Message message = new Message()
            {
                Text = msg.Message,
            };

            if (msg.Flags.HasFlag(MessageFlags.MGOD))
            {
                Player player = Galaxy.GetPlayer(msg.from);
                message.Source = "GOD";
            }
            else
            {
                if (msg.from == 255)
                {
                    message.Source = "GOD";
                }
                else
                {
                    Player player = Galaxy.GetPlayer(msg.from);
                    message.Source = player.SlotName;
                }
            }


            if (msg.Flags.HasFlag(MessageFlags.MINDIV))
            {
                Player player = Galaxy.GetPlayer(msg.recipient);
                if (player != null)
                {
                    message.Recipient = player.SlotNameAndName;
                }
            }
            else if (msg.Flags.HasFlag(MessageFlags.MTEAM))
            {
                NetrekTeam team = (NetrekTeam)msg.recipient;
                if (Enum.IsDefined(typeof(NetrekTeam), team))
                {
                    message.Recipient = team.ToShortName();
                }
                else
                {
                    l.Warn("!Enum.IsDefined(team)");
                }

                //Player player = Galaxy.(msg.recipient);
                //if (player != null)
                //{
                //    message.Recipient = player.SlotNameAndName;
                //}
            }
            else if (msg.Flags.HasFlag(MessageFlags.MALL))
            {
                message.Recipient = "ALL";
            }

            Bridge.MessengerServer.Send(message);
        }
        private void Handle(mesg_spacket msg)
        {
            lMessage.Debug(msg.ToString());

            if (!msg.Flags.HasFlag(MessageFlags.MVALID))
            {
                l.Warn("UNEXPECTED: Got message without MVALID bit set");
                return;
            }

            Message message = new Message()
            {
                Text = msg.Message,
            };

            if (msg.Flags.HasFlag(MessageFlags.MGOD))
            {
                Player player = Galaxy.GetPlayer(msg.from);
                message.Source = "GOD";
            }
            else
            {
                if (msg.from == 255)
                {
                    message.Source = "GOD";
                }
                else
                {
                    Player player = Galaxy.GetPlayer(msg.from);
                    message.Source = player.SlotName;
                }
            }

            if (msg.Flags.HasFlag(MessageFlags.MINDIV))
            {
                Player player = Galaxy.GetPlayer(msg.recipient);
                if (player != null)
                {
                    message.Recipient = player.SlotNameAndName;
                }
            }
            else if (msg.Flags.HasFlag(MessageFlags.MTEAM))
            {
                NetrekTeam team = (NetrekTeam)msg.recipient;
                if (Enum.IsDefined(typeof(NetrekTeam), team))
                {
                    message.Recipient = team.ToShortName();
                }
                else
                {
                    l.Warn("!Enum.IsDefined(team)");
                }

                //Player player = Galaxy.(msg.recipient);
                //if (player != null)
                //{
                //    message.Recipient = player.SlotNameAndName;
                //}
            }
            else if (msg.Flags.HasFlag(MessageFlags.MALL))
            {
                message.Recipient = "ALL";
            }

            Bridge.MessengerServer.Send(message);
        }