Beispiel #1
0
        /// <summary>
        /// Client attempts to create a new character.
        /// </summary>
        /// <param name="packet"></param>
        void OnCreateCharacter(PacketReader packet)
        {
            if (!IsAuthenticated)
            {
                return;
            }

            string characterName  = packet.ReadUTF16();
            int    characterClass = packet.ReadInt32();

            if (Server.Database.IsCharacterNameAvailable(characterName))
            {
                Character newCharacter;
                if (Server.Database.CreateCharacter(Account.Name, characterName, (short)characterClass, out newCharacter))
                {
                    Account.Characters.Add(newCharacter);

                    Send(PacketGenerator.CharacterCreate(0, newCharacter));
                }
                else
                {
                    Send(PacketGenerator.CharacterCreate(4, null));
                }
            }
            else
            {
                Send(PacketGenerator.CharacterCreate(1, null));
            }
        }
Beispiel #2
0
        /// <summary>
        /// this is the execution method which gets executed later
        /// to get more arguments use the internal regArgs variable
        /// </summary>
        /// <param name="arg1">first argument after the command in the string</param>
        /// <param name="arg2">second argument after the command in the string</param>
        /// <param name="arg3">third argument after the command in the string</param>
        /// <param name="arg4">fourth argument after the command in the string</param>
        /// <returns>remember to set the command result in every return case</returns>
        public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4)
        {
            Server.SendExecuteResponse(TriggerPlayer, ClientUser.LastEntityId.ToString());

            PacketGenerator gen = new PacketGenerator();

            gen.Add(ClientUser.LastEntityId);
            gen.Add(100);
            gen.Add(1000);
            gen.Add(100);
            gen.Add((byte)0);
            gen.Add((byte)0);

            ClientSocket c = Client as ClientSocket;

            (Server as ServerSocket).SendPacketToClient(PacketBytes._0x22_EntityTeleport_0x22, TriggerPlayer, gen.ToByteArray());

            XPosition       pos          = Client.Position;
            PacketGenerator teleportData = new PacketGenerator();

            teleportData.Add(100.0);  // X
            teleportData.Add(999.5);  // Y
            teleportData.Add(1000.0); // Stance
            teleportData.Add(100.0);  // Z
            teleportData.Add(pos.Rotation);
            teleportData.Add(pos.Pitch);
            teleportData.Add(pos.Unkown);
            Client.SendPacket(Vitt.Andre.TCPTunnelLib.Vitt.Andre.Tunnel.PacketBytes._0x0D_PlayerMoveAndLook_0x0D, teleportData.ToByteArray());


            (Server as ServerSocket).SendPacketToClient(PacketBytes._0x22_EntityTeleport_0x22, TriggerPlayer, gen.ToByteArray());

            return(new CommandResult(true, string.Format("{0} executed by {1}", Name, TriggerPlayer)));
        }
Beispiel #3
0
 // int count = 0;
 public ZeroGPacket SendNewPlayerInfo()
 {
     try
     {
         GameLevelInfo levelnfo = new GameLevelInfo();
         levelnfo.Generate("Urban_02", 4, 2, false);
         //  GamePacket packet = new GamePacket();
         //packet.packetType = "LevelInfo";
         //   LoadingComplete packetSecond = new LoadingComplete();
         //   packetSecond.Generate(true, "yo");
         //   if(count == 2)
         //  {
         //      packet.Generate("LevelInfo", levelnfo, packetSecond);
         //  }
         //   else
         //  {
         //      packet.Generate("LevelInfo", levelnfo,packetSecond);
         //  }
         //  count = count + 1;
         ZeroGPacket packet = PacketGenerator.Generate("LevelInfo", levelnfo);
         return(packet);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error: " + ex.Message + ex.StackTrace);
         return(null);
     }
 }
Beispiel #4
0
        public void Process(ZeroGPacket packet)
        {
            GamePacket origPacket = PacketGenerator.Decompile(packet);

            if (packet.PacketType == "LevelInfo" && (origPacket.GetType() == typeof(GameLevelInfo)))
            {
                GameLevelInfo newPacket = (GameLevelInfo)origPacket;
                LevelInfoProcessor.Process(newPacket);
            }
            else if (packet.PacketType == "PlayerNames" && (origPacket.GetType() == typeof(PlayerNames)))
            {
                PlayerNames newpacket = (PlayerNames)origPacket;
                PlayerNamesProcessor.Process(newpacket);
            }
            else if (packet.PacketType == "PlayerPosition" && (origPacket.GetType() == typeof(PlayerPosition)))
            {
                PlayerPosition newpacket = (PlayerPosition)origPacket;
                PlayerPositionProcessor.Process(newpacket);
            }
            else if (packet.PacketType == "AllLoaded" && (origPacket.GetType() == typeof(AllPlayersLoaded)))
            {
                AllPlayersLoaded newpacket = (AllPlayersLoaded)origPacket;
                AllPlayersLoadedProcessor.Process(newpacket);
            }
        }
Beispiel #5
0
        public void SendPlayerUpdate(Vector3 position, Quaternion rotation)
        {
            PlayerPosition packet = new PlayerPosition();

            packet.Generate(userName, ConvertCustomTypes.ConvertVectorSerializable(position), ConvertCustomTypes.ConvertQuaternionSerializable(rotation));
            ZeroGPacket mainPacket = PacketGenerator.Generate("PlayerPosition", packet);

            gClient.Send(mainPacket, LiteNetLib.DeliveryMethod.Unreliable);
        }
Beispiel #6
0
        private void EventSender_AllPlayersLoaded(object sender, EventArgs e)
        {
            // throw new NotImplementedException();
            AllPlayersLoaded packet = new AllPlayersLoaded();

            packet.Generate(true);
            ZeroGPacket fullPacket = PacketGenerator.Generate("AllLoaded", packet);

            serverInst.SendToAll(fullPacket, DeliveryMethod.ReliableOrdered);
        }
Beispiel #7
0
        /// <summary>
        /// Client is performing a handshake.
        /// </summary>
        /// <param name="packet"></param>
        void OnHandshake(PacketReader packet)
        {
            // Generate a random key for the encryption. Key has to be 1 or higher. If the
            // key is 0 it causes the client to malform certain unicode encoded strings beyond repair.
            uint key = 2789743391; // (uint)( Server.Random.Next() | 1 );

            Connection.SetEncryption(new Encryption(key));

            Send(PacketGenerator.Handshake(key, Connection.IP));
        }
Beispiel #8
0
 public void SpeakThrough(String message)
 {
     if (IsConnected)
     {
         PacketGenerator gen = new PacketGenerator();
         gen.Add(PacketBytes._0x03_Chat_0x03);
         gen.Add(message);
         SendPackets(gen.ToByteArray());
     }
 }
Beispiel #9
0
        /// <summary>
        /// Client wants to deselect the character and return to the character selection screen.
        /// </summary>
        /// <param name="packet"></param>
        void OnDeselectCharacter(PacketReader packet)
        {
            if (!IsAuthenticated)
            {
                return;
            }

            Character = null;
            Server.Database.AssignCharacterToSession(Key, null);

            Send(PacketGenerator.CharacterDeselect(0));
        }
Beispiel #10
0
        private void Listener_PeerConnectedEvent(NetPeer peer)
        {
            //throw new NotImplementedException();
            resetEvent.Set();
            WriteLog.Debug("Successfully connected to server, sending info: " + peer.EndPoint);
            ClientInfo packet = new ClientInfo();

            packet.Generate(playername);
            ZeroGPacket mainPacket = PacketGenerator.Generate("ClientInfo", packet);

            peer.Send(netPackProc.Write(mainPacket), DeliveryMethod.ReliableOrdered);
        }
Beispiel #11
0
        public void SendLoadingComplete()
        {
            WriteLog.Verbose("Sending loading complete message to server");
            LoadingComplete completePacket = new LoadingComplete();

            completePacket.Generate(true, userName);
            // GamePacket mainPacket = new GamePacket();
            // mainPacket.Generate("LoadingComplete", null, completePacket);
            ZeroGPacket packet = PacketGenerator.Generate("LoadingComplete", completePacket);

            gClient.Send(packet, LiteNetLib.DeliveryMethod.ReliableOrdered);
        }
Beispiel #12
0
        private void CountDownTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            //  throw new NotImplementedException();
            Console.WriteLine("60 sec elapsed, starting game");
            GameLevelInfo packet = new GameLevelInfo();

            packet.Generate(levelname, players.PlayersCount() - 1, 3, false);
            ZeroGPacket fullPacket = PacketGenerator.Generate("LevelInfo", packet);

            serverInst.SendToAll(fullPacket, DeliveryMethod.ReliableOrdered);
            countDownTimer.Stop();
        }
Beispiel #13
0
    private void connectToServer()
    {
        var factory = new TokenFactory(0x1122334455667788L, _privateKey);

        clientId = Random.Range(1, 100);
        string ip = "192.168.1.70";

        ip = "54.243.1.231";
        byte[] connectToken = factory.GenerateConnectToken(
            new IPEndPoint[]
        {
            new IPEndPoint(IPAddress.Parse(ip), 12345),
            new IPEndPoint(IPAddress.Parse("0.0.0.0"), 12345)
        },
            30,
            5,
            1UL,
            (ulong)clientId,
            new byte[256]);

        client.Connect(connectToken);
        client.OnStateChanged    += UpdateStatus;
        client.OnMessageReceived += (payload, payloadSize) =>
        {
            endpoint.ReceivePacket(payload, payloadSize);
        };

        endpoint = new ReliableEndpoint
        {
            ReceiveCallback = (buffer, size) =>
            {
                var packet = PacketGenerator.DecodePacket(buffer);
                if (packet.TickId > tick)
                {
                    processor.Process(packet);
                    tick = packet.TickId;
                }
                else
                {
                    print("Skip: " + packet);
                }
            },
            TransmitCallback = (payload, payloadSize) =>
            {
                client.Send(payload, payloadSize);
            }
        };
    }
Beispiel #14
0
 public void Move(int amount)
 {
     if (isConnected)
     {
         PacketGenerator gen = new PacketGenerator();
         gen.Add(PacketBytes._0x0D_PlayerMoveAndLook_0x0D);
         gen.Add((double)(position.X + amount));
         gen.Add(position.Stance);
         gen.Add(position.Y);
         gen.Add(position.Z);
         gen.Add(position.Rotation);
         gen.Add(position.Pitch);
         gen.Add(position.Unkown);
         SendPackets(gen.ToByteArray());
     }
 }
Beispiel #15
0
        /// <summary>
        /// Client has selected a square.
        /// </summary>
        /// <param name="packet"></param>
        void OnSquareSelect(PacketReader packet)
        {
            if (!IsAuthenticated)
            {
                return;
            }

            Square square = Server.Database.GetSquare(packet.ReadUTF16());

            if (square != null)
            {
                Send(PacketGenerator.SquareConnect(0, square.IP, square.Port, Key));
            }
            else
            {
                Send(PacketGenerator.SquareConnect(4, "", 0, ""));
            }
        }
Beispiel #16
0
        private void Handshake()
        {
            serverHash = ReceiveString(client.Client);
            AddOutput(String.Format("Serverhash: {0}", serverHash));
            if (serverHash == "+")
            {
                PacketGenerator gen = new PacketGenerator();
                gen.Add(PacketBytes._0x01_Login_0x01);
                gen.Add(11); //protocol version
                gen.Add(Name);
                gen.Add((long)0);
                gen.Add((byte)0);
                client.Client.Send(gen.ToByteArray());
                handShakeSendToServer = true;
                loginRequestSend      = true;
            }
            else if (serverHash == "-")
            {
                PacketGenerator gen = new PacketGenerator();
                gen.Add(PacketBytes._0x01_Login_0x01);
                gen.Add(11); //protocol version
                gen.Add(Name);
                gen.Add((long)0);
                gen.Add((byte)0);
                client.Client.Send(gen.ToByteArray());
                handShakeSendToServer = true;
                loginRequestSend      = true;
            }
            else
            {
                Authenticate();

                PacketGenerator gen = new PacketGenerator();
                gen.Add(PacketBytes._0x01_Login_0x01);
                gen.Add(11); //protocol version
                gen.Add(Name);
                gen.Add((long)0);
                gen.Add((byte)0);
                client.Client.Send(gen.ToByteArray());
                handShakeSendToServer = true;
                loginRequestSend      = true;
            }
            handShakeReceived = true;
        }
Beispiel #17
0
        /// <summary>
        /// Client has entered their secondary password.
        /// </summary>
        /// <param name="packet"></param>
        void OnSecondaryLogin(PacketReader packet)
        {
            string accountName = packet.ReadUTF16();
            string password    = packet.ReadUTF16Safe();

            if (Account.SecondaryPassword != null && Account.SecondaryPassword != password)
            {
                //if ( FailedLoginAttemps == 3 )
                //{
                //    PacketGenerator.SecondaryPasswordResult( 3 );
                //}

                Send(PacketGenerator.SecondaryPassword(true, 0, false));
            }
            else
            {
                Send(PacketGenerator.SecondaryPasswordResult(0));
            }
        }
Beispiel #18
0
        /// <summary>
        /// Client wants to remove their secondary password.
        /// </summary>
        /// <param name="packet"></param>
        void OnRemoveSecondaryPassword(PacketReader packet)
        {
            if (!IsAuthenticated)
            {
                return;
            }

            string accountName = packet.ReadUTF16();
            string password    = packet.ReadUTF16Safe();

            int result = 1;

            if (Account.SecondaryPassword == password)
            {
                Server.Database.SetSecondaryPassword(Account.Name, null);

                result = 0;
            }
            Send(PacketGenerator.SecondaryPasswordRemoved(result));
        }
Beispiel #19
0
        public void Process(ZeroGPacket packet, NetPeer peer)
        {
            GamePacket origPacket = PacketGenerator.Decompile(packet);

            if (packet.PacketType == "LoadingComplete" && (origPacket.GetType() == typeof(LoadingComplete)))
            {
                LoadingComplete newPacket = (LoadingComplete)origPacket;
                // Console.WriteLine("Player " + newPacket.userName + " has set loading complete status to " + newPacket.isComplete);
                LoadingCompleteProcessor.Process(newPacket);
            }
            else if (packet.PacketType == "ClientInfo" && (origPacket.GetType() == typeof(ClientInfo)))
            {
                ClientInfo newPacket = (ClientInfo)origPacket;
                ClientInfoProcessor.Process(newPacket, peer.Id);
            }
            else if (packet.PacketType == "PlayerPosition" && (origPacket.GetType() == typeof(PlayerPosition)))
            {
                PlayerPositionProcessor.Process(packet, peer);
            }
        }
Beispiel #20
0
        /// <summary>
        /// Clients wnats to change their secondary password.
        /// </summary>
        /// <param name="packet"></param>
        void OnChangeSecondaryPassword(PacketReader packet)
        {
            if (!IsAuthenticated)
            {
                return;
            }

            string accountName = packet.ReadUTF16();
            string oldPassword = packet.ReadUTF16Safe();
            string newPassword = packet.ReadUTF16Safe();

            int result = 1;

            if (Account.SecondaryPassword == oldPassword)
            {
                Server.Database.SetSecondaryPassword(Account.Name, newPassword);
                Account.SecondaryPassword = newPassword;

                result = 0;
            }
            Send(PacketGenerator.SecondaryPasswordChanged(result));
        }
Beispiel #21
0
        private void OnMaxPlayersReached(object sender, EventArgs e)
        {
            Console.WriteLine("max players reached");
            PlayerNames   packet2    = new PlayerNames();
            List <string> playerName = new List <string>();

            foreach (Player player in players.PlayersList)
            {
                playerName.Add(player.PlayerName);
            }
            packet2.Generate(playerName);
            ZeroGPacket mainPacket2 = PacketGenerator.Generate("PlayerNames", packet2);

            serverInst.SendToAll(mainPacket2, DeliveryMethod.ReliableOrdered);
            GameLevelInfo packet = new GameLevelInfo();

            packet.Generate(levelname, players.PlayersCount() - 1, 3, isReverse);
            ZeroGPacket fullPacket = PacketGenerator.Generate("LevelInfo", packet);

            serverInst.SendToAll(fullPacket, DeliveryMethod.ReliableOrdered);
            countDownTimer.Stop();
        }
Beispiel #22
0
        /// <summary>
        /// Client attempts to login.
        /// </summary>
        /// <param name="packet"></param>
        void OnLogin(PacketReader packet)
        {
            string accountName = packet.ReadUTF16Safe();
            string password    = packet.ReadUTF8();

            Console.WriteLine(password);

            // Check if this account is already logged in.
            if (Server.Database.IsAccountOnline(accountName))
            {
                Send(PacketGenerator.Login(5, ""));     // Tell client account is already connected to lobby.

                return;
            }

            // Load the account.
            Account = Server.Database.GetAccount(accountName);
            if (Account == null)
            {
                Send(PacketGenerator.Login(1, ""));     // Tell client there is no account with the given name.

                return;
            }
            Server.Database.AssignAccountToSession(Key, Account.Name);

            // Get the keybindings associated with this account.
            string keybindings = Server.Database.GetKeybindings(accountName);

            // Send all the required data to the client to complete the login.
            Send(PacketGenerator.Login(0, accountName));
            if (keybindings != null)
            {
                Send(PacketGenerator.Keybindings(keybindings));
            }
            Send(PacketGenerator.CharacterLicenses(Account.MaxCharacters, Account.CharacterLicenses));
            Send(PacketGenerator.CharacterList(Account.Characters));
            Send(PacketGenerator.SecondaryPassword(Account.SecondaryPassword != null, 0, false));
        }
Beispiel #23
0
        /// <summary>
        /// Client wants to select a character and go to the square list.
        /// </summary>
        /// <param name="packet"></param>
        void OnSelectCharacter(PacketReader packet)
        {
            if (!IsAuthenticated)
            {
                return;
            }

            string characterName = packet.ReadUTF16();

            foreach (var character in Account.Characters)
            {
                if (character.Name == characterName)
                {
                    Character = character;

                    Server.Database.AssignCharacterToSession(Key, characterName);

                    Send(PacketGenerator.CharacterSelect(0, characterName));
                    return;
                }
            }
            Send(PacketGenerator.CharacterSelect(1, characterName));
        }
Beispiel #24
0
        /// <summary>
        /// Client attempts to delete a character.
        /// </summary>
        /// <param name="packet"></param>
        void OnDeleteCharacter(PacketReader packet)
        {
            if (!IsAuthenticated)
            {
                return;
            }

            // Attempt to the delete the character.
            string characterName = packet.ReadUTF16();

            foreach (var character in Account.Characters)
            {
                if (character.Name == characterName)
                {
                    Server.Database.DeleteCharacter(characterName);

                    Send(PacketGenerator.CharacterDelete(0, characterName));

                    return;
                }
            }
            Send(PacketGenerator.CharacterDelete(1, characterName));
        }
Beispiel #25
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            while (IsRunning)
            {
                if (!IsConnected)
                {
                    client = new TcpClient();
                    client.ReceiveTimeout = 10000;
                    client.SendTimeout    = 10000;

                    try
                    {
                        client.Connect("localhost", mc.Config.ExternalPort);
                        IsConnected = true;
                    }
                    catch (Exception ex)
                    {
                        if (ClientException != null)
                        {
                            ClientException(this, new ClientExceptionEventArgs(ex));
                            Disconnect();
                            break;
                        }
                    }
                }
                else
                {
                    try
                    {
                        Receive();
                        if (ticker >= tickerMax)
                        {
                            PacketGenerator gen = new PacketGenerator();
                            gen.Add(PacketBytes._0x00_KeepAlive_0x00);
                            client.Client.Send(gen.ToByteArray());

                            if (moveAndLookReceived && !teleported)
                            {
                                teleported = true;
                                if (teleportTo != null)
                                {
                                    CommandTo cmd = new CommandTo(mc);
                                    cmd.TriggerPlayer = Name;
                                    cmd.Execute(teleportTo, "", "", "");
                                }
                            }

                            ticker = 0;
                        }
                        ticker++;
                        if (tickerMovement >= tickerMovementMax)
                        {
                            Move(0);

                            tickerMovement = 0;
                        }
                        tickerMovement++;
                    }
                    catch (Exception ex)
                    {
                        if (ClientException != null)
                        {
                            ClientException(this, new ClientExceptionEventArgs(ex));
                        }
                        try
                        {
                            Disconnect();
                            break;
                        }
                        catch (Exception ex2)
                        {
                            if (ClientException != null)
                            {
                                ClientException(this, new ClientExceptionEventArgs(ex2));
                            }
                        }
                    }
                }
                if (worker.CancellationPending)
                {
                    Disconnect();
                    break;
                }
                Thread.Sleep(1);
            }
            IsConnected = false;
        }
Beispiel #26
0
        private void Receive()
        {
            if (!handShakeSendToServer)
            {
                PacketGenerator gen = new PacketGenerator();
                gen.Add((byte)PacketBytes._0x02_Handshake_0x02);
                gen.Add(Name);
                client.Client.Send(gen.ToByteArray());
                handShakeSendToServer = true;
            }

            extBuffer = ReceiveBytes(client.Client, 1);

            PacketBytes firstByte = (PacketBytes)extBuffer[0];
            PacketSizes size      = MinecraftEnums.GetPacketSize(firstByte);

            if (size != PacketSizes.Minus_1)
            {
                if (firstByte == PacketBytes._0x0D_PlayerMoveAndLook_0x0D)
                {
                    size = PacketSizes.Minus_1;
                }
                if (firstByte == PacketBytes._0x03_Chat_0x03)
                {
                    size = PacketSizes.Minus_1;
                }

                if (size != PacketSizes.Minus_1)
                {
                    ReceiveBytes((int)size);
                }
            }

            if (size == PacketSizes.Minus_1)
            {
                switch (firstByte)
                {
                case PacketBytes.Minues_1:
                    break;

                case PacketBytes._0x00_KeepAlive_0x00:
                    break;

                case PacketBytes._0x01_Login_0x01:
                    if (!loginRequestReceived)
                    {
                        LoginRequest();
                    }
                    break;

                case PacketBytes._0x02_Handshake_0x02:
                    if (!handShakeReceived)
                    {
                        Handshake();
                    }
                    break;

                case PacketBytes._0x03_Chat_0x03:
                    String chat = ReceiveString(client.Client);
                    AddOutput("Chat: " + chat);
                    break;

                case PacketBytes._0x04_UpdateTime_0x04:
                    ReceiveInt64();
                    break;

                case PacketBytes._0x05_EntityEquipment_01_0x05:
                    ReceiveInt32();
                    ReceiveInt16();
                    ReceiveInt16();
                    ReceiveInt16();
                    break;

                case PacketBytes._0x06_SpawnPosition_02_0x06:
                    ReceiveInt32();
                    ReceiveInt32();
                    ReceiveInt32();
                    break;

                case PacketBytes._0x07_Use_Entity_0x07:
                    ReceiveInt32();
                    ReceiveInt32();
                    ReceiveBoolean();
                    break;

                case PacketBytes._0x08_Health_0x08:
                    short health = ReceiveInt16();
                    if (health <= 0)
                    {
                        PacketGenerator gen = new PacketGenerator();
                        gen.Add(PacketBytes._0x08_Health_0x08);
                        client.Client.Send(gen.ToByteArray());
                    }
                    break;

                case PacketBytes._0x09_Respawn_0x09:
                    break;

                case PacketBytes._0x0A_Player_0x0A:
                    break;

                case PacketBytes._0x0B_PlayerPosition_0x0B:
                    break;

                case PacketBytes._0x0C_PlayerLook_0x0C:

                    break;

                case PacketBytes._0x0D_PlayerMoveAndLook_0x0D:
                    position.X          = Util.AtoD(ReceiveBytes(8), 0);
                    position.Y          = Util.AtoD(ReceiveBytes(8), 0);
                    position.Stance     = Util.AtoD(ReceiveBytes(8), 0);
                    position.Z          = Util.AtoD(ReceiveBytes(8), 0);
                    position.Rotation   = Util.AtoF(ReceiveBytes(4), 0);
                    position.Pitch      = Util.AtoF(ReceiveBytes(4), 0);
                    position.Unkown     = ByteArythmetic.GetBoolean(ReceiveBytes(1), 0);
                    moveAndLookReceived = true;
                    Move(0);
                    break;

                case PacketBytes._0x0E_BlockDig_0x0E:
                    break;

                case PacketBytes._0x0F_PlaceBlock_0x0F:
                    break;

                case PacketBytes._0x10_BlockItemSwitch_0x10:
                    ReceiveBytes(2);
                    break;

                case PacketBytes._0x11_UseBed_0x11:
                    ReceiveInt32();
                    ReceiveByte();
                    ReceiveInt32();
                    ReceiveByte();
                    ReceiveInt32();
                    break;

                case PacketBytes._0x12_ArmAnimation_0x12:
                    ReceiveInt32();
                    ReceiveByte();
                    break;

                case PacketBytes._0x13_NewPacket_0x13:
                    ReceiveBytes(5);
                    break;

                case PacketBytes._0x14_EntitySpawnName_0x14:
                    ReceiveInt32();
                    ReceiveString(client.Client);
                    ReceiveInt32();
                    ReceiveInt32();
                    ReceiveInt32();
                    ReceiveByte();
                    ReceiveByte();
                    ReceiveInt16();
                    break;

                case PacketBytes._0x15_EntitySpawn_0x15:
                    ReceiveInt32();
                    ReceiveInt16();
                    ReceiveByte();
                    ReceiveInt16();
                    ReceiveInt32();
                    ReceiveInt32();
                    ReceiveInt32();
                    ReceiveByte();
                    ReceiveByte();
                    ReceiveByte();
                    break;

                case PacketBytes._0x16_CollectItem_0x16:
                    ReceiveInt32();
                    ReceiveInt32();
                    break;

                case PacketBytes._0x17_AddObject_0x17:
                    ReceiveBytes(client.Client, 17);
                    if (Util.AtoI(ReceiveBytes(client.Client, 4), 0) > 0)
                    {
                        ReceiveBytes(client.Client, 6);
                    }
                    break;

                case PacketBytes._0x18_MobSpawn_0x18:
                    ReceiveInt32();
                    ReceiveByte();
                    ReceiveInt32();
                    ReceiveInt32();
                    ReceiveInt32();
                    ReceiveByte();
                    ReceiveByte();
                    HandleInsanity(client.Client);
                    break;

                case PacketBytes._0x1B_NewPacket:
                    ReceiveFloat();
                    ReceiveFloat();
                    ReceiveFloat();
                    ReceiveFloat();
                    ReceiveBoolean();
                    ReceiveBoolean();
                    break;

                case PacketBytes._0x1C_EntityVelocity_0x1C:
                    ReceiveInt32();
                    ReceiveInt16();
                    ReceiveInt16();
                    ReceiveInt16();
                    break;

                case PacketBytes._0x1D_DestroyEntity_0x1D:
                    ReceiveInt32();
                    break;

                case PacketBytes._0x1E_Entity_0x1E:
                    ReceiveInt32();
                    break;

                case PacketBytes._0x1F_RelativeEntityMove_0x1F:
                    ReceiveInt32();
                    ReceiveByte();
                    ReceiveByte();
                    ReceiveByte();
                    break;

                case PacketBytes._0x19_NewPacket_0x19:
                    ReceiveInt32();
                    ReceiveString(client.Client);
                    ReceiveInt32();
                    ReceiveInt32();
                    ReceiveInt32();
                    ReceiveInt32();
                    break;

                case PacketBytes._0x20_EntityLook_0x20:
                    ReceiveInt32();
                    ReceiveByte();
                    ReceiveByte();
                    break;

                case PacketBytes._0x21_RelativeEntityLookAndMove_0x21:
                    ReceiveInt32();
                    ReceiveByte();
                    ReceiveByte();
                    ReceiveByte();
                    ReceiveByte();
                    ReceiveByte();
                    break;

                case PacketBytes._0x22_EntityTeleport_0x22:
                    ReceiveInt32();
                    ReceiveInt32();
                    ReceiveInt32();
                    ReceiveInt32();
                    ReceiveByte();
                    ReceiveByte();
                    break;

                case PacketBytes._0x26_HitEntity_0x26:
                    ReceiveInt32();
                    ReceiveByte();
                    break;

                case PacketBytes._0x27_AttachEntity_0x27:
                    ReceiveInt32();
                    ReceiveInt32();
                    break;

                case PacketBytes._0x28_NewPacket_0x28:
                    ReceiveInt32();
                    HandleInsanity(client.Client);
                    break;

                case PacketBytes._0x32_ChunkPre_0x32:
                    ReceiveInt32();
                    ReceiveInt32();
                    ReceiveBoolean();
                    break;

                case PacketBytes._0x33_ChunkMap_0x33:
                    ReceiveInt32();
                    ReceiveInt16();
                    ReceiveInt32();
                    ReceiveByte();
                    ReceiveByte();
                    ReceiveByte();
                    int chunkSize = ReceiveInt32();
                    ReceiveBytes(chunkSize);
                    break;

                case PacketBytes._0x34_MultiBlockChange_0x34:
                    this.ReceiveBytes(8);
                    this.ReceiveBytes(ByteArythmetic.GetInt16(this.ReceiveBytes(2), 0) * 4);
                    break;

                case PacketBytes._0x35_BlockChange_0x35:
                    ReceiveBytes(11);
                    break;

                case PacketBytes._0x36_BlockAction_0x36:
                    ReceiveBytes(12);
                    break;

                case PacketBytes._0x3C_Explosion_0x3C:
                    ReceiveBytes(28);     //8 + 8 + 8 + 4
                    ReceiveBytes(ByteArythmetic.GetInt32(ReceiveBytes(4), 0) * 3);
                    break;

                case PacketBytes._0x46_InvalidBed_0x46:
                    ReceiveByte();
                    break;

                case PacketBytes._0x47_Weather_0x47:
                    ReceiveBytes(17);
                    break;

                case PacketBytes._0x64_OpenWindow_0x64:
                    ReceiveBytes(2);
                    ReceiveStringUtf8(client.Client);     // UTF8
                    ReceiveBytes(1);
                    break;

                case PacketBytes._0x65_CloseWindow_0x65:
                    ReceiveBytes(1);
                    break;

                case PacketBytes._0x66_WindowClick_0x66:
                    ReceiveBytes(7);     // Update 1.5 + 1 bool
                    if (Util.AtoN(ReceiveBytes(2), 0) >= 0)
                    {
                        ReceiveBytes(3);
                    }
                    break;

                case PacketBytes._0x67_SetSlot_0x67:
                    ReceiveBytes(3);
                    if (Util.AtoN(ReceiveBytes(2), 0) >= 0)
                    {
                        ReceiveBytes(3);
                    }
                    break;

                case PacketBytes._0x68_WindowItems_0x68:
                    short xmax = Util.AtoN(ReceiveBytes(3), 1);
                    for (short cx = 0; cx < xmax; cx++)
                    {
                        if (Util.AtoN(ReceiveBytes(2), 0) >= 0)
                        {
                            ReceiveBytes(3);
                        }
                    }
                    break;

                case PacketBytes._0x69_UpdateProgressBar_0x69:
                    ReceiveBytes(5);
                    break;

                case PacketBytes._0x6A_Transaction_0x6A:
                    ReceiveBytes(4);
                    break;

                case PacketBytes._0x82_UpdateSign_0x82:
                    ReceiveBytes(10);
                    ReceiveString(client.Client);
                    ReceiveString(client.Client);
                    ReceiveString(client.Client);
                    ReceiveString(client.Client);
                    break;

                case PacketBytes._0x83_MapData_0x83:
                {
                    ReceiveBytes(client.Client, 4);
                    ReceiveBytes(client.Client, Util.AtoI(ReceiveBytes(client.Client, 1), 0));
                }
                break;

                case PacketBytes._0xC8_IncrementStatistics_0xC8:
                    ReceiveBytes(5);
                    break;

                case PacketBytes._0xFF_Disconnect_0xFF:
                    String str = ReceiveString(client.Client);
                    AddOutput("NPC Disconnected: " + str);
                    break;

                default:
                    break;
                }
            }
        }
Beispiel #27
0
    public void SendPacketToServer(ServerGameObject change)
    {
        var buffer = PacketGenerator.CreateCommandPacket(tick, change);

        endpoint.SendMessage(buffer, buffer.Length, QosType.Reliable);
    }
Beispiel #28
0
 /// <summary>
 /// Client is requesting the list of squares.
 /// </summary>
 /// <param name="packet"></param>
 void OnGetSquareList(PacketReader packet)
 {
     //Send( PacketGenerator.AchievementServer() );
     //Send( PacketGenerator.FriendsInfo() );
     Send(PacketGenerator.SquareList(Server.Database.GetSquareList()));
 }