786 lines
27 KiB
C#
786 lines
27 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Collections;
|
|
using Server;
|
|
using Server.Accounting;
|
|
|
|
namespace Knives.Chat3
|
|
{
|
|
public enum OnlineStatus { Online, Away, Busy, Hidden }
|
|
|
|
public class Data
|
|
{
|
|
public static void Save()
|
|
{
|
|
foreach (Mobile m in new ArrayList(s_Datas.Keys))
|
|
if (m.Deleted)
|
|
s_Datas.Remove(m);
|
|
|
|
if (!Directory.Exists("Saves/Chat/"))
|
|
Directory.CreateDirectory("Saves/Chat/");
|
|
|
|
GenericWriter writer = new BinaryFileWriter(Path.Combine("Saves/Chat/", "Chat34.bin"), true);
|
|
|
|
writer.Write(0); // version
|
|
|
|
writer.Write(s_Filters.Count);
|
|
foreach (string str in s_Filters)
|
|
writer.Write(str);
|
|
|
|
writer.Write((int)s_FilterPenalty);
|
|
writer.Write(s_MaxMsgs);
|
|
writer.Write(s_ChatSpam);
|
|
writer.Write(s_MsgSpam);
|
|
writer.Write(s_RequestSpam);
|
|
writer.Write(s_FilterBanLength);
|
|
writer.Write(s_IrcPort);
|
|
writer.Write(s_IrcMaxAttempts);
|
|
writer.Write(s_ShowStaff);
|
|
writer.Write(s_IrcEnabled);
|
|
writer.Write(s_IrcAutoConnect);
|
|
writer.Write(s_IrcAutoReconnect);
|
|
writer.Write(s_FilterSpeech);
|
|
writer.Write(s_FilterMsg);
|
|
writer.Write((int)s_IrcStaffColor);
|
|
writer.Write(s_IrcServer);
|
|
writer.Write(s_IrcRoom);
|
|
writer.Write(s_IrcNick);
|
|
|
|
foreach (Data data in new ArrayList(s_Datas.Values))
|
|
if (data.Mobile.Player && ((Account)data.Mobile.Account).LastLogin < DateTime.Now - TimeSpan.FromDays(30))
|
|
s_Datas.Remove(data.Mobile);
|
|
|
|
writer.Write(s_Datas.Count);
|
|
foreach (Data data in s_Datas.Values)
|
|
data.Save(writer);
|
|
|
|
writer.Close();
|
|
}
|
|
|
|
public static void Load()
|
|
{
|
|
if ( !File.Exists( Path.Combine( "Saves/Chat/", "Chat34.bin" ) ) )
|
|
return;
|
|
|
|
using (FileStream bin = new FileStream(Path.Combine("Saves/Chat/", "Chat34.bin"), FileMode.Open, FileAccess.Read, FileShare.Read))
|
|
{
|
|
GenericReader reader = new BinaryFileReader(new BinaryReader(bin));
|
|
|
|
int version = reader.ReadInt();
|
|
|
|
int count = reader.ReadInt();
|
|
for(int i = 0; i < count; ++i )
|
|
s_Filters.Add(reader.ReadString());
|
|
|
|
s_FilterPenalty = (FilterPenalty)reader.ReadInt();
|
|
s_MaxMsgs = reader.ReadInt();
|
|
s_ChatSpam = reader.ReadInt();
|
|
s_MsgSpam = reader.ReadInt();
|
|
s_RequestSpam = reader.ReadInt();
|
|
s_FilterBanLength = reader.ReadInt();
|
|
s_IrcPort = reader.ReadInt();
|
|
s_IrcMaxAttempts = reader.ReadInt();
|
|
s_ShowStaff = reader.ReadBool();
|
|
s_IrcEnabled = reader.ReadBool();
|
|
s_IrcAutoConnect = reader.ReadBool();
|
|
s_IrcAutoReconnect = reader.ReadBool();
|
|
s_FilterSpeech = reader.ReadBool();
|
|
s_FilterMsg = reader.ReadBool();
|
|
s_IrcStaffColor = (IrcColor)reader.ReadInt();
|
|
s_IrcServer = reader.ReadString();
|
|
s_IrcRoom = reader.ReadString();
|
|
s_IrcNick = reader.ReadString();
|
|
|
|
count = reader.ReadInt();
|
|
Data data;
|
|
for (int i = 0; i < count; ++i)
|
|
{
|
|
data = new Data();
|
|
data.Load(reader);
|
|
|
|
if (data.Mobile != null)
|
|
s_Datas[data.Mobile] = data;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
#region Static Definitions
|
|
|
|
private static Hashtable s_Datas = new Hashtable();
|
|
private static ArrayList s_Filters = new ArrayList();
|
|
private static ArrayList s_IrcList = new ArrayList();
|
|
private static FilterPenalty s_FilterPenalty;
|
|
private static int s_MaxMsgs = 50;
|
|
private static int s_ChatSpam = 2;
|
|
private static int s_MsgSpam = 5;
|
|
private static int s_RequestSpam = 24;
|
|
private static int s_FilterBanLength = 5;
|
|
private static int s_IrcPort = 6667;
|
|
private static int s_IrcMaxAttempts = 3;
|
|
private static bool s_ShowStaff = false;
|
|
private static bool s_IrcEnabled = false;
|
|
private static bool s_IrcAutoConnect = false;
|
|
private static bool s_IrcAutoReconnect = false;
|
|
private static bool s_FilterSpeech = false;
|
|
private static bool s_FilterMsg = false;
|
|
private static IrcColor s_IrcStaffColor = IrcColor.Black;
|
|
private static string s_IrcServer = "";
|
|
private static string s_IrcRoom = "";
|
|
private static string s_IrcNick = Server.Misc.ServerList.ServerName;
|
|
|
|
public static Hashtable Datas { get { return s_Datas; } }
|
|
public static ArrayList Filters { get { return s_Filters; } }
|
|
public static ArrayList IrcList { get { return s_IrcList; } }
|
|
public static FilterPenalty FilterPenalty { get { return s_FilterPenalty; } set { s_FilterPenalty = value; } }
|
|
public static int MaxMsgs { get { return s_MaxMsgs; } set { s_MaxMsgs = value; } }
|
|
public static int ChatSpam { get { return s_ChatSpam; } set { s_ChatSpam = value; } }
|
|
public static int MsgSpam { get { return s_MsgSpam; } set { s_MsgSpam = value; } }
|
|
public static int RequestSpam { get { return s_RequestSpam; } set { s_RequestSpam = value; } }
|
|
public static int FilterBanLength { get { return s_FilterBanLength; } set { s_FilterBanLength = value; } }
|
|
public static int IrcPort { get { return s_IrcPort; } set { s_IrcPort = value; } }
|
|
public static int IrcMaxAttempts { get { return s_IrcMaxAttempts; } set { s_IrcMaxAttempts = value; } }
|
|
public static bool ShowStaff { get { return s_ShowStaff; } set { s_ShowStaff = value; } }
|
|
public static bool IrcAutoConnect { get { return s_IrcAutoConnect; } set { s_IrcAutoConnect = value; } }
|
|
public static bool IrcAutoReconnect { get { return s_IrcAutoReconnect; } set { s_IrcAutoReconnect = value; } }
|
|
public static bool FilterSpeech { get { return s_FilterSpeech; } set { s_FilterSpeech = value; } }
|
|
public static bool FilterMsg { get { return s_FilterMsg; } set { s_FilterMsg = value; } }
|
|
public static string IrcServer { get { return s_IrcServer; } set { s_IrcServer = value; } }
|
|
public static string IrcNick { get { return s_IrcNick; } set { s_IrcNick = value; } }
|
|
|
|
public static bool IrcEnabled
|
|
{
|
|
get { return s_IrcEnabled; }
|
|
set
|
|
{
|
|
s_IrcEnabled = value;
|
|
if (!value)
|
|
{
|
|
IrcConnection.Connection.CancelConnect();
|
|
IrcConnection.Connection.Disconnect(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static IrcColor IrcStaffColor
|
|
{
|
|
get { return s_IrcStaffColor; }
|
|
set
|
|
{
|
|
if ((int)value > 15)
|
|
value = (IrcColor)0;
|
|
|
|
if ((int)value < 0)
|
|
value = (IrcColor)15;
|
|
|
|
s_IrcStaffColor = value;
|
|
}
|
|
}
|
|
|
|
public static Data GetData(Mobile m)
|
|
{
|
|
if (s_Datas[m] == null)
|
|
return new Data(m);
|
|
|
|
return (Data)s_Datas[m];
|
|
}
|
|
|
|
public static string IrcRoom
|
|
{
|
|
get { return s_IrcRoom; }
|
|
set
|
|
{
|
|
s_IrcRoom = value;
|
|
|
|
if (s_IrcRoom.IndexOf("#") != 0)
|
|
s_IrcRoom = "#" + s_IrcRoom;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Class Definitions
|
|
|
|
private Mobile c_Mobile;
|
|
private Channel c_CurrentChannel;
|
|
private OnlineStatus c_Status;
|
|
private object c_Recording;
|
|
private ArrayList c_Friends, c_Ignores, c_Messages, c_GIgnores, c_GListens, c_Channels, c_IrcIgnores;
|
|
private Hashtable c_Sounds, c_ChannelColors;
|
|
private int c_GlobalMC, c_GlobalCC, c_GlobalGC, c_GlobalFC, c_GlobalWC, c_SystemC, c_ChannelPP, c_FriendsPP, c_MailPP, c_DefaultSound, c_StaffC;
|
|
private bool c_GlobalAccess, c_Global, c_GlobalM, c_GlobalC, c_GlobalG, c_GlobalF, c_GlobalW, c_Banned, c_FriendsOnly, c_MsgSound, c_ByRequest, c_FriendAlert, c_SevenDays, c_ReadReceipt, c_IrcRaw, c_QuickBar;
|
|
private string c_AwayMsg, c_FriendsSpeech, c_ChannelsSpeech, c_MailSpeech;
|
|
private DateTime c_BannedUntil;
|
|
|
|
public Mobile Mobile { get { return c_Mobile; } }
|
|
public Channel CurrentChannel { get { return c_CurrentChannel; } set { c_CurrentChannel = value; } }
|
|
public OnlineStatus Status { get { return c_Status; } set { c_Status = value; } }
|
|
public object Recording{ get{ return c_Recording; } set{ c_Recording = value; } }
|
|
public ArrayList Friends { get { return c_Friends; } }
|
|
public ArrayList Ignores { get { return c_Ignores; } }
|
|
public ArrayList Messages { get { return c_Messages; } }
|
|
public ArrayList GIgnores { get { return c_GIgnores; } }
|
|
public ArrayList GListens { get { return c_GListens; } }
|
|
public ArrayList Channels { get { return c_Channels; } }
|
|
public ArrayList IrcIgnores { get { return c_IrcIgnores; } }
|
|
public Hashtable ChannelColors { get { return c_ChannelColors; } }
|
|
public bool Global { get { return c_Global; } set { c_Global = value; } }
|
|
public bool GlobalM { get { return c_GlobalM && c_Global; } set { c_GlobalM = value; } }
|
|
public bool GlobalC { get { return c_GlobalC && c_Global; } set { c_GlobalC = value; } }
|
|
public bool GlobalG { get { return c_GlobalG && c_Global; } set { c_GlobalG = value; } }
|
|
public bool GlobalF { get { return c_GlobalF && c_Global; } set { c_GlobalF = value; } }
|
|
public bool GlobalW { get { return c_GlobalW && c_Global; } set { c_GlobalW = value; } }
|
|
public bool FriendsOnly { get { return c_FriendsOnly; } set { c_FriendsOnly = value; } }
|
|
public bool MsgSound { get { return c_MsgSound; } set { c_MsgSound = value; } }
|
|
public bool ByRequest { get { return c_ByRequest; } set { c_ByRequest = value; } }
|
|
public bool FriendAlert { get { return c_FriendAlert; } set { c_FriendAlert = value; } }
|
|
public bool SevenDays { get { return c_SevenDays; } set { c_SevenDays = value; } }
|
|
public bool ReadReceipt { get { return c_ReadReceipt; } set { c_ReadReceipt = value; } }
|
|
public bool IrcRaw { get { return c_IrcRaw; } set { c_IrcRaw = value; } }
|
|
public bool QuickBar { get { return c_QuickBar; } set { c_QuickBar = value; } }
|
|
public int GlobalMC { get { return c_GlobalMC; } set { c_GlobalMC = value; } }
|
|
public int GlobalCC { get { return c_GlobalCC; } set { c_GlobalCC = value; } }
|
|
public int GlobalGC { get { return c_GlobalGC; } set { c_GlobalGC = value; } }
|
|
public int GlobalFC { get { return c_GlobalFC; } set { c_GlobalFC = value; } }
|
|
public int GlobalWC { get { return c_GlobalWC; } set { c_GlobalWC = value; } }
|
|
public int SystemC { get { return c_SystemC; } set { c_SystemC = value; } }
|
|
public int StaffC { get { return c_StaffC; } set { c_StaffC = value; } }
|
|
public string AwayMsg { get { return c_AwayMsg; } set { c_AwayMsg = value; } }
|
|
public string FriendsSpeech { get { return c_FriendsSpeech; } set { c_FriendsSpeech = value; } }
|
|
public string ChannelsSpeech { get { return c_ChannelsSpeech; } set { c_ChannelsSpeech = value; } }
|
|
public string MailSpeech { get { return c_MailSpeech; } set { c_MailSpeech = value; } }
|
|
|
|
public int FriendsPP
|
|
{
|
|
get { return c_FriendsPP; }
|
|
set
|
|
{
|
|
c_FriendsPP = value;
|
|
|
|
if (c_FriendsPP < 5)
|
|
c_FriendsPP = 5;
|
|
if (c_FriendsPP > 15)
|
|
c_FriendsPP = 15;
|
|
}
|
|
}
|
|
|
|
public int ChannelPP
|
|
{
|
|
get { return c_ChannelPP; }
|
|
set
|
|
{
|
|
c_ChannelPP = value;
|
|
|
|
if (c_ChannelPP < 5)
|
|
c_ChannelPP = 5;
|
|
if (c_ChannelPP > 15)
|
|
c_ChannelPP = 15;
|
|
}
|
|
}
|
|
|
|
public int MailPP
|
|
{
|
|
get { return c_MailPP; }
|
|
set
|
|
{
|
|
c_MailPP = value;
|
|
|
|
if (c_MailPP < 3)
|
|
c_MailPP = 3;
|
|
if (c_MailPP > 10)
|
|
c_MailPP = 10;
|
|
}
|
|
}
|
|
|
|
public int DefaultSound
|
|
{
|
|
get { return c_DefaultSound; }
|
|
set
|
|
{
|
|
foreach (Mobile m in c_Sounds.Keys)
|
|
if ((int)c_Sounds[m] == c_DefaultSound)
|
|
c_Sounds[m] = value;
|
|
|
|
c_DefaultSound = value;
|
|
}
|
|
}
|
|
|
|
public bool GlobalAccess
|
|
{
|
|
get { return c_GlobalAccess || c_Mobile.AccessLevel >= AccessLevel.Administrator; }
|
|
set
|
|
{
|
|
c_GlobalAccess = value;
|
|
|
|
if (value)
|
|
c_Mobile.SendMessage(c_SystemC, General.Local(92));
|
|
else
|
|
c_Mobile.SendMessage(c_SystemC, General.Local(93));
|
|
}
|
|
}
|
|
|
|
public bool Banned
|
|
{
|
|
get{ return c_Banned; }
|
|
set
|
|
{
|
|
c_Banned = value;
|
|
|
|
if (value)
|
|
c_Mobile.SendMessage(c_SystemC, General.Local(90));
|
|
else
|
|
c_Mobile.SendMessage(c_SystemC, General.Local(91));
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
public Data()
|
|
{
|
|
c_Friends = new ArrayList();
|
|
c_Ignores = new ArrayList();
|
|
c_Messages = new ArrayList();
|
|
c_GIgnores = new ArrayList();
|
|
c_GListens = new ArrayList();
|
|
c_Channels = new ArrayList();
|
|
c_IrcIgnores = new ArrayList();
|
|
c_Sounds = new Hashtable();
|
|
c_ChannelColors = new Hashtable();
|
|
c_FriendsPP = 10;
|
|
c_ChannelPP = 10;
|
|
c_MailPP = 5;
|
|
c_SystemC = 0x161;
|
|
c_GlobalMC = 0x26;
|
|
c_GlobalCC = 0x47E;
|
|
c_GlobalGC = 0x44;
|
|
c_GlobalFC = 0x17;
|
|
c_GlobalWC = 0x3;
|
|
c_StaffC = 0x3B4;
|
|
c_AwayMsg = "";
|
|
c_FriendsSpeech = "";
|
|
c_ChannelsSpeech = "";
|
|
c_MailSpeech = "";
|
|
c_BannedUntil = DateTime.Now;
|
|
|
|
c_IrcRaw = true;
|
|
}
|
|
|
|
public Data(Mobile m)
|
|
{
|
|
c_Mobile = m;
|
|
|
|
c_Friends = new ArrayList();
|
|
c_Ignores = new ArrayList();
|
|
c_Messages = new ArrayList();
|
|
c_GIgnores = new ArrayList();
|
|
c_GListens = new ArrayList();
|
|
c_Channels = new ArrayList();
|
|
c_IrcIgnores = new ArrayList();
|
|
c_Sounds = new Hashtable();
|
|
c_ChannelColors = new Hashtable();
|
|
c_FriendsPP = 10;
|
|
c_ChannelPP = 10;
|
|
c_MailPP = 5;
|
|
c_SystemC = 0x161;
|
|
c_GlobalMC = 0x26;
|
|
c_GlobalCC = 0x47E;
|
|
c_GlobalGC = 0x44;
|
|
c_GlobalFC = 0x17;
|
|
c_GlobalWC = 0x3;
|
|
c_StaffC = 0x3B4;
|
|
c_AwayMsg = "";
|
|
c_FriendsSpeech = "";
|
|
c_ChannelsSpeech = "";
|
|
c_MailSpeech = "";
|
|
c_BannedUntil = DateTime.Now;
|
|
|
|
if (m.AccessLevel >= AccessLevel.Administrator)
|
|
c_GlobalAccess = true;
|
|
|
|
s_Datas[m] = this;
|
|
|
|
foreach (Channel c in Channel.Channels)
|
|
if (c.NewChars)
|
|
c_Channels.Add(c.Name);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
public bool NewMsg()
|
|
{
|
|
foreach (Message msg in c_Messages)
|
|
if (!msg.Read)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
public bool NewMsgFrom(Mobile m)
|
|
{
|
|
foreach (Message msg in c_Messages)
|
|
if (!msg.Read && msg.From == m)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
public void CheckMsg()
|
|
{
|
|
foreach( Message msg in c_Messages )
|
|
if (!msg.Read)
|
|
{
|
|
MessageGump.SendTo(c_Mobile, msg);
|
|
return;
|
|
}
|
|
}
|
|
|
|
public void CheckMsgFrom(Mobile m)
|
|
{
|
|
foreach(Message msg in c_Messages)
|
|
if (!msg.Read && msg.From == m)
|
|
{
|
|
MessageGump.SendTo(c_Mobile, msg);
|
|
return;
|
|
}
|
|
}
|
|
|
|
public int GetSound(Mobile m)
|
|
{
|
|
if (c_Sounds[m] == null)
|
|
c_Sounds[m] = c_DefaultSound;
|
|
|
|
return (int)c_Sounds[m];
|
|
}
|
|
|
|
public void SetSound(Mobile m, int num)
|
|
{
|
|
if (num < 0)
|
|
num = 0;
|
|
|
|
c_Sounds[m] = num;
|
|
}
|
|
|
|
public int ColorFor(Channel c)
|
|
{
|
|
if (c_ChannelColors[c.Name] == null)
|
|
c_ChannelColors[c.Name] = c.DefaultC;
|
|
|
|
return (int)c_ChannelColors[c.Name];
|
|
}
|
|
|
|
public void AddFriend(Mobile m)
|
|
{
|
|
if (c_Friends.Contains(m) || m == c_Mobile)
|
|
return;
|
|
|
|
c_Friends.Add(m);
|
|
c_Mobile.SendMessage(c_SystemC, m.Name + " " + General.Local(73));
|
|
|
|
if (m.HasGump(typeof(FriendsGump)))
|
|
General.RefreshGump(m, typeof(FriendsGump));
|
|
if (m.HasGump(typeof(ChannelGump)))
|
|
General.RefreshGump(m, typeof(ChannelGump));
|
|
if (c_Mobile.HasGump(typeof(FriendsGump)))
|
|
General.RefreshGump(c_Mobile, typeof(FriendsGump));
|
|
if (c_Mobile.HasGump(typeof(ChannelGump)))
|
|
General.RefreshGump(c_Mobile, typeof(ChannelGump));
|
|
}
|
|
|
|
public void RemoveFriend(Mobile m)
|
|
{
|
|
if (!c_Friends.Contains(m))
|
|
return;
|
|
|
|
c_Friends.Remove(m);
|
|
c_Mobile.SendMessage(c_SystemC, m.Name + " " + General.Local(72));
|
|
|
|
if (m.HasGump(typeof(FriendsGump)))
|
|
General.RefreshGump(m, typeof(FriendsGump));
|
|
if (m.HasGump(typeof(ChannelGump)))
|
|
General.RefreshGump(m, typeof(ChannelGump));
|
|
if (c_Mobile.HasGump(typeof(FriendsGump)))
|
|
General.RefreshGump(c_Mobile, typeof(FriendsGump));
|
|
if (c_Mobile.HasGump(typeof(ChannelGump)))
|
|
General.RefreshGump(c_Mobile, typeof(ChannelGump));
|
|
}
|
|
|
|
public void AddIgnore(Mobile m)
|
|
{
|
|
if (c_Ignores.Contains(m) || m == c_Mobile)
|
|
return;
|
|
|
|
c_Ignores.Add(m);
|
|
c_Mobile.SendMessage(c_SystemC, General.Local(68) + " " + m.Name);
|
|
}
|
|
|
|
public void RemoveIgnore(Mobile m)
|
|
{
|
|
if (!c_Ignores.Contains(m))
|
|
return;
|
|
|
|
c_Ignores.Remove(m);
|
|
c_Mobile.SendMessage(c_SystemC, General.Local(74) + " " + m.Name);
|
|
}
|
|
|
|
public void AddGIgnore(Mobile m)
|
|
{
|
|
if (c_GIgnores.Contains(m))
|
|
return;
|
|
|
|
c_GIgnores.Add(m);
|
|
c_Mobile.SendMessage(c_SystemC, General.Local(80) + " " + m.Name);
|
|
}
|
|
|
|
public void RemoveGIgnore(Mobile m)
|
|
{
|
|
if (!c_GIgnores.Contains(m))
|
|
return;
|
|
|
|
c_GIgnores.Remove(m);
|
|
c_Mobile.SendMessage(c_SystemC, General.Local(79) + " " + m.Name);
|
|
}
|
|
|
|
public void AddGListen(Mobile m)
|
|
{
|
|
if (c_GListens.Contains(m))
|
|
return;
|
|
|
|
c_GListens.Add(m);
|
|
c_Mobile.SendMessage(c_SystemC, General.Local(82) + " " + m.Name);
|
|
}
|
|
|
|
public void RemoveGListen(Mobile m)
|
|
{
|
|
if (!c_GListens.Contains(m))
|
|
return;
|
|
|
|
c_GListens.Remove(m);
|
|
c_Mobile.SendMessage(c_SystemC, General.Local(81) + " " + m.Name);
|
|
}
|
|
|
|
public void AddIrcIgnore(string str)
|
|
{
|
|
if (c_IrcIgnores.Contains(str))
|
|
return;
|
|
|
|
c_IrcIgnores.Add(str);
|
|
c_Mobile.SendMessage(c_SystemC, General.Local(68) + " " + str);
|
|
}
|
|
|
|
public void RemoveIrcIgnore(string str)
|
|
{
|
|
if (!c_IrcIgnores.Contains(str))
|
|
return;
|
|
|
|
c_IrcIgnores.Remove(str);
|
|
c_Mobile.SendMessage(c_SystemC, General.Local(74) + " " + str);
|
|
}
|
|
|
|
public void AddMessage(Message msg)
|
|
{
|
|
c_Messages.Add(msg);
|
|
|
|
if(c_MsgSound)
|
|
c_Mobile.SendSound(GetSound(msg.From));
|
|
}
|
|
|
|
public void DeleteMessage(Message msg)
|
|
{
|
|
c_Messages.Remove(msg);
|
|
|
|
c_Mobile.SendMessage(c_SystemC, General.Local(69));
|
|
}
|
|
|
|
public void Ban(TimeSpan ts)
|
|
{
|
|
c_BannedUntil = DateTime.Now + ts;
|
|
c_Banned = true;
|
|
Mobile.SendMessage(c_SystemC, General.Local(90));
|
|
|
|
Timer.DelayCall(ts, new TimerCallback(RemoveBan));
|
|
}
|
|
|
|
public void RemoveBan()
|
|
{
|
|
c_BannedUntil = DateTime.Now;
|
|
c_Banned = false;
|
|
Mobile.SendMessage(c_SystemC, General.Local(91));
|
|
}
|
|
|
|
public void Save(GenericWriter writer)
|
|
{
|
|
writer.Write(1); // Version
|
|
|
|
// version 1
|
|
|
|
writer.Write(c_ReadReceipt);
|
|
writer.Write(c_QuickBar);
|
|
|
|
// version 0
|
|
|
|
writer.Write(c_Mobile);
|
|
writer.Write((int)c_Status);
|
|
writer.WriteMobileList(c_Friends, true);
|
|
writer.WriteMobileList(c_Ignores, true);
|
|
writer.WriteMobileList(c_GIgnores, true);
|
|
writer.WriteMobileList(c_GListens, true);
|
|
|
|
foreach (string str in new ArrayList(c_Channels))
|
|
if (Channel.GetByName(str) == null)
|
|
c_Channels.Remove(str);
|
|
|
|
writer.Write(c_Channels.Count);
|
|
foreach (string str in c_Channels)
|
|
writer.Write(str);
|
|
|
|
writer.Write(c_Messages.Count);
|
|
foreach (Message msg in c_Messages)
|
|
msg.Save(writer);
|
|
|
|
writer.Write(c_Sounds.Count);
|
|
foreach (Mobile m in c_Sounds.Keys)
|
|
{
|
|
writer.Write(m);
|
|
writer.Write((int)c_Sounds[m]);
|
|
}
|
|
|
|
foreach (string str in new ArrayList(c_ChannelColors.Keys))
|
|
if (Channel.GetByName(str) == null)
|
|
c_ChannelColors.Remove(str);
|
|
|
|
writer.Write(c_ChannelColors.Count);
|
|
foreach (string str in c_ChannelColors.Keys)
|
|
{
|
|
writer.Write(str);
|
|
writer.Write((int)c_ChannelColors[str]);
|
|
}
|
|
|
|
writer.Write(c_GlobalMC);
|
|
writer.Write(c_GlobalCC);
|
|
writer.Write(c_GlobalGC);
|
|
writer.Write(c_GlobalFC);
|
|
writer.Write(c_GlobalWC);
|
|
writer.Write(c_SystemC);
|
|
writer.Write(c_ChannelPP);
|
|
writer.Write(c_FriendsPP);
|
|
writer.Write(c_MailPP);
|
|
writer.Write(c_DefaultSound);
|
|
writer.Write(c_StaffC);
|
|
writer.Write(c_GlobalAccess);
|
|
writer.Write(c_Global);
|
|
writer.Write(c_GlobalM);
|
|
writer.Write(c_GlobalC);
|
|
writer.Write(c_GlobalG);
|
|
writer.Write(c_GlobalF);
|
|
writer.Write(c_GlobalW);
|
|
writer.Write(c_Banned);
|
|
writer.Write(c_FriendsOnly);
|
|
writer.Write(c_MsgSound);
|
|
writer.Write(c_ByRequest);
|
|
writer.Write(c_FriendAlert);
|
|
writer.Write(c_SevenDays);
|
|
writer.Write(c_IrcRaw);
|
|
writer.Write(c_AwayMsg);
|
|
writer.Write(c_FriendsSpeech);
|
|
writer.Write(c_ChannelsSpeech);
|
|
writer.Write(c_MailSpeech);
|
|
writer.Write(c_BannedUntil);
|
|
}
|
|
|
|
public void Load(GenericReader reader)
|
|
{
|
|
int version = reader.ReadInt();
|
|
|
|
if( version >= 1 )
|
|
{
|
|
c_ReadReceipt = reader.ReadBool();
|
|
c_QuickBar = reader.ReadBool();
|
|
}
|
|
|
|
c_Mobile = reader.ReadMobile();
|
|
c_Status = (OnlineStatus)reader.ReadInt();
|
|
c_Friends = reader.ReadMobileList();
|
|
c_Ignores = reader.ReadMobileList();
|
|
c_GIgnores = reader.ReadMobileList();
|
|
c_GListens = reader.ReadMobileList();
|
|
|
|
c_Channels = new ArrayList();
|
|
int count = reader.ReadInt();
|
|
for (int i = 0; i < count; ++i)
|
|
c_Channels.Add(reader.ReadString());
|
|
|
|
c_Messages = new ArrayList();
|
|
Message msg;
|
|
count = reader.ReadInt();
|
|
for (int i = 0; i < count; ++i)
|
|
{
|
|
msg = new Message();
|
|
msg.Load(reader);
|
|
|
|
if (msg.From != null)
|
|
c_Messages.Add(msg);
|
|
}
|
|
|
|
c_Sounds = new Hashtable();
|
|
Mobile m;
|
|
count = reader.ReadInt();
|
|
for (int i = 0; i < count; ++i)
|
|
{
|
|
m = reader.ReadMobile();
|
|
c_Sounds[m] = reader.ReadInt();
|
|
}
|
|
|
|
c_ChannelColors = new Hashtable();
|
|
string str = "";
|
|
count = reader.ReadInt();
|
|
for (int i = 0; i < count; ++i)
|
|
{
|
|
str = reader.ReadString();
|
|
c_ChannelColors[str] = reader.ReadInt();
|
|
}
|
|
|
|
c_GlobalMC = reader.ReadInt();
|
|
c_GlobalCC = reader.ReadInt();
|
|
c_GlobalGC = reader.ReadInt();
|
|
c_GlobalFC = reader.ReadInt();
|
|
c_GlobalWC = reader.ReadInt();
|
|
c_SystemC = reader.ReadInt();
|
|
c_ChannelPP = reader.ReadInt();
|
|
c_FriendsPP = reader.ReadInt();
|
|
c_MailPP = reader.ReadInt();
|
|
c_DefaultSound = reader.ReadInt();
|
|
c_StaffC = reader.ReadInt();
|
|
c_GlobalAccess = reader.ReadBool();
|
|
c_Global = reader.ReadBool();
|
|
c_GlobalM = reader.ReadBool();
|
|
c_GlobalC = reader.ReadBool();
|
|
c_GlobalG = reader.ReadBool();
|
|
c_GlobalF = reader.ReadBool();
|
|
c_GlobalW = reader.ReadBool();
|
|
c_Banned = reader.ReadBool();
|
|
c_FriendsOnly = reader.ReadBool();
|
|
c_MsgSound = reader.ReadBool();
|
|
c_ByRequest = reader.ReadBool();
|
|
c_FriendAlert = reader.ReadBool();
|
|
c_SevenDays = reader.ReadBool();
|
|
c_IrcRaw = reader.ReadBool();
|
|
c_AwayMsg = reader.ReadString();
|
|
c_FriendsSpeech = reader.ReadString();
|
|
c_ChannelsSpeech = reader.ReadString();
|
|
c_MailSpeech = reader.ReadString();
|
|
c_BannedUntil = reader.ReadDateTime();
|
|
|
|
if (c_BannedUntil > DateTime.Now)
|
|
Ban(c_BannedUntil - DateTime.Now);
|
|
else
|
|
RemoveBan();
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
} |