[PacketHandler(RealmServerOpCode.NormalChat)] //5084 public static void NormalChatRequest(IRealmClient client, RealmPacketIn packet) { packet.Position -= 2; var msg = packet.ReadAsciiString(client.Locale); //default : if (msg.Length < 1 || RealmCommandHandler.HandleCommand(client.ActiveCharacter, msg, client.ActiveCharacter.Target as Character)) { return; } if (client.ActiveCharacter.ChatBanned) { client.ActiveCharacter.SendInfoMsg("Your chat is banned."); return; } var isPrueEnglish = client.Locale == Locale.En || Asda2EncodingHelper.IsPrueEnglish(msg); var locale = isPrueEnglish ? Locale.Any : client.Locale; if (client.ActiveCharacter.PlaceInRating <= 50) { client.ActiveCharacter.SendPacketToArea(CreateGlobalChatMessage( CreateSenderName(client.ActiveCharacter), msg, GetChatColor(client.ActiveCharacter), locale), locale: locale); } else { client.ActiveCharacter.SendPacketToArea( CreateNormalChatMessagePacket(CreateSenderName(client.ActiveCharacter), msg, client.Locale), true, false, locale); } }
[PacketHandler(RealmServerOpCode.CreateChatRoom)] //6240 public static void CreateChatRoomRequest(IRealmClient client, RealmPacketIn packet) { var isPrivate = packet.ReadByte() == 1; //tab35 default : stab35Len : 1 var maxMemberCount = packet.ReadByte(); //default : 15Len : 1 var roomName = packet.ReadAsdaString(28, Locale.En); //default : Len : 28 packet.Position += 2; //nk2 default : 0Len : 2 var password = packet.ReadAsdaString(8, Locale.En); //default : Len : 8 if (client.ActiveCharacter.ChatRoom != null) { SendChatRoomCreatedResponse(client, CreateChatRoomStatus.YouAreAlreadyInChatRoom, client.ActiveCharacter.ChatRoom); return; } if (client.ActiveCharacter.ChatBanned) { SendChatRoomCreatedResponse(client, CreateChatRoomStatus.UnableToOpen, client.ActiveCharacter.ChatRoom); return; } if (client.ActiveCharacter.IsAsda2BattlegroundInProgress) { SendChatRoomCreatedResponse(client, CreateChatRoomStatus.UnableOpenOnBattle, client.ActiveCharacter.ChatRoom); return; } if (isPrivate && string.IsNullOrWhiteSpace(password)) { SendChatRoomCreatedResponse(client, CreateChatRoomStatus.SetPassword, client.ActiveCharacter.ChatRoom); return; } var isPrueEnglish = Asda2EncodingHelper.IsPrueEnglish(roomName); /*if (!isPrueEnglish) * { * client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("Room name"); * SendChatRoomCreatedResponse(client, CreateChatRoomStatus.UnableToOpen, client.ActiveCharacter.ChatRoom); * return; * }*/ isPrueEnglish = Asda2EncodingHelper.IsPrueEnglish(password); if (!isPrueEnglish) { client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("password"); SendChatRoomCreatedResponse(client, CreateChatRoomStatus.UnableToOpen, client.ActiveCharacter.ChatRoom); return; } if (maxMemberCount > 20 || maxMemberCount < 2) { maxMemberCount = 20; } client.ActiveCharacter.ChatRoom = new Asda2Chatroom(client.ActiveCharacter, isPrivate, maxMemberCount, roomName, password); SendChatRoomCreatedResponse(client, CreateChatRoomStatus.Ok, client.ActiveCharacter.ChatRoom); SendChatRoomVisibleResponse(client.ActiveCharacter, ChatRoomVisibilityStatus.Visible, client.ActiveCharacter.ChatRoom); }
public static void ChangePetNameRequest(IRealmClient client, RealmPacketIn packet) { int key = packet.ReadInt32(); string s = packet.ReadAsdaString(16, Locale.Start); if (!Asda2EncodingHelper.IsPrueEnglish(s)) { client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("pet name"); Asda2PetHandler.SendPetNameChangedResponse(client, Asda2PetNamehangeResult.AbnormalPetInfo, (Asda2PetRecord)null, (Asda2Item)null); } else { ++packet.Position; short slotInq = packet.ReadInt16(); if (!client.ActiveCharacter.OwnedPets.ContainsKey(key)) { client.ActiveCharacter.YouAreFuckingCheater("Trying to summon not existing pet.", 20); Asda2PetHandler.SendPetNameChangedResponse(client, Asda2PetNamehangeResult.AbnormalPetInfo, (Asda2PetRecord)null, (Asda2Item)null); } else { Asda2PetRecord ownedPet = client.ActiveCharacter.OwnedPets[key]; Asda2Item shopShopItem = client.ActiveCharacter.Asda2Inventory.GetShopShopItem(slotInq); if (!ownedPet.CanChangeName) { if (shopShopItem == null) { Asda2PetHandler.SendPetNameChangedResponse(client, Asda2PetNamehangeResult.YouMustHavePremiumItemToChangePetName, ownedPet, (Asda2Item)null); return; } shopShopItem.ModAmount(-1); } ownedPet.Name = s; ownedPet.CanChangeName = false; Asda2PetHandler.SendPetNameChangedResponse(client, Asda2PetNamehangeResult.Ok, ownedPet, shopShopItem); GlobalHandler.UpdateCharacterPetInfoToArea(client.ActiveCharacter); } } }
public static void SendWishperChatResponse(IRealmClient recieverClient, byte soulmate, int senderAccId, short rcvSessId, string sender, string msg, IRealmClient senderClient = null) { var isPrueEnglish = Asda2EncodingHelper.IsPrueEnglish(msg); var locale = Locale.En; if (!isPrueEnglish) { if (senderClient != null) { locale = senderClient.Locale; if (senderClient.Locale != recieverClient.Locale) { senderClient.Send(CreateGlobalChatMessage("Chat manager", "You can send only english text to this character", Color.Red, Locale.En)); return; } } } using (var packet = new RealmPacketOut(RealmServerOpCode.WishperChat)) //5089 { packet.WriteByte(soulmate); //{soulmate}default value : 0 Len : 1 packet.WriteByte(1); //value name : unk0 default value : 1Len : 1 packet.WriteInt32(senderAccId); //{senderAccId}default value : 340701 Len : 4 packet.WriteInt16(rcvSessId); //{rcvSessId}default value : 37 Len : 2 packet.WriteFixedAsciiString(sender, 21); //{sender}default value : Len : 21 packet.WriteAsciiString(msg, recieverClient.Locale); //{msg}default value : Len : 0 if (senderClient != null) { senderClient.Send(packet, addEnd: false); } recieverClient.Send(packet, addEnd: false); } }
public static void SendMailMessageRequest(IRealmClient client, RealmPacketIn packet) { packet.ReadInt32(); short slotInq = packet.ReadInt16(); Asda2InventoryType asda2InventoryType = (Asda2InventoryType)packet.ReadByte(); ushort num = packet.ReadUInt16(); uint sendedGold = packet.ReadUInt32(); string str = packet.ReadAsdaString(20, Locale.Start); string subject = packet.ReadAsdaString(32, Locale.Start); string message = packet.ReadAsdaString(126, Locale.Start); if (!Asda2EncodingHelper.IsPrueEnglish(message)) { client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("message"); Asda2MailHandler.SendMailMessageSendedResponse(client, MailMessageSendedStatus.WrongInformation, (Asda2Item)null); } else if (!Asda2EncodingHelper.IsPrueEnglish(subject)) { client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("subject"); Asda2MailHandler.SendMailMessageSendedResponse(client, MailMessageSendedStatus.WrongInformation, (Asda2Item)null); } else { Asda2Item asda2Item = asda2InventoryType == Asda2InventoryType.Shop ? client.ActiveCharacter.Asda2Inventory.GetShopShopItem(slotInq) : client.ActiveCharacter.Asda2Inventory.GetRegularItem(slotInq); if (client.ActiveCharacter.Money < 1001U || client.ActiveCharacter.Money - 1000U < sendedGold) { Asda2MailHandler.SendMailMessageSendedResponse(client, MailMessageSendedStatus.IncifitientGold, (Asda2Item)null); } else { Character chr = World.GetCharacter(str, false); CharacterRecord chrRec = chr == null?CharacterRecord.GetRecordByName(str) : chr.Record; if (chrRec == null) { Asda2MailHandler.SendMailMessageSendedResponse(client, MailMessageSendedStatus.RecipentNotFounded, (Asda2Item)null); } else { Asda2Item sendItem = (Asda2Item)null; if (asda2Item != null) { if (asda2Item.IsSoulbound) { Asda2MailHandler.SendMailMessageSendedResponse(client, MailMessageSendedStatus.YouCantSendThisItem, (Asda2Item)null); return; } if (asda2Item.Amount < (int)num) { client.ActiveCharacter.YouAreFuckingCheater("Tying to mail wrong item amount", 50); Asda2MailHandler.SendMailMessageSendedResponse(client, MailMessageSendedStatus.WrongInformation, (Asda2Item)null); return; } asda2Item.ModAmount(-(num == (ushort)0 ? 1 : (int)num)); sendItem = Asda2Item.CreateItem(asda2Item.Template, (Character)null, num == (ushort)0 ? 1 : (int)num); sendItem.Record.SaveLater(); } client.ActiveCharacter.SubtractMoney(sendedGold + 1000U); Log.Create(Log.Types.ItemOperations, LogSourceType.Character, client.ActiveCharacter.EntryId) .AddAttribute("source", 0.0, "send_mail").AddItemAttributes(sendItem, "sent") .AddItemAttributes(asda2Item, "source").AddAttribute("gold", (double)sendedGold, "") .AddAttribute("receiver", (double)chrRec.EntityLowId, str).Write(); ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() => { Asda2MailMessage record = new Asda2MailMessage(subject, message, sendItem, sendedGold, chrRec.EntityLowId, client.ActiveCharacter.Name); record.CreateLater(); if (chr == null) { return; } chr.MailMessages.Add(record.Guid, record); chr.SendMailMsg(string.Format("You recieve new message from {0}. Subject {1}.", (object)client.ActiveCharacter.Name, (object)record.Subject)); Asda2MailHandler.SendYouHaveNewMailResponse(chr.Client, 1); })); Asda2MailHandler.SendMailMessageSendedResponse(client, MailMessageSendedStatus.Ok, asda2Item); } } } }
public static void OpenPrivateShopRequest(IRealmClient client, RealmPacketIn packet) { if (client.ActiveCharacter.PrivateShop == null) { Asda2PrivateShopHandler.SendPrivateShopOpenedResponse(client, PrivateShopOpenedResult.Error, (Asda2ItemTradeRef[])null); client.ActiveCharacter.YouAreFuckingCheater("Trying to open not existing private shop", 2); } else { ++packet.Position; List <Asda2ItemTradeRef> asda2ItemTradeRefList = new List <Asda2ItemTradeRef>(); for (int index = 0; index < 10; ++index) { bool flag = false; if (packet.ReadInt32() == 0) { flag = true; } Asda2InventoryType asda2InventoryType = (Asda2InventoryType)packet.ReadByte(); short num1 = packet.ReadInt16(); short num2 = packet.ReadInt16(); packet.Position += 4; if (num1 < (short)0 || (int)num1 >= client.ActiveCharacter.Asda2Inventory.ShopItems.Length || num2 < (short)0) { flag = true; } int num3 = packet.ReadInt32(); if (!flag) { Asda2Item asda2Item = asda2InventoryType == Asda2InventoryType.Regular ? client.ActiveCharacter.Asda2Inventory.RegularItems[(int)num1] : client.ActiveCharacter.Asda2Inventory.ShopItems[(int)num1]; if (asda2Item == null) { Asda2PrivateShopHandler.SendPrivateShopOpenedResponse(client, PrivateShopOpenedResult.ThereIsNoItemInfo, (Asda2ItemTradeRef[])null); return; } if (asda2Item.Amount < (int)num2) { num2 = (short)asda2Item.Amount; } foreach (Asda2ItemTradeRef asda2ItemTradeRef in asda2ItemTradeRefList) { if (asda2ItemTradeRef.Item.InventoryType == asda2Item.InventoryType && (int)asda2ItemTradeRef.Item.Slot == (int)asda2Item.Slot) { flag = true; break; } } if (!flag) { asda2ItemTradeRefList.Add(new Asda2ItemTradeRef() { Item = asda2Item, Amount = (int)num2, Price = num3, TradeSlot = (byte)asda2ItemTradeRefList.Count <Asda2ItemTradeRef>() }); } } packet.Position += 28; } string str = packet.ReadAsdaString(50, Locale.Start); if (!Asda2EncodingHelper.IsPrueEnglish(str)) { client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("Shop title"); Asda2PrivateShopHandler.SendPrivateShopOpenedResponse(client, PrivateShopOpenedResult.Error, (Asda2ItemTradeRef[])null); } else { int num = (int)client.ActiveCharacter.PrivateShop.StartTrade(asda2ItemTradeRefList, str); } } }