[PacketHandler(RealmServerOpCode.WarChatRequest)] //6718 public static void WarChatRequestRequest(IRealmClient client, RealmPacketIn packet) { var faction = packet.ReadInt16(); //default : 1Len : 2 var sessId = packet.ReadInt16(); //default : 26Len : 2 packet.Position += 20; var message = packet.ReadAsdaString(200, client.Locale); //default : Len : 204 if (message.Length < 1 || Commands.RealmCommandHandler.HandleCommand(client.ActiveCharacter, message, client.ActiveCharacter.Target as Character)) { return; } if (!client.ActiveCharacter.IsAsda2BattlegroundInProgress) { // client.ActiveCharacter.YouAreFuckingCheater("Trying to war chat in not war."); return; } if (client.ActiveCharacter.ChatBanned) { client.ActiveCharacter.SendInfoMsg("You are Banned"); return; } var locale = Asda2EncodingHelper.MinimumAvailableLocale(client.Locale, message); SendWarChatResponseResponse(client.ActiveCharacter.CurrentBattleGround, client.ActiveCharacter.Name, message, client.ActiveCharacter.Asda2FactionId, locale); }
[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); } }
public void WriteAsciiString(string msg, Locale locale = Locale.En) { var msgData = Asda2EncodingHelper.Encode(msg, locale); Write(msgData); WriteByte(0); }
[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 void WriteAsdaString(string s, int len, Locale locale = Locale.Start) { if (s == null) { s = "null"; } byte[] buffer = Asda2EncodingHelper.Encode(s.Length > len ? s.Substring(0, len) : s, locale); Write(buffer); for (int index = 0; index < len - buffer.Length; ++index) { Write((byte)0); } }
public void WriteAsdaString(string s, int len, Locale locale = Locale.En) { if (s == null) { s = "null"; } var data = Asda2EncodingHelper.Encode(s.Length > len ? s.Substring(0, len) : s, locale); Write(data); for (int i = 0; i < len - data.Length; i++) { Write((byte)0); } }
public string ReadAsdaString(int len, Locale locale) { List <byte> byteList = new List <byte>(); byte num; while ((num = ReadByte()) != 0) { byteList.Add(num); } if (byteList.Count < len) { Position += len - byteList.Count - 1; } return(Asda2EncodingHelper.Decode(byteList.ToArray(), locale)); }
public static void PrivateShopChatReqRequest(IRealmClient client, RealmPacketIn packet) { packet.Position += 22; string str = packet.ReadAsciiString(client.Locale); if (client.ActiveCharacter.PrivateShop == null) { client.ActiveCharacter.YouAreFuckingCheater("Trying to chat to private shop while not exist shop.", 2); } else { Locale locale = Asda2EncodingHelper.MinimumAvailableLocale(client.Locale, str); client.ActiveCharacter.PrivateShop.SendMessage(str, client.ActiveCharacter, locale); } }
public string ReadAsciiString(Locale locale) {//todo asda2 Read string as client locale byte tempByte; var chrBuffer = new List <byte>(); try { while ((tempByte = ReadByte()) != 0) { chrBuffer.Add(tempByte); } } catch (EndOfStreamException) {} return(Asda2EncodingHelper.Decode(chrBuffer.ToArray(), locale)); }
public string ReadAsdaString(int len, Locale locale) { //todo asda2 Read string as client locale byte tempByte; var chrBuffer = new List <byte>(); while ((tempByte = ReadByte()) != 0) { chrBuffer.Add(tempByte); } if (chrBuffer.Count < len) { Position += len - chrBuffer.Count - 1; } return(Asda2EncodingHelper.Decode(chrBuffer.ToArray(), locale)); }
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 string ReadAsciiString(Locale locale) { List <byte> byteList = new List <byte>(); try { byte num; while ((num = ReadByte()) != 0) { byteList.Add(num); } } catch (EndOfStreamException ex) { } return(Asda2EncodingHelper.Decode(byteList.ToArray(), locale)); }
public static void WarChatRequestRequest(IRealmClient client, RealmPacketIn packet) { int num1 = (int)packet.ReadInt16(); int num2 = (int)packet.ReadInt16(); packet.Position += 20; string str = packet.ReadAsdaString(200, client.Locale); if (str.Length < 1 || RealmCommandHandler.HandleCommand((IUser)client.ActiveCharacter, str, (IGenericChatTarget)(client.ActiveCharacter.Target as Character)) || !client.ActiveCharacter.IsAsda2BattlegroundInProgress) { return; } Locale locale = Asda2EncodingHelper.MinimumAvailableLocale(client.Locale, str); Asda2BattlegroundHandler.SendWarChatResponseResponse(client.ActiveCharacter.CurrentBattleGround, client.ActiveCharacter.Name, str, (int)client.ActiveCharacter.Asda2FactionId, locale); }
[PacketHandler(RealmServerOpCode.SendRoomChatMessage)]//6246 public static void SendRoomChatMessageRequest(IRealmClient client, RealmPacketIn packet) { var color = packet.ReadInt32(); //default : -10240Len : 4 packet.Position += 4; //nk9 default : 0Len : 4 var message = packet.ReadAsciiString(client.Locale); //default : Len : 0 if (client.ActiveCharacter.ChatRoom == null) { client.ActiveCharacter.SendInfoMsg("You are not in chat room."); return; } if (client.ActiveCharacter.ChatBanned) { client.ActiveCharacter.SendInfoMsg("you are banned"); return; } var locale = Asda2EncodingHelper.MinimumAvailableLocale(client.Locale, message); SendRoomChatMsgResponse(client, client.ActiveCharacter.AccId, color, message, locale); }
[PacketHandler(RealmServerOpCode.GlobalChatWithItem)] //6560 public static void GlobalChatWithItemRequest(IRealmClient client, RealmPacketIn packet) { packet.Position -= 24; var success = client.ActiveCharacter.Asda2Inventory.UseGlobalChatItem(); if (!success) { return; } //var accId = packet.ReadInt32();//default : 0Len : 4 packet.Position += 1; //nk1 default : 0Len : 1 var msg = packet.ReadAsciiString(client.Locale); //default : Len : 0 if (msg.Length < 1 || RealmCommandHandler.HandleCommand(client.ActiveCharacter, msg, client.ActiveCharacter.Target as Character)) { return; } if (msg.Length > 200) { client.ActiveCharacter.YouAreFuckingCheater("Global chat message more than 200 symbols.", 80); return; } if (client.ActiveCharacter.ChatBanned) { client.ActiveCharacter.SendInfoMsg("Your chat is banned."); return; } if (GuessEventManager.Started) { GuessEventManager.TryGuess(msg, client.ActiveCharacter); } var locale = Asda2EncodingHelper.MinimumAvailableLocale(client.Locale, msg); SendGlobalChatWithItemResponseResponse(CreateSenderName(client.ActiveCharacter), msg, client.ActiveCharacter.ChatColor, locale); }
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 void WriteAsciiString(string msg, Locale locale = Locale.Start) { this.Write(Asda2EncodingHelper.Encode(msg, locale)); this.WriteByte(0); }
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); } } }