Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)

This commit is contained in:
Kamron Batman 2019-03-11 14:29:59 -07:00 committed by GitHub
parent e748af4430
commit 513e54f70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1094 changed files with 15913 additions and 21892 deletions

View file

@ -49,17 +49,12 @@ namespace Server.Engines.Chat
public bool IgnorePrivateMessage{ get; set; }
public bool IsModerator => CurrentChannel != null && CurrentChannel.IsModerator(this);
public bool IsModerator => CurrentChannel?.IsModerator(this) == true;
public char GetColorCharacter()
{
if (CurrentChannel != null && CurrentChannel.IsModerator(this))
return ModeratorColorCharacter;
if (CurrentChannel != null && CurrentChannel.IsVoiced(this))
return VoicedColorCharacter;
return NormalColorCharacter;
return IsModerator ? ModeratorColorCharacter :
CurrentChannel?.IsVoiced(this) == true ? VoicedColorCharacter : NormalColorCharacter;
}
public bool CheckOnline()
@ -71,17 +66,7 @@ namespace Server.Engines.Chat
return false;
}
public void SendMessage(int number)
{
SendMessage(number, null, null);
}
public void SendMessage(int number, string param1)
{
SendMessage(number, param1, null);
}
public void SendMessage(int number, string param1, string param2)
public void SendMessage(int number, string param1 = null, string param2 = null)
{
if (Mobile.NetState != null)
Mobile.Send(new ChatMessagePacket(Mobile, number, param1, param2));
@ -135,28 +120,28 @@ namespace Server.Engines.Chat
{
ChatUser user = GetChatUser(from);
if (user == null)
if (user != null)
return user;
user = new ChatUser(from);
m_Users.Add(user);
m_Table[from] = user;
Channel.SendChannelsTo(user);
List<Channel> list = Channel.Channels;
for (int i = 0; i < list.Count; ++i)
{
user = new ChatUser(from);
Channel c = list[i];
m_Users.Add(user);
m_Table[from] = user;
Channel.SendChannelsTo(user);
List<Channel> list = Channel.Channels;
for (int i = 0; i < list.Count; ++i)
{
Channel c = list[i];
if (c.AddUser(user))
break;
}
//ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
if (c.AddUser(user))
break;
}
//ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
return user;
}
@ -205,32 +190,12 @@ namespace Server.Engines.Chat
return 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, string param2)
public static void GlobalSendCommand(ChatCommand command, string param1, string param2 = null)
{
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, string param1)
{
GlobalSendCommand(command, initiator, param1, null);
}
public static void GlobalSendCommand(ChatCommand command, ChatUser initiator, string param1, string param2)
public static void GlobalSendCommand(ChatCommand command, ChatUser initiator = null, string param1 = null, string param2 = null)
{
for (int i = 0; i < m_Users.Count; ++i)
{
@ -244,4 +209,4 @@ namespace Server.Engines.Chat
}
}
}
}
}