Beispiel #1
0
        private void OnReceivedPacket(object sender, PacketEventArgs e)
        {
            int    nBytesUsed = 0;
            ushort nRecvType  = 0;

            while (nBytesUsed < e.Length)
            {
                nRecvType   = BitConverter.ToUInt16(e.Data, nBytesUsed);
                nBytesUsed += 2;
                switch (nRecvType)
                {
                case Protocols.T_PC_CONNECT_GET_SERVER_GROUP_LIST_OK:
                {
                    MSG_PC_CONNECT_GET_SERVER_GROUP_LIST_OK Info = Operations.ByteArrayToStruct <MSG_PC_CONNECT_GET_SERVER_GROUP_LIST_OK>(e.Data, ref nBytesUsed);

                    if (Info.NumOfServerGroup == 0)
                    {
                        MessageBox.Show("Gameserver is offline!\nPlease check [http://ace.gaming-paradise.net] for further information!");
                        Exit();
                    }

                    if (Info.ServerGroup.Crowdedness <= 0)
                    {
                        UpdateProgress(0, "Gameserver offline", false);

                        System.Threading.Thread.Sleep(5000);

                        m_Sock.SendPacket(Protocols.T_PC_CONNECT_GET_SERVER_GROUP_LIST);

                        continue;
                    }

                    m_ServerGroup = Info.ServerGroup;

                    MSG_PC_CONNECT_SINGLE_FILE_VERSION_CHECK Msg = new MSG_PC_CONNECT_SINGLE_FILE_VERSION_CHECK();
                    Msg.DeleteFileListVersion = new ushort[] { 0, 0, 0, 0 };
                    Msg.NoticeVersion         = new ushort[] { 0, 0, 0, 0 };

                    m_Sock.SendPacket(Protocols.T_PC_CONNECT_SINGLE_FILE_VERSION_CHECK, Msg);
                }
                break;

                case Protocols.T_PC_CONNECT_SINGLE_FILE_UPDATE_INFO:
                {
                    MSG_PC_CONNECT_SINGLE_FILE_UPDATE_INFO Msg = Operations.ByteArrayToStruct <MSG_PC_CONNECT_SINGLE_FILE_UPDATE_INFO>(e.Data, ref nBytesUsed);

                    MSG_PC_CONNECT_VERSION SendMsg = new MSG_PC_CONNECT_VERSION();
                    SendMsg.ClientVersion = new ushort[] { 0, 0, 0, 0 };

                    m_Sock.SendPacket(Protocols.T_PC_CONNECT_VERSION, SendMsg);
                }
                break;

                case Protocols.T_PC_CONNECT_SINGLE_FILE_VERSION_CHECK_OK:
                {
                    MSG_PC_CONNECT_VERSION SendMsg = new MSG_PC_CONNECT_VERSION();
                    SendMsg.ClientVersion = new ushort[] { 0, 0, 0, 0 };

                    m_Sock.SendPacket(Protocols.T_PC_CONNECT_VERSION, SendMsg);
                }
                break;

                case Protocols.T_PC_CONNECT_REINSTALL_CLIENT:
                {
                    MSG_PC_CONNECT_REINSTALL_CLIENT Msg = Operations.ByteArrayToStruct <MSG_PC_CONNECT_REINSTALL_CLIENT>(e.Data, ref nBytesUsed);

                    // Use current version, we don't need the update thingy
                    MSG_PC_CONNECT_VERSION SendMsg = new MSG_PC_CONNECT_VERSION();
                    SendMsg.ClientVersion = Msg.LatestVersion;

                    m_Sock.SendPacket(Protocols.T_PC_CONNECT_VERSION, SendMsg);
                }
                break;

                case Protocols.T_PC_CONNECT_VERSION_OK:
                {
                    UpdateProgressCallback callback = UpdateProgress;
                    FileCheck.GetHashList(callback);
                }
                break;

                case Protocols.T_PC_CONNECT_LOGIN_OK:
                {
                    MSG_PC_CONNECT_LOGIN_OK Msg = Operations.ByteArrayToStruct <MSG_PC_CONNECT_LOGIN_OK>(e.Data, ref nBytesUsed);

                    if (Properties.Settings.Default.StoreLogins)
                    {
                        Properties.Settings.Default.AccountName = tbAccount.Text;
                        Properties.Settings.Default.Password    = tbPassword.Text;
                        Properties.Settings.Default.Save();
                    }

                    string Args = String.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11}"
                                                , Msg.FieldServerIP.ToManagedString()
                                                , Msg.FieldServerPort
                                                , Msg.IMServerIP.ToManagedString()
                                                , Msg.IMServerPort

                                                , Msg.AccountName.ToManagedString()
                                                , BitConverter.ToString(MD5Lib.GetPasswordMD5(tbPassword.Text)).Replace("-", "").ToLowerInvariant()

                                                , (Properties.Settings.Default.Fullscreen) ? 1 : 0
                                                , Properties.Settings.Default.Width
                                                , Properties.Settings.Default.Height
                                                , 2

                                                , (Msg.ConnectToTestServer) ? 1 : 0

                                                , (Properties.Settings.Default.UseVSync) ? 1 : 0);

                    ProcessStartInfo pInfo = new ProcessStartInfo();
                    pInfo.FileName  = "ca.exe";
                    pInfo.Arguments = Args;

                    Process.Start(pInfo);

                    Environment.Exit(0);
                }
                break;

                case Protocols.T_PC_CONNECT_LOGIN_BLOCKED:
                {
                    MSG_PC_CONNECT_LOGIN_BLOCKED Msg = Operations.ByteArrayToStruct <MSG_PC_CONNECT_LOGIN_BLOCKED>(e.Data, ref nBytesUsed);

                    if (Msg.IsMacBlocked)
                    {
                        MessageBox.Show("Your account is blocked presently.\n If you believe this is an error please Contact Customer Support at [http://gaming-paradise.net/support/] for further details");
                    }
                    else
                    {
                        string BlockedMsg = String.Format("{0}\'s account is blocked presently.\n  Reason: {1}\n  Period: {2} ~ {3}\n\nContact Customer Support at [http://gaming-paradise.net/support/] for further details."
                                                          , Msg.szAccountName.ToManagedString()
                                                          , Msg.szBlockedReasonForUser.ToManagedString()
                                                          , Msg.atimeStart.ToString()
                                                          , Msg.atimeEnd.ToString());
                        MessageBox.Show(BlockedMsg);
                    }
                }
                break;

                case Protocols.T_ERROR:
                {
                    MSG_ERROR ErrorMsg = Operations.ByteArrayToStruct <MSG_ERROR>(e.Data, ref nBytesUsed);

                    string Msg = Operations.GetChatMessageFromPacket(e.Data, ref nBytesUsed, ErrorMsg.StringLength);

                    ShowError(ErrorMsg, Msg);
                }
                break;

                default:
                {
                    MessageBox.Show("Got unknown data from server!");
                    Exit();
                }
                break;
                }
            }
        }
Beispiel #2
0
        private void ShowError(MSG_ERROR Error, string Msg)
        {
            switch (Error.ErrorCode)
            {
            case ErrorCodes.ERR_COMMON_LOGIN_FAILED:
            {
                MessageBox.Show("ID and password do not match.");
                UpdateProgress(100, "", true);
                FocusPassword();
            }
            break;

            case ErrorCodes.ERR_PROTOCOL_INVALID_PRESERVER_CLIENT_STATE:
            {
                MessageBox.Show("Error in login process");
                Exit();
            }
            break;

            case ErrorCodes.ERR_PROTOCOL_DUPLICATE_LOGIN:
            {
                MessageBox.Show("Double log in");
                Exit();
                FocusAccount();
            }
            break;

            case ErrorCodes.ERR_PROTOCOL_ALL_FIELD_SERVER_NOT_ALIVE:
            {
                MessageBox.Show("GameServer is offline!");
                Exit();
            }
            break;

            case ErrorCodes.ERR_PROTOCOL_IM_SERVER_NOT_ALIVE:
            {
                MessageBox.Show("ChatServer is offline!");
                Exit();
            }
            break;

            case ErrorCodes.ERR_COMMON_SERVICE_TEMPORARILY_PAUSED:
            {
                MessageBox.Show("Server is in pause mode!");
                Exit();
            }
            break;

            case ErrorCodes.ERR_PROTOCOL_LIMIT_GROUP_USER_COUNT:
            {
                MessageBox.Show("There are too many users online.\n\nTry logging in later.");
                UpdateProgress(100, "", true);
            }
            break;

            case ErrorCodes.ERR_PROTOCOL_ACCOUNT_BLOCKED:
            {
                MessageBox.Show(String.Format("Your account is currently blocked.\nPeriod : {0}\n\nContact Customer Support at [http://gaming-paradise.net/support/] for further details.", Msg));
                UpdateProgress(100, "", true);
                FocusAccount();
            }
            break;

            case ErrorCodes.ERR_COMMON_INVALID_CLIENT_VERSION:
            {
                MessageBox.Show("Game client version is not valid.\r\n  Please reinstall or download the patch file.");
                Exit();
            }
            break;

            case ErrorCodes.ERR_DB_NO_SUCH_ACCOUNT:
            {
                MessageBox.Show("This account does not exist!");
                UpdateProgress(100, "", true);
                FocusAccount();
            }
            break;

            case ErrorCodes.ERR_PERMISSION_DENIED:
            {
                MessageBox.Show("The game server is currently offline for maintenance. Please check the official homepage (http://ace.gaming-paradise.net) for further information.");
                Exit();
            }
            break;

            case ErrorCodes.ERR_NO_SEARCH_CHARACTER:
            case ErrorCodes.ERR_DB_EXECUTION_FAILED:
            {
                MessageBox.Show("The creation of characters is currently forbidden!");
                Exit();
            }
            break;

            case ErrorCodes.ERR_PROTOCOL_SELECTIVE_SHUTDOWN_NOT_ALLOWED_TIME:
            {
                MessageBox.Show("Server is in shutdown state!");
                Exit();
            }
            break;

            default:
            {
                MessageBox.Show(String.Format("Got unknown error: {0}", Error.ErrorCode));
                Exit();
            }
            break;
            }
        }