public static void MyChar_Info_Req(InPacket lea, Client gc) { string[] data = lea.ReadString(lea.Available).Split(new[] { (char)0x20 }, StringSplitOptions.None); int encryptKey = int.Parse(data[1]); string username = data[2]; string password = data[4]; gc.SetAccount(new Account(gc)); try { gc.Account.Load(username); var pe = new PasswordEncrypt(encryptKey); string encryptPassword = ServerConstants.PASSWORD_DECODE ? pe.encrypt(gc.Account.Password, gc.RetryLoginCount > 0 ? password.ToCharArray() : null) : gc.Account.Password; if (!password.Equals(encryptPassword)) { gc.Dispose(); Log.Error("Login Fail!"); } else { gc.Account.Characters = new List <Character>(); foreach (dynamic datum in new Datums("Characters").PopulateWith("id", "accountId = '{0}' && worldId = '{1}' ORDER BY position ASC", gc.Account.ID, gc.WorldID)) { Character character = new Character(datum.id, gc); character.Load(false); gc.Account.Characters.Add(character); } CharPacket.MyChar_Info_Ack(gc, gc.Account.Characters); Log.Success("Login Success!"); } Log.Inform("Password = {0}", password); //Log.Inform("encryptKey = {0}", encryptKey); //Log.Inform("encryptPassword = {0}", encryptPassword); } catch (NoAccountException) { gc.Dispose(); Log.Error("Login Fail!"); } }
public static void Login_Req(InPacket lea, Client c) { string username = lea.ReadString(); string password = lea.ReadString(); short encryptKey = lea.ReadShort(); if (username.IsAlphaNumeric() == false) { LoginPacket.Login_Ack(c, ServerState.LoginState.NO_USERNAME); return; } c.SetAccount(new Account(c)); try { c.Account.Load(username); var pe = new PasswordEncrypt(encryptKey); string encryptPassword = ServerConstants.PASSWORD_DECODE ? pe.encrypt(c.Account.Password, c.RetryLoginCount > 0 ? password.ToCharArray() : null) : c.Account.Password; if (!password.Equals(encryptPassword)) { LoginPacket.Login_Ack(c, ServerState.LoginState.PASSWORD_ERROR); Log.Error("Login Fail!"); c.RetryLoginCount += 1; } else if (c.Account.Banned == 1) { LoginPacket.Login_Ack(c, ServerState.LoginState.USER_LOCK); } else { LoginPacket.Login_Ack(c, ServerState.LoginState.OK, encryptKey, c.Account.Master > 0 ? true : false); c.Account.LoggedIn = 1; Log.Success("Login Success!"); } Log.Inform("Password = {0}", password); //Log.Inform("encryptKey = {0}", encryptKey); //Log.Inform("encryptPassword = {0}", encryptPassword); } catch (NoAccountException) { if (ServerConstants.AUTO_REGISTRATION == true) { if (username.Length < 5 || password.Length < 5) { LoginPacket.Login_Ack(c, ServerState.LoginState.NO_USERNAME); } Account account = new Account(c); account.Username = username.ToLower(); account.Password = password; account.Creation = DateTime.Now; account.LoggedIn = 0; account.Banned = 0; account.Master = 0; account.GamePoints = 0; account.GiftPoints = 0; account.BonusPoints = 0; account.Save(); LoginPacket.Login_Ack(c, ServerState.LoginState.USER_LOCK); return; } LoginPacket.Login_Ack(c, ServerState.LoginState.NO_USERNAME); } }
public static void Game_Log_Req(InPacket lea, Client gc) { //int re = SearchBytes(lea.Content, new byte[] { 0x0 }); string[] data = lea.ReadString(0x100 /*re*/).Split(new[] { (char)0x20 }, StringSplitOptions.None); int encryptKey = int.Parse(data[1]); string username = data[2]; string password = data[4]; int selectCharacter = lea.ReadByte(); IPAddress hostid = lea.ReadIPAddress(); gc.SetAccount(new Account(gc)); try { gc.Account.Load(username); var pe = new PasswordEncrypt(encryptKey); string encryptPassword = ServerConstants.PASSWORD_DECODE ? pe.encrypt(gc.Account.Password, gc.RetryLoginCount > 0 ? password.ToCharArray() : null) : gc.Account.Password; if (!password.Equals(encryptPassword)) { gc.Dispose(); Log.Error("Login Fail!"); } else { gc.Account.Characters = new List <Character>(); foreach (dynamic datum in new Datums("Characters").PopulateWith("id", "accountId = '{0}' ORDER BY position ASC", gc.Account.ID)) { Character character = new Character(datum.id, gc); character.Load(false); character.IP = hostid; gc.Account.Characters.Add(character); } gc.SetCharacter(gc.Account.Characters[selectCharacter]); } Log.Inform("Password = {0}", password); //Log.Inform("encryptKey = {0}", encryptKey); //Log.Inform("encryptPassword = {0}", encryptPassword); } catch (NoAccountException) { gc.Dispose(); Log.Error("Login Fail!"); } Character chr = gc.Character; chr.CharacterID = gc.CharacterID; MapFactory.AllCharacters.Add(chr); StatusPacket.UpdateHpMp(gc, 0, 0, 0, 0); GamePacket.FW_DISCOUNTFACTION(gc); StatusPacket.getStatusInfo(gc); InventoryPacket.getCharacterEquip(gc); SkillPacket.getSkillInfo(gc, chr.Skills.getSkills()); QuestPacket.getQuestInfo(gc, chr.Quests.getQuests()); GamePacket.getQuickSlot(gc, chr.Keymap); StoragePacket.getStoreInfo(gc); StoragePacket.getStoreMoney(gc); MapPacket.enterMapStart(gc); InventoryPacket.getInvenCash(gc); CashShopPacket.MgameCash(gc); CashShopPacket.GuiHonCash(gc); InventoryPacket.getInvenEquip(gc); InventoryPacket.getInvenEquip1(gc); InventoryPacket.getInvenEquip2(gc); InventoryPacket.getInvenSpend3(gc); InventoryPacket.getInvenOther4(gc); InventoryPacket.getInvenPet5(gc); }