public void DeleteCharacter(string packet) { Logger.Debug(packet, Session.SessionId); if (Session.HasCurrentMap) { return; } string[] deleteCharacterPacket = packet.Split(' '); AccountDTO account = DAOFactory.AccountDAO.LoadBySessionId(Session.SessionId); if (deleteCharacterPacket.Length <= 3) { return; } if (account != null && account.Password.ToLower() == EncryptionBase.sha512(deleteCharacterPacket[3])) { DAOFactory.GeneralLogDAO.SetCharIdNull(Convert.ToInt64(DAOFactory.CharacterDAO.LoadBySlot(account.AccountId, Convert.ToByte(deleteCharacterPacket[2])).CharacterId)); DAOFactory.CharacterDAO.DeleteByPrimaryKey(account.AccountId, Convert.ToByte(deleteCharacterPacket[2])); LoadCharacters(packet); } else { Session.SendPacket($"info {Language.Instance.GetMessageFromKey("BAD_PASSWORD")}"); } }
public void LoadCharacters(string packet) { string[] loginPacketParts = packet.Split(' '); // Load account by given SessionId if (Session.Account == null) { bool hasRegisteredAccountLogin = true; try { hasRegisteredAccountLogin = ServiceFactory.Instance.CommunicationService.HasRegisteredAccountLogin(loginPacketParts[4], Session.SessionId); } catch (Exception ex) { Logger.Log.Error("WCF Communication Failed.", ex); } if (loginPacketParts.Length > 4 && hasRegisteredAccountLogin) { AccountDTO accountDTO = DAOFactory.AccountDAO.LoadByName(loginPacketParts[4]); if (accountDTO != null) { if (accountDTO.Password.ToLower().Equals(EncryptionBase.sha512(loginPacketParts[6]))) { var account = new Account() { AccountId = accountDTO.AccountId, Name = accountDTO.Name, Password = accountDTO.Password.ToLower(), Authority = accountDTO.Authority, LastCompliment = accountDTO.LastCompliment, }; foreach (PenaltyLogDTO penalty in DAOFactory.PenaltyLogDAO.LoadByAccount(accountDTO.AccountId)) { account.PenaltyLogs.Add(new PenaltyLog() { AccountId = penalty.AccountId, DateEnd = penalty.DateEnd, DateStart = penalty.DateStart, Reason = penalty.Reason, Penalty = penalty.Penalty, PenaltyLogId = penalty.PenaltyLogId }); } foreach (GeneralLogDTO general in DAOFactory.GeneralLogDAO.LoadByAccount(accountDTO.AccountId)) { account.GeneralLogs.Add(new GeneralLog() { AccountId = general.AccountId, LogData = general.LogData, IpAddress = general.IpAddress, LogType = general.LogType, LogId = general.LogId, Timestamp = general.Timestamp, CharacterId = general.CharacterId }); } Session.InitializeAccount(account); } else { Logger.Log.ErrorFormat($"Client {Session.ClientId} forced Disconnection, invalid Password or SessionId."); Session.Disconnect(); } } else { Logger.Log.ErrorFormat($"Client {Session.ClientId} forced Disconnection, invalid AccountName."); Session.Disconnect(); } } else { Logger.Log.ErrorFormat($"Client {Session.ClientId} forced Disconnection, login has not been registered or Account is already logged in."); Session.Disconnect(); return; } } //TODO: Wrap Database access up to GO IEnumerable <CharacterDTO> characters = DAOFactory.CharacterDAO.LoadByAccount(Session.Account.AccountId); Logger.Log.InfoFormat(Language.Instance.GetMessageFromKey("ACCOUNT_ARRIVED"), Session.SessionId); Session.SendPacket("clist_start 0"); foreach (CharacterDTO character in characters) { IEnumerable <InventoryDTO> inventory = DAOFactory.InventoryDAO.LoadByType(character.CharacterId, InventoryType.Equipment); WearableInstance[] equipment = new WearableInstance[16]; foreach (InventoryDTO equipmentEntry in inventory) { //explicit load of iteminstance WearableInstance currentInstance = equipmentEntry.ItemInstance as WearableInstance; equipment[currentInstance.Item.EquipmentSlot] = currentInstance; } // 1 1 before long string of -1.-1 = act completion Session.SendPacket($"clist {character.Slot} {character.Name} 0 {character.Gender} {character.HairStyle} {character.HairColor} 0 {character.Class} {character.Level} {character.HeroLevel} {(equipment[(byte)EquipmentType.Hat] != null ? equipment[(byte)EquipmentType.Hat].ItemVNum : -1)}.{(equipment[(byte)EquipmentType.Armor] != null ? equipment[(byte)EquipmentType.Armor].ItemVNum : -1)}.{(equipment[(byte)EquipmentType.WeaponSkin] != null ? equipment[(byte)EquipmentType.WeaponSkin].ItemVNum : equipment[(byte)EquipmentType.MainWeapon] != null ? equipment[(byte)EquipmentType.MainWeapon].ItemVNum : -1)}.{(equipment[(byte)EquipmentType.SecondaryWeapon] != null ? equipment[(byte)EquipmentType.SecondaryWeapon].ItemVNum : -1)}.{(equipment[(byte)EquipmentType.Mask] != null ? equipment[(byte)EquipmentType.Mask].ItemVNum : -1)}.{(equipment[(byte)EquipmentType.Fairy] != null ? equipment[(byte)EquipmentType.Fairy].ItemVNum : -1)}.{(equipment[(byte)EquipmentType.CostumeSuit] != null ? equipment[(byte)EquipmentType.CostumeSuit].ItemVNum : -1)}.{(equipment[(byte)EquipmentType.CostumeHat] != null ? equipment[(byte)EquipmentType.CostumeHat].ItemVNum : -1)} {character.JobLevel} 1 1 -1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1.-1 0 0"); } Session.SendPacket("clist_end"); }