예제 #1
0
 /// <summary>
 /// Called only when the client is completely closed (exited out of the character selection screen even).
 /// </summary>
 protected override void Shutdown()
 {
     ServerDispatch  -= FilterCore_ServerDispatch;
     CommandLineText -= Machine.Interpreter.Command;
     ClientDispatch  -= FilterCore_ClientDispatch;
     LogonTimer.Tick -= LogonTimer_Tick;
     LogonTimer?.Dispose();
     Machine.BotManagerView?.Dispose();
     Machine = null;
 }
예제 #2
0
        /// <summary>
        /// Parses server messages.
        /// Protocols known at time of creation:
        /// http://skunkworks.sourceforge.net/protocol/Protocol.php
        /// https://acemulator.github.io/protocol/
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FilterCore_ServerDispatch(object sender, NetworkMessageEventArgs e)
        {
            // End 3D Mode and return to character screen
            if (e.Message.Type.Equals(0xF653))
            {
                Machine.LoggedIn  = false;
                CommandLineText  -= Machine.Interpreter.Command;
                Core.RenderFrame -= Machine.Clock;
                Core.WorldFilter.ChangeObject -= Machine.WorldFilter_ChangeObject;
                Machine.BotManagerView?.Dispose();
            }

            // Received the character list from the server
            if (e.Message.Type.Equals(0xF658))
            {
                AccountCharacters.Clear();
                TotalSlots = Convert.ToInt32(e.Message["slotCount"]);
                int charCount = Convert.ToInt32(e.Message["characterCount"]);

                MessageStruct characterStruct = e.Message.Struct("characters");
                for (int i = 0; i < charCount; i++)
                {
                    AccountCharacters.Add(characterStruct.Struct(i)["name"].ToString());
                }

                // Must sort the characters ordinally to be in the same order as displayed
                AccountCharacters.Sort((a, b) => String.Compare(a, b, StringComparison.Ordinal));
            }

            // Login Character
            if (e.Message.Type.Equals(0xF746))
            {
                LogonTimer.Stop();
            }

            // Game events
            if (e.Message.Type.Equals(0xF7B0))
            {
                // Action complete
                if (Convert.ToInt32(e.Message["event"]).Equals(0x01C7))
                {
                    Machine.CastCompleted = true;
                }

                // Status messages
                if (Convert.ToInt32(e.Message["event"]).Equals(0x028A))
                {
                    // Your spell fizzled.
                    if (Convert.ToInt32(e.Message[3]).Equals(0x0402))
                    {
                        Machine.Fizzled = true;
                    }
                }
            }

            // Server Name (last server message sent when logging out)
            if (e.Message.Type.Equals(0xF7E1) && Machine.CurrentState == SwitchingCharacters.GetInstance)
            {
                LogonTimer.Start();
            }
        }