static public void F_SOCIAL_NETWORK(BaseClient client, PacketIn packet) { GameClient cclient = client as GameClient; if (!cclient.IsPlaying() || !cclient.Plr.IsInWorld()) return; Player Plr = cclient.Plr; byte Type = packet.GetUint8(); switch (Type) { case 11: // Inspection { Player Target = Plr.CbtInterface.GetTarget(GameData.TargetTypes.TARGETTYPES_TARGET_ALLY) as Player; if (Target == null) Plr.SendLocalizeString("", GameData.Localized_text.TEXT_SN_LISTS_ERR_PLAYER_NOT_FOUND); else Target.ItmInterface.SendInspect(Plr); } break; case 8: { packet.Skip(1); byte NameSize = packet.GetUint8(); packet.Skip(1); string Name = packet.GetString(NameSize); byte GuildSize = packet.GetUint8(); packet.Skip(1); string GuildName = packet.GetString(GuildSize); packet.Skip(1); UInt16 Career = packet.GetUint16(); packet.Skip(4); UInt16 ZoneId = packet.GetUint16(); while (ZoneId > 256) ZoneId -= 256; while (packet.GetUint8() != 0xFF) ; packet.Skip(2 + (ZoneId == 255 ? 0 : 1)); byte MinLevel = packet.GetUint8(); byte MaxLevel = packet.GetUint8(); Plr.SocInterface.SendPlayers(Player.GetPlayers(Name, GuildName, Career, ZoneId, MinLevel, MaxLevel)); } break; } }
static public void F_CONNECT(BaseClient client, PacketIn packet) { GameClient cclient = client as GameClient; packet.Skip(8); UInt32 Tag = packet.GetUint32(); string Token = packet.GetString(80); packet.Skip(21); string Username = packet.GetString(23); // TODO AuthResult Result = Program.AcctMgr.CheckToken(Username, Token); if (Result != AuthResult.AUTH_SUCCESS) { Log.Error("F_CONNECT", "Invalid Token =" + Username); cclient.Disconnect(); } else { cclient._Account = Program.AcctMgr.GetAccount(Username); if (cclient._Account == null) { Log.Error("F_CONNECT", "Invalid Account =" + Username); cclient.Disconnect(); } else { //Log.Success("F_CONNECT", "MeId=" + cclient.Id); GameClient Other = (cclient.Server as TCPServer).GetClientByAccount(cclient, cclient._Account.AccountId); if (Other != null) Other.Disconnect(); { PacketOut Out = new PacketOut((byte)Opcodes.S_CONNECTED); Out.WriteUInt32(0); Out.WriteUInt32(Tag); Out.WriteByte(Program.Rm.RealmId); Out.WriteUInt32(1); Out.WritePascalString(Username); Out.WritePascalString(Program.Rm.Name); Out.WriteByte(0); Out.WriteUInt16(0); cclient.SendPacket(Out); } } } }
static public void F_TEXT(BaseClient client, PacketIn packet) { GameClient cclient = client as GameClient; if (cclient.Plr == null) return; byte Unk = packet.GetUint8(); string Text = packet.GetString((int)(packet.Length - packet.Position)); CommandMgr.HandleText(cclient.Plr, Text); }
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_RENAME_CHARACTER(BaseClient client, PacketIn packet) { GameClient cclient = client as GameClient; packet.Skip(3); string OldName = packet.GetString(24); string NewName = packet.GetString(24); Log.Success("F_RENAME_CHARACTER", "Renaming: '" + OldName + "' To: '" + NewName + "'"); if (NewName.Length > 2 && !CharMgr.NameIsUsed(NewName)) { Character Char = CharMgr.GetCharacter(OldName); if (Char == null || Char.AccountId != cclient._Account.AccountId) { Log.Error("CharacterRename", "Hack: Tried to rename character which account dosen't own"); cclient.Disconnect(); return; } Char.Name = NewName; CharMgr.Database.SaveObject(Char); // Wrong response? Perhaps needs to send F_REQUEST_CHAR_RESPONSE again. PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE); Out.WritePascalString(cclient._Account.Username); cclient.SendPacket(Out); } else { // Wrong response? PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_ERROR); Out.WritePascalString(cclient._Account.Username); 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_DELETE_NAME(BaseClient client, PacketIn packet) { GameClient cclient = client as GameClient; string CharName = packet.GetString(30); string UserName = packet.GetString(20); byte Bad = 0; if (CharName.Length <= 0 || CharMgr.NameIsUsed(CharName)) Bad = 1; Log.Debug("F_DELETE_NAME", "Bad=" + Bad + ",Name=" + CharName); PacketOut Out = new PacketOut((byte)Opcodes.F_CHECK_NAME); Out.WriteString(CharName, 30); Out.WriteString(UserName, 20); Out.WriteByte(Bad); Out.WriteByte(0); Out.WriteByte(0); Out.WriteByte(0); cclient.SendPacket(Out); }
public void BuildMail(PacketIn packet) { Player Plr = GetPlayer(); if (Plr == null) return; if (nextSend >= TCPServer.GetTimeStamp()) { SendResult(GameData.MailResult.TEXT_MAIL_RESULT6); return; } // Recipient read packet.Skip(1); byte NameSize = packet.GetUint8(); string Name = packet.GetString(NameSize); Character Receiver = CharMgr.GetCharacter(Name); if (Receiver == null) { SendResult(GameData.MailResult.TEXT_MAIL_RESULT7); return; } if (Receiver.Name == Plr.Name) // You cannot mail yourself { Plr.SendLocalizeString("", GameData.Localized_text.TEXT_PLAYER_CANT_MAIL_YOURSELF); return; } // Subject byte SubjectSize = packet.GetUint8(); packet.Skip(1); string Subject = packet.GetString(SubjectSize); // Message byte MessageSize = packet.GetUint8(); packet.Skip(1); string Message = packet.GetString(MessageSize); // Money UInt32 money = ByteOperations.ByteSwap.Swap(packet.GetUint32()); // COD? byte cr = packet.GetUint8(); // Item byte itemcounts = packet.GetUint8(); if (!Plr.RemoveMoney((cr == 0 ? money : 0) + MAIL_PRICE)) { SendResult(MailResult.TEXT_MAIL_RESULT8); return; } // Make a Mail Character_mail CMail = new Character_mail(); CMail.Guid = CharMgr.GenerateMailGUID(); CMail.CharacterId = Receiver.CharacterId; CMail.CharacterIdSender = Plr._Info.CharacterId; CMail.SenderName = Plr._Info.Name; CMail.ReceiverName = Name; CMail.Title = Subject; CMail.Content = Message; CMail.Money = money; CMail.Cr = true; CMail.Opened = false; Log.Debug("Mail", "Itemcount: " + itemcounts + ""); for (byte i = 0; i < itemcounts; ++i) { UInt16 itmslot = ByteOperations.ByteSwap.Swap(packet.GetUint16()); packet.Skip(2); ByteOperations.ByteSwap.Swap(itmslot); Item itm = Plr.ItmInterface.GetItemInSlot(itmslot); if (itm != null) { CMail.ItemsReqInfo.Add(itm.CharItem); Plr.ItmInterface.DeleteItem(itmslot, itm.CharItem.Counts, false); itm.Owner = null; } } SendResult(MailResult.TEXT_MAIL_RESULT4); CharMgr.Database.AddObject(CMail); //If player exists let them know they have mail. Player mailToPlayer = Player.GetPlayer(Name); if (mailToPlayer != null) mailToPlayer.MlInterface.AddMail(CMail); nextSend = (uint)TCPServer.GetTimeStamp() + 5; }
public static void F_PLAYER_ENTER_FULL(BaseClient client, PacketIn packet) { GameClient cclient = client as GameClient; UInt16 SID; byte unk1, serverID, characterSlot; SID = packet.GetUint16(); unk1 = packet.GetUint8(); serverID = packet.GetUint8(); string CharName = packet.GetString(24); packet.Skip(2); string Language = packet.GetString(2); packet.Skip(4); characterSlot = packet.GetUint8(); Log.Debug("F_PLAYER_ENTER_FULL", "Entrer en jeu de : " + CharName + ",Slot=" + characterSlot); if (Program.Rm.RealmId != serverID) cclient.Disconnect(); else { PacketOut Out = new PacketOut((byte)Opcodes.S_PID_ASSIGN); Out.WriteUInt16R((ushort)cclient.Id); cclient.SendPacket(Out); } }
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); }