Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,164 +1,160 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Server.Accounting;
|
||||
using Server.Misc;
|
||||
using Server.Network;
|
||||
using Server.Accounting;
|
||||
|
||||
namespace Server.Engines.Chat
|
||||
{
|
||||
public class ChatSystem
|
||||
{
|
||||
public static bool Enabled { get; set; } = true;
|
||||
public class ChatSystem
|
||||
{
|
||||
public static bool Enabled{ get; set; } = true;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
PacketHandlers.Register( 0xB5, 0x40, true, OpenChatWindowRequest );
|
||||
PacketHandlers.Register( 0xB3, 0, true, ChatAction );
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
PacketHandlers.Register(0xB5, 0x40, true, OpenChatWindowRequest);
|
||||
PacketHandlers.Register(0xB3, 0, true, ChatAction);
|
||||
}
|
||||
|
||||
public static void SendCommandTo( Mobile to, ChatCommand type )
|
||||
{
|
||||
SendCommandTo( to, type, null, null );
|
||||
}
|
||||
public static void SendCommandTo(Mobile to, ChatCommand type)
|
||||
{
|
||||
SendCommandTo(to, type, null, null);
|
||||
}
|
||||
|
||||
public static void SendCommandTo( Mobile to, ChatCommand type, string param1 )
|
||||
{
|
||||
SendCommandTo( to, type, param1, null );
|
||||
}
|
||||
public static void SendCommandTo(Mobile to, ChatCommand type, string param1)
|
||||
{
|
||||
SendCommandTo(to, type, param1, null);
|
||||
}
|
||||
|
||||
public static void SendCommandTo( Mobile to, ChatCommand type, string param1, string param2 )
|
||||
{
|
||||
to?.Send( new ChatMessagePacket( null, (int)type + 20, param1, param2 ) );
|
||||
}
|
||||
public static void SendCommandTo(Mobile to, ChatCommand type, string param1, string param2)
|
||||
{
|
||||
to?.Send(new ChatMessagePacket(null, (int)type + 20, param1, param2));
|
||||
}
|
||||
|
||||
public static void OpenChatWindowRequest( NetState state, PacketReader pvSrc )
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
public static void OpenChatWindowRequest(NetState state, PacketReader pvSrc)
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
|
||||
if ( !Enabled )
|
||||
{
|
||||
from.SendMessage( "The chat system has been disabled." );
|
||||
return;
|
||||
}
|
||||
if (!Enabled)
|
||||
{
|
||||
from.SendMessage("The chat system has been disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
pvSrc.Seek( 2, System.IO.SeekOrigin.Begin );
|
||||
string chatName = pvSrc.ReadUnicodeStringSafe( ( 0x40 - 2 ) >> 1 ).Trim();
|
||||
pvSrc.Seek(2, SeekOrigin.Begin);
|
||||
string chatName = pvSrc.ReadUnicodeStringSafe((0x40 - 2) >> 1).Trim();
|
||||
|
||||
Account acct = state.Account as Account;
|
||||
Account acct = state.Account as Account;
|
||||
|
||||
string accountChatName = null;
|
||||
string accountChatName = null;
|
||||
|
||||
if ( acct != null )
|
||||
accountChatName = acct.GetTag( "ChatName" );
|
||||
if (acct != null)
|
||||
accountChatName = acct.GetTag("ChatName");
|
||||
|
||||
accountChatName = accountChatName?.Trim();
|
||||
accountChatName = accountChatName?.Trim();
|
||||
|
||||
if ( accountChatName != null && accountChatName.Length > 0 )
|
||||
{
|
||||
if ( chatName.Length > 0 && chatName != accountChatName )
|
||||
from.SendMessage( "You cannot change chat nickname once it has been set." );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( chatName == null || chatName.Length == 0 )
|
||||
{
|
||||
SendCommandTo( from, ChatCommand.AskNewNickname );
|
||||
return;
|
||||
}
|
||||
if (accountChatName != null && accountChatName.Length > 0)
|
||||
{
|
||||
if (chatName.Length > 0 && chatName != accountChatName)
|
||||
from.SendMessage("You cannot change chat nickname once it has been set.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (chatName == null || chatName.Length == 0)
|
||||
{
|
||||
SendCommandTo(from, ChatCommand.AskNewNickname);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( NameVerification.Validate( chatName, 2, 31, true, true, true, 0, NameVerification.SpaceDashPeriodQuote ) && chatName.ToLower().IndexOf( "system" ) == -1 )
|
||||
{
|
||||
// TODO: Optimize this search
|
||||
if (NameVerification.Validate(chatName, 2, 31, true, true, true, 0, NameVerification.SpaceDashPeriodQuote) &&
|
||||
chatName.ToLower().IndexOf("system") == -1)
|
||||
{
|
||||
// TODO: Optimize this search
|
||||
|
||||
foreach ( Account checkAccount in Accounts.GetAccounts() )
|
||||
{
|
||||
string existingName = checkAccount.GetTag( "ChatName" );
|
||||
foreach (Account checkAccount in Accounts.GetAccounts())
|
||||
{
|
||||
string existingName = checkAccount.GetTag("ChatName");
|
||||
|
||||
if ( existingName != null )
|
||||
{
|
||||
existingName = existingName.Trim();
|
||||
if (existingName != null)
|
||||
{
|
||||
existingName = existingName.Trim();
|
||||
|
||||
if ( Insensitive.Equals( existingName, chatName ) )
|
||||
{
|
||||
from.SendMessage( "Nickname already in use." );
|
||||
SendCommandTo( from, ChatCommand.AskNewNickname );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Insensitive.Equals(existingName, chatName))
|
||||
{
|
||||
from.SendMessage("Nickname already in use.");
|
||||
SendCommandTo(from, ChatCommand.AskNewNickname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
accountChatName = chatName;
|
||||
accountChatName = chatName;
|
||||
|
||||
acct?.AddTag( "ChatName", chatName );
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage( 501173 ); // That name is disallowed.
|
||||
SendCommandTo( from, ChatCommand.AskNewNickname );
|
||||
return;
|
||||
}
|
||||
}
|
||||
acct?.AddTag("ChatName", chatName);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(501173); // That name is disallowed.
|
||||
SendCommandTo(from, ChatCommand.AskNewNickname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SendCommandTo( from, ChatCommand.OpenChatWindow, accountChatName );
|
||||
ChatUser.AddChatUser( from );
|
||||
}
|
||||
SendCommandTo(from, ChatCommand.OpenChatWindow, accountChatName);
|
||||
ChatUser.AddChatUser(from);
|
||||
}
|
||||
|
||||
public static ChatUser SearchForUser( ChatUser from, string name )
|
||||
{
|
||||
ChatUser user = ChatUser.GetChatUser( name );
|
||||
public static ChatUser SearchForUser(ChatUser from, string name)
|
||||
{
|
||||
ChatUser user = ChatUser.GetChatUser(name);
|
||||
|
||||
if ( user == null )
|
||||
from.SendMessage( 32, name ); // There is no player named '%1'.
|
||||
if (user == null)
|
||||
from.SendMessage(32, name); // There is no player named '%1'.
|
||||
|
||||
return user;
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
public static void ChatAction( NetState state, PacketReader pvSrc )
|
||||
{
|
||||
if ( !Enabled )
|
||||
return;
|
||||
public static void ChatAction(NetState state, PacketReader pvSrc)
|
||||
{
|
||||
if (!Enabled)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
ChatUser user = ChatUser.GetChatUser( from );
|
||||
try
|
||||
{
|
||||
Mobile from = state.Mobile;
|
||||
ChatUser user = ChatUser.GetChatUser(from);
|
||||
|
||||
if ( user == null )
|
||||
return;
|
||||
if (user == null)
|
||||
return;
|
||||
|
||||
string lang = pvSrc.ReadStringSafe( 4 );
|
||||
int actionID = pvSrc.ReadInt16();
|
||||
string param = pvSrc.ReadUnicodeString();
|
||||
string lang = pvSrc.ReadStringSafe(4);
|
||||
int actionID = pvSrc.ReadInt16();
|
||||
string param = pvSrc.ReadUnicodeString();
|
||||
|
||||
ChatActionHandler handler = ChatActionHandlers.GetHandler( actionID );
|
||||
ChatActionHandler handler = ChatActionHandlers.GetHandler(actionID);
|
||||
|
||||
if ( handler != null )
|
||||
{
|
||||
Channel channel = user.CurrentChannel;
|
||||
if (handler != null)
|
||||
{
|
||||
Channel channel = user.CurrentChannel;
|
||||
|
||||
if ( handler.RequireConference && channel == null )
|
||||
{
|
||||
user.SendMessage( 31 ); /* You must be in a conference to do this.
|
||||
if (handler.RequireConference && channel == null)
|
||||
user.SendMessage(31); /* You must be in a conference to do this.
|
||||
* To join a conference, select one from the Conference menu.
|
||||
*/
|
||||
}
|
||||
else if ( handler.RequireModerator && !user.IsModerator )
|
||||
{
|
||||
user.SendMessage( 29 ); // You must have operator status to do this.
|
||||
}
|
||||
else
|
||||
{
|
||||
handler.Callback( user, channel, param );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine( "Client: {0}: Unknown chat action 0x{1:X}: {2}", state, actionID, param );
|
||||
}
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
Console.WriteLine( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (handler.RequireModerator && !user.IsModerator)
|
||||
user.SendMessage(29); // You must have operator status to do this.
|
||||
else
|
||||
handler.Callback(user, channel, param);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Client: {0}: Unknown chat action 0x{1:X}: {2}", state, actionID, param);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,20 @@
|
|||
namespace Server.Engines.Chat
|
||||
{
|
||||
public delegate void OnChatAction( ChatUser from, Channel channel, string param );
|
||||
public delegate void OnChatAction(ChatUser from, Channel channel, string param);
|
||||
|
||||
public class ChatActionHandler
|
||||
{
|
||||
public bool RequireModerator { get; }
|
||||
public class ChatActionHandler
|
||||
{
|
||||
public ChatActionHandler(bool requireModerator, bool requireConference, OnChatAction callback)
|
||||
{
|
||||
RequireModerator = requireModerator;
|
||||
RequireConference = requireConference;
|
||||
Callback = callback;
|
||||
}
|
||||
|
||||
public bool RequireConference { get; }
|
||||
public bool RequireModerator{ get; }
|
||||
|
||||
public OnChatAction Callback { get; }
|
||||
public bool RequireConference{ get; }
|
||||
|
||||
public ChatActionHandler( bool requireModerator, bool requireConference, OnChatAction callback )
|
||||
{
|
||||
RequireModerator = requireModerator;
|
||||
RequireConference = requireConference;
|
||||
Callback = callback;
|
||||
}
|
||||
}
|
||||
public OnChatAction Callback{ get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,355 +1,358 @@
|
|||
namespace Server.Engines.Chat
|
||||
{
|
||||
public class ChatActionHandlers
|
||||
{
|
||||
private static ChatActionHandler[] m_Handlers;
|
||||
public class ChatActionHandlers
|
||||
{
|
||||
private static ChatActionHandler[] m_Handlers;
|
||||
|
||||
static ChatActionHandlers()
|
||||
{
|
||||
m_Handlers = new ChatActionHandler[0x100];
|
||||
static ChatActionHandlers()
|
||||
{
|
||||
m_Handlers = new ChatActionHandler[0x100];
|
||||
|
||||
Register( 0x41, true, true, ChangeChannelPassword );
|
||||
Register(0x41, true, true, ChangeChannelPassword);
|
||||
|
||||
Register( 0x58, false, false, LeaveChat );
|
||||
Register(0x58, false, false, LeaveChat);
|
||||
|
||||
Register( 0x61, false, true, ChannelMessage );
|
||||
Register( 0x62, false, false, JoinChannel );
|
||||
Register( 0x63, false, false, JoinNewChannel );
|
||||
Register( 0x64, true, true, RenameChannel );
|
||||
Register( 0x65, false, false, PrivateMessage );
|
||||
Register( 0x66, false, false, AddIgnore );
|
||||
Register( 0x67, false, false, RemoveIgnore );
|
||||
Register( 0x68, false, false, ToggleIgnore );
|
||||
Register( 0x69, true, true, AddVoice );
|
||||
Register( 0x6A, true, true, RemoveVoice );
|
||||
Register( 0x6B, true, true, ToggleVoice );
|
||||
Register( 0x6C, true, true, AddModerator );
|
||||
Register( 0x6D, true, true, RemoveModerator );
|
||||
Register( 0x6E, true, true, ToggleModerator );
|
||||
Register( 0x6F, false, false, AllowPrivateMessages );
|
||||
Register( 0x70, false, false, DisallowPrivateMessages );
|
||||
Register( 0x71, false, false, TogglePrivateMessages );
|
||||
Register( 0x72, false, false, ShowCharacterName );
|
||||
Register( 0x73, false, false, HideCharacterName );
|
||||
Register( 0x74, false, false, ToggleCharacterName );
|
||||
Register( 0x75, false, false, QueryWhoIs );
|
||||
Register( 0x76, true, true, Kick );
|
||||
Register( 0x77, true, true, EnableDefaultVoice );
|
||||
Register( 0x78, true, true, DisableDefaultVoice );
|
||||
Register( 0x79, true, true, ToggleDefaultVoice );
|
||||
Register( 0x7A, false, true, EmoteMessage );
|
||||
}
|
||||
Register(0x61, false, true, ChannelMessage);
|
||||
Register(0x62, false, false, JoinChannel);
|
||||
Register(0x63, false, false, JoinNewChannel);
|
||||
Register(0x64, true, true, RenameChannel);
|
||||
Register(0x65, false, false, PrivateMessage);
|
||||
Register(0x66, false, false, AddIgnore);
|
||||
Register(0x67, false, false, RemoveIgnore);
|
||||
Register(0x68, false, false, ToggleIgnore);
|
||||
Register(0x69, true, true, AddVoice);
|
||||
Register(0x6A, true, true, RemoveVoice);
|
||||
Register(0x6B, true, true, ToggleVoice);
|
||||
Register(0x6C, true, true, AddModerator);
|
||||
Register(0x6D, true, true, RemoveModerator);
|
||||
Register(0x6E, true, true, ToggleModerator);
|
||||
Register(0x6F, false, false, AllowPrivateMessages);
|
||||
Register(0x70, false, false, DisallowPrivateMessages);
|
||||
Register(0x71, false, false, TogglePrivateMessages);
|
||||
Register(0x72, false, false, ShowCharacterName);
|
||||
Register(0x73, false, false, HideCharacterName);
|
||||
Register(0x74, false, false, ToggleCharacterName);
|
||||
Register(0x75, false, false, QueryWhoIs);
|
||||
Register(0x76, true, true, Kick);
|
||||
Register(0x77, true, true, EnableDefaultVoice);
|
||||
Register(0x78, true, true, DisableDefaultVoice);
|
||||
Register(0x79, true, true, ToggleDefaultVoice);
|
||||
Register(0x7A, false, true, EmoteMessage);
|
||||
}
|
||||
|
||||
public static void Register( int actionID, bool requireModerator, bool requireConference, OnChatAction callback )
|
||||
{
|
||||
if ( actionID >= 0 && actionID < m_Handlers.Length )
|
||||
m_Handlers[actionID] = new ChatActionHandler( requireModerator, requireConference, callback );
|
||||
}
|
||||
public static void Register(int actionID, bool requireModerator, bool requireConference, OnChatAction callback)
|
||||
{
|
||||
if (actionID >= 0 && actionID < m_Handlers.Length)
|
||||
m_Handlers[actionID] = new ChatActionHandler(requireModerator, requireConference, callback);
|
||||
}
|
||||
|
||||
public static ChatActionHandler GetHandler( int actionID )
|
||||
{
|
||||
if ( actionID >= 0 && actionID < m_Handlers.Length )
|
||||
return m_Handlers[actionID];
|
||||
public static ChatActionHandler GetHandler(int actionID)
|
||||
{
|
||||
if (actionID >= 0 && actionID < m_Handlers.Length)
|
||||
return m_Handlers[actionID];
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void ChannelMessage( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
if ( channel.CanTalk( from ) )
|
||||
channel.SendIgnorableMessage( 57, from, from.GetColorCharacter() + from.Username, param ); // %1: %2
|
||||
else
|
||||
from.SendMessage( 36 ); // The moderator of this conference has not given you speaking privileges.
|
||||
}
|
||||
public static void ChannelMessage(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
if (channel.CanTalk(from))
|
||||
channel.SendIgnorableMessage(57, from, from.GetColorCharacter() + from.Username, param); // %1: %2
|
||||
else
|
||||
from.SendMessage(36); // The moderator of this conference has not given you speaking privileges.
|
||||
}
|
||||
|
||||
public static void EmoteMessage( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
if ( channel.CanTalk( from ) )
|
||||
channel.SendIgnorableMessage( 58, from, from.GetColorCharacter() + from.Username, param ); // %1 %2
|
||||
else
|
||||
from.SendMessage( 36 ); // The moderator of this conference has not given you speaking privileges.
|
||||
}
|
||||
public static void EmoteMessage(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
if (channel.CanTalk(from))
|
||||
channel.SendIgnorableMessage(58, from, from.GetColorCharacter() + from.Username, param); // %1 %2
|
||||
else
|
||||
from.SendMessage(36); // The moderator of this conference has not given you speaking privileges.
|
||||
}
|
||||
|
||||
public static void PrivateMessage( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
int indexOf = param.IndexOf( ' ' );
|
||||
public static void PrivateMessage(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
int indexOf = param.IndexOf(' ');
|
||||
|
||||
string name = param.Substring( 0, indexOf );
|
||||
string text = param.Substring( indexOf + 1 );
|
||||
string name = param.Substring(0, indexOf);
|
||||
string text = param.Substring(indexOf + 1);
|
||||
|
||||
ChatUser target = ChatSystem.SearchForUser( from, name );
|
||||
ChatUser target = ChatSystem.SearchForUser(from, name);
|
||||
|
||||
if ( target == null )
|
||||
return;
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
if ( target.IsIgnored( from ) )
|
||||
from.SendMessage( 35, target.Username ); // %1 has chosen to ignore you. None of your messages to them will get through.
|
||||
else if ( target.IgnorePrivateMessage )
|
||||
from.SendMessage( 42, target.Username ); // %1 has chosen to not receive private messages at the moment.
|
||||
else
|
||||
target.SendMessage( 59, from.Mobile, from.GetColorCharacter() + from.Username, text ); // [%1]: %2
|
||||
}
|
||||
if (target.IsIgnored(from))
|
||||
from.SendMessage(35,
|
||||
target.Username); // %1 has chosen to ignore you. None of your messages to them will get through.
|
||||
else if (target.IgnorePrivateMessage)
|
||||
from.SendMessage(42, target.Username); // %1 has chosen to not receive private messages at the moment.
|
||||
else
|
||||
target.SendMessage(59, from.Mobile, from.GetColorCharacter() + from.Username, text); // [%1]: %2
|
||||
}
|
||||
|
||||
public static void LeaveChat( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
ChatUser.RemoveChatUser( from );
|
||||
}
|
||||
public static void LeaveChat(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
ChatUser.RemoveChatUser(from);
|
||||
}
|
||||
|
||||
public static void ChangeChannelPassword( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
channel.Password = param;
|
||||
from.SendMessage( 60 ); // The password to the conference has been changed.
|
||||
}
|
||||
public static void ChangeChannelPassword(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
channel.Password = param;
|
||||
from.SendMessage(60); // The password to the conference has been changed.
|
||||
}
|
||||
|
||||
public static void AllowPrivateMessages( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
from.IgnorePrivateMessage = false;
|
||||
from.SendMessage( 37 ); // You can now receive private messages.
|
||||
}
|
||||
public static void AllowPrivateMessages(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
from.IgnorePrivateMessage = false;
|
||||
from.SendMessage(37); // You can now receive private messages.
|
||||
}
|
||||
|
||||
public static void DisallowPrivateMessages( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
from.IgnorePrivateMessage = true;
|
||||
from.SendMessage( 38 ); /* You will no longer receive private messages.
|
||||
public static void DisallowPrivateMessages(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
from.IgnorePrivateMessage = true;
|
||||
from.SendMessage(38); /* You will no longer receive private messages.
|
||||
* Those who send you a message will be notified that you are blocking incoming messages.
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
public static void TogglePrivateMessages( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
from.IgnorePrivateMessage = !from.IgnorePrivateMessage;
|
||||
from.SendMessage( from.IgnorePrivateMessage ? 38 : 37 ); // See above for messages
|
||||
}
|
||||
public static void TogglePrivateMessages(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
from.IgnorePrivateMessage = !from.IgnorePrivateMessage;
|
||||
from.SendMessage(from.IgnorePrivateMessage ? 38 : 37); // See above for messages
|
||||
}
|
||||
|
||||
public static void ShowCharacterName( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
from.Anonymous = false;
|
||||
from.SendMessage( 39 ); // You are now showing your character name to any players who inquire with the whois command.
|
||||
}
|
||||
public static void ShowCharacterName(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
from.Anonymous = false;
|
||||
from.SendMessage(
|
||||
39); // You are now showing your character name to any players who inquire with the whois command.
|
||||
}
|
||||
|
||||
public static void HideCharacterName( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
from.Anonymous = true;
|
||||
from.SendMessage( 40 ); // You are no longer showing your character name to any players who inquire with the whois command.
|
||||
}
|
||||
public static void HideCharacterName(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
from.Anonymous = true;
|
||||
from.SendMessage(
|
||||
40); // You are no longer showing your character name to any players who inquire with the whois command.
|
||||
}
|
||||
|
||||
public static void ToggleCharacterName( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
from.Anonymous = !from.Anonymous;
|
||||
from.SendMessage( from.Anonymous ? 40 : 39 ); // See above for messages
|
||||
}
|
||||
public static void ToggleCharacterName(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
from.Anonymous = !from.Anonymous;
|
||||
from.SendMessage(from.Anonymous ? 40 : 39); // See above for messages
|
||||
}
|
||||
|
||||
public static void JoinChannel( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
string name;
|
||||
string password = null;
|
||||
public static void JoinChannel(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
string name;
|
||||
string password = null;
|
||||
|
||||
int start = param.IndexOf( '\"' );
|
||||
int start = param.IndexOf('\"');
|
||||
|
||||
if ( start >= 0 )
|
||||
{
|
||||
int end = param.IndexOf( '\"', ++start );
|
||||
if (start >= 0)
|
||||
{
|
||||
int end = param.IndexOf('\"', ++start);
|
||||
|
||||
if ( end >= 0 )
|
||||
{
|
||||
name = param.Substring( start, end - start );
|
||||
password = param.Substring( ++end );
|
||||
}
|
||||
else
|
||||
{
|
||||
name = param.Substring( start );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int indexOf = param.IndexOf( ' ' );
|
||||
if (end >= 0)
|
||||
{
|
||||
name = param.Substring(start, end - start);
|
||||
password = param.Substring(++end);
|
||||
}
|
||||
else
|
||||
{
|
||||
name = param.Substring(start);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int indexOf = param.IndexOf(' ');
|
||||
|
||||
if ( indexOf >= 0 )
|
||||
{
|
||||
name = param.Substring( 0, indexOf++ );
|
||||
password = param.Substring( indexOf );
|
||||
}
|
||||
else
|
||||
{
|
||||
name = param;
|
||||
}
|
||||
}
|
||||
if (indexOf >= 0)
|
||||
{
|
||||
name = param.Substring(0, indexOf++);
|
||||
password = param.Substring(indexOf);
|
||||
}
|
||||
else
|
||||
{
|
||||
name = param;
|
||||
}
|
||||
}
|
||||
|
||||
password = password?.Trim();
|
||||
password = password?.Trim();
|
||||
|
||||
if ( password != null && password.Length == 0 )
|
||||
password = null;
|
||||
if (password != null && password.Length == 0)
|
||||
password = null;
|
||||
|
||||
Channel joined = Channel.FindChannelByName( name );
|
||||
Channel joined = Channel.FindChannelByName(name);
|
||||
|
||||
if ( joined == null )
|
||||
from.SendMessage( 33, name ); // There is no conference named '%1'.
|
||||
else
|
||||
joined.AddUser( from, password );
|
||||
}
|
||||
if (joined == null)
|
||||
from.SendMessage(33, name); // There is no conference named '%1'.
|
||||
else
|
||||
joined.AddUser(from, password);
|
||||
}
|
||||
|
||||
public static void JoinNewChannel( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
if ( (param = param.Trim()).Length == 0 )
|
||||
return;
|
||||
public static void JoinNewChannel(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
if ((param = param.Trim()).Length == 0)
|
||||
return;
|
||||
|
||||
string name;
|
||||
string password = null;
|
||||
string name;
|
||||
string password = null;
|
||||
|
||||
int start = param.IndexOf( '{' );
|
||||
int start = param.IndexOf('{');
|
||||
|
||||
if ( start >= 0 )
|
||||
{
|
||||
name = param.Substring( 0, start++ );
|
||||
if (start >= 0)
|
||||
{
|
||||
name = param.Substring(0, start++);
|
||||
|
||||
int end = param.IndexOf( '}', start );
|
||||
int end = param.IndexOf('}', start);
|
||||
|
||||
if ( end >= start )
|
||||
password = param.Substring( start, end - start );
|
||||
}
|
||||
else
|
||||
{
|
||||
name = param;
|
||||
}
|
||||
if (end >= start)
|
||||
password = param.Substring(start, end - start);
|
||||
}
|
||||
else
|
||||
{
|
||||
name = param;
|
||||
}
|
||||
|
||||
password = password?.Trim();
|
||||
password = password?.Trim();
|
||||
|
||||
if ( password != null && password.Length == 0 )
|
||||
password = null;
|
||||
if (password != null && password.Length == 0)
|
||||
password = null;
|
||||
|
||||
Channel.AddChannel( name, password ).AddUser( from, password );
|
||||
}
|
||||
Channel.AddChannel(name, password).AddUser(from, password);
|
||||
}
|
||||
|
||||
public static void AddIgnore( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser( from, param );
|
||||
public static void AddIgnore(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser(from, param);
|
||||
|
||||
if ( target == null )
|
||||
return;
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
from.AddIgnored( target );
|
||||
}
|
||||
from.AddIgnored(target);
|
||||
}
|
||||
|
||||
public static void RemoveIgnore( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser( from, param );
|
||||
public static void RemoveIgnore(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser(from, param);
|
||||
|
||||
if ( target == null )
|
||||
return;
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
from.RemoveIgnored( target );
|
||||
}
|
||||
from.RemoveIgnored(target);
|
||||
}
|
||||
|
||||
public static void ToggleIgnore( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser( from, param );
|
||||
public static void ToggleIgnore(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser(from, param);
|
||||
|
||||
if ( target == null )
|
||||
return;
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
if ( from.IsIgnored( target ) )
|
||||
from.RemoveIgnored( target );
|
||||
else
|
||||
from.AddIgnored( target );
|
||||
}
|
||||
if (from.IsIgnored(target))
|
||||
from.RemoveIgnored(target);
|
||||
else
|
||||
from.AddIgnored(target);
|
||||
}
|
||||
|
||||
public static void AddVoice( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser( from, param );
|
||||
public static void AddVoice(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser(from, param);
|
||||
|
||||
if ( target != null )
|
||||
channel.AddVoiced( target, from );
|
||||
}
|
||||
if (target != null)
|
||||
channel.AddVoiced(target, from);
|
||||
}
|
||||
|
||||
public static void RemoveVoice( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser( from, param );
|
||||
public static void RemoveVoice(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser(from, param);
|
||||
|
||||
if ( target != null )
|
||||
channel.RemoveVoiced( target, from );
|
||||
}
|
||||
if (target != null)
|
||||
channel.RemoveVoiced(target, from);
|
||||
}
|
||||
|
||||
public static void ToggleVoice( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser( from, param );
|
||||
public static void ToggleVoice(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser(from, param);
|
||||
|
||||
if ( target == null )
|
||||
return;
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
if ( channel.IsVoiced( target ) )
|
||||
channel.RemoveVoiced( target, from );
|
||||
else
|
||||
channel.AddVoiced( target, from );
|
||||
}
|
||||
if (channel.IsVoiced(target))
|
||||
channel.RemoveVoiced(target, from);
|
||||
else
|
||||
channel.AddVoiced(target, from);
|
||||
}
|
||||
|
||||
public static void AddModerator( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser( from, param );
|
||||
public static void AddModerator(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser(from, param);
|
||||
|
||||
if ( target != null )
|
||||
channel.AddModerator( target, from );
|
||||
}
|
||||
if (target != null)
|
||||
channel.AddModerator(target, from);
|
||||
}
|
||||
|
||||
public static void RemoveModerator( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser( from, param );
|
||||
public static void RemoveModerator(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser(from, param);
|
||||
|
||||
if ( target != null )
|
||||
channel.RemoveModerator( target, from );
|
||||
}
|
||||
if (target != null)
|
||||
channel.RemoveModerator(target, from);
|
||||
}
|
||||
|
||||
public static void ToggleModerator( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser( from, param );
|
||||
public static void ToggleModerator(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser(from, param);
|
||||
|
||||
if ( target == null )
|
||||
return;
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
if ( channel.IsModerator( target ) )
|
||||
channel.RemoveModerator( target, from );
|
||||
else
|
||||
channel.AddModerator( target, from );
|
||||
}
|
||||
if (channel.IsModerator(target))
|
||||
channel.RemoveModerator(target, from);
|
||||
else
|
||||
channel.AddModerator(target, from);
|
||||
}
|
||||
|
||||
public static void RenameChannel( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
channel.Name = param;
|
||||
}
|
||||
public static void RenameChannel(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
channel.Name = param;
|
||||
}
|
||||
|
||||
public static void QueryWhoIs( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser( from, param );
|
||||
public static void QueryWhoIs(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser(from, param);
|
||||
|
||||
if ( target == null )
|
||||
return;
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
if ( target.Anonymous )
|
||||
from.SendMessage( 41, target.Username ); // %1 is remaining anonymous.
|
||||
else
|
||||
from.SendMessage( 43, target.Username, target.Mobile.Name ); // %2 is known in the lands of Britannia as %2.
|
||||
}
|
||||
if (target.Anonymous)
|
||||
from.SendMessage(41, target.Username); // %1 is remaining anonymous.
|
||||
else
|
||||
from.SendMessage(43, target.Username, target.Mobile.Name); // %2 is known in the lands of Britannia as %2.
|
||||
}
|
||||
|
||||
public static void Kick( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser( from, param );
|
||||
public static void Kick(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
ChatUser target = ChatSystem.SearchForUser(from, param);
|
||||
|
||||
if ( target != null )
|
||||
channel.Kick( target, from );
|
||||
}
|
||||
if (target != null)
|
||||
channel.Kick(target, from);
|
||||
}
|
||||
|
||||
public static void EnableDefaultVoice( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
channel.VoiceRestricted = false;
|
||||
}
|
||||
public static void EnableDefaultVoice(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
channel.VoiceRestricted = false;
|
||||
}
|
||||
|
||||
public static void DisableDefaultVoice( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
channel.VoiceRestricted = true;
|
||||
}
|
||||
public static void DisableDefaultVoice(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
channel.VoiceRestricted = true;
|
||||
}
|
||||
|
||||
public static void ToggleDefaultVoice( ChatUser from, Channel channel, string param )
|
||||
{
|
||||
channel.VoiceRestricted = !channel.VoiceRestricted;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void ToggleDefaultVoice(ChatUser from, Channel channel, string param)
|
||||
{
|
||||
channel.VoiceRestricted = !channel.VoiceRestricted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +1,50 @@
|
|||
namespace Server.Engines.Chat
|
||||
{
|
||||
public enum ChatCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Add a channel to top list.
|
||||
/// </summary>
|
||||
AddChannel = 0x3E8,
|
||||
/// <summary>
|
||||
/// Remove channel from top list.
|
||||
/// </summary>
|
||||
RemoveChannel = 0x3E9,
|
||||
/// <summary>
|
||||
/// Queries for a new chat nickname.
|
||||
/// </summary>
|
||||
AskNewNickname = 0x3EB,
|
||||
/// <summary>
|
||||
/// Closes the chat window.
|
||||
/// </summary>
|
||||
CloseChatWindow = 0x3EC,
|
||||
/// <summary>
|
||||
/// Opens the chat window.
|
||||
/// </summary>
|
||||
OpenChatWindow = 0x3ED,
|
||||
/// <summary>
|
||||
/// Add a user to current channel.
|
||||
/// </summary>
|
||||
AddUserToChannel = 0x3EE,
|
||||
/// <summary>
|
||||
/// Remove a user from current channel.
|
||||
/// </summary>
|
||||
RemoveUserFromChannel = 0x3EF,
|
||||
/// <summary>
|
||||
/// Send a message putting generic conference name at top when player leaves a channel.
|
||||
/// </summary>
|
||||
LeaveChannel = 0x3F0,
|
||||
/// <summary>
|
||||
/// Send a message putting Channel name at top and telling player he joined the channel.
|
||||
/// </summary>
|
||||
JoinedChannel = 0x3F1
|
||||
}
|
||||
public enum ChatCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Add a channel to top list.
|
||||
/// </summary>
|
||||
AddChannel = 0x3E8,
|
||||
|
||||
/// <summary>
|
||||
/// Remove channel from top list.
|
||||
/// </summary>
|
||||
RemoveChannel = 0x3E9,
|
||||
|
||||
/// <summary>
|
||||
/// Queries for a new chat nickname.
|
||||
/// </summary>
|
||||
AskNewNickname = 0x3EB,
|
||||
|
||||
/// <summary>
|
||||
/// Closes the chat window.
|
||||
/// </summary>
|
||||
CloseChatWindow = 0x3EC,
|
||||
|
||||
/// <summary>
|
||||
/// Opens the chat window.
|
||||
/// </summary>
|
||||
OpenChatWindow = 0x3ED,
|
||||
|
||||
/// <summary>
|
||||
/// Add a user to current channel.
|
||||
/// </summary>
|
||||
AddUserToChannel = 0x3EE,
|
||||
|
||||
/// <summary>
|
||||
/// Remove a user from current channel.
|
||||
/// </summary>
|
||||
RemoveUserFromChannel = 0x3EF,
|
||||
|
||||
/// <summary>
|
||||
/// Send a message putting generic conference name at top when player leaves a channel.
|
||||
/// </summary>
|
||||
LeaveChannel = 0x3F0,
|
||||
|
||||
/// <summary>
|
||||
/// Send a message putting Channel name at top and telling player he joined the channel.
|
||||
/// </summary>
|
||||
JoinedChannel = 0x3F1
|
||||
}
|
||||
}
|
||||
|
|
@ -3,245 +3,245 @@ using Server.Accounting;
|
|||
|
||||
namespace Server.Engines.Chat
|
||||
{
|
||||
public class ChatUser
|
||||
{
|
||||
public ChatUser( Mobile m )
|
||||
{
|
||||
Mobile = m;
|
||||
Ignored = new List<ChatUser>();
|
||||
Ignoring = new List<ChatUser>();
|
||||
}
|
||||
public class ChatUser
|
||||
{
|
||||
public const char NormalColorCharacter = '0';
|
||||
public const char ModeratorColorCharacter = '1';
|
||||
public const char VoicedColorCharacter = '2';
|
||||
|
||||
public Mobile Mobile { get; }
|
||||
private static List<ChatUser> m_Users = new List<ChatUser>();
|
||||
private static Dictionary<Mobile, ChatUser> m_Table = new Dictionary<Mobile, ChatUser>();
|
||||
|
||||
public List<ChatUser> Ignored { get; }
|
||||
public ChatUser(Mobile m)
|
||||
{
|
||||
Mobile = m;
|
||||
Ignored = new List<ChatUser>();
|
||||
Ignoring = new List<ChatUser>();
|
||||
}
|
||||
|
||||
public List<ChatUser> Ignoring { get; }
|
||||
public Mobile Mobile{ get; }
|
||||
|
||||
public string Username
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( Mobile.Account is Account acct )
|
||||
return acct.GetTag( "ChatName" );
|
||||
public List<ChatUser> Ignored{ get; }
|
||||
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if ( Mobile.Account is Account acct )
|
||||
acct.SetTag( "ChatName", value );
|
||||
}
|
||||
}
|
||||
public List<ChatUser> Ignoring{ get; }
|
||||
|
||||
public Channel CurrentChannel { get; set; }
|
||||
public string Username
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Mobile.Account is Account acct)
|
||||
return acct.GetTag("ChatName");
|
||||
|
||||
public bool IsOnline => ( Mobile.NetState != null );
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (Mobile.Account is Account acct)
|
||||
acct.SetTag("ChatName", value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Anonymous { get; set; }
|
||||
public Channel CurrentChannel{ get; set; }
|
||||
|
||||
public bool IgnorePrivateMessage { get; set; }
|
||||
public bool IsOnline => Mobile.NetState != null;
|
||||
|
||||
public const char NormalColorCharacter = '0';
|
||||
public const char ModeratorColorCharacter = '1';
|
||||
public const char VoicedColorCharacter = '2';
|
||||
public bool Anonymous{ get; set; }
|
||||
|
||||
public char GetColorCharacter()
|
||||
{
|
||||
if ( CurrentChannel != null && CurrentChannel.IsModerator( this ) )
|
||||
return ModeratorColorCharacter;
|
||||
public bool IgnorePrivateMessage{ get; set; }
|
||||
|
||||
if ( CurrentChannel != null && CurrentChannel.IsVoiced( this ) )
|
||||
return VoicedColorCharacter;
|
||||
public bool IsModerator => CurrentChannel != null && CurrentChannel.IsModerator(this);
|
||||
|
||||
return NormalColorCharacter;
|
||||
}
|
||||
public char GetColorCharacter()
|
||||
{
|
||||
if (CurrentChannel != null && CurrentChannel.IsModerator(this))
|
||||
return ModeratorColorCharacter;
|
||||
|
||||
public bool CheckOnline()
|
||||
{
|
||||
if ( IsOnline )
|
||||
return true;
|
||||
if (CurrentChannel != null && CurrentChannel.IsVoiced(this))
|
||||
return VoicedColorCharacter;
|
||||
|
||||
RemoveChatUser( this );
|
||||
return false;
|
||||
}
|
||||
return NormalColorCharacter;
|
||||
}
|
||||
|
||||
public void SendMessage( int number )
|
||||
{
|
||||
SendMessage( number, null, null );
|
||||
}
|
||||
public bool CheckOnline()
|
||||
{
|
||||
if (IsOnline)
|
||||
return true;
|
||||
|
||||
public void SendMessage( int number, string param1 )
|
||||
{
|
||||
SendMessage( number, param1, null );
|
||||
}
|
||||
RemoveChatUser(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SendMessage( int number, string param1, string param2 )
|
||||
{
|
||||
if ( Mobile.NetState != null )
|
||||
Mobile.Send( new ChatMessagePacket( Mobile, number, param1, param2 ) );
|
||||
}
|
||||
public void SendMessage(int number)
|
||||
{
|
||||
SendMessage(number, null, null);
|
||||
}
|
||||
|
||||
public void SendMessage( int number, Mobile from, string param1, string param2 )
|
||||
{
|
||||
if ( Mobile.NetState != null )
|
||||
Mobile.Send( new ChatMessagePacket( from, number, param1, param2 ) );
|
||||
}
|
||||
public void SendMessage(int number, string param1)
|
||||
{
|
||||
SendMessage(number, param1, null);
|
||||
}
|
||||
|
||||
public bool IsIgnored( ChatUser check )
|
||||
{
|
||||
return Ignored.Contains( check );
|
||||
}
|
||||
public void SendMessage(int number, string param1, string param2)
|
||||
{
|
||||
if (Mobile.NetState != null)
|
||||
Mobile.Send(new ChatMessagePacket(Mobile, number, param1, param2));
|
||||
}
|
||||
|
||||
public bool IsModerator => ( CurrentChannel != null && CurrentChannel.IsModerator( this ) );
|
||||
public void SendMessage(int number, Mobile from, string param1, string param2)
|
||||
{
|
||||
if (Mobile.NetState != null)
|
||||
Mobile.Send(new ChatMessagePacket(from, number, param1, param2));
|
||||
}
|
||||
|
||||
public void AddIgnored( ChatUser user )
|
||||
{
|
||||
if ( IsIgnored( user ) )
|
||||
{
|
||||
SendMessage( 22, user.Username ); // You are already ignoring %1.
|
||||
}
|
||||
else
|
||||
{
|
||||
Ignored.Add( user );
|
||||
user.Ignoring.Add( this );
|
||||
public bool IsIgnored(ChatUser check)
|
||||
{
|
||||
return Ignored.Contains(check);
|
||||
}
|
||||
|
||||
SendMessage( 23, user.Username ); // You are now ignoring %1.
|
||||
}
|
||||
}
|
||||
public void AddIgnored(ChatUser user)
|
||||
{
|
||||
if (IsIgnored(user))
|
||||
{
|
||||
SendMessage(22, user.Username); // You are already ignoring %1.
|
||||
}
|
||||
else
|
||||
{
|
||||
Ignored.Add(user);
|
||||
user.Ignoring.Add(this);
|
||||
|
||||
public void RemoveIgnored( ChatUser user )
|
||||
{
|
||||
if ( IsIgnored( user ) )
|
||||
{
|
||||
Ignored.Remove( user );
|
||||
user.Ignoring.Remove( this );
|
||||
SendMessage(23, user.Username); // You are now ignoring %1.
|
||||
}
|
||||
}
|
||||
|
||||
SendMessage( 24, user.Username ); // You are no longer ignoring %1.
|
||||
public void RemoveIgnored(ChatUser user)
|
||||
{
|
||||
if (IsIgnored(user))
|
||||
{
|
||||
Ignored.Remove(user);
|
||||
user.Ignoring.Remove(this);
|
||||
|
||||
if ( Ignored.Count == 0 )
|
||||
SendMessage( 26 ); // You are no longer ignoring anyone.
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessage( 25, user.Username ); // You are not ignoring %1.
|
||||
}
|
||||
}
|
||||
SendMessage(24, user.Username); // You are no longer ignoring %1.
|
||||
|
||||
private static List<ChatUser> m_Users = new List<ChatUser>();
|
||||
private static Dictionary<Mobile, ChatUser> m_Table = new Dictionary<Mobile, ChatUser>();
|
||||
if (Ignored.Count == 0)
|
||||
SendMessage(26); // You are no longer ignoring anyone.
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessage(25, user.Username); // You are not ignoring %1.
|
||||
}
|
||||
}
|
||||
|
||||
public static ChatUser AddChatUser( Mobile from )
|
||||
{
|
||||
ChatUser user = GetChatUser( from );
|
||||
public static ChatUser AddChatUser(Mobile from)
|
||||
{
|
||||
ChatUser user = GetChatUser(from);
|
||||
|
||||
if ( user == null )
|
||||
{
|
||||
user = new ChatUser( from );
|
||||
if (user == null)
|
||||
{
|
||||
user = new ChatUser(from);
|
||||
|
||||
m_Users.Add( user );
|
||||
m_Table[from] = user;
|
||||
m_Users.Add(user);
|
||||
m_Table[from] = user;
|
||||
|
||||
Channel.SendChannelsTo( user );
|
||||
Channel.SendChannelsTo(user);
|
||||
|
||||
List<Channel> list = Channel.Channels;
|
||||
List<Channel> list = Channel.Channels;
|
||||
|
||||
for ( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
Channel c = list[i];
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
Channel c = list[i];
|
||||
|
||||
if ( c.AddUser( user ) )
|
||||
break;
|
||||
}
|
||||
if (c.AddUser(user))
|
||||
break;
|
||||
}
|
||||
|
||||
//ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
|
||||
}
|
||||
//ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
public static void RemoveChatUser( ChatUser user )
|
||||
{
|
||||
if ( user == null )
|
||||
return;
|
||||
public static void RemoveChatUser(ChatUser user)
|
||||
{
|
||||
if (user == null)
|
||||
return;
|
||||
|
||||
for ( int i = 0; i < user.Ignoring.Count; ++i )
|
||||
user.Ignoring[i].RemoveIgnored( user );
|
||||
for (int i = 0; i < user.Ignoring.Count; ++i)
|
||||
user.Ignoring[i].RemoveIgnored(user);
|
||||
|
||||
if ( m_Users.Contains( user ) )
|
||||
{
|
||||
ChatSystem.SendCommandTo( user.Mobile, ChatCommand.CloseChatWindow );
|
||||
if (m_Users.Contains(user))
|
||||
{
|
||||
ChatSystem.SendCommandTo(user.Mobile, ChatCommand.CloseChatWindow);
|
||||
|
||||
user.CurrentChannel?.RemoveUser( user );
|
||||
user.CurrentChannel?.RemoveUser(user);
|
||||
|
||||
m_Users.Remove( user );
|
||||
m_Table.Remove( user.Mobile );
|
||||
}
|
||||
}
|
||||
m_Users.Remove(user);
|
||||
m_Table.Remove(user.Mobile);
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveChatUser( Mobile from )
|
||||
{
|
||||
ChatUser user = GetChatUser( from );
|
||||
public static void RemoveChatUser(Mobile from)
|
||||
{
|
||||
ChatUser user = GetChatUser(from);
|
||||
|
||||
RemoveChatUser( user );
|
||||
}
|
||||
RemoveChatUser(user);
|
||||
}
|
||||
|
||||
public static ChatUser GetChatUser( Mobile from )
|
||||
{
|
||||
m_Table.TryGetValue( from, out ChatUser c );
|
||||
return c;
|
||||
}
|
||||
public static ChatUser GetChatUser(Mobile from)
|
||||
{
|
||||
m_Table.TryGetValue(from, out ChatUser c);
|
||||
return c;
|
||||
}
|
||||
|
||||
public static ChatUser GetChatUser( string username )
|
||||
{
|
||||
for ( int i = 0; i < m_Users.Count; ++i )
|
||||
{
|
||||
ChatUser user = m_Users[i];
|
||||
public static ChatUser GetChatUser(string username)
|
||||
{
|
||||
for (int i = 0; i < m_Users.Count; ++i)
|
||||
{
|
||||
ChatUser user = m_Users[i];
|
||||
|
||||
if ( user.Username == username )
|
||||
return user;
|
||||
}
|
||||
if (user.Username == username)
|
||||
return user;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void GlobalSendCommand( ChatCommand command )
|
||||
{
|
||||
GlobalSendCommand( command, null, null, null );
|
||||
}
|
||||
public static void GlobalSendCommand(ChatCommand command)
|
||||
{
|
||||
GlobalSendCommand(command, null, null, null);
|
||||
}
|
||||
|
||||
public static void GlobalSendCommand( ChatCommand command, string param1 )
|
||||
{
|
||||
GlobalSendCommand( command, null, param1, null );
|
||||
}
|
||||
public static void GlobalSendCommand(ChatCommand command, string param1)
|
||||
{
|
||||
GlobalSendCommand(command, null, param1, null);
|
||||
}
|
||||
|
||||
public static void GlobalSendCommand( ChatCommand command, string param1, string param2 )
|
||||
{
|
||||
GlobalSendCommand( command, null, param1, param2 );
|
||||
}
|
||||
public static void GlobalSendCommand(ChatCommand command, string param1, string param2)
|
||||
{
|
||||
GlobalSendCommand(command, null, param1, param2);
|
||||
}
|
||||
|
||||
public static void GlobalSendCommand( ChatCommand command, ChatUser initiator )
|
||||
{
|
||||
GlobalSendCommand( command, initiator, null, null );
|
||||
}
|
||||
public static void GlobalSendCommand(ChatCommand command, ChatUser initiator)
|
||||
{
|
||||
GlobalSendCommand(command, initiator, null, null);
|
||||
}
|
||||
|
||||
public static void GlobalSendCommand( ChatCommand command, ChatUser initiator, string param1 )
|
||||
{
|
||||
GlobalSendCommand( command, initiator, param1, null );
|
||||
}
|
||||
public static void GlobalSendCommand(ChatCommand command, ChatUser initiator, string param1)
|
||||
{
|
||||
GlobalSendCommand(command, initiator, param1, null);
|
||||
}
|
||||
|
||||
public static void GlobalSendCommand( ChatCommand command, ChatUser initiator, string param1, string param2 )
|
||||
{
|
||||
for ( int i = 0; i < m_Users.Count; ++i )
|
||||
{
|
||||
ChatUser user = m_Users[i];
|
||||
public static void GlobalSendCommand(ChatCommand command, ChatUser initiator, string param1, string param2)
|
||||
{
|
||||
for (int i = 0; i < m_Users.Count; ++i)
|
||||
{
|
||||
ChatUser user = m_Users[i];
|
||||
|
||||
if ( user == initiator )
|
||||
continue;
|
||||
if (user == initiator)
|
||||
continue;
|
||||
|
||||
if ( user.CheckOnline() )
|
||||
ChatSystem.SendCommandTo( user.Mobile, command, param1, param2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (user.CheckOnline())
|
||||
ChatSystem.SendCommandTo(user.Mobile, command, param1, param2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
namespace Server.Chat
|
||||
{
|
||||
public class ChatSystem
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.ChatRequest += EventSink_ChatRequest;
|
||||
}
|
||||
public class ChatSystem
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
EventSink.ChatRequest += EventSink_ChatRequest;
|
||||
}
|
||||
|
||||
private static void EventSink_ChatRequest( ChatRequestEventArgs e )
|
||||
{
|
||||
e.Mobile.SendMessage( "Chat is not currently supported." );
|
||||
}
|
||||
}
|
||||
private static void EventSink_ChatRequest(ChatRequestEventArgs e)
|
||||
{
|
||||
e.Mobile.SendMessage("Chat is not currently supported.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +1,28 @@
|
|||
using System;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.Chat
|
||||
{
|
||||
public sealed class ChatMessagePacket : Packet
|
||||
{
|
||||
public ChatMessagePacket( Mobile who, int number, string param1, string param2 ) : base( 0xB2 )
|
||||
{
|
||||
if ( param1 == null )
|
||||
param1 = string.Empty;
|
||||
public sealed class ChatMessagePacket : Packet
|
||||
{
|
||||
public ChatMessagePacket(Mobile who, int number, string param1, string param2) : base(0xB2)
|
||||
{
|
||||
if (param1 == null)
|
||||
param1 = string.Empty;
|
||||
|
||||
if ( param2 == null )
|
||||
param2 = string.Empty;
|
||||
if (param2 == null)
|
||||
param2 = string.Empty;
|
||||
|
||||
EnsureCapacity( 13 + ((param1.Length + param2.Length) * 2) );
|
||||
EnsureCapacity(13 + (param1.Length + param2.Length) * 2);
|
||||
|
||||
m_Stream.Write( (ushort) (number - 20) );
|
||||
m_Stream.Write((ushort)(number - 20));
|
||||
|
||||
if ( who != null )
|
||||
m_Stream.WriteAsciiFixed( who.Language, 4 );
|
||||
else
|
||||
m_Stream.Write( (int) 0 );
|
||||
if (who != null)
|
||||
m_Stream.WriteAsciiFixed(who.Language, 4);
|
||||
else
|
||||
m_Stream.Write(0);
|
||||
|
||||
m_Stream.WriteBigUniNull( param1 );
|
||||
m_Stream.WriteBigUniNull( param2 );
|
||||
}
|
||||
}
|
||||
m_Stream.WriteBigUniNull(param1);
|
||||
m_Stream.WriteBigUniNull(param2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue