Exemplo n.º 1
0
        public static void AddEntry(TNLConnection session, Packet packet, SocialType type)
        {
            packet.ReadPadding(4);
            var coid = packet.ReadLong();
            /*var name = */packet.ReadUtf8StringOn(17);
            packet.ReadPadding(7);

            DataAccess.Social.AddEntry(session.CurrentCharacter.GetCOID(), coid, type);
        }
Exemplo n.º 2
0
        public static void HandleChat(TNLConnection conn, Packet packet)
        {
            var type = (ChatType) packet.ReadUInteger();
            var isGm = packet.ReadBoolean();
            var recipient = packet.ReadUtf8StringOn(17);
            var sender = packet.ReadUtf8StringOn(17);
            packet.ReadPadding(1);
            var msglen = packet.ReadUShort();

            var msg = packet.ReadUtf8StringOn(msglen);
            if (msg.StartsWith("/"))
            {
                if (msg.Equals("/save"))
                    conn.CurrentCharacter.SaveToDB();

                return;
            }

            var pack = ConstructChatPacket(type, isGm, recipient, sender, msg);

            switch (type)
            {
                default:
                    Logger.WriteLog("Unhandled ChatType in HandleChat: {0}", LogType.Error, type);
                    break;
            }
        }
Exemplo n.º 3
0
        public static void HandleBroadcast(TNLConnection conn, Packet packet)
        {
            var type = (ChatType) packet.ReadUInteger();
            var sendercoid = packet.ReadLong();
            var isGm = packet.ReadBoolean();

            packet.ReadPadding(1);

            var msglen = packet.ReadUShort();
            var sender = packet.ReadUtf8StringOn(17);

            var msg = packet.ReadUtf8StringOn(msglen);
            if (msg.StartsWith("/"))
            {
                if (msg.Equals("/save"))
                    conn.CurrentCharacter.SaveToDB();

                return;
            }

            conn.CurrentCharacter.GetMap().BroadcastChat(type, ConstructBroadcastPacket(type, isGm, sender, sendercoid, msg), conn.CurrentCharacter);
        }
Exemplo n.º 4
0
 public static CreateCharacterModel Read(Packet packet)
 {
     return new CreateCharacterModel
     {
         CBid = packet.ReadInteger(),
         AccountName = packet.ReadUtf8StringOn(33),
         CharacterName = packet.ReadUtf8StringOn(51),
         Head = packet.ReadInteger(),
         Body = packet.ReadInteger(),
         HeadDetail = packet.ReadInteger(),
         HeadDetail2 = packet.ReadInteger(),
         Helmet = packet.ReadInteger(),
         Eyes = packet.ReadInteger(),
         Mouth = packet.ReadInteger(),
         Hair = packet.ReadInteger(),
         PrimaryColor = packet.ReadUInteger(),
         SecondaryColor = packet.ReadUInteger(),
         EyeColor = packet.ReadUInteger(),
         HairColor = packet.ReadUInteger(),
         SkinColor = packet.ReadUInteger(),
         SpecialColor = packet.ReadUInteger(),
         ShardId = packet.ReadUInteger(),
         VehiclePrimaryColor = packet.ReadUInteger(),
         VehicleSecondaryColor = packet.ReadUInteger(),
         VehicleTrim = packet.ReadByte(),
         ScaleOffset = packet.ReadPadding(3).ReadSingle(),
         CBidWheelset = packet.ReadInteger(),
         VehicleName = packet.ReadUtf8StringOn(33),
     };
 }
Exemplo n.º 5
0
        public override void HandleMove(Packet packet)
        {
            base.HandleMove(packet);

            Acceleration = packet.ReadSingle();
            Steering = packet.ReadSingle();
            TurretDirection = packet.ReadSingle();

            var vehFlags = packet.ReadUInteger();
            var firing = packet.ReadBoolean();

            var target = packet.ReadPadding(2).ReadTFID();

            var targetObj = GetMap().GetObject(target);

            if (targetObj != null)
                SetTargetObject(targetObj);
        }
Exemplo n.º 6
0
        private void HandlePacket(ByteBuffer buffer)
        {
            var packet = new Packet(buffer.GetBuffer());

            Logger.WriteLog("Incoming Packet: {0}", LogType.Network, packet.Opcode);
            try
            {
                switch (packet.Opcode)
                {
                    // Global
                    case Opcode.LoginRequest:
                        HandleLoginRequest(packet);
                        break;

                    case Opcode.LoginNewCharacter:
                        HandleLoginNewCharacter(packet);
                        break;

                    case Opcode.LoginDeleteCharacter:
                        HandleLoginDeleteCharacter(packet);
                        break;

                    case Opcode.News:
                        HandleNews(packet);
                        break;

                    case Opcode.Login:
                        HandleGlobalLogin(packet);
                        break;

                    case Opcode.Disconnect:
                        HandleDisconnect(packet);
                        break;

                    case Opcode.Chat:
                        ChatManager.HandleChat(this, packet);
                        break;

                    case Opcode.GetFriends:
                        SocialManager.GetFriends(this);
                        break;

                    case Opcode.GetEnemies:
                        SocialManager.GetEnemies(this);
                        break;

                    case Opcode.GetIgnored:
                        SocialManager.GetIgnored(this);
                        break;

                    case Opcode.AddFriend:
                        SocialManager.AddEntry(this, packet, SocialType.Friend);
                        break;

                    case Opcode.AddEnemy:
                        SocialManager.AddEntry(this, packet, SocialType.Enemy);
                        break;

                    case Opcode.AddIgnore:
                        SocialManager.AddEntry(this, packet, SocialType.Ignore);
                        break;

                    case Opcode.RemoveFriend:
                        SocialManager.RemoveEntry(this, packet.ReadPadding(4).ReadLong(), SocialType.Friend);
                        break;

                    case Opcode.RemoveEnemy:
                        SocialManager.RemoveEntry(this, packet.ReadPadding(4).ReadLong(), SocialType.Enemy);
                        break;

                    case Opcode.RemoveIgnore:
                        SocialManager.RemoveEntry(this, packet.ReadPadding(4).ReadLong(), SocialType.Ignore);
                        break;

                    case Opcode.RequestClanInfo:
                        ClanManager.RequestInfo(this);
                        break;

                    case Opcode.ConvoyMissionsRequest:
                        ConvoyManager.MissionsRequest(this);
                        break;

                    // Sector
                    case Opcode.TransferFromGlobal:
                        HandleTransferFromGlobal(packet);
                        break;

                    case Opcode.TransferFromGlobalStage2:
                        HandleTransferFromGlobalStage2(packet);
                        break;

                    case Opcode.TransferFromGlobalStage3:
                        HandleTransferFromGlobalStage3(packet);
                        break;

                    case Opcode.UpdateFirstTimeFlagsRequest:
                        HandleUpdateFirstTimeFlagsRequest(packet);
                        break;

                    case Opcode.Broadcast:
                        ChatManager.HandleBroadcast(this, packet);
                        break;

                    default:
                        Logger.WriteLog("Unhandled Opcode: {0}", LogType.Error, packet.Opcode);
                        break;
                }
            }
            catch (Exception e)
            {
                Logger.WriteLog("Caught exception while handling packets!", LogType.Error);
                Logger.WriteLog("Exception: {0}", LogType.Error, e);
            }
        }
Exemplo n.º 7
0
        public virtual void HandleMove(Packet packet)
        {
            var fidObject = packet.ReadPadding(4).ReadTFID();
            Debug.Assert(fidObject == GetTFID(), "A TFID nem egyezik?");

            Position = new Vector3(packet.ReadSingle(), packet.ReadSingle(), packet.ReadSingle());
            Velocity = new Vector3(packet.ReadSingle(), packet.ReadSingle(), packet.ReadSingle());
            Rotation = new Vector4(packet.ReadSingle(), packet.ReadSingle(), packet.ReadSingle(), packet.ReadSingle());
            AngularVelocity = new Vector3(packet.ReadSingle(), packet.ReadSingle(), packet.ReadSingle());

            Console.WriteLine("Pos: {0} | {1} | {2} ", Position.X, Position.Y, Position.Z);
            Console.WriteLine("Rot: {0} | {1} | {2} | {3}", Rotation.X, Rotation.Y, Rotation.Z, Rotation.W);

            var absolute = packet.ReadBoolean();
            var tarLoc = new Vector3(packet.ReadPadding(3).ReadSingle(), packet.ReadSingle(), packet.ReadSingle());

            packet.ReadPadding(4);

            //if (GhostObject != null)
            //GhostObject.SetMaskBits(2UL);
        }