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;
            }
        }
Пример #2
0
        private static CharacterBook ReadCharactersImpl()
        {
            CharacterBook charMgr = new CharacterBook();

            foreach (string filepath in EnumerateCharacterFilepaths())
            {
                using (var file = new StreamReader(filepath))
                {
                    string contents = file.ReadToEnd();
                    // to avoid json vulnerability, do not use TypeNameHandling.All
                    var data = JsonConvert.DeserializeObject <Dictionary <string, ServerCharacterListByAccount> >(contents);
                    charMgr.AppendCharacters(data);
                }
            }
            return(charMgr);
        }
        private static CharacterBook ReadCharactersImpl()
        {
            string path = FileLocations.GetCharacterFilePath();

            if (!File.Exists(path))
            {
                path = FileLocations.GetOldCharacterFilePath();
            }

            if (!File.Exists(path))
            {
                return(new CharacterBook());
            }
            using (var file = new StreamReader(path))
            {
                string contents = file.ReadToEnd();
                // to avoid json vulnerability, do not use TypeNameHandling.All
                var           data    = JsonConvert.DeserializeObject <Dictionary <string, ServerCharacterListByAccount> >(contents);
                CharacterBook charMgr = new CharacterBook(data);
                return(charMgr);
            }
        }
Пример #4
0
 public static System.Collections.Generic.List <string> GetAllCharacterFilePaths()
 {
     return(CharacterBook.EnumerateCharacterFilepaths());
 }