コード例 #1
0
        public static void HandleCharacterCreate(PacketStream P, ref LoginClient Client,
                                                 ref CityServerListener CServerListener)
        {
            byte PacketLength = (byte)P.ReadByte();
            //Length of the unencrypted data, excluding the header (ID, length, unencrypted length).
            byte UnencryptedLength = (byte)P.ReadByte();

            P.DecryptPacket(Client.EncKey, Client.CryptoService, UnencryptedLength);

            Logger.LogDebug("Received CharacterCreate!");

            string AccountName = P.ReadString();

            Sim Char = new Sim(P.ReadString());

            Char.Timestamp          = P.ReadString();
            Char.Name               = P.ReadString();
            Char.Sex                = P.ReadString();
            Char.CreatedThisSession = true;

            Client.CurrentlyActiveSim = Char;

            switch (Character.CreateCharacter(Char))
            {
            case CharacterCreationStatus.NameAlreadyExisted:
                //TODO: Send packet.
                break;

            case CharacterCreationStatus.ExceededCharacterLimit:
                //TODO: Send packet.
                break;
            }
        }
コード例 #2
0
        public static void HandleCharacterCreate(PacketStream P, ref LoginClient Client, 
            ref CityServerListener CServerListener)
        {
            byte PacketLength = (byte)P.ReadByte();
            //Length of the unencrypted data, excluding the header (ID, length, unencrypted length).
            byte UnencryptedLength = (byte)P.ReadByte();

            P.DecryptPacket(Client.EncKey, Client.CryptoService, UnencryptedLength);

            Logger.LogDebug("Received CharacterCreate!");

            string AccountName = P.ReadString();

            Sim Char = new Sim(P.ReadString());
            Char.Timestamp = P.ReadString();
            Char.Name = P.ReadString();
            Char.Sex = P.ReadString();
            Char.CreatedThisSession = true;

            Client.CurrentlyActiveSim = Char;

            switch (Character.CreateCharacter(Char))
            {
                case CharacterCreationStatus.NameAlreadyExisted:
                    //TODO: Send packet.
                    break;
                case CharacterCreationStatus.ExceededCharacterLimit:
                    //TODO: Send packet.
                    break;
            }
        }
コード例 #3
0
        /// <summary>
        /// A cityserver logged in!
        /// </summary>
        public static void HandleCityServerLogin(PacketStream P, ref CityServerClient Client)
        {
            byte PacketLength = (byte)P.ReadByte();

            string Name = P.ReadString();
            string Description = P.ReadString();
            ulong Thumbnail = P.ReadUInt64();
            string IP = P.ReadString();
            int Port = P.ReadInt32();

            CityServerInfo Info = new CityServerInfo(Name, Description, Thumbnail, IP, Port);
            Client.ServerInfo = Info;
        }
コード例 #4
0
        /// <summary>
        /// A cityserver requested a decryptionkey for a client!
        /// </summary>
        public static void HandleKeyFetch(ref LoginListener Listener, PacketStream P, CityServerClient Client)
        {
            string AccountName = P.ReadString();

            byte[] EncKey = new byte[1];

            foreach (LoginClient Cl in Listener.Clients)
            {
                if (Cl.Username == AccountName)
                {
                    EncKey = Cl.EncKey;

                    if (Cl.CurrentlyActiveSim.CreatedThisSession)
                    {
                        //TODO: Update the DB to reflect the city that
                        //      this sim resides in.
                        Database.UpdateCityForCharacter(Cl.CurrentlyActiveSim.Name, Client.ServerInfo.Name);
                    }
                }
            }

            PacketStream OutPacket = new PacketStream(0x01, 0x00);

            OutPacket.WriteByte((byte)0x01);
            OutPacket.WriteByte((byte)(EncKey.Length + 2));
            OutPacket.WriteByte((byte)EncKey.Length);
            OutPacket.Write(EncKey, 0, EncKey.Length);
            Client.Send(OutPacket.ToArray());

            //For now, assume client has already disconnected and doesn't need to be disconnected manually.
            Listener.TransferringClients.Remove(Client);
        }
コード例 #5
0
        /// <summary>
        /// A cityserver requested a decryptionkey for a client!
        /// </summary>
        public static void HandleKeyFetch(ref LoginListener Listener, PacketStream P, CityServerClient Client)
        {
            string AccountName = P.ReadString();

            byte[] EncKey = new byte[1];

            foreach (LoginClient Cl in Listener.Clients)
            {
                if (Cl.Username == AccountName)
                {
                    EncKey = Cl.EncKey;

                    if (Cl.CurrentlyActiveSim.CreatedThisSession)
                    {
                        //TODO: Update the DB to reflect the city that
                        //      this sim resides in.
                        Database.UpdateCityForCharacter(Cl.CurrentlyActiveSim.Name, Client.ServerInfo.Name);
                    }
                }
            }

            PacketStream OutPacket = new PacketStream(0x01, 0x00);
            OutPacket.WriteByte((byte)0x01);
            OutPacket.WriteByte((byte)(EncKey.Length + 2));
            OutPacket.WriteByte((byte)EncKey.Length);
            OutPacket.Write(EncKey, 0, EncKey.Length);
            Client.Send(OutPacket.ToArray());

            //For now, assume client has already disconnected and doesn't need to be disconnected manually.
            Listener.TransferringClients.Remove(Client);
        }
コード例 #6
0
        /// <summary>
        /// A cityserver logged in!
        /// </summary>
        public static void HandleCityServerLogin(PacketStream P, ref CityServerClient Client)
        {
            byte PacketLength = (byte)P.ReadByte();
            Logger.LogDebug("CityServer logged in!");

            string Name = P.ReadString();
            string Description = P.ReadString();
            ulong Thumbnail = P.ReadUInt64();
            Guid GUID = new Guid();
            string UUID = GUID.ToString();
            ulong Map = P.ReadUInt64();
            string IP = P.ReadString();
            int Port = P.ReadInt32();

            CityInfo Info = new CityInfo(Name, Description, Thumbnail, UUID, Map, IP, Port);
            Client.ServerInfo = Info;
        }
コード例 #7
0
        public static void HandleCharacterCreate(ref LoginClient Client, PacketStream P)
        {
            ushort PacketLength = (ushort)P.ReadUShort();
            //Length of the unencrypted data, excluding the header (ID, length, unencrypted length).
            ushort UnencryptedLength = (ushort)P.ReadUShort();

            P.DecryptPacket(Client.EncKey, Client.CryptoService, UnencryptedLength);

            Logger.LogDebug("Received CharacterCreate!");

            string AccountName = P.ReadString();

            //GUID generation should always be done on the server side
            //You cant trust the client side, it may have been hacked
            Sim Char = new Sim(Guid.NewGuid());

            Char.Timestamp          = P.ReadString();
            Char.Name               = P.ReadString();
            Char.Sex                = P.ReadString();
            Char.CreatedThisSession = true;

            Client.CurrentlyActiveSim = Char;

            using (var db = DataAccess.Get())
            {
                var characterModel = new Character();
                characterModel.Name       = Char.Name;
                characterModel.Sex        = Char.Sex;
                characterModel.LastCached = Char.Timestamp;
                characterModel.GUID       = Char.GUID;

                var status = db.Characters.CreateCharacter(characterModel);

                switch (status)
                {
                case CharacterCreationStatus.NameAlreadyExisted:
                    //TODO: Send packet.
                    break;

                case CharacterCreationStatus.ExceededCharacterLimit:
                    //TODO: Send packet.
                    break;
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// A cityserver logged in!
        /// </summary>
        public static void HandleCityServerLogin(PacketStream P, ref CityServerClient Client)
        {
            byte PacketLength = (byte)P.ReadByte();

            Logger.LogDebug("CityServer logged in!");

            string Name        = P.ReadString();
            string Description = P.ReadString();
            ulong  Thumbnail   = P.ReadUInt64();
            Guid   GUID        = new Guid();
            string UUID        = GUID.ToString();
            ulong  Map         = P.ReadUInt64();
            string IP          = P.ReadString();
            int    Port        = P.ReadInt32();

            CityInfo Info = new CityInfo(Name, Description, Thumbnail, UUID, Map, IP, Port);

            Client.ServerInfo = Info;
        }
コード例 #9
0
        public static void HandleCharacterCreate(ref LoginClient Client, PacketStream P)
        {
            ushort PacketLength = (ushort)P.ReadUShort();
            //Length of the unencrypted data, excluding the header (ID, length, unencrypted length).
            ushort UnencryptedLength = (ushort)P.ReadUShort();

            P.DecryptPacket(Client.EncKey, Client.CryptoService, UnencryptedLength);

            Logger.LogDebug("Received CharacterCreate!");

            string AccountName = P.ReadString();

            //GUID generation should always be done on the server side
            //You cant trust the client side, it may have been hacked
            Sim Char = new Sim(Guid.NewGuid());
            Char.Timestamp = P.ReadString();
            Char.Name = P.ReadString();
            Char.Sex = P.ReadString();
            Char.CreatedThisSession = true;

            Client.CurrentlyActiveSim = Char;

            using (var db = DataAccess.Get())
            {
                var characterModel = new Character();
                characterModel.Name = Char.Name;
                characterModel.Sex = Char.Sex;
                characterModel.LastCached = Char.Timestamp;
                characterModel.GUID = Char.GUID;

                var status = db.Characters.CreateCharacter(characterModel);

                switch (status)
                {
                    case CharacterCreationStatus.NameAlreadyExisted:
                        //TODO: Send packet.
                        break;
                    case CharacterCreationStatus.ExceededCharacterLimit:
                        //TODO: Send packet.
                        break;
                }
            }
        }