[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 static bool HandleCommand(WCellUser wcellUser, IrcUser user, IrcChannel chan, string text) { var uArgs = user.Args as WCellArgs; if (uArgs != null) { if (uArgs.Account.Role >= RoleStatus.Staff) { var cmdArgs = uArgs.CmdArgs; var trigger = new WCellCmdTrigger(wcellUser, chan, new WCellStr(text), cmdArgs); bool isDouble; RealmCommandHandler.ConsumeCommandPrefix(trigger.Text, out isDouble); trigger.Args.Double = isDouble; // init the trigger and check if the given args are valid if (trigger.InitTrigger()) { RealmCommandHandler.Instance.ExecuteInContext(trigger, OnExecuted, OnFail); } return(true); } } return(false); }
/// <summary>Sends a message to this channel.</summary> /// <param name="sender">the chatter saying the message</param> public void SendMessage(IChatter sender, string message) { ChannelMember channelMember; if (!this.Members.TryGetValue(sender.EntityId.Low, out channelMember)) { ChannelHandler.SendNotOnChannelReply((IPacketReceiver)sender, this.m_name); } else if (channelMember.IsMuted) { ChannelHandler.SendMutedReply((IPacketReceiver)sender, this.m_name); } else if (this.IsModerated && !channelMember.IsModerator) { ChannelHandler.SendNotOnChannelReply((IPacketReceiver)sender, this.m_name); } else { if (sender is IUser && RealmCommandHandler.HandleCommand((IUser)sender, message, (IGenericChatTarget)this)) { return; } ChannelHandler.SendPacketToChannel(this, ChatMgr.CreateNormalChatMessagePacket(sender.Name, message, Locale.Start, (Character)null)); } }
/// <summary> /// Sends a message to this channel. /// </summary> /// <param name="sender">the chatter saying the message</param> public void SendMessage(IChatter sender, string message) { ChannelMember mi; if (!Members.TryGetValue(sender.EntityId.Low, out mi)) { ChannelHandler.SendNotOnChannelReply(sender, m_name); return; } if (mi.IsMuted) { ChannelHandler.SendMutedReply(sender, m_name); return; } bool isMod = mi.IsModerator; if (IsModerated && !isMod) { ChannelHandler.SendNotOnChannelReply(sender, m_name); return; } if (sender is IUser) { if (RealmCommandHandler.HandleCommand((IUser)sender, message, this)) { return; } } ChannelHandler.SendPacketToChannel(this, ChatMgr.CreateNormalChatMessagePacket(sender.Name, message, Locale.En)); /*using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT)) * { * packet.Write((byte)ChatMsgType.Channel); * packet.Write((uint)sender.SpokenLanguage); * packet.Write(sender.EntityId); * packet.Write(0); // unknown * packet.WriteCString(Name); * packet.Write(sender.EntityId); * packet.WriteUIntPascalString(message); * packet.Write((byte)sender.ChatTag); // chat tag * * if (isMod) * { * ChannelHandler.SendPacketToChannel(this, packet); * } * else * { * ChannelHandler.SendPacketToChannel(this, packet, sender.EntityId); * } * * ChatMgr.ChatNotify(sender, message, sender.SpokenLanguage, ChatMsgType.Channel, this); * }*/ }
[PacketHandler(RealmServerOpCode.WishperChatRequest)] //5088 public static void WishperChatRequest(IRealmClient client, RealmPacketIn packet) { packet.Position -= 24; var isSoulmate = packet.ReadByte(); //default : 0Len : 1 var target = packet.ReadAsdaString(20, Locale.En); //default : Len : 20 var index = target.IndexOf('|'); if (index >= 0) { target = target.Substring(index + 1, target.Length - index - 1); } var msg = packet.ReadAsciiString(client.Locale); //default : Len : 0 if (msg.Length > 100) { client.ActiveCharacter.SendSystemMessage(string.Format( "Can't send wishper to {0} cause it's length more than 100 symbols.", target)); return; } if (msg.Length < 1 || RealmCommandHandler.HandleCommand(client.ActiveCharacter, msg, client.ActiveCharacter.Target as Character)) { return; } var targetChar = World.GetCharacter(target, false); if (targetChar == null) { client.ActiveCharacter.SendSystemMessage(string.Format( "Can't send wishper to {0} cause can't found it.", target)); return; } if (!targetChar.EnableWishpers && !client.ActiveCharacter.Role.IsStaff) { client.ActiveCharacter.SendSystemMessage(string.Format( "Sorry, but {0} rejects all wishpers.", target)); return; } //if (client.ActiveCharacter.ChatBanned) //{ // client.ActiveCharacter.SendInfoMsg("Your chat is banned."); // return; //} SendWishperChatResponse(client, isSoulmate, targetChar.SessionId, client.ActiveCharacter.SessionId, CreateSenderName(client.ActiveCharacter), msg); SendWishperChatResponse(targetChar.Client, isSoulmate, client.ActiveCharacter.SessionId, targetChar.SessionId, CreateSenderName(client.ActiveCharacter), msg, client); Asda2TitleChecker.OnWishperChat(client.ActiveCharacter); }
public static void SayGroup(this Character sender, ChatLanguage language, string msg) { if (RealmCommandHandler.HandleCommand(sender, msg, sender.Target as Character)) { return; } var group = sender.Group; if (group != null) { using (var packetOut = CreateCharChatMessage(ChatMsgType.Party, ChatLanguage.Universal, sender, sender, null, msg, sender.ChatTag)) { group.SendAll(packetOut); } } }
/// <summary> /// Parses any incoming channel messages. /// </summary> /// <param name="type">the type of chat message indicated by the client</param> /// <param name="language">the chat language indicated by the client</param> /// <param name="packet">the actual chat message packet</param> private static void ChannelParser(Character sender, ChatMsgType type, ChatLanguage language, RealmPacketIn packet) { var channel = packet.ReadCString(); var message = packet.ReadCString(); if (RealmCommandHandler.HandleCommand(sender, message, sender.Target as Character)) { return; } var chan = ChatChannelGroup.RetrieveChannel(sender, channel); if (chan == null) { return; } chan.SendMessage(sender, message); }
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); }
public static void CreateCommandDocs(string dir) { RealmServ.EntryLocation = Path.GetFullPath(ToolConfig.WCellRealmServerConsoleExe); var realmServ = RealmServ.Instance; // make sure to create the RealmServ instance first LogUtil.SetupConsoleLogging(); Console.WriteLine("Output Directory: " + new DirectoryInfo(dir).FullName); RealmServerConfiguration.Instance.AutoSave = false; RealmServerConfiguration.Initialize(); RealmCommandHandler.Initialize(); AuthCommandHandler.Initialize(); ToolCommandHandler.Initialize(); CreateCommandDocs(Path.Combine(dir, "RealmServer"), RealmCommandHandler.Instance.Commands); CreateCommandDocs(Path.Combine(dir, "AuthServer"), AuthCommandHandler.Instance.Commands); CreateCommandDocs(Path.Combine(dir, "Tools"), ToolCommandHandler.Instance.Commands); }
/// <summary> /// Parses any incoming officer message. /// </summary> /// <param name="sender">The character sending the message</param> /// <param name="type">the type of chat message indicated by the client</param> /// <param name="language">the chat language indicated by the client</param> /// <param name="packet">the actual chat message packet</param> private static void OfficerParser(Character sender, ChatMsgType type, ChatLanguage language, RealmPacketIn packet) { string msg = ReadMessage(packet); if (msg.Length == 0) { return; } if (RealmCommandHandler.HandleCommand(sender, msg, sender.Target as Character)) { return; } /*var guild = Guild.CheckPrivs(sender, GuildCommandId.MEMBER, GuildPrivileges.GCHATSPEAK); * if (guild != null) * { * SendGuildOfficerMessage(sender, guild, msg); * }*/ }
[PacketHandler(RealmServerOpCode.PartyChat)] //5105 public static void PartyChatRequest(IRealmClient client, RealmPacketIn packet) { packet.Position -= 22; //nk default : 40Len : 2 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 (client.ActiveCharacter.ChatBanned) { client.ActiveCharacter.SendInfoMsg(" You are Banned"); return; } if (!client.ActiveCharacter.IsInGroup) { return; } SendPartyChatResponse(client.ActiveCharacter, msg); }
[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); }
/// <summary> /// Parses any incoming party or raid messages. /// </summary> /// <param name="sender">The character sending the message</param> /// <param name="type">the type of chat message indicated by the client</param> /// <param name="language">the chat language indicated by the client</param> /// <param name="packet">the actual chat message packet</param> private static void SubGroupParser(Character sender, ChatMsgType type, ChatLanguage language, RealmPacketIn packet) { string msg = ReadMessage(packet); if (msg.Length == 0) { return; } if (RealmCommandHandler.HandleCommand(sender, msg, sender.Target as Character)) { return; } var group = sender.SubGroup; if (group != null) { using (var packetOut = CreateCharChatMessage(type, ChatLanguage.Universal, sender, sender, null, msg)) { group.Send(packetOut, null); } } }
internal static void Run() { DatabaseUtil.ReleaseConsole(); var server = RealmServ.Instance; if (!server.IsRunning) { Thread.Sleep(300); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } else { Console.WriteLine("Console ready. Type ? for help"); DefaultTrigger = new DefaultCmdTrigger { Args = new RealmServerCmdArgs(null, false, null) }; while (RealmServ.Instance.IsRunning) { string line; try { while (!Console.KeyAvailable && RealmServ.Instance.IsRunning) { Thread.Sleep(100); } if (!RealmServ.Instance.IsRunning) { break; } line = Console.ReadLine(); } catch { // console shutdown break; } if (line == null || !RealmServ.Instance.IsRunning) { break; } try { if (DatabaseUtil.IsWaiting) { DatabaseUtil.Input.Write(line); } else { var text = new StringStream(line); DefaultTrigger.Text = text; if (!DefaultTrigger.InitTrigger()) { continue; } var isSelect = text.ConsumeNext(RealmCommandHandler.SelectCommandPrefix); if (isSelect) { var cmd = RealmCommandHandler.Instance.SelectCommand(text); if (cmd != null) { Console.WriteLine(@"Selected: {0}", cmd); DefaultTrigger.SelectedCommand = cmd; } else if (DefaultTrigger.SelectedCommand != null) { Console.WriteLine(@"Cleared Command selection."); DefaultTrigger.SelectedCommand = null; } } else { bool dbl; RealmCommandHandler.ConsumeCommandPrefix(text, out dbl); DefaultTrigger.Args.Double = dbl; RealmCommandHandler.Instance.ExecuteInContext(DefaultTrigger, OnExecuted, OnFail); } } } catch (Exception e) { LogUtil.ErrorException(e, false, "Failed to execute Command."); } } } }
public BufferedCommandResponse ExecuteCommand(string cmd) { return(RealmCommandHandler.ExecuteBufferedCommand(cmd)); }
/// <summary> /// Parses any incoming whispers. /// </summary> /// <param name="type">the type of chat message indicated by the client</param> /// <param name="language">the chat language indicated by the client</param> /// <param name="packet">the actual chat message packet</param> private static void WhisperParser(Character sender, ChatMsgType type, ChatLanguage language, RealmPacketIn packet) { var recipient = packet.ReadCString(); var msg = ReadMessage(packet); if (msg.Length == 0) { return; } if (RealmCommandHandler.HandleCommand(sender, msg, sender.Target as Character)) { return; } var targetChr = World.GetCharacter(recipient, false); if (targetChr == null) { SendChatPlayerNotFoundReply(sender.Client, recipient); return; } if (targetChr.Faction.Group != sender.Faction.Group) { SendChatPlayerWrongTeamReply(sender.Client); return; } if (targetChr.IsIgnoring(sender)) { using (var packetOut = CreateCharChatMessage(ChatMsgType.Ignored, ChatLanguage.Universal, targetChr, sender, null, msg)) { sender.Send(packetOut); } } else { using (var packetOut = CreateCharChatMessage(ChatMsgType.Whisper, ChatLanguage.Universal, sender, targetChr, null, msg)) { targetChr.Send(packetOut); } } using (var packetOut = CreateCharChatMessage(ChatMsgType.MsgReply, ChatLanguage.Universal, targetChr, targetChr, null, msg, sender.ChatTag)) { sender.Send(packetOut); } // handle afk/dnd situations if (targetChr.IsAFK) { using (var packetOut = CreateCharChatMessage(ChatMsgType.AFK, ChatLanguage.Universal, targetChr, sender, null, targetChr.AFKReason, targetChr.ChatTag)) { sender.Send(packetOut); } } if (targetChr.IsDND) { using (var packetOut = CreateCharChatMessage(ChatMsgType.DND, ChatLanguage.Universal, targetChr, sender, null, string.Empty, targetChr.ChatTag)) { sender.Send(packetOut); } } }
/// <summary> /// Is called after Character has been added to a map the first time and /// before it receives the first Update packet /// </summary> internal protected void InitializeCharacter() { World.AddCharacter(this); m_initialized = true; try { Regenerates = true; ((PlayerSpellCollection)m_spells).PlayerInitialize(); OnLogin(); if (m_record.JustCreated) { if (!m_client.Account.Role.IsStaff) { CharacterHandler.SendCinematic(this); } if (m_zone != null) { m_zone.EnterZone(this, null); } m_spells.AddDefaultSpells(); m_reputations.Initialize(); if (Class == ClassId.Warrior && Spells.Contains(SpellId.ClassSkillBattleStance)) { CallDelayed(1000, obj => SpellCast.Start(SpellId.ClassSkillBattleStance, false)); } else if (Class == ClassId.DeathKnight && Spells.Contains(SpellId.ClassSkillBloodPresence)) { CallDelayed(1000, obj => SpellCast.Start(SpellId.ClassSkillBloodPresence, false)); } // set initial weapon skill max values Skills.UpdateSkillsForLevel(Level); } else { LoadDeathState(); LoadEquipmentState(); } // load items #if DEV // do this check in case that we did not load Items yet if (ItemMgr.Loaded) #endif InitItems(); // load ticket information var ticket = TicketMgr.Instance.GetTicket(EntityId.Low); if (ticket != null) { Ticket = ticket; Ticket.OnOwnerLogin(this); } // initialize sub systems GroupMgr.Instance.OnCharacterLogin(this); GuildMgr.Instance.OnCharacterLogin(this); RelationMgr.Instance.OnCharacterLogin(this); // set login date LastLogin = DateTime.Now; var isNew = m_record.JustCreated; // perform some stuff ingame AddMessage(() => { if (LastLogout == null) { RealmCommandHandler.ExecFirstLoginFileFor(this); } RealmCommandHandler.ExecAllCharsFileFor(this); if (Account.Role.IsStaff) { RealmCommandHandler.ExecFileFor(this); } Stunned--; if (m_record.NextTaxiVertexId != 0) { // we are on a Taxi var vertex = TaxiMgr.GetVertex(m_record.NextTaxiVertexId); if (vertex != null && vertex.MapId == m_Map.Id && vertex.ListEntry.Next != null && IsInRadius(vertex.Pos, vertex.ListEntry.Next.Value.DistFromPrevious)) { TaxiPaths.Enqueue(vertex.Path); TaxiMgr.FlyUnit(this, true, vertex.ListEntry); } else { m_record.NextTaxiVertexId = 0; } } else { // cannot stand up instantly because else no one will see the char sitting in the first place StandState = StandState.Stand; } GodMode = m_record.GodMode; if (isNew) { // newly created Char logs in the first time var evt = Created; if (evt != null) { evt(this); } } //if (Role.IsStaff) if (GodMode) { //Notify("Your GodMode is " + (GodMode ? "ON" : "OFF") + "!"); Notify(RealmLangKey.GodModeIsActivated); } var login = LoggedIn; if (login != null) { login(this, true); } }); if (isNew) { SaveLater(); m_record.JustCreated = false; } else { RealmServer.IOQueue.AddMessage(() => { try { m_record.Update(); } catch (Exception ex) { SaveLater(); LogUtil.ErrorException(ex, "Failed to Update CharacterRecord: " + m_record); } }); } } catch (Exception e) { if (m_record.JustCreated) { m_record.CanSave = false; m_record.Delete(); } World.RemoveCharacter(this); LogUtil.ErrorException(e, "Failed to initialize Character: " + this); m_client.Disconnect(); } }
public static void SayYellEmote(this Character sender, ChatMsgType type, ChatLanguage language, string msg, float radius) { if (RealmCommandHandler.HandleCommand(sender, msg, sender.Target as Character)) { return; } if (type != ChatMsgType.WhisperInform && msg.Length == 0) { return; } if (GlobalChat) { using (var packetOut = CreateCharChatMessage(type, language, sender.EntityId, sender.EntityId, null, msg, sender.ChatTag)) { foreach (var chr in World.GetAllCharacters()) { chr.Send(packetOut); } } } else { var faction = sender.FactionGroup; RealmPacketOut pckt = null, scrambledPckt = null; var scrambleDefault = ScrambleChat && sender.Role.ScrambleChat; Func <WorldObject, bool> iterator = obj => { if ((obj is Character)) { var chr = (Character)obj; if (!scrambleDefault || chr.FactionGroup == faction || !chr.Role.ScrambleChat) { if (pckt == null) { pckt = CreateCharChatMessage(type, language, sender.EntityId, sender.EntityId, null, msg, sender.ChatTag); } chr.Send(pckt); } else { if (scrambledPckt == null) { scrambledPckt = CreateCharChatMessage(type, language, sender.EntityId, sender.EntityId, null, ScrambleMessage(msg), sender.ChatTag); } chr.Send(scrambledPckt); } } return(true); }; if (radius == WorldObject.BroadcastRange) { sender.NearbyObjects.Iterate(iterator); } else { sender.IterateEnvironment(radius, iterator); } if (pckt != null) { pckt.Close(); } if (scrambledPckt != null) { scrambledPckt.Close(); } } }