Esempio n. 1
0
 public static Packet_Client CreateLoginPacket(GamePlatform platform, string username, string verificationKey)
 {
     Packet_ClientIdentification p = new Packet_ClientIdentification();
     {
         p.Username = username;
         p.MdProtocolVersion = platform.GetGameVersion();
         p.VerificationKey = verificationKey;
     }
     Packet_Client pp = new Packet_Client();
     pp.Id = Packet_ClientIdEnum.PlayerIdentification;
     pp.Identification = p;
     return pp;
 }
Esempio n. 2
0
    public static Packet_Client CreateLoginPacket(GamePlatform platform, string username, string verificationKey)
    {
        Packet_ClientIdentification p = new Packet_ClientIdentification();
        {
            p.Username          = username;
            p.MdProtocolVersion = platform.GetGameVersion();
            p.VerificationKey   = verificationKey;
        }
        Packet_Client pp = new Packet_Client();

        pp.Id             = Packet_ClientIdEnum.PlayerIdentification;
        pp.Identification = p;
        return(pp);
    }
Esempio n. 3
0
    void ProcessPacket(int client, Packet_Client packet)
    {
        switch (packet.GetId())
        {
        case Packet_ClientIdEnum.PlayerIdentification:
        {
            if (packet.Identification == null)
            {
                return;
            }
            SendPacket(client, ServerPackets.Identification(0, MapSizeX, MapSizeY, MapSizeZ, platform.GetGameVersion()));
            clients[client].Name = packet.Identification.Username;
        }
        break;

        case Packet_ClientIdEnum.RequestBlob:
        {
            SendPacket(client, ServerPackets.LevelInitialize());
            for (int i = 0; i < blockTypesCount; i++)
            {
                Packet_BlockType blocktype = blockTypes[i];
                if (blocktype == null)
                {
                    blocktype = new Packet_BlockType();
                }
                SendPacket(client, ServerPackets.BlockType(i, blocktype));
            }
            SendPacket(client, ServerPackets.BlockTypes());
            SendPacket(client, ServerPackets.LevelFinalize());
            for (int i = 0; i < clientsCount; i++)
            {
                if (clients[i] == null)
                {
                    continue;
                }
                clients[i].glX = spawnGlX;
                clients[i].glY = spawnGlY;
                clients[i].glZ = spawnGlZ;
                Packet_PositionAndOrientation pos = new Packet_PositionAndOrientation();
                pos.X     = platform.FloatToInt(32 * clients[i].glX);
                pos.Y     = platform.FloatToInt(32 * clients[i].glY);
                pos.Z     = platform.FloatToInt(32 * clients[i].glZ);
                pos.Pitch = 255 / 2;
                //SendPacket(client, ServerPackets.Spawn(i, clients[i].Name, pos));
                Packet_ServerEntity e = new Packet_ServerEntity();
                e.DrawModel             = new Packet_ServerEntityAnimatedModel();
                e.DrawModel.Model_      = "player.txt";
                e.DrawModel.ModelHeight = platform.FloatToInt((one * 17 / 10) * 32);
                e.DrawModel.EyeHeight   = platform.FloatToInt((one * 15 / 10) * 32);
                e.Position = pos;
                SendPacket(client, ServerPackets.EntitySpawn(0, e));
                SendPacket(client, ServerPackets.PlayerStats(100, 100, 100, 100));
            }
            for (int i = 0; i < modsCount; i++)
            {
                mods[i].OnPlayerJoin(client);
            }
            clients[client].connected = true;
        }
        break;

        case Packet_ClientIdEnum.Message:
        {
            SendPacketToAll(ServerPackets.Message(platform.StringFormat2("{0}: &f{1}", clients[client].Name, packet.Message.Message)));
        }
        break;

        case Packet_ClientIdEnum.SetBlock:
        {
            int x     = packet.SetBlock.X;
            int y     = packet.SetBlock.Y;
            int z     = packet.SetBlock.Z;
            int block = packet.SetBlock.BlockType;
            int mode  = packet.SetBlock.Mode;
            if (mode == Packet_BlockSetModeEnum.Create)
            {
            }
            if (mode == Packet_BlockSetModeEnum.Destroy)
            {
                SendPacketToAll(ServerPackets.SetBlock(x, y, z, 0));
            }
            if (mode == Packet_BlockSetModeEnum.Use)
            {
            }
            if (mode == Packet_BlockSetModeEnum.UseWithTool)
            {
            }
        }
        break;

        case Packet_ClientIdEnum.PositionandOrientation:
        {
            clients[client].glX = one * packet.PositionAndOrientation.X / 32;
            clients[client].glY = one * packet.PositionAndOrientation.Y / 32;
            clients[client].glZ = one * packet.PositionAndOrientation.Z / 32;
        }
        break;

        case Packet_ClientIdEnum.InventoryAction:
        {
            switch (packet.InventoryAction.Action)
            {
            case Packet_InventoryActionTypeEnum.Click:
                break;
            }
        }
        break;
        }
    }