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;
            }
        }
Beispiel #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;
            }
        }
 public CityServerClient(Socket ClientSocket, CityServerListener Server)
     : base(ClientSocket, Server)
 {
     m_PulseTimer = new Timer(1500);
     m_PulseTimer.AutoReset = true;
     m_PulseTimer.Elapsed += new ElapsedEventHandler(m_PulseTimer_Elapsed);
     m_PulseTimer.Start();
 }
        public CityServerClient(Socket ClientSocket, CityServerListener Server)
        {
            m_Socket = ClientSocket;
            m_Listener = Server;

            m_Socket.BeginReceive(m_RecvBuffer, 0, m_RecvBuffer.Length, SocketFlags.None,
                new AsyncCallback(OnReceivedData), m_Socket);
        }
 public CityServerClient(Socket ClientSocket, CityServerListener Server) :
     base(ClientSocket, Server)
 {
     m_PulseTimer           = new Timer(1500);
     m_PulseTimer.AutoReset = true;
     m_PulseTimer.Elapsed  += new ElapsedEventHandler(m_PulseTimer_Elapsed);
     m_PulseTimer.Start();
 }
        /// <summary>
        /// Creates a character in the DB.
        /// </summary>
        /// <param name="Character">The character that was created by a client.</param>
        /// <param name="CServerListener">A CityServerListener instance, that can be used to
        ///                               retrieve info about cityservers when sending a reply to the client.</param>
        public static void CreateCharacter(LoginClient Client, Sim Character, ref CityServerListener CServerListener)
        {
            SqlCommand Command = new SqlCommand("INSERT INTO Characters(LastCached, Name, Sex) VALUES('" +
                                                Character.Timestamp + "', '" + Character.Name + "', '" + Character.Sex + "')");

            Command.BeginExecuteNonQuery(new AsyncCallback(EndCreateCharacter), new DatabaseAsyncObject(Client, Command,
                                                                                                        ref CServerListener));
        }
        public CityServerClient(Socket ClientSocket, CityServerListener Server)
        {
            m_Socket = ClientSocket;
            m_Listener = Server;

            m_PulseTimer = new Timer(1500);
            m_PulseTimer.AutoReset = true;
            m_PulseTimer.Elapsed += new ElapsedEventHandler(m_PulseTimer_Elapsed);
            m_PulseTimer.Start();

            m_Socket.BeginReceive(m_RecvBuffer, 0, m_RecvBuffer.Length, SocketFlags.None,
                new AsyncCallback(OnReceivedData), m_Socket);
        }
Beispiel #8
0
        public CityServerClient(Socket ClientSocket, CityServerListener Server)
        {
            m_Socket   = ClientSocket;
            m_Listener = Server;

            m_PulseTimer           = new Timer(1500);
            m_PulseTimer.AutoReset = true;
            m_PulseTimer.Elapsed  += new ElapsedEventHandler(m_PulseTimer_Elapsed);
            m_PulseTimer.Start();

            m_Socket.BeginReceive(m_RecvBuffer, 0, m_RecvBuffer.Length, SocketFlags.None,
                                  new AsyncCallback(OnReceivedData), m_Socket);
        }
Beispiel #9
0
        public Form1()
        {
            InitializeComponent();

            try
            {
                Database.Connect();
            }
            catch (NoDBConnection NoDB)
            {
                MessageBox.Show(NoDB.Message);
                Environment.Exit(0);
            }

            Logger.Initialize("Log.txt");
            Logger.InfoEnabled = true;

            m_Listener = new LoginListener();
            m_Listener.OnReceiveEvent += new OnReceiveDelegate(m_Listener_OnReceiveEvent);

            //LoginRequest - Variable size.
            LoginClient.RegisterLoginPacketID(0x00, 0);
            //CharacterInfoRequest - Variable size.
            LoginClient.RegisterLoginPacketID(0x05, 0);
            //CharacterCreate - Variable size.
            LoginClient.RegisterLoginPacketID(0x06, 0);

            m_Listener.Initialize(2106);

            m_CServerListener = new CityServerListener();
            m_CServerListener.OnReceiveEvent += new OnCityReceiveDelegate(m_CServerListener_OnReceiveEvent);

            //CityServerLogin - Variable size.
            CityServerClient.RegisterPatchPacketID(0x00, 0);

            m_CServerListener.Initialize(2348);
        }
Beispiel #10
0
 /// <summary>
 /// Creates a character in the DB.
 /// </summary>
 /// <param name="Character">The character that was created by a client.</param>
 /// <param name="CServerListener">A CityServerListener instance, that can be used to 
 ///                               retrieve info about cityservers when sending a reply to the client.</param>
 public static void CreateCharacter(LoginClient Client, Sim Character, ref CityServerListener CServerListener)
 {
     SqlCommand Command = new SqlCommand("INSERT INTO Characters(LastCached, Name, Sex) VALUES('" +
         Character.Timestamp + "', '" + Character.Name + "', '" + Character.Sex  + "')");
     Command.BeginExecuteNonQuery(new AsyncCallback(EndCreateCharacter), new DatabaseAsyncObject(Client, Command,
         ref CServerListener));
 }
 /// <summary>
 /// Constructs a DBAsyncObject instance.
 /// </summary>
 /// <param name="Client">The client.</param>
 /// <param name="Command">The SQL command.</param>
 /// <param name="CSListener">A CityServerListener that holds information about connected CityServers.
 ///                          Must be passed by reference in order to ensure that any servers that might
 ///                          connect before a reply is sent to the client will be written into the reply.</param>
 public DatabaseAsyncObject(LoginClient Client, MySqlCommand Command, ref CityServerListener CSListener)
 {
     m_Client = Client;
     m_MySqlCmd = Command;
     m_CServerListener = CSListener;
 }
Beispiel #12
0
 /// <summary>
 /// Constructs a DBAsyncObject instance.
 /// </summary>
 /// <param name="Client">The client.</param>
 /// <param name="Command">The SQL command.</param>
 /// <param name="CSListener">A CityServerListener that holds information about connected CityServers.
 ///                          Must be passed by reference in order to ensure that any servers that might
 ///                          connect before a reply is sent to the client will be written into the reply.</param>
 public DatabaseAsyncObject(LoginClient Client, MySqlCommand Command, ref CityServerListener CSListener)
 {
     m_Client          = Client;
     m_MySqlCmd        = Command;
     m_CServerListener = CSListener;
 }