예제 #1
0
        public static bool OnSendData(ref int msgType, ref int remoteClient, ref int ignoreClient, ref string text, ref int number, ref float number2, ref float number3, ref float number4)
        {
            if (SendData == null)
            {
                return(false);
            }

            var args = new SendDataEventArgs()
            {
                MsgID        = (PacketTypes)msgType,
                remoteClient = remoteClient,
                ignoreClient = ignoreClient,
                text         = text,
                number       = number,
                number2      = number2,
                number3      = number3,
                number4      = number4,
            };

            SendData(args);

            msgType      = (int)args.MsgID;
            remoteClient = args.remoteClient;
            ignoreClient = args.ignoreClient;
            text         = args.text;
            number       = args.number;
            number2      = args.number2;
            number3      = args.number3;
            number4      = args.number4;

            return(args.Handled);
        }
예제 #2
0
 private static void NetHooks_SendData(SendDataEventArgs e)
 {
     if (Main.netMode != 2 && e.MsgID == PacketTypes.ChatText)
     {
         string msg = e.text;
         e.Handled = OnChat(ref msg);
         e.text = msg;
     }
 }
예제 #3
0
 private static void NetHooks_SendData(SendDataEventArgs e)
 {
     if (Main.netMode != 2 && e.MsgID == PacketTypes.ChatText)
     {
         string msg = e.text;
         e.Handled = OnChat(ref msg);
         e.text    = msg;
     }
 }
예제 #4
0
        public static bool OnSendData(ref int msgType, ref int remoteClient, ref int ignoreClient, ref string text, ref int number, ref float number2, ref float number3, ref float number4)
        {
            if (SendData == null)
                return false;

            var args = new SendDataEventArgs()
            {
                MsgID = (PacketTypes)msgType,
                remoteClient = remoteClient,
                ignoreClient = ignoreClient,
                text = text,
                number = number,
                number2 = number2,
                number3 = number3,
                number4 = number4,
            };

            SendData(args);

            msgType = (int)args.MsgID;
            remoteClient = args.remoteClient;
            ignoreClient = args.ignoreClient;
            text = args.text;
            number = args.number;
            number2 = args.number2;
            number3 = args.number3;
            number4 = args.number4;

            return args.Handled;
        }
예제 #5
0
파일: TShock.cs 프로젝트: char213/TShock
        void NetHooks_SendData(SendDataEventArgs e)
        {
            if (e.MsgID == PacketTypes.Disconnect)
            {
                Action<ServerSock,string> senddisconnect = (sock, str) =>
                {
                    if (sock == null || !sock.active)
                        return;
                    sock.kill = true;
                    using (var ms = new MemoryStream())
                    {
                        new DisconnectMsg {Reason = str}.PackFull(ms);
                        SendBytesBufferless(sock, ms.ToArray());
                    }
                };

                if (e.remoteClient != -1)
                {
                    senddisconnect(Netplay.serverSock[e.remoteClient], e.text);
                }
                else
                {
                    for (int i = 0; i < Netplay.serverSock.Length; i++)
                    {
                        if (e.ignoreClient != -1 && e.ignoreClient == i)
                            continue;

                        senddisconnect(Netplay.serverSock[i], e.text);
                    }
                }
                e.Handled = true;
            }
        }
예제 #6
0
        public void OnSendData(SendDataEventArgs e)
        {
            try
            {
                List<int> ghostIDs = new List<int>();
                for (int i = 0; i < 256; i++)
                {

                    if (isGhost[i])
                    {

                        ghostIDs.Add(i);

                    }

                }
                switch (e.MsgID)
                {

                    case PacketTypes.DoorUse:
                    case PacketTypes.EffectHeal:
                    case PacketTypes.EffectMana:
                    case PacketTypes.PlayerDamage:
                    case PacketTypes.Zones:
                    case PacketTypes.PlayerAnimation:
                    case PacketTypes.PlayerTeam:
                    case PacketTypes.PlayerSpawn:
                        if ((ghostIDs.Contains(e.number)) && (isGhost[e.number]))
                            e.Handled = true;
                        break;

                }
                if ((e.number >= 0) && (e.number <= 255) && (isGhost[e.number]))
                {

                    if ((!cansend) && (e.MsgID == PacketTypes.PlayerUpdate))
                    {

                        e.Handled = true;

                    }
                }
            }
            catch (Exception) { }
        }