internal void FilterCore_ServerDispatch(object sender, NetworkMessageEventArgs e) { if (e.Message.Type == 0xF658) // Zone Name { zonename = Convert.ToString(e.Message["zonename"]); log.WriteInfo("zonename: '{0}'", 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: '{0}'", server); } if (e.Message.Type == 0xF658) // Character List { log.WriteInfo("Inside ServerDispatch. 0xF658"); 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 (zonename != null && characters != null) { CharacterBook mgr = CharacterBook.ReadCharacters(); mgr.WriteCharacters(zonename: zonename, characters: characters); log.WriteInfo("Wrote our characters to file"); Heartbeat.LaunchHeartbeat(); written = true; } } if (CoreManager.Current.CharacterFilter.Name != characterName) { GameRepo.Game.SetCharacter(CoreManager.Current.CharacterFilter.Name); characterName = CoreManager.Current.CharacterFilter.Name; } }
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(); var data = JsonConvert.DeserializeObject <Dictionary <string, ServerCharacterListByAccount> >(contents); CharacterBook charMgr = new CharacterBook(data); return(charMgr); } }