示例#1
0
        public bool handlePacket <T>(Kaminari.PacketReader packet, T client, ushort blockId) where T : Kaminari.IBaseClient
        {
            switch (packet.getOpcode())
            {
            case (ushort)Opcodes.opcodeMove:
                return(handleMove(this, packet, (IClient)client, blockId));

            case (ushort)Opcodes.opcodeHandshake:
                return(handleHandshake(this, packet, (IClient)client, blockId));

            case (ushort)Opcodes.opcodeLoginCharacter:
                return(handleLoginCharacter(this, packet, (IClient)client, blockId));

            case (ushort)Opcodes.opcodeLogin:
                return(handleLogin(this, packet, (IClient)client, blockId));

            case (ushort)Opcodes.opcodeCreateCharacter:
                return(handleCreateCharacter(this, packet, (IClient)client, blockId));

            case (ushort)Opcodes.opcodeClientUpdate:
                return(handleClientUpdate(this, packet, (IClient)client, blockId));

            default:
                return(false);
            }
        }
示例#2
0
文件: LoginData.cs 项目: AErbis/Kumo
 public bool unpack(Kaminari.IMarshal marshal, Kaminari.PacketReader packet)
 {
     if (packet.bytesRead() + marshal.size <byte>() > packet.bufferSize())
     {
         return(false);
     }
     if (packet.bytesRead() + marshal.size <byte>() + packet.getData().peekByte() > packet.bufferSize())
     {
         return(false);
     }
     this.username = packet.getData().readString();
     if (packet.bytesRead() + marshal.size <ulong>() > packet.bufferSize())
     {
         return(false);
     }
     this.password0 = packet.getData().readUlong();
     if (packet.bytesRead() + marshal.size <ulong>() > packet.bufferSize())
     {
         return(false);
     }
     this.password1 = packet.getData().readUlong();
     if (packet.bytesRead() + marshal.size <ulong>() > packet.bufferSize())
     {
         return(false);
     }
     this.password2 = packet.getData().readUlong();
     if (packet.bytesRead() + marshal.size <ulong>() > packet.bufferSize())
     {
         return(false);
     }
     this.password3 = packet.getData().readUlong();
     return(true);
 }
示例#3
0
 public bool unpack(Kaminari.IMarshal marshal, Kaminari.PacketReader packet)
 {
     if (packet.bytesRead() + this.size(marshal) > packet.bufferSize())
     {
         return(false);
     }
     return(true);
 }
示例#4
0
文件: Status.cs 项目: AErbis/Kumo
 public bool unpack(Kaminari.IMarshal marshal, Kaminari.PacketReader packet)
 {
     if (packet.bytesRead() + this.size(marshal) > packet.bufferSize())
     {
         return(false);
     }
     this.success = packet.getData().readBool();
     return(true);
 }
示例#5
0
文件: Complex.cs 项目: AErbis/Kumo
        public bool unpack(Kaminari.IMarshal marshal, Kaminari.PacketReader packet)
        {
            if (packet.bytesRead() + sizeof(byte) > packet.bufferSize())
            {
                return(false);
            }
            this.x = new Kaminari.Optional <uint>();
            if (packet.getData().readByte() == 1)
            {
                if (packet.bytesRead() + marshal.size <uint>() > packet.bufferSize())
                {
                    return(false);
                }
                this.x.setValue(packet.getData().readUint());
            }
            int size_y = packet.getData().readByte();

            this.y = new List <SpawnData>();
            for (int i = 0; i < size_y; ++i)
            {
                SpawnData data = new SpawnData();
                if (data.unpack(marshal, packet))
                {
                    this.y.Add(data);
                }
                else
                {
                    return(false);
                }
            }
            if (packet.bytesRead() + marshal.size <int>() > packet.bufferSize())
            {
                return(false);
            }
            this.z = packet.getData().readInt();
            if (packet.bytesRead() + sizeof(byte) > packet.bufferSize())
            {
                return(false);
            }
            this.w = new Kaminari.Optional <List <bool> >();
            if (packet.getData().readByte() == 1)
            {
                int size_w = packet.getData().readByte();
                if (packet.bytesRead() + size_w * marshal.size <bool>() > packet.bufferSize())
                {
                    return(false);
                }
                this.w.setValue(new List <bool>());
                for (int i = 0; i < size_w; ++i)
                {
                    this.w.getValue().Add(packet.getData().readBool());
                }
            }
            return(true);
        }
示例#6
0
 public bool unpack(Kaminari.IMarshal marshal, Kaminari.PacketReader packet)
 {
     if (packet.bytesRead() + this.size(marshal) > packet.bufferSize())
     {
         return(false);
     }
     this.id = packet.getData().readUlong();
     this.x  = packet.getData().readFloat();
     this.z  = packet.getData().readFloat();
     return(true);
 }
示例#7
0
 public bool unpack(Kaminari.IMarshal marshal, Kaminari.PacketReader packet)
 {
     if (packet.bytesRead() + this.size(marshal) > packet.bufferSize())
     {
         return(false);
     }
     this.x     = packet.getData().readFloat();
     this.z     = packet.getData().readFloat();
     this.speed = packet.getData().readFloat();
     this.vx    = packet.getData().readFloat();
     this.vz    = packet.getData().readFloat();
     this.seq   = packet.getData().readByte();
     this.frame = packet.getData().readUshort();
     return(true);
 }
示例#8
0
        private bool handleClientUpdate(Kaminari.IMarshal marshal, Kaminari.PacketReader packet, IClient client, ushort blockId)
        {
            if (Overflow.leq(blockId, clientUpdateLastCalled))
            {
                // TODO: Returning true here means the packet is understood as correctly parsed, while we are ignoring it
                return(true);
            }
            var data = emplaceData(clientUpdate, blockId, packet.timestamp());

            if (!data.unpack(marshal, packet))
            {
                return(false);
            }
            // The user is assumed to provide all peek methods in C#
            // TODO: Test if the method exists in the class
            return(client.peekClientUpdate(data, packet.timestamp()));
        }
示例#9
0
文件: Character.cs 项目: AErbis/Kumo
 public bool unpack(Kaminari.IMarshal marshal, Kaminari.PacketReader packet)
 {
     if (packet.bytesRead() + marshal.size <byte>() > packet.bufferSize())
     {
         return(false);
     }
     if (packet.bytesRead() + marshal.size <byte>() + packet.getData().peekByte() > packet.bufferSize())
     {
         return(false);
     }
     this.name = packet.getData().readString();
     if (packet.bytesRead() + marshal.size <ushort>() > packet.bufferSize())
     {
         return(false);
     }
     this.level = packet.getData().readUshort();
     return(true);
 }
示例#10
0
        public bool unpack(Kaminari.IMarshal marshal, Kaminari.PacketReader packet)
        {
            int size_data = packet.getData().readByte();

            this.data = new List <EntityUpdate>();
            for (int i = 0; i < size_data; ++i)
            {
                EntityUpdate data = new EntityUpdate();
                if (data.unpack(marshal, packet))
                {
                    this.data.Add(data);
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
示例#11
0
        private bool handleLoginCharacter(Kaminari.IMarshal marshal, Kaminari.PacketReader packet, IClient client, ushort blockId)
        {
            if (!client.check(client, "status", ingame_status::login_done))
            {
                return(client.handleClientError(client, packet.getOpcode()));
            }
            if (Overflow.leq(blockId, loginCharacterLastCalled))
            {
                // TODO: Returning true here means the packet is understood as correctly parsed, while we are ignoring it
                return(true);
            }
            var data = emplaceData(loginCharacter, blockId, packet.timestamp());

            if (!data.unpack(marshal, packet))
            {
                return(false);
            }
            // The user is assumed to provide all peek methods in C#
            // TODO: Test if the method exists in the class
            return(client.peekLoginCharacter(data, packet.timestamp()));
        }