private void ExecuteHandler(ClientSession session) { try { Character character = new Character(DAOFactory.CharacterDAO.LoadBySlot(session.Account.AccountId, Slot)); if (session.Account != null && !session.HasSelectedCharacter) { character.Initialize(); #if !DEBUG if (session.Account.Authority > Domain.AuthorityType.Moderator) { character.Invisible = true; character.InvisibleGm = true; } #endif character.GeneralLogs = new ThreadSafeGenericList<GeneralLogDTO>(); character.GeneralLogs.AddRange(DAOFactory.GeneralLogDAO.LoadByAccount(session.Account.AccountId) .Where(s => s.CharacterId == character.CharacterId).ToList()); character.MapInstanceId = ServerManager.GetBaseMapInstanceIdByMapId(character.MapId); character.PositionX = character.MapX; character.PositionY = character.MapY; character.Authority = session.Account.Authority; session.SetCharacter(character); if (!session.Character.GeneralLogs.Any(s => s.Timestamp == DateTime.UtcNow && s.LogData == "World" && s.LogType == "Connection")) { session.Character.SpAdditionPoint += session.Character.SpPoint; session.Character.SpPoint = 10000; } if (session.Character.Hp > session.Character.HPLoad()) { session.Character.Hp = (int)session.Character.HPLoad(); } if (session.Character.Mp > session.Character.MPLoad()) { session.Character.Mp = (int)session.Character.MPLoad(); } session.Character.Respawns = DAOFactory.RespawnDAO.LoadByCharacter(session.Character.CharacterId).ToList(); session.Character.StaticBonusList = DAOFactory.StaticBonusDAO .LoadByCharacterId(session.Character.CharacterId).ToList(); session.Character.LoadInventory(); session.Character.LoadQuicklists(); session.Character.GenerateMiniland(); Map miniland = ServerManager.GetMapInstanceByMapId(20001).Map; DAOFactory.MateDAO.LoadByCharacterId(session.Character.CharacterId).ToList().ForEach(s => { Mate mate = new Mate(s) { Owner = session.Character }; mate.GenerateMateTransportId(); mate.Monster = ServerManager.GetNpcMonster(s.NpcMonsterVNum); mate.IsAlive = true; if (!mate.IsTeamMember && miniland.IsBlockedZone(mate.MapX, mate.MapY)) { MapCell cell = miniland.GetRandomPosition(); mate.MapX = cell.X; mate.MapY = cell.Y; } if (mate.MateType == MateType.Pet && mate.MateSlot == -1) { mate.MateSlot = session.Character.GetNextMateSlot(mate.MateType); mate.PartnerSlot = 0; } else if (mate.MateType == MateType.Partner && mate.PartnerSlot == -1) { mate.PartnerSlot = session.Character.GetNextMateSlot(mate.MateType); mate.MateSlot = 0; } session.Character.Mates.Add(mate); mate.StartLife(); }); session.Character.CharacterLifeDisposable = Observable.Interval(TimeSpan.FromMilliseconds(300)) .Subscribe(x => session.Character.CharacterLife()); session.Character.GeneralLogs.Add(new GeneralLogDTO { AccountId = session.Account.AccountId, CharacterId = session.Character.CharacterId, IpAddress = session.IpAddress, LogData = "World", LogType = "Connection", Timestamp = DateTime.UtcNow }); session.SendPacket("OK"); // Inform everyone about connected character CommunicationServiceClient.Instance.ConnectCharacter(ServerManager.Instance.WorldId, character.CharacterId); } } catch (Exception ex) { Logger.Error("Select character failed.", ex); } }