Changes properties to use automatic property initializers
This commit is contained in:
parent
f0a48ad431
commit
06fa31a7bf
623 changed files with 13072 additions and 19304 deletions
|
|
@ -9,7 +9,6 @@ namespace Server.Engines.Chat
|
|||
private string m_Password;
|
||||
private List<ChatUser> m_Users, m_Banned, m_Moderators, m_Voices;
|
||||
private bool m_VoiceRestricted;
|
||||
private bool m_AlwaysAvailable;
|
||||
|
||||
public Channel( string name )
|
||||
{
|
||||
|
|
@ -141,7 +140,7 @@ namespace Server.Engines.Chat
|
|||
m_Users.Add( user );
|
||||
user.CurrentChannel = this;
|
||||
|
||||
if ( user.Mobile.AccessLevel >= AccessLevel.GameMaster || (!m_AlwaysAvailable && m_Users.Count == 1) )
|
||||
if ( user.Mobile.AccessLevel >= AccessLevel.GameMaster || (!AlwaysAvailable && m_Users.Count == 1) )
|
||||
AddModerator( user );
|
||||
|
||||
SendUsersTo( user );
|
||||
|
|
@ -165,7 +164,7 @@ namespace Server.Engines.Chat
|
|||
SendCommand( ChatCommand.RemoveUserFromChannel, user, user.Username );
|
||||
ChatSystem.SendCommandTo( user.Mobile, ChatCommand.LeaveChannel );
|
||||
|
||||
if ( m_Users.Count == 0 && !m_AlwaysAvailable )
|
||||
if ( m_Users.Count == 0 && !AlwaysAvailable )
|
||||
RemoveChannel( this );
|
||||
}
|
||||
}
|
||||
|
|
@ -241,11 +240,7 @@ namespace Server.Engines.Chat
|
|||
}
|
||||
}
|
||||
|
||||
public bool AlwaysAvailable
|
||||
{
|
||||
get => m_AlwaysAvailable;
|
||||
set => m_AlwaysAvailable = value;
|
||||
}
|
||||
public bool AlwaysAvailable { get; set; }
|
||||
|
||||
public void AddVoiced( ChatUser user )
|
||||
{
|
||||
|
|
@ -441,15 +436,13 @@ namespace Server.Engines.Chat
|
|||
}
|
||||
}
|
||||
|
||||
private static List<Channel> m_Channels = new List<Channel>();
|
||||
|
||||
public static List<Channel> Channels => m_Channels;
|
||||
public static List<Channel> Channels { get; } = new List<Channel>();
|
||||
|
||||
public static void SendChannelsTo( ChatUser user )
|
||||
{
|
||||
for ( int i = 0; i < m_Channels.Count; ++i )
|
||||
for ( int i = 0; i < Channels.Count; ++i )
|
||||
{
|
||||
Channel channel = m_Channels[i];
|
||||
Channel channel = Channels[i];
|
||||
|
||||
if ( !channel.IsBanned( user ) )
|
||||
ChatSystem.SendCommandTo( user.Mobile, ChatCommand.AddChannel, channel.Name, "0" );
|
||||
|
|
@ -468,7 +461,7 @@ namespace Server.Engines.Chat
|
|||
if ( channel == null )
|
||||
{
|
||||
channel = new Channel( name, password );
|
||||
m_Channels.Add( channel );
|
||||
Channels.Add( channel );
|
||||
}
|
||||
|
||||
ChatUser.GlobalSendCommand( ChatCommand.AddChannel, name, "0" ) ;
|
||||
|
|
@ -486,22 +479,22 @@ namespace Server.Engines.Chat
|
|||
if ( channel == null )
|
||||
return;
|
||||
|
||||
if ( m_Channels.Contains( channel ) && channel.m_Users.Count == 0 )
|
||||
if ( Channels.Contains( channel ) && channel.m_Users.Count == 0 )
|
||||
{
|
||||
ChatUser.GlobalSendCommand( ChatCommand.RemoveChannel, channel.Name ) ;
|
||||
|
||||
channel.m_Moderators.Clear();
|
||||
channel.m_Voices.Clear();
|
||||
|
||||
m_Channels.Remove( channel );
|
||||
Channels.Remove( channel );
|
||||
}
|
||||
}
|
||||
|
||||
public static Channel FindChannelByName( string name )
|
||||
{
|
||||
for ( int i = 0; i < m_Channels.Count; ++i )
|
||||
for ( int i = 0; i < Channels.Count; ++i )
|
||||
{
|
||||
Channel channel = m_Channels[i];
|
||||
Channel channel = Channels[i];
|
||||
|
||||
if ( channel.m_Name == name )
|
||||
return channel;
|
||||
|
|
|
|||
|
|
@ -7,13 +7,7 @@ namespace Server.Engines.Chat
|
|||
{
|
||||
public class ChatSystem
|
||||
{
|
||||
private static bool m_Enabled = true;
|
||||
|
||||
public static bool Enabled
|
||||
{
|
||||
get => m_Enabled;
|
||||
set => m_Enabled = value;
|
||||
}
|
||||
public static bool Enabled { get; set; } = true;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
|
|
@ -40,7 +34,7 @@ namespace Server.Engines.Chat
|
|||
{
|
||||
Mobile from = state.Mobile;
|
||||
|
||||
if ( !m_Enabled )
|
||||
if ( !Enabled )
|
||||
{
|
||||
from.SendMessage( "The chat system has been disabled." );
|
||||
return;
|
||||
|
|
@ -120,7 +114,7 @@ namespace Server.Engines.Chat
|
|||
|
||||
public static void ChatAction( NetState state, PacketReader pvSrc )
|
||||
{
|
||||
if ( !m_Enabled )
|
||||
if ( !Enabled )
|
||||
return;
|
||||
|
||||
try
|
||||
|
|
|
|||
|
|
@ -4,19 +4,17 @@ namespace Server.Engines.Chat
|
|||
|
||||
public class ChatActionHandler
|
||||
{
|
||||
private bool m_RequireModerator;
|
||||
private bool m_RequireConference;
|
||||
private OnChatAction m_Callback;
|
||||
public bool RequireModerator { get; }
|
||||
|
||||
public bool RequireModerator => m_RequireModerator;
|
||||
public bool RequireConference => m_RequireConference;
|
||||
public OnChatAction Callback => m_Callback;
|
||||
public bool RequireConference { get; }
|
||||
|
||||
public OnChatAction Callback { get; }
|
||||
|
||||
public ChatActionHandler( bool requireModerator, bool requireConference, OnChatAction callback )
|
||||
{
|
||||
m_RequireModerator = requireModerator;
|
||||
m_RequireConference = requireConference;
|
||||
m_Callback = callback;
|
||||
RequireModerator = requireModerator;
|
||||
RequireConference = requireConference;
|
||||
Callback = callback;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,60 +5,42 @@ namespace Server.Engines.Chat
|
|||
{
|
||||
public class ChatUser
|
||||
{
|
||||
private Mobile m_Mobile;
|
||||
private Channel m_Channel;
|
||||
private bool m_Anonymous;
|
||||
private bool m_IgnorePrivateMessage;
|
||||
private List<ChatUser> m_Ignored, m_Ignoring;
|
||||
|
||||
public ChatUser( Mobile m )
|
||||
{
|
||||
m_Mobile = m;
|
||||
m_Ignored = new List<ChatUser>();
|
||||
m_Ignoring = new List<ChatUser>();
|
||||
Mobile = m;
|
||||
Ignored = new List<ChatUser>();
|
||||
Ignoring = new List<ChatUser>();
|
||||
}
|
||||
|
||||
public Mobile Mobile => m_Mobile;
|
||||
public Mobile Mobile { get; }
|
||||
|
||||
public List<ChatUser> Ignored => m_Ignored;
|
||||
public List<ChatUser> Ignored { get; }
|
||||
|
||||
public List<ChatUser> Ignoring => m_Ignoring;
|
||||
public List<ChatUser> Ignoring { get; }
|
||||
|
||||
public string Username
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( m_Mobile.Account is Account acct )
|
||||
if ( Mobile.Account is Account acct )
|
||||
return acct.GetTag( "ChatName" );
|
||||
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if ( m_Mobile.Account is Account acct )
|
||||
if ( Mobile.Account is Account acct )
|
||||
acct.SetTag( "ChatName", value );
|
||||
}
|
||||
}
|
||||
|
||||
public Channel CurrentChannel
|
||||
{
|
||||
get => m_Channel;
|
||||
set => m_Channel = value;
|
||||
}
|
||||
public Channel CurrentChannel { get; set; }
|
||||
|
||||
public bool IsOnline => ( m_Mobile.NetState != null );
|
||||
public bool IsOnline => ( Mobile.NetState != null );
|
||||
|
||||
public bool Anonymous
|
||||
{
|
||||
get => m_Anonymous;
|
||||
set => m_Anonymous = value;
|
||||
}
|
||||
public bool Anonymous { get; set; }
|
||||
|
||||
public bool IgnorePrivateMessage
|
||||
{
|
||||
get => m_IgnorePrivateMessage;
|
||||
set => m_IgnorePrivateMessage = value;
|
||||
}
|
||||
public bool IgnorePrivateMessage { get; set; }
|
||||
|
||||
public const char NormalColorCharacter = '0';
|
||||
public const char ModeratorColorCharacter = '1';
|
||||
|
|
@ -66,10 +48,10 @@ namespace Server.Engines.Chat
|
|||
|
||||
public char GetColorCharacter()
|
||||
{
|
||||
if ( m_Channel != null && m_Channel.IsModerator( this ) )
|
||||
if ( CurrentChannel != null && CurrentChannel.IsModerator( this ) )
|
||||
return ModeratorColorCharacter;
|
||||
|
||||
if ( m_Channel != null && m_Channel.IsVoiced( this ) )
|
||||
if ( CurrentChannel != null && CurrentChannel.IsVoiced( this ) )
|
||||
return VoicedColorCharacter;
|
||||
|
||||
return NormalColorCharacter;
|
||||
|
|
@ -96,22 +78,22 @@ namespace Server.Engines.Chat
|
|||
|
||||
public void SendMessage( int number, string param1, string param2 )
|
||||
{
|
||||
if ( m_Mobile.NetState != null )
|
||||
m_Mobile.Send( new ChatMessagePacket( m_Mobile, number, param1, param2 ) );
|
||||
if ( Mobile.NetState != null )
|
||||
Mobile.Send( new ChatMessagePacket( Mobile, number, param1, param2 ) );
|
||||
}
|
||||
|
||||
public void SendMessage( int number, Mobile from, string param1, string param2 )
|
||||
{
|
||||
if ( m_Mobile.NetState != null )
|
||||
m_Mobile.Send( new ChatMessagePacket( from, number, param1, param2 ) );
|
||||
if ( Mobile.NetState != null )
|
||||
Mobile.Send( new ChatMessagePacket( from, number, param1, param2 ) );
|
||||
}
|
||||
|
||||
public bool IsIgnored( ChatUser check )
|
||||
{
|
||||
return m_Ignored.Contains( check );
|
||||
return Ignored.Contains( check );
|
||||
}
|
||||
|
||||
public bool IsModerator => ( m_Channel != null && m_Channel.IsModerator( this ) );
|
||||
public bool IsModerator => ( CurrentChannel != null && CurrentChannel.IsModerator( this ) );
|
||||
|
||||
public void AddIgnored( ChatUser user )
|
||||
{
|
||||
|
|
@ -121,8 +103,8 @@ namespace Server.Engines.Chat
|
|||
}
|
||||
else
|
||||
{
|
||||
m_Ignored.Add( user );
|
||||
user.m_Ignoring.Add( this );
|
||||
Ignored.Add( user );
|
||||
user.Ignoring.Add( this );
|
||||
|
||||
SendMessage( 23, user.Username ); // You are now ignoring %1.
|
||||
}
|
||||
|
|
@ -132,12 +114,12 @@ namespace Server.Engines.Chat
|
|||
{
|
||||
if ( IsIgnored( user ) )
|
||||
{
|
||||
m_Ignored.Remove( user );
|
||||
user.m_Ignoring.Remove( this );
|
||||
Ignored.Remove( user );
|
||||
user.Ignoring.Remove( this );
|
||||
|
||||
SendMessage( 24, user.Username ); // You are no longer ignoring %1.
|
||||
|
||||
if ( m_Ignored.Count == 0 )
|
||||
if ( Ignored.Count == 0 )
|
||||
SendMessage( 26 ); // You are no longer ignoring anyone.
|
||||
}
|
||||
else
|
||||
|
|
@ -183,17 +165,17 @@ namespace Server.Engines.Chat
|
|||
if ( user == null )
|
||||
return;
|
||||
|
||||
for ( int i = 0; i < user.m_Ignoring.Count; ++i )
|
||||
user.m_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 );
|
||||
|
||||
user.m_Channel?.RemoveUser( user );
|
||||
user.CurrentChannel?.RemoveUser( user );
|
||||
|
||||
m_Users.Remove( user );
|
||||
m_Table.Remove( user.m_Mobile );
|
||||
m_Table.Remove( user.Mobile );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -258,7 +240,7 @@ namespace Server.Engines.Chat
|
|||
continue;
|
||||
|
||||
if ( user.CheckOnline() )
|
||||
ChatSystem.SendCommandTo( user.m_Mobile, command, param1, param2 );
|
||||
ChatSystem.SendCommandTo( user.Mobile, command, param1, param2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue