public static void HandlePacket(BaseClient client, PacketIn packet) { LobbyClient cclient = client as LobbyClient; byte freeslot = Program.CharMgr.GetFreeSlot(cclient.Account.Id); if (freeslot == 0 || cclient.CreateChar == null) ANS_CHARACTER_CREATE.Send(cclient); else { cclient.CreateChar.SlotId = freeslot; cclient.CreateChar.Faction = packet.GetUint8(); cclient.CreateChar.Gender = packet.GetUint8(); cclient.CreateChar.Version = (int)packet.GetUint32R(); cclient.CreateChar.Seconds = (int)packet.GetUint32R(); byte[] Custom = new byte[packet.Length - packet.Position]; packet.Read(Custom, 0, Custom.Length); cclient.CreateChar.Custom = BitConverter.ToString(Custom); Program.CharMgr.CreateCharacter(cclient.CreateChar); ANS_CHARACTER_CREATE.Send(cclient); } }
public PacketIn DeCrypt(PacketIn packet) { if (m_crypts.Count <= 0) { return(packet); } ulong opcode = packet.Opcode; ulong size = packet.Size; long StartPos = packet.Position; foreach (KeyValuePair <ICryptHandler, CryptKey[]> Entry in m_crypts) { try { Log.Debug("Decrypt", "Decrypt with " + Entry.Key + ",Size=" + packet.Size); byte[] Buf = new byte[size]; long Pos = packet.Position; packet.Read(Buf, 0, (int)Buf.Length); packet.Position = Pos; PacketIn Pack = Entry.Key.Decrypt(Entry.Value[1], Buf); packet.Write(Pack.ToArray(), 0, Pack.ToArray().Length); packet.Opcode = opcode; packet.Size = size; } catch (Exception e) { Log.Error("BaseClient", "Decrypt Error : " + e.ToString()); continue; } } Log.Tcp("Decrypt", packet.ToArray(), 0, packet.ToArray().Length); packet.Position = StartPos; return(packet); }
public static void HandlePacket(BaseClient client, PacketIn packet) { LobbyClient cclient = (LobbyClient)client; byte FileId = packet.GetUint8(); UInt32 Version = packet.GetUint32R(); byte[] File = new byte[packet.Length - packet.Position]; packet.Read(File, 0, File.Length); File = ZlibMgr.Decompress(File); Log.Debug("ConfigSave", "Config saved : fileid=" + FileId + ", Version=" + Version + ",Size=" + File.Length); Program.FileMgr.SaveInfo(cclient.Account.Id, FileId, File); PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CONFIGFILE_SAVE); Out.WriteUInt32R(0); Out.WriteByte(FileId); Out.Write(File, 0, File.Length); cclient.SendTCP(Out); }
static public void CL_START(BaseClient client, PacketIn packet) { Client cclient = client as Client; string Username = packet.GetString(); UInt32 Len = packet.GetUint32(); byte[] Password = packet.Read((int)Len); bool result = Program.AcctMgr.CheckAccount(Username, Password); Log.Debug("CL_START", "Lancement du client : " + Username + " " + result); PacketOut Out = new PacketOut((byte)Opcodes.LCR_START); if (result == true) { Out.WriteByte(0); Out.WriteString(Program.AcctMgr.GenerateToken(Username)); } else Out.WriteByte(1); cclient.SendPacket(Out); }
static public void F_CREATE_CHARACTER(BaseClient client, PacketIn packet) { GameClient cclient = client as GameClient; CreateInfo Info; Info.slot = packet.GetUint8(); Info.race = packet.GetUint8(); Info.career = packet.GetUint8(); Info.sex = packet.GetUint8(); Info.model = packet.GetUint8(); Info.NameSize = packet.GetUint16(); packet.Skip(2); byte[] Traits = new byte[8]; packet.Read(Traits, 0, Traits.Length); packet.Skip(7); string Name = packet.GetString(Info.NameSize); if (Name.Length > 2 && !CharMgr.NameIsUsed(Name)) { CharacterInfo CharInfo = CharMgr.GetCharacterInfo(Info.career); if (CharInfo == null) { Log.Error("ON_CREATE", "Can not find career :" + Info.career); } else { Log.Success("OnCreate", "New Character : " + Name); Character Char = new Character(); Char.AccountId = cclient._Account.AccountId; Char.bTraits = Traits; Char.Career = Info.career; Char.CareerLine = CharInfo.CareerLine; Char.ModelId = Info.model; Char.Name = Name; Char.Race = Info.race; Char.Realm = CharInfo.Realm; Char.RealmId = Program.Rm.RealmId; Char.Sex = Info.sex; Char.FirstConnect = true; if (!CharMgr.CreateChar(Char)) { Log.Error("CreateCharacter", "Hack : can not create more than 10 characters!"); } else { Character_item Citm = null; List < CharacterInfo_item > Items = CharMgr.GetCharacterInfoItem(Char.CareerLine); foreach (CharacterInfo_item Itm in Items) { if (Itm == null) continue; Citm = new Character_item(); Citm.Counts = Itm.Count; Citm.CharacterId = Char.CharacterId; Citm.Entry = Itm.Entry; Citm.ModelId = Itm.ModelId; Citm.SlotId = Itm.SlotId; CharMgr.CreateItem(Citm); } Character_value CInfo = new Character_value(); CInfo.CharacterId = Char.CharacterId; CInfo.Level = 1; CInfo.Money = 0; CInfo.Online = false; CInfo.RallyPoint = CharInfo.RallyPt; CInfo.RegionId = CharInfo.Region; CInfo.Renown = 0; CInfo.RenownRank = 1; CInfo.RestXp = 0; CInfo.Skills = CharInfo.Skills; CInfo.Speed = 100; CInfo.WorldO = CharInfo.WorldO; CInfo.WorldX = CharInfo.WorldX; CInfo.WorldY = CharInfo.WorldY; CInfo.WorldZ = CharInfo.WorldZ; CInfo.Xp = 0; CInfo.ZoneId = CharInfo.ZoneId; CharMgr.Database.AddObject(CInfo); Program.AcctMgr.UpdateRealmCharacters(Program.Rm.RealmId, (uint)CharMgr.Database.GetObjectCount<Character>(" Realm=1"), (uint)CharMgr.Database.GetObjectCount<Character>(" Realm=2")); Char.Value = CInfo; PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE); Out.WritePascalString(cclient._Account.Username); cclient.SendPacket(Out); } } } else { PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_ERROR); Out.WritePascalString(cclient._Account.Username); cclient.SendPacket(Out); } }
static public void F_ENCRYPTKEY(BaseClient client, PacketIn packet) { GameClient cclient = client as GameClient; sEncrypt Result = BaseClient.ByteToType<sEncrypt>(packet); string Version = Result.major + "." + Result.minor + "." + Result.revision; Log.Debug("F_ENCRYPTKEY", "Version = " + Version); if (Result.cipher == 0) { PacketOut Out = new PacketOut((byte)Opcodes.F_RECEIVE_ENCRYPTKEY); Out.WriteByte(1); cclient.SendPacket(Out); } else if (Result.cipher == 1) { byte[] EncryptKey = new byte[256]; packet.Read(EncryptKey, 0, EncryptKey.Length); cclient.AddCrypt("RC4Crypto", new CryptKey(EncryptKey), new CryptKey(EncryptKey)); } }
public static void F_CREATE_CHARACTER(BaseClient client, PacketIn packet) { GameClient cclient = client as GameClient; CreateInfo Info; Info.slot = packet.GetUint8(); Info.race = packet.GetUint8(); Info.career = packet.GetUint8(); Info.sex = packet.GetUint8(); Info.model = packet.GetUint8(); Info.NameSize = packet.GetUint16(); packet.Skip(2); byte[] Traits = new byte[8]; packet.Read(Traits, 0, Traits.Length); packet.Skip(7); string Name = packet.GetString(Info.NameSize); if (!CharMgr.NameIsUsed(Name)) { CharacterInfo CharInfo = CharMgr.GetCharacterInfo(Info.career); if (CharInfo == null) { Log.Error("ON_CREATE", "Can not find career :" + Info.career); return; } Log.Success("OnCreate", "Creating new Character : " + Name); Character Char = new Character(); Char.AccountId = cclient._Account.AccountId; Char.bTraits = Traits; Char.Career = Info.career; Char.CareerLine = CharInfo.CareerLine; Char.ModelId = Info.model; Char.Name = Name; Char.Race = Info.race; Char.Realm = CharInfo.Realm; Char.RealmId = Program.Rm.RealmId; Char.Sex = Info.sex; if (!CharMgr.CreateChar(Char)) { Log.Error("CreateCharacter", "Hack : can not create more than 10 characters!"); return; } Character_items Citm = null; CharacterInfo_item[] Items = CharMgr.GetCharacterInfoItem(Char.CareerLine); for (int i = 0; i < Items.Length; ++i) { if (Items[i] == null) continue; Citm = new Character_items(); Citm.Counts = Items[i].Count; Citm.CharacterId = Char.CharacterId; Citm.Entry = Items[i].Entry; Citm.ModelId = Items[i].ModelId; Citm.SlotId = Items[i].SlotId; CharMgr.CreateItem(Citm); } Character_value CInfo = new Character_value(); CInfo.CharacterId = Char.CharacterId; CInfo.Level = 1; CInfo.Money = 0; CInfo.Online = false; CInfo.RallyPoint = CharInfo.RallyPt; CInfo.RegionId = CharInfo.Region; CInfo.Renown = 0; CInfo.RenownRank = 1; CInfo.RestXp = 0; CInfo.Skills = CharInfo.Skills; CInfo.Speed = 100; CInfo.WorldO = CharInfo.WorldO; CInfo.WorldX = CharInfo.WorldX; CInfo.WorldY = CharInfo.WorldY; CInfo.WorldZ = CharInfo.WorldZ; CInfo.Xp = 0; CInfo.ZoneId = CharInfo.ZoneId; CharMgr.Database.AddObject(CInfo); Char.Value = new Character_value[1] { CInfo }; } PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE); Out.WritePascalString(cclient._Account.Username); cclient.SendTCP(Out); }