Exemplo n.º 1
0
        public void FilterCore_ClientDispatch(object sender, NetworkMessageEventArgs e)
        {
            if (e.Message.Type == 0xF7C8) // Enter Game
            {
                freshLogin = true;
                try
                {
                    LaunchControl.RecordLaunchResponse(DateTime.UtcNow);
                }
                catch
                {
                    log.WriteInfo("FilterCore_ClientDispatch: Exception trying to record launch response");
                }
                Heartbeat.LaunchHeartbeat();
            }

            if (freshLogin && e.Message.Type == 0xF7B1 && Convert.ToInt32(e.Message["action"]) == 0xA1)             // Character Materialize (Any time is done portalling in, login or portal)
            {
                freshLogin = false;

                if (loginMessageQueue.Count > 0)
                {
                    sendingLastEnter = false;
                    CoreManager.Current.RenderFrame += new EventHandler <EventArgs>(Current_RenderFrame);
                }
            }
        }
        internal void FilterCore_ServerDispatch(object sender, NetworkMessageEventArgs e)
        {
            if (e.Message.Type == 0xF658) // Zone Name
            {
                zonename = Convert.ToString(e.Message["zonename"]);
                log.WriteInfo("zonename (saved to GameRepo.Game): '{0}'", zonename);
                GameRepo.Game.SetAccount(zonename);
            }

            if (e.Message.Type == 0xF7E1) // Server Name
            {
                //Server Name retrieved from the server message, not used (unreliable in EMU)
                var server = Convert.ToString(e.Message["server"]);
                log.WriteInfo("server (saved to GameRepo.Game): '{0}'", server);
                GameRepo.Game.SetServer(server);
            }

            if (e.Message.Type == 0xF658) // Character List
            {
                characterSlots = Convert.ToInt32(e.Message["slotCount"]);

                characters = new List <Character>();

                MessageStruct charactersStruct = e.Message.Struct("characters");

                for (int i = 0; i < charactersStruct.Count; i++)
                {
                    int    character     = Convert.ToInt32(charactersStruct.Struct(i)["character"]);
                    string name          = Convert.ToString(charactersStruct.Struct(i)["name"]);
                    int    deleteTimeout = Convert.ToInt32(charactersStruct.Struct(i)["deleteTimeout"]);

                    characters.Add(new Character(character, name, deleteTimeout));
                    log.WriteInfo(character.ToString() + " " + name + " " + deleteTimeout.ToString());
                }

                characters.Sort((a, b) => String.Compare(a.Name, b.Name, StringComparison.Ordinal));
            }
            if (!written)
            {
                if (GameRepo.Game.Server != "" && zonename != null && characters != null)
                {
                    CharacterBook.WriteCharacters(ServerName: GameRepo.Game.Server, zonename: zonename, characters: characters);
                    Heartbeat.LaunchHeartbeat();
                    written = true;
                }
            }
            if (CoreManager.Current.CharacterFilter.Name != characterName)
            {
                GameRepo.Game.SetCharacter(CoreManager.Current.CharacterFilter.Name);
                characterName = CoreManager.Current.CharacterFilter.Name;
            }
        }