Пример #1
0
        protected void HandleGameState(GameStateMessage Message)
        {
            CRCCreatorEnabled = true;

            // go to game protocol mode
            Mode = ProtocolMode.Game;
            OnProtocolModeChanged(new EventArgs());
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Message"></param>
        protected void HandleGameStateMessage(GameStateMessage Message)
        {
            // set connection state
            connectionState = ConnectionState.Online;

            // log
            Logger.Log(MODULENAME, LogType.Info, "ConnectionState: Online");

            // start pinging
            timPing.Enabled = true;
        }
Пример #3
0
        /// <summary>
        /// Helper function for "ExtractMessage"
        /// </summary>
        /// <param name="e">LoginMode Buffer</param>
        /// <param name="PI">Decoded PI</param>
        /// <returns>Typed message or generic</returns>
        protected unsafe GameMessage ExtractLoginModeMessage(MessageBufferEventArgs e, MessageTypeLoginMode PI)
        {
            GameMessage TypedMessage = null;
           
            // pin the byte[] for pointer parsers
            fixed (byte* pBuffer = e.MessageBuffer)
            {
                byte* pMessage = pBuffer;

                switch (PI)
                {
                    case MessageTypeLoginMode.Login:                  // PI: 2
                        TypedMessage = new LoginMessage(e.MessageBuffer);
                        break;

                    case MessageTypeLoginMode.ReqGame:                // PI: 4
                        TypedMessage = new ReqGameStateMessage(e.MessageBuffer);
                        break;

                    case MessageTypeLoginMode.ReqAdmin:               // PI: 5
                        TypedMessage = new ReqAdminMessageLoginMode(e.MessageBuffer);
                        break;

                    case MessageTypeLoginMode.GetClient:              // PI: 7
                        TypedMessage = new GetClientMessage(e.MessageBuffer);
                        break;

                    case MessageTypeLoginMode.GetLogin:               // PI: 21
                        TypedMessage = new GetLoginMessage(e.MessageBuffer);
                        break;

                    case MessageTypeLoginMode.GetChoice:              // PI: 22
                        TypedMessage = new GetChoiceMessage(e.MessageBuffer);
                        HandleGetChoice((GetChoiceMessage)TypedMessage);
                        break;

                    case MessageTypeLoginMode.LoginOK:                // PI: 23
                        TypedMessage = new LoginOKMessage(e.MessageBuffer);
                        break;

                    case MessageTypeLoginMode.LoginFailed:            // PI: 24
                        TypedMessage = new LoginFailedMessage(e.MessageBuffer);
                        break;

                    case MessageTypeLoginMode.Game:                   // PI: 25
                        TypedMessage = new GameStateMessage(e.MessageBuffer);
                        HandleGameState((GameStateMessage)TypedMessage);
                        break;

                    case MessageTypeLoginMode.Admin:                  // PI: 26
                        TypedMessage = new AdminMessageLoginMode(e.MessageBuffer);
                        break;

                    case MessageTypeLoginMode.Credits:                // PI: 30
                        TypedMessage = new CreditsMessage(e.MessageBuffer);
                        break;

                    case MessageTypeLoginMode.Download:               // PI: 31
                        TypedMessage = new DownloadMessage(ref pMessage);
                        break;
                        
                    case MessageTypeLoginMode.Message:                // PI: 34
                        TypedMessage = new LoginModeMessageMessage(e.MessageBuffer);
                        break;

                    case MessageTypeLoginMode.NoCharacters:           // PI: 37
                        TypedMessage = new NoCharactersMessage(e.MessageBuffer);
                        break;

                    default:
                        TypedMessage = new GenericGameMessage(e.MessageBuffer);     // All unknown ones
                        break;
                }
            }

            return TypedMessage;
        }